id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
49,600
gethuman/pancakes-angular
lib/transformers/ng.uipart.transformer.js
parseNames
function parseNames(filePath, prefix, defaultAppName) { var appName = this.getAppName(filePath, defaultAppName); var names = { appShortName: appName, appName: this.getAppModuleName(prefix, appName), isPartial: !!filePath.match(/^.*\.partial\.js/) }; names.isPage = !names.isPartial; // name of the page used for setting the css style (ex. my.home.page.js would be my.home) // the class name on the maincontent in HTML would be something like gh-my-home var lastSlash = filePath.lastIndexOf(delim); names.uiPartName = filePath.substring(lastSlash + 1) .replace('.page.js', '') .replace('.partial.js', ''); // view url is what is used as unique key in template cache for generated HTML names.viewUrl = 'templates/' + names.uiPartName; // get the directive and controller name (ex. directive ghAnswerList and controller AnswerListCtrl var moduleNamePascal = this.pancakes.utils.getPascalCase(filePath) .replace('Page', '') .replace('Partial', ''); names.directiveName = prefix + moduleNamePascal; names.controllerName = moduleNamePascal + 'Ctrl'; return names; }
javascript
function parseNames(filePath, prefix, defaultAppName) { var appName = this.getAppName(filePath, defaultAppName); var names = { appShortName: appName, appName: this.getAppModuleName(prefix, appName), isPartial: !!filePath.match(/^.*\.partial\.js/) }; names.isPage = !names.isPartial; // name of the page used for setting the css style (ex. my.home.page.js would be my.home) // the class name on the maincontent in HTML would be something like gh-my-home var lastSlash = filePath.lastIndexOf(delim); names.uiPartName = filePath.substring(lastSlash + 1) .replace('.page.js', '') .replace('.partial.js', ''); // view url is what is used as unique key in template cache for generated HTML names.viewUrl = 'templates/' + names.uiPartName; // get the directive and controller name (ex. directive ghAnswerList and controller AnswerListCtrl var moduleNamePascal = this.pancakes.utils.getPascalCase(filePath) .replace('Page', '') .replace('Partial', ''); names.directiveName = prefix + moduleNamePascal; names.controllerName = moduleNamePascal + 'Ctrl'; return names; }
[ "function", "parseNames", "(", "filePath", ",", "prefix", ",", "defaultAppName", ")", "{", "var", "appName", "=", "this", ".", "getAppName", "(", "filePath", ",", "defaultAppName", ")", ";", "var", "names", "=", "{", "appShortName", ":", "appName", ",", "appName", ":", "this", ".", "getAppModuleName", "(", "prefix", ",", "appName", ")", ",", "isPartial", ":", "!", "!", "filePath", ".", "match", "(", "/", "^.*\\.partial\\.js", "/", ")", "}", ";", "names", ".", "isPage", "=", "!", "names", ".", "isPartial", ";", "// name of the page used for setting the css style (ex. my.home.page.js would be my.home)", "// the class name on the maincontent in HTML would be something like gh-my-home", "var", "lastSlash", "=", "filePath", ".", "lastIndexOf", "(", "delim", ")", ";", "names", ".", "uiPartName", "=", "filePath", ".", "substring", "(", "lastSlash", "+", "1", ")", ".", "replace", "(", "'.page.js'", ",", "''", ")", ".", "replace", "(", "'.partial.js'", ",", "''", ")", ";", "// view url is what is used as unique key in template cache for generated HTML", "names", ".", "viewUrl", "=", "'templates/'", "+", "names", ".", "uiPartName", ";", "// get the directive and controller name (ex. directive ghAnswerList and controller AnswerListCtrl", "var", "moduleNamePascal", "=", "this", ".", "pancakes", ".", "utils", ".", "getPascalCase", "(", "filePath", ")", ".", "replace", "(", "'Page'", ",", "''", ")", ".", "replace", "(", "'Partial'", ",", "''", ")", ";", "names", ".", "directiveName", "=", "prefix", "+", "moduleNamePascal", ";", "names", ".", "controllerName", "=", "moduleNamePascal", "+", "'Ctrl'", ";", "return", "names", ";", "}" ]
Using the file path, parse out all the names needed for the UI part template @param filePath @param prefix @param defaultAppName
[ "Using", "the", "file", "path", "parse", "out", "all", "the", "names", "needed", "for", "the", "UI", "part", "template" ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/transformers/ng.uipart.transformer.js#L63-L90
49,601
gethuman/pancakes-angular
lib/transformers/ng.uipart.transformer.js
getHtml
function getHtml(uipart, options) { options = options || {}; var me = this; // if any subviews, add them as dependencies var model = { isMobile: options.isMobile, appName: options.appName, pageCssId: options.appName + 'PageCssId' }; var deps = _.extend({ subviews: {}, model: model, pageContent: options.pageContent || ' ', sideviewContent: options.sideviewContent || ' ' }, this.getJangularDeps()); _.each(uipart.subviews, function (subview, subviewName) { deps.subviews[subviewName] = me.pancakes.cook(subview, { dependencies: deps }); }); // cook the view; the result will be jeff objects var view = this.pancakes.cook(uipart.view, { dependencies: deps }); // we can now generate HTML off the jyt objects (using jyt render so angular NOT interpreted) var html = jangular.jytRender(view); html = html.replace(/\'/g, '\\\''); // need to protect all single quotes return html; }
javascript
function getHtml(uipart, options) { options = options || {}; var me = this; // if any subviews, add them as dependencies var model = { isMobile: options.isMobile, appName: options.appName, pageCssId: options.appName + 'PageCssId' }; var deps = _.extend({ subviews: {}, model: model, pageContent: options.pageContent || ' ', sideviewContent: options.sideviewContent || ' ' }, this.getJangularDeps()); _.each(uipart.subviews, function (subview, subviewName) { deps.subviews[subviewName] = me.pancakes.cook(subview, { dependencies: deps }); }); // cook the view; the result will be jeff objects var view = this.pancakes.cook(uipart.view, { dependencies: deps }); // we can now generate HTML off the jyt objects (using jyt render so angular NOT interpreted) var html = jangular.jytRender(view); html = html.replace(/\'/g, '\\\''); // need to protect all single quotes return html; }
[ "function", "getHtml", "(", "uipart", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "var", "me", "=", "this", ";", "// if any subviews, add them as dependencies", "var", "model", "=", "{", "isMobile", ":", "options", ".", "isMobile", ",", "appName", ":", "options", ".", "appName", ",", "pageCssId", ":", "options", ".", "appName", "+", "'PageCssId'", "}", ";", "var", "deps", "=", "_", ".", "extend", "(", "{", "subviews", ":", "{", "}", ",", "model", ":", "model", ",", "pageContent", ":", "options", ".", "pageContent", "||", "' '", ",", "sideviewContent", ":", "options", ".", "sideviewContent", "||", "' '", "}", ",", "this", ".", "getJangularDeps", "(", ")", ")", ";", "_", ".", "each", "(", "uipart", ".", "subviews", ",", "function", "(", "subview", ",", "subviewName", ")", "{", "deps", ".", "subviews", "[", "subviewName", "]", "=", "me", ".", "pancakes", ".", "cook", "(", "subview", ",", "{", "dependencies", ":", "deps", "}", ")", ";", "}", ")", ";", "// cook the view; the result will be jeff objects", "var", "view", "=", "this", ".", "pancakes", ".", "cook", "(", "uipart", ".", "view", ",", "{", "dependencies", ":", "deps", "}", ")", ";", "// we can now generate HTML off the jyt objects (using jyt render so angular NOT interpreted)", "var", "html", "=", "jangular", ".", "jytRender", "(", "view", ")", ";", "html", "=", "html", ".", "replace", "(", "/", "\\'", "/", "g", ",", "'\\\\\\''", ")", ";", "// need to protect all single quotes", "return", "html", ";", "}" ]
Get the HTML for a given ui part @param uipart @param options @returns {string}
[ "Get", "the", "HTML", "for", "a", "given", "ui", "part" ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/transformers/ng.uipart.transformer.js#L195-L224
49,602
flacnut/npm-dependencies-spreadsheet
index.js
ensureRowsDeleted
function ensureRowsDeleted(rows) { async.whilst( () => rows.length, (cb) => { rows[0].del(() => { sheet.getRows(query_options, (err, _rows) => { rows = _rows; cb(); }); }); }, next); }
javascript
function ensureRowsDeleted(rows) { async.whilst( () => rows.length, (cb) => { rows[0].del(() => { sheet.getRows(query_options, (err, _rows) => { rows = _rows; cb(); }); }); }, next); }
[ "function", "ensureRowsDeleted", "(", "rows", ")", "{", "async", ".", "whilst", "(", "(", ")", "=>", "rows", ".", "length", ",", "(", "cb", ")", "=>", "{", "rows", "[", "0", "]", ".", "del", "(", "(", ")", "=>", "{", "sheet", ".", "getRows", "(", "query_options", ",", "(", "err", ",", "_rows", ")", "=>", "{", "rows", "=", "_rows", ";", "cb", "(", ")", ";", "}", ")", ";", "}", ")", ";", "}", ",", "next", ")", ";", "}" ]
Once you delete a row, google API may incorrectly delete future rows. The only garuntee is to fetch a single row then delete it.
[ "Once", "you", "delete", "a", "row", "google", "API", "may", "incorrectly", "delete", "future", "rows", ".", "The", "only", "garuntee", "is", "to", "fetch", "a", "single", "row", "then", "delete", "it", "." ]
691f5f93aae2cd868ee34d0ee597d87df7d0a4e6
https://github.com/flacnut/npm-dependencies-spreadsheet/blob/691f5f93aae2cd868ee34d0ee597d87df7d0a4e6/index.js#L139-L151
49,603
xiamidaxia/xiami
meteor/livedata/server/livedata_server.js
function () { var self = this; // Already destroyed. if (!self.inQueue) return; if (self.heartbeat) { self.heartbeat.stop(); self.heartbeat = null; } if (self.socket) { self.socket.close(); self.socket._meteorSession = null; } // Drop the merge box data immediately. self.collectionViews = {}; self.inQueue = null; Package.facts && Package.facts.Facts.incrementServerFact( "livedata", "sessions", -1); Meteor.defer(function () { // stop callbacks can yield, so we defer this on destroy. // sub._isDeactivated() detects that we set inQueue to null and // treats it as semi-deactivated (it will ignore incoming callbacks, etc). self._deactivateAllSubscriptions(); // Defer calling the close callbacks, so that the caller closing // the session isn't waiting for all the callbacks to complete. _.each(self._closeCallbacks, function (callback) { callback(); }); }); }
javascript
function () { var self = this; // Already destroyed. if (!self.inQueue) return; if (self.heartbeat) { self.heartbeat.stop(); self.heartbeat = null; } if (self.socket) { self.socket.close(); self.socket._meteorSession = null; } // Drop the merge box data immediately. self.collectionViews = {}; self.inQueue = null; Package.facts && Package.facts.Facts.incrementServerFact( "livedata", "sessions", -1); Meteor.defer(function () { // stop callbacks can yield, so we defer this on destroy. // sub._isDeactivated() detects that we set inQueue to null and // treats it as semi-deactivated (it will ignore incoming callbacks, etc). self._deactivateAllSubscriptions(); // Defer calling the close callbacks, so that the caller closing // the session isn't waiting for all the callbacks to complete. _.each(self._closeCallbacks, function (callback) { callback(); }); }); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "// Already destroyed.", "if", "(", "!", "self", ".", "inQueue", ")", "return", ";", "if", "(", "self", ".", "heartbeat", ")", "{", "self", ".", "heartbeat", ".", "stop", "(", ")", ";", "self", ".", "heartbeat", "=", "null", ";", "}", "if", "(", "self", ".", "socket", ")", "{", "self", ".", "socket", ".", "close", "(", ")", ";", "self", ".", "socket", ".", "_meteorSession", "=", "null", ";", "}", "// Drop the merge box data immediately.", "self", ".", "collectionViews", "=", "{", "}", ";", "self", ".", "inQueue", "=", "null", ";", "Package", ".", "facts", "&&", "Package", ".", "facts", ".", "Facts", ".", "incrementServerFact", "(", "\"livedata\"", ",", "\"sessions\"", ",", "-", "1", ")", ";", "Meteor", ".", "defer", "(", "function", "(", ")", "{", "// stop callbacks can yield, so we defer this on destroy.", "// sub._isDeactivated() detects that we set inQueue to null and", "// treats it as semi-deactivated (it will ignore incoming callbacks, etc).", "self", ".", "_deactivateAllSubscriptions", "(", ")", ";", "// Defer calling the close callbacks, so that the caller closing", "// the session isn't waiting for all the callbacks to complete.", "_", ".", "each", "(", "self", ".", "_closeCallbacks", ",", "function", "(", "callback", ")", "{", "callback", "(", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Destroy this session. Stop all processing and tear everything down. If a socket was attached, close it.
[ "Destroy", "this", "session", ".", "Stop", "all", "processing", "and", "tear", "everything", "down", ".", "If", "a", "socket", "was", "attached", "close", "it", "." ]
6fcee92c493c12bf8fd67c7068e67fa6a72a306b
https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/livedata/server/livedata_server.js#L424-L460
49,604
xiamidaxia/xiami
meteor/livedata/server/livedata_server.js
function () { var self = this; // For the reported client address for a connection to be correct, // the developer must set the HTTP_FORWARDED_COUNT environment // variable to an integer representing the number of hops they // expect in the `x-forwarded-for` header. E.g., set to "1" if the // server is behind one proxy. // // This could be computed once at startup instead of every time. var httpForwardedCount = parseInt(process.env['HTTP_FORWARDED_COUNT']) || 0; if (httpForwardedCount === 0) return self.socket.remoteAddress; var forwardedFor = self.socket.headers["x-forwarded-for"]; if (! _.isString(forwardedFor)) return null; forwardedFor = forwardedFor.trim().split(/\s*,\s*/); // Typically the first value in the `x-forwarded-for` header is // the original IP address of the client connecting to the first // proxy. However, the end user can easily spoof the header, in // which case the first value(s) will be the fake IP address from // the user pretending to be a proxy reporting the original IP // address value. By counting HTTP_FORWARDED_COUNT back from the // end of the list, we ensure that we get the IP address being // reported by *our* first proxy. if (httpForwardedCount < 0 || httpForwardedCount > forwardedFor.length) return null; return forwardedFor[forwardedFor.length - httpForwardedCount]; }
javascript
function () { var self = this; // For the reported client address for a connection to be correct, // the developer must set the HTTP_FORWARDED_COUNT environment // variable to an integer representing the number of hops they // expect in the `x-forwarded-for` header. E.g., set to "1" if the // server is behind one proxy. // // This could be computed once at startup instead of every time. var httpForwardedCount = parseInt(process.env['HTTP_FORWARDED_COUNT']) || 0; if (httpForwardedCount === 0) return self.socket.remoteAddress; var forwardedFor = self.socket.headers["x-forwarded-for"]; if (! _.isString(forwardedFor)) return null; forwardedFor = forwardedFor.trim().split(/\s*,\s*/); // Typically the first value in the `x-forwarded-for` header is // the original IP address of the client connecting to the first // proxy. However, the end user can easily spoof the header, in // which case the first value(s) will be the fake IP address from // the user pretending to be a proxy reporting the original IP // address value. By counting HTTP_FORWARDED_COUNT back from the // end of the list, we ensure that we get the IP address being // reported by *our* first proxy. if (httpForwardedCount < 0 || httpForwardedCount > forwardedFor.length) return null; return forwardedFor[forwardedFor.length - httpForwardedCount]; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "// For the reported client address for a connection to be correct,", "// the developer must set the HTTP_FORWARDED_COUNT environment", "// variable to an integer representing the number of hops they", "// expect in the `x-forwarded-for` header. E.g., set to \"1\" if the", "// server is behind one proxy.", "//", "// This could be computed once at startup instead of every time.", "var", "httpForwardedCount", "=", "parseInt", "(", "process", ".", "env", "[", "'HTTP_FORWARDED_COUNT'", "]", ")", "||", "0", ";", "if", "(", "httpForwardedCount", "===", "0", ")", "return", "self", ".", "socket", ".", "remoteAddress", ";", "var", "forwardedFor", "=", "self", ".", "socket", ".", "headers", "[", "\"x-forwarded-for\"", "]", ";", "if", "(", "!", "_", ".", "isString", "(", "forwardedFor", ")", ")", "return", "null", ";", "forwardedFor", "=", "forwardedFor", ".", "trim", "(", ")", ".", "split", "(", "/", "\\s*,\\s*", "/", ")", ";", "// Typically the first value in the `x-forwarded-for` header is", "// the original IP address of the client connecting to the first", "// proxy. However, the end user can easily spoof the header, in", "// which case the first value(s) will be the fake IP address from", "// the user pretending to be a proxy reporting the original IP", "// address value. By counting HTTP_FORWARDED_COUNT back from the", "// end of the list, we ensure that we get the IP address being", "// reported by *our* first proxy.", "if", "(", "httpForwardedCount", "<", "0", "||", "httpForwardedCount", ">", "forwardedFor", ".", "length", ")", "return", "null", ";", "return", "forwardedFor", "[", "forwardedFor", ".", "length", "-", "httpForwardedCount", "]", ";", "}" ]
Determine the remote client's IP address, based on the HTTP_FORWARDED_COUNT environment variable representing how many proxies the server is behind.
[ "Determine", "the", "remote", "client", "s", "IP", "address", "based", "on", "the", "HTTP_FORWARDED_COUNT", "environment", "variable", "representing", "how", "many", "proxies", "the", "server", "is", "behind", "." ]
6fcee92c493c12bf8fd67c7068e67fa6a72a306b
https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/livedata/server/livedata_server.js#L827-L860
49,605
xiamidaxia/xiami
meteor/livedata/server/livedata_server.js
function (name, handler, options) { var self = this; options = options || {}; if (name && name in self.publish_handlers) { Meteor._debug("Ignoring duplicate publish named '" + name + "'"); return; } if (Package.autopublish && !options.is_auto) { // They have autopublish on, yet they're trying to manually // picking stuff to publish. They probably should turn off // autopublish. (This check isn't perfect -- if you create a // publish before you turn on autopublish, it won't catch // it. But this will definitely handle the simple case where // you've added the autopublish package to your app, and are // calling publish from your app code.) if (!self.warned_about_autopublish) { self.warned_about_autopublish = true; Meteor._debug( "** You've set up some data subscriptions with Meteor.publish(), but\n" + "** you still have autopublish turned on. Because autopublish is still\n" + "** on, your Meteor.publish() calls won't have much effect. All data\n" + "** will still be sent to all clients.\n" + "**\n" + "** Turn off autopublish by removing the autopublish package:\n" + "**\n" + "** $ meteor remove autopublish\n" + "**\n" + "** .. and make sure you have Meteor.publish() and Meteor.subscribe() calls\n" + "** for each collection that you want clients to see.\n"); } } if (name) self.publish_handlers[name] = handler; else { self.universal_publish_handlers.push(handler); // Spin up the new publisher on any existing session too. Run each // session's subscription in a new Fiber, so that there's no change for // self.sessions to change while we're running this loop. _.each(self.sessions, function (session) { if (!session._dontStartNewUniversalSubs) { Fiber(function() { session._startSubscription(handler); }).run(); } }); } }
javascript
function (name, handler, options) { var self = this; options = options || {}; if (name && name in self.publish_handlers) { Meteor._debug("Ignoring duplicate publish named '" + name + "'"); return; } if (Package.autopublish && !options.is_auto) { // They have autopublish on, yet they're trying to manually // picking stuff to publish. They probably should turn off // autopublish. (This check isn't perfect -- if you create a // publish before you turn on autopublish, it won't catch // it. But this will definitely handle the simple case where // you've added the autopublish package to your app, and are // calling publish from your app code.) if (!self.warned_about_autopublish) { self.warned_about_autopublish = true; Meteor._debug( "** You've set up some data subscriptions with Meteor.publish(), but\n" + "** you still have autopublish turned on. Because autopublish is still\n" + "** on, your Meteor.publish() calls won't have much effect. All data\n" + "** will still be sent to all clients.\n" + "**\n" + "** Turn off autopublish by removing the autopublish package:\n" + "**\n" + "** $ meteor remove autopublish\n" + "**\n" + "** .. and make sure you have Meteor.publish() and Meteor.subscribe() calls\n" + "** for each collection that you want clients to see.\n"); } } if (name) self.publish_handlers[name] = handler; else { self.universal_publish_handlers.push(handler); // Spin up the new publisher on any existing session too. Run each // session's subscription in a new Fiber, so that there's no change for // self.sessions to change while we're running this loop. _.each(self.sessions, function (session) { if (!session._dontStartNewUniversalSubs) { Fiber(function() { session._startSubscription(handler); }).run(); } }); } }
[ "function", "(", "name", ",", "handler", ",", "options", ")", "{", "var", "self", "=", "this", ";", "options", "=", "options", "||", "{", "}", ";", "if", "(", "name", "&&", "name", "in", "self", ".", "publish_handlers", ")", "{", "Meteor", ".", "_debug", "(", "\"Ignoring duplicate publish named '\"", "+", "name", "+", "\"'\"", ")", ";", "return", ";", "}", "if", "(", "Package", ".", "autopublish", "&&", "!", "options", ".", "is_auto", ")", "{", "// They have autopublish on, yet they're trying to manually", "// picking stuff to publish. They probably should turn off", "// autopublish. (This check isn't perfect -- if you create a", "// publish before you turn on autopublish, it won't catch", "// it. But this will definitely handle the simple case where", "// you've added the autopublish package to your app, and are", "// calling publish from your app code.)", "if", "(", "!", "self", ".", "warned_about_autopublish", ")", "{", "self", ".", "warned_about_autopublish", "=", "true", ";", "Meteor", ".", "_debug", "(", "\"** You've set up some data subscriptions with Meteor.publish(), but\\n\"", "+", "\"** you still have autopublish turned on. Because autopublish is still\\n\"", "+", "\"** on, your Meteor.publish() calls won't have much effect. All data\\n\"", "+", "\"** will still be sent to all clients.\\n\"", "+", "\"**\\n\"", "+", "\"** Turn off autopublish by removing the autopublish package:\\n\"", "+", "\"**\\n\"", "+", "\"** $ meteor remove autopublish\\n\"", "+", "\"**\\n\"", "+", "\"** .. and make sure you have Meteor.publish() and Meteor.subscribe() calls\\n\"", "+", "\"** for each collection that you want clients to see.\\n\"", ")", ";", "}", "}", "if", "(", "name", ")", "self", ".", "publish_handlers", "[", "name", "]", "=", "handler", ";", "else", "{", "self", ".", "universal_publish_handlers", ".", "push", "(", "handler", ")", ";", "// Spin up the new publisher on any existing session too. Run each", "// session's subscription in a new Fiber, so that there's no change for", "// self.sessions to change while we're running this loop.", "_", ".", "each", "(", "self", ".", "sessions", ",", "function", "(", "session", ")", "{", "if", "(", "!", "session", ".", "_dontStartNewUniversalSubs", ")", "{", "Fiber", "(", "function", "(", ")", "{", "session", ".", "_startSubscription", "(", "handler", ")", ";", "}", ")", ".", "run", "(", ")", ";", "}", "}", ")", ";", "}", "}" ]
Register a publish handler function. @param name {String} identifier for query @param handler {Function} publish handler @param options {Object} Server will call handler function on each new subscription, either when receiving DDP sub message for a named subscription, or on DDP connect for a universal subscription. If name is null, this will be a subscription that is automatically established and permanently on for all connected client, instead of a subscription that can be turned on and off with subscribe(). options to contain: - (mostly internal) is_auto: true if generated automatically from an autopublish hook. this is for cosmetic purposes only (it lets us determine whether to print a warning suggesting that you turn off autopublish.)
[ "Register", "a", "publish", "handler", "function", "." ]
6fcee92c493c12bf8fd67c7068e67fa6a72a306b
https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/livedata/server/livedata_server.js#L1290-L1340
49,606
xiamidaxia/xiami
meteor/livedata/server/livedata_server.js
function (exception, context) { if (!exception || exception instanceof Meteor.Error) return exception; // Did the error contain more details that could have been useful if caught in // server code (or if thrown from non-client-originated code), but also // provided a "sanitized" version with more context than 500 Internal server // error? Use that. if (exception.sanitizedError) { if (exception.sanitizedError instanceof Meteor.Error) return exception.sanitizedError; Meteor._debug("Exception " + context + " provides a sanitizedError that " + "is not a Meteor.Error; ignoring"); } // tests can set the 'expected' flag on an exception so it won't go to the // server log if (!exception.expected) Meteor._debug("Exception " + context, exception.stack); return new Meteor.Error(500, "Internal server error"); }
javascript
function (exception, context) { if (!exception || exception instanceof Meteor.Error) return exception; // Did the error contain more details that could have been useful if caught in // server code (or if thrown from non-client-originated code), but also // provided a "sanitized" version with more context than 500 Internal server // error? Use that. if (exception.sanitizedError) { if (exception.sanitizedError instanceof Meteor.Error) return exception.sanitizedError; Meteor._debug("Exception " + context + " provides a sanitizedError that " + "is not a Meteor.Error; ignoring"); } // tests can set the 'expected' flag on an exception so it won't go to the // server log if (!exception.expected) Meteor._debug("Exception " + context, exception.stack); return new Meteor.Error(500, "Internal server error"); }
[ "function", "(", "exception", ",", "context", ")", "{", "if", "(", "!", "exception", "||", "exception", "instanceof", "Meteor", ".", "Error", ")", "return", "exception", ";", "// Did the error contain more details that could have been useful if caught in", "// server code (or if thrown from non-client-originated code), but also", "// provided a \"sanitized\" version with more context than 500 Internal server", "// error? Use that.", "if", "(", "exception", ".", "sanitizedError", ")", "{", "if", "(", "exception", ".", "sanitizedError", "instanceof", "Meteor", ".", "Error", ")", "return", "exception", ".", "sanitizedError", ";", "Meteor", ".", "_debug", "(", "\"Exception \"", "+", "context", "+", "\" provides a sanitizedError that \"", "+", "\"is not a Meteor.Error; ignoring\"", ")", ";", "}", "// tests can set the 'expected' flag on an exception so it won't go to the", "// server log", "if", "(", "!", "exception", ".", "expected", ")", "Meteor", ".", "_debug", "(", "\"Exception \"", "+", "context", ",", "exception", ".", "stack", ")", ";", "return", "new", "Meteor", ".", "Error", "(", "500", ",", "\"Internal server error\"", ")", ";", "}" ]
"blind" exceptions other than those that were deliberately thrown to signal errors to the client
[ "blind", "exceptions", "other", "than", "those", "that", "were", "deliberately", "thrown", "to", "signal", "errors", "to", "the", "client" ]
6fcee92c493c12bf8fd67c7068e67fa6a72a306b
https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/livedata/server/livedata_server.js#L1472-L1493
49,607
zeropaper/git-beat
lib/git-beat.js
GitBeat
function GitBeat(options) { var self = this; var url; options = options || {}; if (typeof options === 'string') { url = options; options = {}; } this.cwd = path.resolve(options.cwd || ''); this.logger = options.logger || noop; url = url || options.url; this.isCloned = false; if (url) { this.logger('initial clone', url, !!options.done); this.clone(url, options.done || noop); } }
javascript
function GitBeat(options) { var self = this; var url; options = options || {}; if (typeof options === 'string') { url = options; options = {}; } this.cwd = path.resolve(options.cwd || ''); this.logger = options.logger || noop; url = url || options.url; this.isCloned = false; if (url) { this.logger('initial clone', url, !!options.done); this.clone(url, options.done || noop); } }
[ "function", "GitBeat", "(", "options", ")", "{", "var", "self", "=", "this", ";", "var", "url", ";", "options", "=", "options", "||", "{", "}", ";", "if", "(", "typeof", "options", "===", "'string'", ")", "{", "url", "=", "options", ";", "options", "=", "{", "}", ";", "}", "this", ".", "cwd", "=", "path", ".", "resolve", "(", "options", ".", "cwd", "||", "''", ")", ";", "this", ".", "logger", "=", "options", ".", "logger", "||", "noop", ";", "url", "=", "url", "||", "options", ".", "url", ";", "this", ".", "isCloned", "=", "false", ";", "if", "(", "url", ")", "{", "this", ".", "logger", "(", "'initial clone'", ",", "url", ",", "!", "!", "options", ".", "done", ")", ";", "this", ".", "clone", "(", "url", ",", "options", ".", "done", "||", "noop", ")", ";", "}", "}" ]
GitBeat is aimed to take the pulse of Git repositories. @param {Object|String} options is either an object or the URL of a repository @param {String} [options.cwd] to set the working directory path @param {Function} [options.logger] a function to log
[ "GitBeat", "is", "aimed", "to", "take", "the", "pulse", "of", "Git", "repositories", "." ]
380e8af87b527287380345303566bd7b27e6c799
https://github.com/zeropaper/git-beat/blob/380e8af87b527287380345303566bd7b27e6c799/lib/git-beat.js#L23-L44
49,608
wunderbyte/grunt-spiritual-dox
src/js/[email protected]/spirits/aside/dox.FormSpirit.js
function () { this._super.onenter (); this.element.action = "javascript:void(0)"; this._scrollbar ( gui.Client.scrollBarSize ); this._flexboxerize ( this.dom.q ( "label" ), this.dom.q ( "input" ) ); }
javascript
function () { this._super.onenter (); this.element.action = "javascript:void(0)"; this._scrollbar ( gui.Client.scrollBarSize ); this._flexboxerize ( this.dom.q ( "label" ), this.dom.q ( "input" ) ); }
[ "function", "(", ")", "{", "this", ".", "_super", ".", "onenter", "(", ")", ";", "this", ".", "element", ".", "action", "=", "\"javascript:void(0)\"", ";", "this", ".", "_scrollbar", "(", "gui", ".", "Client", ".", "scrollBarSize", ")", ";", "this", ".", "_flexboxerize", "(", "this", ".", "dom", ".", "q", "(", "\"label\"", ")", ",", "this", ".", "dom", ".", "q", "(", "\"input\"", ")", ")", ";", "}" ]
Layout fixes on startup.
[ "Layout", "fixes", "on", "startup", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/[email protected]/spirits/aside/dox.FormSpirit.js#L10-L18
49,609
wunderbyte/grunt-spiritual-dox
src/js/[email protected]/spirits/aside/dox.FormSpirit.js
function ( label, input ) { var avail = this.box.width - label.offsetWidth; var space = gui.Client.isGecko ? 6 : 4; input.style.width = avail - space + "px"; }
javascript
function ( label, input ) { var avail = this.box.width - label.offsetWidth; var space = gui.Client.isGecko ? 6 : 4; input.style.width = avail - space + "px"; }
[ "function", "(", "label", ",", "input", ")", "{", "var", "avail", "=", "this", ".", "box", ".", "width", "-", "label", ".", "offsetWidth", ";", "var", "space", "=", "gui", ".", "Client", ".", "isGecko", "?", "6", ":", "4", ";", "input", ".", "style", ".", "width", "=", "avail", "-", "space", "+", "\"px\"", ";", "}" ]
Something that should go to CSS. @param {HTMLLabelElement} label @param {HTMLInputElement} input
[ "Something", "that", "should", "go", "to", "CSS", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/[email protected]/spirits/aside/dox.FormSpirit.js#L40-L44
49,610
alexpods/ClazzJS
src/components/meta/Base.js
function(clazz, metaData) { // Apply clazz interface if (!clazz.__isClazz) { _.extend(clazz, this.clazz_interface); } // Apply interface common for clazz and its prototype if (!clazz.__interfaces) { clazz.__interfaces = []; clazz.prototype.__interfaces = []; _.extend(clazz, this.common_interface); _.extend(clazz.prototype, this.common_interface); } // Calls sub processors clazz.__metaProcessors = metaData.meta_processors || {}; var parent = metaData.parent; if (parent) { if (!clazz.__isSubclazzOf(parent)) { throw new Error('Clazz "' + clazz.__name + '" must be sub clazz of "' + parent.__isClazz ? parent.__name : parent + '"!'); } } var processors = clazz.__getMetaProcessors(); _.each(processors, function(processor) { processor.process(clazz, metaData); }); // Sets clazz defaults if (_.isFunction(clazz.__setDefaults)) { clazz.__setDefaults(); } }
javascript
function(clazz, metaData) { // Apply clazz interface if (!clazz.__isClazz) { _.extend(clazz, this.clazz_interface); } // Apply interface common for clazz and its prototype if (!clazz.__interfaces) { clazz.__interfaces = []; clazz.prototype.__interfaces = []; _.extend(clazz, this.common_interface); _.extend(clazz.prototype, this.common_interface); } // Calls sub processors clazz.__metaProcessors = metaData.meta_processors || {}; var parent = metaData.parent; if (parent) { if (!clazz.__isSubclazzOf(parent)) { throw new Error('Clazz "' + clazz.__name + '" must be sub clazz of "' + parent.__isClazz ? parent.__name : parent + '"!'); } } var processors = clazz.__getMetaProcessors(); _.each(processors, function(processor) { processor.process(clazz, metaData); }); // Sets clazz defaults if (_.isFunction(clazz.__setDefaults)) { clazz.__setDefaults(); } }
[ "function", "(", "clazz", ",", "metaData", ")", "{", "// Apply clazz interface", "if", "(", "!", "clazz", ".", "__isClazz", ")", "{", "_", ".", "extend", "(", "clazz", ",", "this", ".", "clazz_interface", ")", ";", "}", "// Apply interface common for clazz and its prototype", "if", "(", "!", "clazz", ".", "__interfaces", ")", "{", "clazz", ".", "__interfaces", "=", "[", "]", ";", "clazz", ".", "prototype", ".", "__interfaces", "=", "[", "]", ";", "_", ".", "extend", "(", "clazz", ",", "this", ".", "common_interface", ")", ";", "_", ".", "extend", "(", "clazz", ".", "prototype", ",", "this", ".", "common_interface", ")", ";", "}", "// Calls sub processors", "clazz", ".", "__metaProcessors", "=", "metaData", ".", "meta_processors", "||", "{", "}", ";", "var", "parent", "=", "metaData", ".", "parent", ";", "if", "(", "parent", ")", "{", "if", "(", "!", "clazz", ".", "__isSubclazzOf", "(", "parent", ")", ")", "{", "throw", "new", "Error", "(", "'Clazz \"'", "+", "clazz", ".", "__name", "+", "'\" must be sub clazz of \"'", "+", "parent", ".", "__isClazz", "?", "parent", ".", "__name", ":", "parent", "+", "'\"!'", ")", ";", "}", "}", "var", "processors", "=", "clazz", ".", "__getMetaProcessors", "(", ")", ";", "_", ".", "each", "(", "processors", ",", "function", "(", "processor", ")", "{", "processor", ".", "process", "(", "clazz", ",", "metaData", ")", ";", "}", ")", ";", "// Sets clazz defaults", "if", "(", "_", ".", "isFunction", "(", "clazz", ".", "__setDefaults", ")", ")", "{", "clazz", ".", "__setDefaults", "(", ")", ";", "}", "}" ]
Process meta data for specified clazz @param {clazz} clazz Clazz @param {object} metaData Meta data @throw {Error} if wrong meta data are passed @this {metaProcessor}
[ "Process", "meta", "data", "for", "specified", "clazz" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L29-L69
49,611
alexpods/ClazzJS
src/components/meta/Base.js
function() { var processors = this._processors; _.each(processors, function(processor, name) { if (_.isString(processor)) { processors[name] = meta(processor); } }); return processors; }
javascript
function() { var processors = this._processors; _.each(processors, function(processor, name) { if (_.isString(processor)) { processors[name] = meta(processor); } }); return processors; }
[ "function", "(", ")", "{", "var", "processors", "=", "this", ".", "_processors", ";", "_", ".", "each", "(", "processors", ",", "function", "(", "processor", ",", "name", ")", "{", "if", "(", "_", ".", "isString", "(", "processor", ")", ")", "{", "processors", "[", "name", "]", "=", "meta", "(", "processor", ")", ";", "}", "}", ")", ";", "return", "processors", ";", "}" ]
Gets sub processors @returns {array} Sub processors @this {metaProcessor}
[ "Gets", "sub", "processors" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L78-L88
49,612
alexpods/ClazzJS
src/components/meta/Base.js
function(processors) { var that = this; _.each(processors, function(processor, name) { if (name in that._processors) { throw new Error('Processor "' + name + '" already exists!'); } that._processors[name] = processor; }); return this; }
javascript
function(processors) { var that = this; _.each(processors, function(processor, name) { if (name in that._processors) { throw new Error('Processor "' + name + '" already exists!'); } that._processors[name] = processor; }); return this; }
[ "function", "(", "processors", ")", "{", "var", "that", "=", "this", ";", "_", ".", "each", "(", "processors", ",", "function", "(", "processor", ",", "name", ")", "{", "if", "(", "name", "in", "that", ".", "_processors", ")", "{", "throw", "new", "Error", "(", "'Processor \"'", "+", "name", "+", "'\" already exists!'", ")", ";", "}", "that", ".", "_processors", "[", "name", "]", "=", "processor", ";", "}", ")", ";", "return", "this", ";", "}" ]
Sets sub processors @param {array} processors Sub processors @returns {metaProcessor} this @throws {Error} if sub processor already exist @this {metaProcessor}
[ "Sets", "sub", "processors" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L100-L110
49,613
alexpods/ClazzJS
src/components/meta/Base.js
function(parent) { var clazzParent = this; while (clazzParent) { if (clazzParent === parent || clazzParent.__name === parent) { return true; } clazzParent = clazzParent.__parent; } return false; }
javascript
function(parent) { var clazzParent = this; while (clazzParent) { if (clazzParent === parent || clazzParent.__name === parent) { return true; } clazzParent = clazzParent.__parent; } return false; }
[ "function", "(", "parent", ")", "{", "var", "clazzParent", "=", "this", ";", "while", "(", "clazzParent", ")", "{", "if", "(", "clazzParent", "===", "parent", "||", "clazzParent", ".", "__name", "===", "parent", ")", "{", "return", "true", ";", "}", "clazzParent", "=", "clazzParent", ".", "__parent", ";", "}", "return", "false", ";", "}" ]
Checks whether this clazz is sub clazz of specified one @param {clazz|string} parent Parent clazz @returns {boolean} true if this clazz is sub clazz of specified one @this {clazz}
[ "Checks", "whether", "this", "clazz", "is", "sub", "clazz", "of", "specified", "one" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L184-L195
49,614
alexpods/ClazzJS
src/components/meta/Base.js
function(property) { if (this.hasOwnProperty(property) && !_.isUndefined(this[property])) { return this[property]; } if (this.__proto && this.__proto.hasOwnProperty(property) && !_.isUndefined(this.__proto[property])) { return this.__proto[property]; } var parent = this.__parent; while (parent) { if (parent.hasOwnProperty(property) && !_.isUndefined(parent[property])) { return parent[property]; } parent = parent.__parent; } }
javascript
function(property) { if (this.hasOwnProperty(property) && !_.isUndefined(this[property])) { return this[property]; } if (this.__proto && this.__proto.hasOwnProperty(property) && !_.isUndefined(this.__proto[property])) { return this.__proto[property]; } var parent = this.__parent; while (parent) { if (parent.hasOwnProperty(property) && !_.isUndefined(parent[property])) { return parent[property]; } parent = parent.__parent; } }
[ "function", "(", "property", ")", "{", "if", "(", "this", ".", "hasOwnProperty", "(", "property", ")", "&&", "!", "_", ".", "isUndefined", "(", "this", "[", "property", "]", ")", ")", "{", "return", "this", "[", "property", "]", ";", "}", "if", "(", "this", ".", "__proto", "&&", "this", ".", "__proto", ".", "hasOwnProperty", "(", "property", ")", "&&", "!", "_", ".", "isUndefined", "(", "this", ".", "__proto", "[", "property", "]", ")", ")", "{", "return", "this", ".", "__proto", "[", "property", "]", ";", "}", "var", "parent", "=", "this", ".", "__parent", ";", "while", "(", "parent", ")", "{", "if", "(", "parent", ".", "hasOwnProperty", "(", "property", ")", "&&", "!", "_", ".", "isUndefined", "(", "parent", "[", "property", "]", ")", ")", "{", "return", "parent", "[", "property", "]", ";", "}", "parent", "=", "parent", ".", "__parent", ";", "}", "}" ]
Collects all property value from current and parent clazzes @param {string} property Property name @returns {*} Property value @this {clazz|object}
[ "Collects", "all", "property", "value", "from", "current", "and", "parent", "clazzes" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L241-L258
49,615
alexpods/ClazzJS
src/components/meta/Base.js
function(property, level /* fields */) { var propertyContainers = []; if (this.hasOwnProperty(property)) { propertyContainers.push(this[property]); } if (this.__proto && this.__proto.hasOwnProperty(property)) { propertyContainers.push(this.__proto[property]); } var parent = this.__parent; while (parent) { if (parent.hasOwnProperty(property)) { propertyContainers.push(parent[property]); } parent = parent.__parent; } var fields = _.toArray(arguments).slice(2); var propertyValues = {}; for (var i = 0, ii = propertyContainers.length; i < ii; ++i) { this.__collectValues(propertyValues, propertyContainers[i], level || 1, fields); } return propertyValues; }
javascript
function(property, level /* fields */) { var propertyContainers = []; if (this.hasOwnProperty(property)) { propertyContainers.push(this[property]); } if (this.__proto && this.__proto.hasOwnProperty(property)) { propertyContainers.push(this.__proto[property]); } var parent = this.__parent; while (parent) { if (parent.hasOwnProperty(property)) { propertyContainers.push(parent[property]); } parent = parent.__parent; } var fields = _.toArray(arguments).slice(2); var propertyValues = {}; for (var i = 0, ii = propertyContainers.length; i < ii; ++i) { this.__collectValues(propertyValues, propertyContainers[i], level || 1, fields); } return propertyValues; }
[ "function", "(", "property", ",", "level", "/* fields */", ")", "{", "var", "propertyContainers", "=", "[", "]", ";", "if", "(", "this", ".", "hasOwnProperty", "(", "property", ")", ")", "{", "propertyContainers", ".", "push", "(", "this", "[", "property", "]", ")", ";", "}", "if", "(", "this", ".", "__proto", "&&", "this", ".", "__proto", ".", "hasOwnProperty", "(", "property", ")", ")", "{", "propertyContainers", ".", "push", "(", "this", ".", "__proto", "[", "property", "]", ")", ";", "}", "var", "parent", "=", "this", ".", "__parent", ";", "while", "(", "parent", ")", "{", "if", "(", "parent", ".", "hasOwnProperty", "(", "property", ")", ")", "{", "propertyContainers", ".", "push", "(", "parent", "[", "property", "]", ")", ";", "}", "parent", "=", "parent", ".", "__parent", ";", "}", "var", "fields", "=", "_", ".", "toArray", "(", "arguments", ")", ".", "slice", "(", "2", ")", ";", "var", "propertyValues", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ",", "ii", "=", "propertyContainers", ".", "length", ";", "i", "<", "ii", ";", "++", "i", ")", "{", "this", ".", "__collectValues", "(", "propertyValues", ",", "propertyContainers", "[", "i", "]", ",", "level", "||", "1", ",", "fields", ")", ";", "}", "return", "propertyValues", ";", "}" ]
Collect all property values from current and parent clazzes @param {string} property Property name @param {number} level Level of property search depth @returns {*} Collected property values @this {clazz|object}
[ "Collect", "all", "property", "values", "from", "current", "and", "parent", "clazzes" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L269-L298
49,616
alexpods/ClazzJS
src/components/meta/Base.js
self
function self(collector, container, level, fields, reverse) { fields = [].concat(fields || []); _.each(container, function(value, name) { if (fields[0] && (name !== fields[0])) { return; } if (level > 1 && _.isSimpleObject(value)) { if (!(name in collector)) { collector[name] = {}; } self(collector[name], value, level-1, fields.slice(1)); } else if (reverse || (!(name in collector))) { collector[name] = value; } }); return collector; }
javascript
function self(collector, container, level, fields, reverse) { fields = [].concat(fields || []); _.each(container, function(value, name) { if (fields[0] && (name !== fields[0])) { return; } if (level > 1 && _.isSimpleObject(value)) { if (!(name in collector)) { collector[name] = {}; } self(collector[name], value, level-1, fields.slice(1)); } else if (reverse || (!(name in collector))) { collector[name] = value; } }); return collector; }
[ "function", "self", "(", "collector", ",", "container", ",", "level", ",", "fields", ",", "reverse", ")", "{", "fields", "=", "[", "]", ".", "concat", "(", "fields", "||", "[", "]", ")", ";", "_", ".", "each", "(", "container", ",", "function", "(", "value", ",", "name", ")", "{", "if", "(", "fields", "[", "0", "]", "&&", "(", "name", "!==", "fields", "[", "0", "]", ")", ")", "{", "return", ";", "}", "if", "(", "level", ">", "1", "&&", "_", ".", "isSimpleObject", "(", "value", ")", ")", "{", "if", "(", "!", "(", "name", "in", "collector", ")", ")", "{", "collector", "[", "name", "]", "=", "{", "}", ";", "}", "self", "(", "collector", "[", "name", "]", ",", "value", ",", "level", "-", "1", ",", "fields", ".", "slice", "(", "1", ")", ")", ";", "}", "else", "if", "(", "reverse", "||", "(", "!", "(", "name", "in", "collector", ")", ")", ")", "{", "collector", "[", "name", "]", "=", "value", ";", "}", "}", ")", ";", "return", "collector", ";", "}" ]
Collect values to specified collector @param {object} collector Collected values will be added to it @param {object} container Searched for specified fields @param {number} level Lever of property search depth @param {array} fields Searching @param {boolean} reverse If true overwrite collector property value @returns {object} Collector @this {clazz|object}
[ "Collect", "values", "to", "specified", "collector" ]
2f94496019669813c8246d48fcceb12a3e68a870
https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L313-L332
49,617
JamesMGreene/node-playerglobal-latest
index.js
function(FLEX_HOME, done) { var playersDir = path.join(FLEX_HOME, 'frameworks', 'libs', 'player'); if (fs.existsSync(playersDir) && fs.statSync(playersDir).isDirectory()) { var tmpDirRoot = os.tmpdir ? os.tmpdir() : os.tmpDir(); var tmpOldPlayersDir = path.join(tmpDirRoot, 'node-playerglobal'); var prepOldPlayerStorage = function(done) { function cb(err) { done(err ? new Error('Failed to prepare the storage location for the old "playerglobal.swc" library collection.\nError: ' + err) : null); } if (fs.existsSync(tmpOldPlayersDir)) { async.series( [ function(done) { rimraf(tmpOldPlayersDir, done); }, function(done) { mkdirp(tmpOldPlayersDir, done); } ], cb ); } else { mkdirp(tmpOldPlayersDir, cb); } }; var saveOldPlayers = function(done) { ncp(playersDir, tmpOldPlayersDir, function(err) { done(err ? new Error('Failed to maintain the old "playerglobal.swc" library collection.\nError: ' + err) : null); }); }; var installNewPlayers = function(done) { ncp(downloadDir, playersDir, function(err) { done(err ? new Error('Failed to install the new "playerglobal.swc" library collection.\nError: ' + err) : null); }); }; var restoreNonConflictingOldPlayers = function(done) { ncp(tmpOldPlayersDir, playersDir, { clobber: false }, function(err) { if (err) { console.warn('WARNING: Failed to restore any non-conflicting files from the old "playerglobal.swc" library collection.\nError: ' + err); } done(); }); }; async.series( [ prepOldPlayerStorage, saveOldPlayers, installNewPlayers, restoreNonConflictingOldPlayers ], done ); } else { done(new TypeError('The FLEX_HOME provided does not contain the expected directory structure')); } }
javascript
function(FLEX_HOME, done) { var playersDir = path.join(FLEX_HOME, 'frameworks', 'libs', 'player'); if (fs.existsSync(playersDir) && fs.statSync(playersDir).isDirectory()) { var tmpDirRoot = os.tmpdir ? os.tmpdir() : os.tmpDir(); var tmpOldPlayersDir = path.join(tmpDirRoot, 'node-playerglobal'); var prepOldPlayerStorage = function(done) { function cb(err) { done(err ? new Error('Failed to prepare the storage location for the old "playerglobal.swc" library collection.\nError: ' + err) : null); } if (fs.existsSync(tmpOldPlayersDir)) { async.series( [ function(done) { rimraf(tmpOldPlayersDir, done); }, function(done) { mkdirp(tmpOldPlayersDir, done); } ], cb ); } else { mkdirp(tmpOldPlayersDir, cb); } }; var saveOldPlayers = function(done) { ncp(playersDir, tmpOldPlayersDir, function(err) { done(err ? new Error('Failed to maintain the old "playerglobal.swc" library collection.\nError: ' + err) : null); }); }; var installNewPlayers = function(done) { ncp(downloadDir, playersDir, function(err) { done(err ? new Error('Failed to install the new "playerglobal.swc" library collection.\nError: ' + err) : null); }); }; var restoreNonConflictingOldPlayers = function(done) { ncp(tmpOldPlayersDir, playersDir, { clobber: false }, function(err) { if (err) { console.warn('WARNING: Failed to restore any non-conflicting files from the old "playerglobal.swc" library collection.\nError: ' + err); } done(); }); }; async.series( [ prepOldPlayerStorage, saveOldPlayers, installNewPlayers, restoreNonConflictingOldPlayers ], done ); } else { done(new TypeError('The FLEX_HOME provided does not contain the expected directory structure')); } }
[ "function", "(", "FLEX_HOME", ",", "done", ")", "{", "var", "playersDir", "=", "path", ".", "join", "(", "FLEX_HOME", ",", "'frameworks'", ",", "'libs'", ",", "'player'", ")", ";", "if", "(", "fs", ".", "existsSync", "(", "playersDir", ")", "&&", "fs", ".", "statSync", "(", "playersDir", ")", ".", "isDirectory", "(", ")", ")", "{", "var", "tmpDirRoot", "=", "os", ".", "tmpdir", "?", "os", ".", "tmpdir", "(", ")", ":", "os", ".", "tmpDir", "(", ")", ";", "var", "tmpOldPlayersDir", "=", "path", ".", "join", "(", "tmpDirRoot", ",", "'node-playerglobal'", ")", ";", "var", "prepOldPlayerStorage", "=", "function", "(", "done", ")", "{", "function", "cb", "(", "err", ")", "{", "done", "(", "err", "?", "new", "Error", "(", "'Failed to prepare the storage location for the old \"playerglobal.swc\" library collection.\\nError: '", "+", "err", ")", ":", "null", ")", ";", "}", "if", "(", "fs", ".", "existsSync", "(", "tmpOldPlayersDir", ")", ")", "{", "async", ".", "series", "(", "[", "function", "(", "done", ")", "{", "rimraf", "(", "tmpOldPlayersDir", ",", "done", ")", ";", "}", ",", "function", "(", "done", ")", "{", "mkdirp", "(", "tmpOldPlayersDir", ",", "done", ")", ";", "}", "]", ",", "cb", ")", ";", "}", "else", "{", "mkdirp", "(", "tmpOldPlayersDir", ",", "cb", ")", ";", "}", "}", ";", "var", "saveOldPlayers", "=", "function", "(", "done", ")", "{", "ncp", "(", "playersDir", ",", "tmpOldPlayersDir", ",", "function", "(", "err", ")", "{", "done", "(", "err", "?", "new", "Error", "(", "'Failed to maintain the old \"playerglobal.swc\" library collection.\\nError: '", "+", "err", ")", ":", "null", ")", ";", "}", ")", ";", "}", ";", "var", "installNewPlayers", "=", "function", "(", "done", ")", "{", "ncp", "(", "downloadDir", ",", "playersDir", ",", "function", "(", "err", ")", "{", "done", "(", "err", "?", "new", "Error", "(", "'Failed to install the new \"playerglobal.swc\" library collection.\\nError: '", "+", "err", ")", ":", "null", ")", ";", "}", ")", ";", "}", ";", "var", "restoreNonConflictingOldPlayers", "=", "function", "(", "done", ")", "{", "ncp", "(", "tmpOldPlayersDir", ",", "playersDir", ",", "{", "clobber", ":", "false", "}", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "console", ".", "warn", "(", "'WARNING: Failed to restore any non-conflicting files from the old \"playerglobal.swc\" library collection.\\nError: '", "+", "err", ")", ";", "}", "done", "(", ")", ";", "}", ")", ";", "}", ";", "async", ".", "series", "(", "[", "prepOldPlayerStorage", ",", "saveOldPlayers", ",", "installNewPlayers", ",", "restoreNonConflictingOldPlayers", "]", ",", "done", ")", ";", "}", "else", "{", "done", "(", "new", "TypeError", "(", "'The FLEX_HOME provided does not contain the expected directory structure'", ")", ")", ";", "}", "}" ]
Install these "playerglobal.swc" files into the appropriate location within a Flex SDK directory
[ "Install", "these", "playerglobal", ".", "swc", "files", "into", "the", "appropriate", "location", "within", "a", "Flex", "SDK", "directory" ]
600426fb30f62f013f9bcf966115c5cce90a076d
https://github.com/JamesMGreene/node-playerglobal-latest/blob/600426fb30f62f013f9bcf966115c5cce90a076d/index.js#L24-L87
49,618
wunderbyte/grunt-spiritual-dox
src/js/[email protected]/spirits/main/dox.MainSpirit.js
function () { this._super.onready (); this.element.tabIndex = 0; this._doctitle ( location.hash ); this.event.add ( "hashchange", window ); }
javascript
function () { this._super.onready (); this.element.tabIndex = 0; this._doctitle ( location.hash ); this.event.add ( "hashchange", window ); }
[ "function", "(", ")", "{", "this", ".", "_super", ".", "onready", "(", ")", ";", "this", ".", "element", ".", "tabIndex", "=", "0", ";", "this", ".", "_doctitle", "(", "location", ".", "hash", ")", ";", "this", ".", "event", ".", "add", "(", "\"hashchange\"", ",", "window", ")", ";", "}" ]
Support focus transfer to MAIN whenever the ASIDE gets closed.
[ "Support", "focus", "transfer", "to", "MAIN", "whenever", "the", "ASIDE", "gets", "closed", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/[email protected]/spirits/main/dox.MainSpirit.js#L10-L15
49,619
junosuarez/prometido
index.js
when
function when(promises) { promises = arrayify(promises); var whenPromise = new PromiseFactory(); var pending = promises.length; var results = []; var resolve = function (i) { return function (val) { results[i] = val; pending--; if (pending === 0) { whenPromise.resolve(results); } }; }; promises.forEach(function (p, i) { if (!p || !p.then) return; p.then(resolve(i), whenPromise.reject); }); return whenPromise.promise(); }
javascript
function when(promises) { promises = arrayify(promises); var whenPromise = new PromiseFactory(); var pending = promises.length; var results = []; var resolve = function (i) { return function (val) { results[i] = val; pending--; if (pending === 0) { whenPromise.resolve(results); } }; }; promises.forEach(function (p, i) { if (!p || !p.then) return; p.then(resolve(i), whenPromise.reject); }); return whenPromise.promise(); }
[ "function", "when", "(", "promises", ")", "{", "promises", "=", "arrayify", "(", "promises", ")", ";", "var", "whenPromise", "=", "new", "PromiseFactory", "(", ")", ";", "var", "pending", "=", "promises", ".", "length", ";", "var", "results", "=", "[", "]", ";", "var", "resolve", "=", "function", "(", "i", ")", "{", "return", "function", "(", "val", ")", "{", "results", "[", "i", "]", "=", "val", ";", "pending", "--", ";", "if", "(", "pending", "===", "0", ")", "{", "whenPromise", ".", "resolve", "(", "results", ")", ";", "}", "}", ";", "}", ";", "promises", ".", "forEach", "(", "function", "(", "p", ",", "i", ")", "{", "if", "(", "!", "p", "||", "!", "p", ".", "then", ")", "return", ";", "p", ".", "then", "(", "resolve", "(", "i", ")", ",", "whenPromise", ".", "reject", ")", ";", "}", ")", ";", "return", "whenPromise", ".", "promise", "(", ")", ";", "}" ]
Aggregates an array of promises into one promise which is resolved when every constituent promise is resolved or rejected when some constituent promise is rejected @param {Promise|Array.<Promise>} promises @return {Promise}
[ "Aggregates", "an", "array", "of", "promises", "into", "one", "promise", "which", "is", "resolved", "when", "every", "constituent", "promise", "is", "resolved", "or", "rejected", "when", "some", "constituent", "promise", "is", "rejected" ]
20ff7a41b355e60d13859770956090cd098ac5c2
https://github.com/junosuarez/prometido/blob/20ff7a41b355e60d13859770956090cd098ac5c2/index.js#L20-L45
49,620
junosuarez/prometido
index.js
PromiseFactory
function PromiseFactory() { var deferred = whenjs.defer(); //var timeout = setTimeout(function () { console.log(t, 'Promise timed out')}, 3000); this.reject = function (err) { deferred.reject(err); }; this.resolve = function (val) { // clearTimeout(timeout); deferred.resolve(val); }; this.promise = function () { return deferred.promise; }; }
javascript
function PromiseFactory() { var deferred = whenjs.defer(); //var timeout = setTimeout(function () { console.log(t, 'Promise timed out')}, 3000); this.reject = function (err) { deferred.reject(err); }; this.resolve = function (val) { // clearTimeout(timeout); deferred.resolve(val); }; this.promise = function () { return deferred.promise; }; }
[ "function", "PromiseFactory", "(", ")", "{", "var", "deferred", "=", "whenjs", ".", "defer", "(", ")", ";", "//var timeout = setTimeout(function () { console.log(t, 'Promise timed out')}, 3000);", "this", ".", "reject", "=", "function", "(", "err", ")", "{", "deferred", ".", "reject", "(", "err", ")", ";", "}", ";", "this", ".", "resolve", "=", "function", "(", "val", ")", "{", "//\tclearTimeout(timeout);", "deferred", ".", "resolve", "(", "val", ")", ";", "}", ";", "this", ".", "promise", "=", "function", "(", ")", "{", "return", "deferred", ".", "promise", ";", "}", ";", "}" ]
Make an object with properly-bound `resolve` and `reject`
[ "Make", "an", "object", "with", "properly", "-", "bound", "resolve", "and", "reject" ]
20ff7a41b355e60d13859770956090cd098ac5c2
https://github.com/junosuarez/prometido/blob/20ff7a41b355e60d13859770956090cd098ac5c2/index.js#L92-L106
49,621
junosuarez/prometido
index.js
asPromise
function asPromise (val) { if (val && typeof val.then === 'function') { return val; } var deferred = new PromiseFactory(); deferred.resolve(val); return deferred.promise(); }
javascript
function asPromise (val) { if (val && typeof val.then === 'function') { return val; } var deferred = new PromiseFactory(); deferred.resolve(val); return deferred.promise(); }
[ "function", "asPromise", "(", "val", ")", "{", "if", "(", "val", "&&", "typeof", "val", ".", "then", "===", "'function'", ")", "{", "return", "val", ";", "}", "var", "deferred", "=", "new", "PromiseFactory", "(", ")", ";", "deferred", ".", "resolve", "(", "val", ")", ";", "return", "deferred", ".", "promise", "(", ")", ";", "}" ]
Helper function to return a resolved promise with a given value
[ "Helper", "function", "to", "return", "a", "resolved", "promise", "with", "a", "given", "value" ]
20ff7a41b355e60d13859770956090cd098ac5c2
https://github.com/junosuarez/prometido/blob/20ff7a41b355e60d13859770956090cd098ac5c2/index.js#L111-L118
49,622
lisplate/lisplate
spec/lib/jsreporter.js
failures
function failures (items) { var fs = [], i, v; for (i = 0; i < items.length; i += 1) { v = items[i]; if (!v.passed_) { fs.push(v); } } return fs; }
javascript
function failures (items) { var fs = [], i, v; for (i = 0; i < items.length; i += 1) { v = items[i]; if (!v.passed_) { fs.push(v); } } return fs; }
[ "function", "failures", "(", "items", ")", "{", "var", "fs", "=", "[", "]", ",", "i", ",", "v", ";", "for", "(", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", "+=", "1", ")", "{", "v", "=", "items", "[", "i", "]", ";", "if", "(", "!", "v", ".", "passed_", ")", "{", "fs", ".", "push", "(", "v", ")", ";", "}", "}", "return", "fs", ";", "}" ]
Create a new array which contains only the failed items. @param items Items which will be filtered @returns {Array} of failed items
[ "Create", "a", "new", "array", "which", "contains", "only", "the", "failed", "items", "." ]
75ae58facbe52158270fd40bb9a9d650c97d2ed9
https://github.com/lisplate/lisplate/blob/75ae58facbe52158270fd40bb9a9d650c97d2ed9/spec/lib/jsreporter.js#L64-L73
49,623
wbyoung/corazon
lib/mixin.js
function() { return this.__all__.reduce(function(all, mixin) { return mixin instanceof Mixin.__class__ ? all.concat(mixin.__flatten__()) : all.concat([mixin]); }, []); }
javascript
function() { return this.__all__.reduce(function(all, mixin) { return mixin instanceof Mixin.__class__ ? all.concat(mixin.__flatten__()) : all.concat([mixin]); }, []); }
[ "function", "(", ")", "{", "return", "this", ".", "__all__", ".", "reduce", "(", "function", "(", "all", ",", "mixin", ")", "{", "return", "mixin", "instanceof", "Mixin", ".", "__class__", "?", "all", ".", "concat", "(", "mixin", ".", "__flatten__", "(", ")", ")", ":", "all", ".", "concat", "(", "[", "mixin", "]", ")", ";", "}", ",", "[", "]", ")", ";", "}" ]
Create a flattened array of properties are required to be mixed into a class in the order in which they should be mixed in. @method @private @return {Array.<Object>} The properties
[ "Create", "a", "flattened", "array", "of", "properties", "are", "required", "to", "be", "mixed", "into", "a", "class", "in", "the", "order", "in", "which", "they", "should", "be", "mixed", "in", "." ]
c3cc87f3de28f8e40ab091c8f215479c9e61f379
https://github.com/wbyoung/corazon/blob/c3cc87f3de28f8e40ab091c8f215479c9e61f379/lib/mixin.js#L38-L44
49,624
wbyoung/corazon
lib/mixin.js
function(reopen, name) { return function() { // the `reopen` function that was passed in to this function will continue // the process of reopening to the function that this is monkey-patching. // it is not a recursive call. // the `recursiveReopen` function, on the other hand, is the reopen // function that's actually defined on the class object and will allow us // to restart the reopen process from the beginning for each individual // mixin that we find. var recursiveReopen = Class.__metaclass__.prototype[name]; var args = _.toArray(arguments); var properties = args.shift(); if (properties instanceof Mixin.__class__) { properties.__flatten__().forEach(function(mixin) { recursiveReopen.call(this, mixin); }, this); properties = {}; } args.unshift(properties); return reopen.apply(this, args); }; }
javascript
function(reopen, name) { return function() { // the `reopen` function that was passed in to this function will continue // the process of reopening to the function that this is monkey-patching. // it is not a recursive call. // the `recursiveReopen` function, on the other hand, is the reopen // function that's actually defined on the class object and will allow us // to restart the reopen process from the beginning for each individual // mixin that we find. var recursiveReopen = Class.__metaclass__.prototype[name]; var args = _.toArray(arguments); var properties = args.shift(); if (properties instanceof Mixin.__class__) { properties.__flatten__().forEach(function(mixin) { recursiveReopen.call(this, mixin); }, this); properties = {}; } args.unshift(properties); return reopen.apply(this, args); }; }
[ "function", "(", "reopen", ",", "name", ")", "{", "return", "function", "(", ")", "{", "// the `reopen` function that was passed in to this function will continue", "// the process of reopening to the function that this is monkey-patching.", "// it is not a recursive call.", "// the `recursiveReopen` function, on the other hand, is the reopen", "// function that's actually defined on the class object and will allow us", "// to restart the reopen process from the beginning for each individual", "// mixin that we find.", "var", "recursiveReopen", "=", "Class", ".", "__metaclass__", ".", "prototype", "[", "name", "]", ";", "var", "args", "=", "_", ".", "toArray", "(", "arguments", ")", ";", "var", "properties", "=", "args", ".", "shift", "(", ")", ";", "if", "(", "properties", "instanceof", "Mixin", ".", "__class__", ")", "{", "properties", ".", "__flatten__", "(", ")", ".", "forEach", "(", "function", "(", "mixin", ")", "{", "recursiveReopen", ".", "call", "(", "this", ",", "mixin", ")", ";", "}", ",", "this", ")", ";", "properties", "=", "{", "}", ";", "}", "args", ".", "unshift", "(", "properties", ")", ";", "return", "reopen", ".", "apply", "(", "this", ",", "args", ")", ";", "}", ";", "}" ]
Shared function for supporting mixins via `reopen` and `reopenClass`. @memberof Mixin~ClassPatching @type function @private
[ "Shared", "function", "for", "supporting", "mixins", "via", "reopen", "and", "reopenClass", "." ]
c3cc87f3de28f8e40ab091c8f215479c9e61f379
https://github.com/wbyoung/corazon/blob/c3cc87f3de28f8e40ab091c8f215479c9e61f379/lib/mixin.js#L100-L124
49,625
loomio/router
docs/traceur-package/services/atParser.js
parseModule
function parseModule(fileInfo) { var moduleName = file2modulename(fileInfo.relativePath); var sourceFile = new SourceFile(moduleName, fileInfo.content); var comments = []; var moduleTree; var parser = new Parser(sourceFile); // Configure the parser parser.handleComment = function(range) { comments.push({ range: range }); }; traceurOptions.setFromObject(service.traceurOptions); try { // Parse the file as a module, attaching the comments moduleTree = parser.parseModule(); attachComments(moduleTree, comments); } catch(ex) { // HACK: sometime traceur crashes for various reasons including // Not Yet Implemented (NYI)! log.error(ex.stack); moduleTree = {}; } log.debug(moduleName); moduleTree.moduleName = moduleName; // We return the module AST but also a collection of all the comments // since it can be helpful to iterate through them without having to // traverse the AST again return { moduleTree: moduleTree, comments: comments }; }
javascript
function parseModule(fileInfo) { var moduleName = file2modulename(fileInfo.relativePath); var sourceFile = new SourceFile(moduleName, fileInfo.content); var comments = []; var moduleTree; var parser = new Parser(sourceFile); // Configure the parser parser.handleComment = function(range) { comments.push({ range: range }); }; traceurOptions.setFromObject(service.traceurOptions); try { // Parse the file as a module, attaching the comments moduleTree = parser.parseModule(); attachComments(moduleTree, comments); } catch(ex) { // HACK: sometime traceur crashes for various reasons including // Not Yet Implemented (NYI)! log.error(ex.stack); moduleTree = {}; } log.debug(moduleName); moduleTree.moduleName = moduleName; // We return the module AST but also a collection of all the comments // since it can be helpful to iterate through them without having to // traverse the AST again return { moduleTree: moduleTree, comments: comments }; }
[ "function", "parseModule", "(", "fileInfo", ")", "{", "var", "moduleName", "=", "file2modulename", "(", "fileInfo", ".", "relativePath", ")", ";", "var", "sourceFile", "=", "new", "SourceFile", "(", "moduleName", ",", "fileInfo", ".", "content", ")", ";", "var", "comments", "=", "[", "]", ";", "var", "moduleTree", ";", "var", "parser", "=", "new", "Parser", "(", "sourceFile", ")", ";", "// Configure the parser", "parser", ".", "handleComment", "=", "function", "(", "range", ")", "{", "comments", ".", "push", "(", "{", "range", ":", "range", "}", ")", ";", "}", ";", "traceurOptions", ".", "setFromObject", "(", "service", ".", "traceurOptions", ")", ";", "try", "{", "// Parse the file as a module, attaching the comments", "moduleTree", "=", "parser", ".", "parseModule", "(", ")", ";", "attachComments", "(", "moduleTree", ",", "comments", ")", ";", "}", "catch", "(", "ex", ")", "{", "// HACK: sometime traceur crashes for various reasons including", "// Not Yet Implemented (NYI)!", "log", ".", "error", "(", "ex", ".", "stack", ")", ";", "moduleTree", "=", "{", "}", ";", "}", "log", ".", "debug", "(", "moduleName", ")", ";", "moduleTree", ".", "moduleName", "=", "moduleName", ";", "// We return the module AST but also a collection of all the comments", "// since it can be helpful to iterate through them without having to", "// traverse the AST again", "return", "{", "moduleTree", ":", "moduleTree", ",", "comments", ":", "comments", "}", ";", "}" ]
Parse the contents of the file using traceur
[ "Parse", "the", "contents", "of", "the", "file", "using", "traceur" ]
4af3b95674216b6a415b802322f5e44b78351d06
https://github.com/loomio/router/blob/4af3b95674216b6a415b802322f5e44b78351d06/docs/traceur-package/services/atParser.js#L30-L64
49,626
dalekjs/dalek-driver-sauce
lib/commands/cookie.js
function (name, contents, hash) { this.actionQueue.push(this.webdriverClient.setCookie.bind(this.webdriverClient, {name: name, value: contents})); this.actionQueue.push(this._setCookieCb.bind(this, name, contents, hash)); return this; }
javascript
function (name, contents, hash) { this.actionQueue.push(this.webdriverClient.setCookie.bind(this.webdriverClient, {name: name, value: contents})); this.actionQueue.push(this._setCookieCb.bind(this, name, contents, hash)); return this; }
[ "function", "(", "name", ",", "contents", ",", "hash", ")", "{", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "webdriverClient", ".", "setCookie", ".", "bind", "(", "this", ".", "webdriverClient", ",", "{", "name", ":", "name", ",", "value", ":", "contents", "}", ")", ")", ";", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "_setCookieCb", ".", "bind", "(", "this", ",", "name", ",", "contents", ",", "hash", ")", ")", ";", "return", "this", ";", "}" ]
Sets an cookie @method setCookie @param {string} name Name of the cookie @param {string} contents Contents of the cookie @param {string} hash Unique hash of that fn call @chainable
[ "Sets", "an", "cookie" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/cookie.js#L50-L54
49,627
dalekjs/dalek-driver-sauce
lib/commands/cookie.js
function (name, cookie, hash) { this.actionQueue.push(this.webdriverClient.getCookie.bind(this.webdriverClient, name)); this.actionQueue.push(this._cookieCb.bind(this, name, hash)); return this; }
javascript
function (name, cookie, hash) { this.actionQueue.push(this.webdriverClient.getCookie.bind(this.webdriverClient, name)); this.actionQueue.push(this._cookieCb.bind(this, name, hash)); return this; }
[ "function", "(", "name", ",", "cookie", ",", "hash", ")", "{", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "webdriverClient", ".", "getCookie", ".", "bind", "(", "this", ".", "webdriverClient", ",", "name", ")", ")", ";", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "_cookieCb", ".", "bind", "(", "this", ",", "name", ",", "hash", ")", ")", ";", "return", "this", ";", "}" ]
Retrieves an cookie @method cookie @param {string} name Name of the cookie @param {string} cookie Expected contents of the cookie @param {string} hash Unique hash of that fn call @chainable
[ "Retrieves", "an", "cookie" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/cookie.js#L84-L88
49,628
jgnewman/brightsocket.io
src/socketpool.js
send
function send(pool, id, event, message) { const socket = pool.sockets.connected[id]; if (socket) { return socket.emit(event, message); } else { console.log(`Cannot send ${event} to disconnected socket ${id}`); } }
javascript
function send(pool, id, event, message) { const socket = pool.sockets.connected[id]; if (socket) { return socket.emit(event, message); } else { console.log(`Cannot send ${event} to disconnected socket ${id}`); } }
[ "function", "send", "(", "pool", ",", "id", ",", "event", ",", "message", ")", "{", "const", "socket", "=", "pool", ".", "sockets", ".", "connected", "[", "id", "]", ";", "if", "(", "socket", ")", "{", "return", "socket", ".", "emit", "(", "event", ",", "message", ")", ";", "}", "else", "{", "console", ".", "log", "(", "`", "${", "event", "}", "${", "id", "}", "`", ")", ";", "}", "}" ]
Sends a message to a single socket connected to socket.io. @param {Object} pool The socket.io connection pool. @param {String} id The socket's ID. @param {String} event The name of the event to emit. @param {Any} message The serializable message to send. @return {undefined}
[ "Sends", "a", "message", "to", "a", "single", "socket", "connected", "to", "socket", ".", "io", "." ]
19ec67d69946ab09ca389143ebbdcb0a7f22f950
https://github.com/jgnewman/brightsocket.io/blob/19ec67d69946ab09ca389143ebbdcb0a7f22f950/src/socketpool.js#L59-L66
49,629
pdubroy/jsjoins
index.js
newChannel
function newChannel() { let chan = new Channel(); let result = chan.send.bind(chan); result._inst = chan; return result; }
javascript
function newChannel() { let chan = new Channel(); let result = chan.send.bind(chan); result._inst = chan; return result; }
[ "function", "newChannel", "(", ")", "{", "let", "chan", "=", "new", "Channel", "(", ")", ";", "let", "result", "=", "chan", ".", "send", ".", "bind", "(", "chan", ")", ";", "result", ".", "_inst", "=", "chan", ";", "return", "result", ";", "}" ]
Create a new synchronous channel, and return a function which sends a message on that channel.
[ "Create", "a", "new", "synchronous", "channel", "and", "return", "a", "function", "which", "sends", "a", "message", "on", "that", "channel", "." ]
5848fe6e9695f4af7254be8cb7f6b5c61db577eb
https://github.com/pdubroy/jsjoins/blob/5848fe6e9695f4af7254be8cb7f6b5c61db577eb/index.js#L249-L254
49,630
yefremov/aggregatejs
variance.js
variance
function variance(array) { var length = array.length; if (length === 0) { throw new RangeError('Error'); } var index = -1; var mean = 0; while (++index < length) { mean += array[index] / length; } var result = 0; for (var i = 0; i < length; i++) { result += Math.pow(array[i] - mean, 2); } return 1 / length * result; }
javascript
function variance(array) { var length = array.length; if (length === 0) { throw new RangeError('Error'); } var index = -1; var mean = 0; while (++index < length) { mean += array[index] / length; } var result = 0; for (var i = 0; i < length; i++) { result += Math.pow(array[i] - mean, 2); } return 1 / length * result; }
[ "function", "variance", "(", "array", ")", "{", "var", "length", "=", "array", ".", "length", ";", "if", "(", "length", "===", "0", ")", "{", "throw", "new", "RangeError", "(", "'Error'", ")", ";", "}", "var", "index", "=", "-", "1", ";", "var", "mean", "=", "0", ";", "while", "(", "++", "index", "<", "length", ")", "{", "mean", "+=", "array", "[", "index", "]", "/", "length", ";", "}", "var", "result", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "result", "+=", "Math", ".", "pow", "(", "array", "[", "i", "]", "-", "mean", ",", "2", ")", ";", "}", "return", "1", "/", "length", "*", "result", ";", "}" ]
Returns the variance population of the numbers in `array`. @param {Array} array @return {number} @example variance([2, 4, 4, 4, 5, 5, 7, 9]); // => 4
[ "Returns", "the", "variance", "population", "of", "the", "numbers", "in", "array", "." ]
932b28a15a5707135e7095950000a838db409511
https://github.com/yefremov/aggregatejs/blob/932b28a15a5707135e7095950000a838db409511/variance.js#L19-L40
49,631
derdesign/protos
engines/swig.js
Swig
function Swig() { var opts = (app.config.engines && app.config.engines.swig) || {}; this.options = protos.extend({ cache: false }, opts); swig.setDefaults(this.options); // Set options for swig this.module = swig; this.multiPart = true; this.extensions = ['swig', 'swig.html']; }
javascript
function Swig() { var opts = (app.config.engines && app.config.engines.swig) || {}; this.options = protos.extend({ cache: false }, opts); swig.setDefaults(this.options); // Set options for swig this.module = swig; this.multiPart = true; this.extensions = ['swig', 'swig.html']; }
[ "function", "Swig", "(", ")", "{", "var", "opts", "=", "(", "app", ".", "config", ".", "engines", "&&", "app", ".", "config", ".", "engines", ".", "swig", ")", "||", "{", "}", ";", "this", ".", "options", "=", "protos", ".", "extend", "(", "{", "cache", ":", "false", "}", ",", "opts", ")", ";", "swig", ".", "setDefaults", "(", "this", ".", "options", ")", ";", "// Set options for swig", "this", ".", "module", "=", "swig", ";", "this", ".", "multiPart", "=", "true", ";", "this", ".", "extensions", "=", "[", "'swig'", ",", "'swig.html'", "]", ";", "}" ]
Swig engine class https://github.com/paularmstrong/swig
[ "Swig", "engine", "class" ]
0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9
https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/engines/swig.js#L14-L28
49,632
warmsea/WarmseaJS
src/debug.js
function(name) { if (debuggers[name]) { return debuggers[name]; } var dbg = function(fmt) { // if this debugger is not enabled, do nothing. // Check it every time so we can enable or disable a debugger at runtime. // It won't be slow. if (!enableStatus[this._name]) { return; } fmt = coerce.apply(this, arguments); var curr = +new Date(); // IE8 don't have `Date.now()` var ms = curr - (this._timestamp || curr); this._timestamp = curr; if (isChrome) { fmt = '%c' + name + '%c ' + fmt + ' %c+' + humanize(ms); w.global.console.log(fmt, this._style, this._msgStyle, this._style); } else { fmt = name + ' ' + fmt + ' +' + humanize(ms); if (w.global.console && w.global.console.log) { w.global.console.log(fmt); } // Any one want to alert debug message? I think it's annoying. } }; dbg._name = name; dbg._msgStyle = styles[0]; dbg._style = style(); enableStatus[name] = debug.enabled(name); debuggers[name] = dbg.bind(dbg); return debuggers[name]; }
javascript
function(name) { if (debuggers[name]) { return debuggers[name]; } var dbg = function(fmt) { // if this debugger is not enabled, do nothing. // Check it every time so we can enable or disable a debugger at runtime. // It won't be slow. if (!enableStatus[this._name]) { return; } fmt = coerce.apply(this, arguments); var curr = +new Date(); // IE8 don't have `Date.now()` var ms = curr - (this._timestamp || curr); this._timestamp = curr; if (isChrome) { fmt = '%c' + name + '%c ' + fmt + ' %c+' + humanize(ms); w.global.console.log(fmt, this._style, this._msgStyle, this._style); } else { fmt = name + ' ' + fmt + ' +' + humanize(ms); if (w.global.console && w.global.console.log) { w.global.console.log(fmt); } // Any one want to alert debug message? I think it's annoying. } }; dbg._name = name; dbg._msgStyle = styles[0]; dbg._style = style(); enableStatus[name] = debug.enabled(name); debuggers[name] = dbg.bind(dbg); return debuggers[name]; }
[ "function", "(", "name", ")", "{", "if", "(", "debuggers", "[", "name", "]", ")", "{", "return", "debuggers", "[", "name", "]", ";", "}", "var", "dbg", "=", "function", "(", "fmt", ")", "{", "// if this debugger is not enabled, do nothing.", "// Check it every time so we can enable or disable a debugger at runtime.", "// It won't be slow.", "if", "(", "!", "enableStatus", "[", "this", ".", "_name", "]", ")", "{", "return", ";", "}", "fmt", "=", "coerce", ".", "apply", "(", "this", ",", "arguments", ")", ";", "var", "curr", "=", "+", "new", "Date", "(", ")", ";", "// IE8 don't have `Date.now()`", "var", "ms", "=", "curr", "-", "(", "this", ".", "_timestamp", "||", "curr", ")", ";", "this", ".", "_timestamp", "=", "curr", ";", "if", "(", "isChrome", ")", "{", "fmt", "=", "'%c'", "+", "name", "+", "'%c '", "+", "fmt", "+", "' %c+'", "+", "humanize", "(", "ms", ")", ";", "w", ".", "global", ".", "console", ".", "log", "(", "fmt", ",", "this", ".", "_style", ",", "this", ".", "_msgStyle", ",", "this", ".", "_style", ")", ";", "}", "else", "{", "fmt", "=", "name", "+", "' '", "+", "fmt", "+", "' +'", "+", "humanize", "(", "ms", ")", ";", "if", "(", "w", ".", "global", ".", "console", "&&", "w", ".", "global", ".", "console", ".", "log", ")", "{", "w", ".", "global", ".", "console", ".", "log", "(", "fmt", ")", ";", "}", "// Any one want to alert debug message? I think it's annoying.", "}", "}", ";", "dbg", ".", "_name", "=", "name", ";", "dbg", ".", "_msgStyle", "=", "styles", "[", "0", "]", ";", "dbg", ".", "_style", "=", "style", "(", ")", ";", "enableStatus", "[", "name", "]", "=", "debug", ".", "enabled", "(", "name", ")", ";", "debuggers", "[", "name", "]", "=", "dbg", ".", "bind", "(", "dbg", ")", ";", "return", "debuggers", "[", "name", "]", ";", "}" ]
Create a debugger function with a name. @param {string} name @return {function}
[ "Create", "a", "debugger", "function", "with", "a", "name", "." ]
58c32c75b26647bbec39dc401a78b0fdb5896c8d
https://github.com/warmsea/WarmseaJS/blob/58c32c75b26647bbec39dc401a78b0fdb5896c8d/src/debug.js#L81-L116
49,633
warmsea/WarmseaJS
src/debug.js
function(fmt) { if (fmt instanceof Error) { return fmt.stack || fmt.message; } else { return w.format.apply(this, arguments); } }
javascript
function(fmt) { if (fmt instanceof Error) { return fmt.stack || fmt.message; } else { return w.format.apply(this, arguments); } }
[ "function", "(", "fmt", ")", "{", "if", "(", "fmt", "instanceof", "Error", ")", "{", "return", "fmt", ".", "stack", "||", "fmt", ".", "message", ";", "}", "else", "{", "return", "w", ".", "format", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "}" ]
Coerce `fmt`.
[ "Coerce", "fmt", "." ]
58c32c75b26647bbec39dc401a78b0fdb5896c8d
https://github.com/warmsea/WarmseaJS/blob/58c32c75b26647bbec39dc401a78b0fdb5896c8d/src/debug.js#L121-L127
49,634
warmsea/WarmseaJS
src/debug.js
function(ms) { var sec = 1000; var min = 60 * 1000; var hour = 60 * min; if (ms >= hour) { return (ms / hour).toFixed(1) + 'h'; } if (ms >= min) { return (ms / min).toFixed(1) + 'm'; } if (ms >= sec) { return (ms / sec | 0) + 's'; } return ms + 'ms'; }
javascript
function(ms) { var sec = 1000; var min = 60 * 1000; var hour = 60 * min; if (ms >= hour) { return (ms / hour).toFixed(1) + 'h'; } if (ms >= min) { return (ms / min).toFixed(1) + 'm'; } if (ms >= sec) { return (ms / sec | 0) + 's'; } return ms + 'ms'; }
[ "function", "(", "ms", ")", "{", "var", "sec", "=", "1000", ";", "var", "min", "=", "60", "*", "1000", ";", "var", "hour", "=", "60", "*", "min", ";", "if", "(", "ms", ">=", "hour", ")", "{", "return", "(", "ms", "/", "hour", ")", ".", "toFixed", "(", "1", ")", "+", "'h'", ";", "}", "if", "(", "ms", ">=", "min", ")", "{", "return", "(", "ms", "/", "min", ")", ".", "toFixed", "(", "1", ")", "+", "'m'", ";", "}", "if", "(", "ms", ">=", "sec", ")", "{", "return", "(", "ms", "/", "sec", "|", "0", ")", "+", "'s'", ";", "}", "return", "ms", "+", "'ms'", ";", "}" ]
Humanize the given milliseconds. @param {number} ms number of milliseconds. @return {string} A human readable representation.
[ "Humanize", "the", "given", "milliseconds", "." ]
58c32c75b26647bbec39dc401a78b0fdb5896c8d
https://github.com/warmsea/WarmseaJS/blob/58c32c75b26647bbec39dc401a78b0fdb5896c8d/src/debug.js#L141-L156
49,635
rabbitlive/rabbitpack
src/entry.js
wxappEntry
function wxappEntry() { const regex = /src\/pages\/([^\/]+)\/[^\.]+.js/; return { entry: () => { let pages = {} let core = [] glob.sync(`./src/pages/**/*.js`).forEach(x => { const name = x.match(regex)[1] const key = `pages/${name}/${name}` pages[key] = x }) return Object.assign({}, pages, { app: [ //'webpack-dev-server/client', //'webpack/hot/only-dev-server', './src/app.js' ] }) } } }
javascript
function wxappEntry() { const regex = /src\/pages\/([^\/]+)\/[^\.]+.js/; return { entry: () => { let pages = {} let core = [] glob.sync(`./src/pages/**/*.js`).forEach(x => { const name = x.match(regex)[1] const key = `pages/${name}/${name}` pages[key] = x }) return Object.assign({}, pages, { app: [ //'webpack-dev-server/client', //'webpack/hot/only-dev-server', './src/app.js' ] }) } } }
[ "function", "wxappEntry", "(", ")", "{", "const", "regex", "=", "/", "src\\/pages\\/([^\\/]+)\\/[^\\.]+.js", "/", ";", "return", "{", "entry", ":", "(", ")", "=>", "{", "let", "pages", "=", "{", "}", "let", "core", "=", "[", "]", "glob", ".", "sync", "(", "`", "`", ")", ".", "forEach", "(", "x", "=>", "{", "const", "name", "=", "x", ".", "match", "(", "regex", ")", "[", "1", "]", "const", "key", "=", "`", "${", "name", "}", "${", "name", "}", "`", "pages", "[", "key", "]", "=", "x", "}", ")", "return", "Object", ".", "assign", "(", "{", "}", ",", "pages", ",", "{", "app", ":", "[", "//'webpack-dev-server/client',", "//'webpack/hot/only-dev-server',", "'./src/app.js'", "]", "}", ")", "}", "}", "}" ]
WeChat app looks like multi entries app. @see https://github.com/rabbitlive/rabbitinit/tree/master/wxapp
[ "WeChat", "app", "looks", "like", "multi", "entries", "app", "." ]
8d572a88e660cc4bcf67a39f9c877f8213ded845
https://github.com/rabbitlive/rabbitpack/blob/8d572a88e660cc4bcf67a39f9c877f8213ded845/src/entry.js#L70-L95
49,636
SebastianOsuna/configure.js
bin/configure.js
setup
function setup() { // check if config directory is given if( _config_path !== -1 ) { // get path var config_path = path.resolve( process.argv[ _config_path + 1 ] ); // check if directory exists and is a valid directory fs.stat( config_path, function( err, stats ) { if( err && err.code === "ENOENT" ) { process.stdout.write( "The given directory doesn't exists.\n".red ); } else if( err ) { // unknown error process.stdout.write( (err.message + "\n").red ); } else if( !stats.isDirectory() ) { process.stdout.write( "The given config directory is not an actual directory.\n".red ); } else { readConfigDir( config_path ); } } ); return; } // ask for config directory ask( "Where are your config files? ", function( c_path ) { readConfigDir( c_path ); } ); }
javascript
function setup() { // check if config directory is given if( _config_path !== -1 ) { // get path var config_path = path.resolve( process.argv[ _config_path + 1 ] ); // check if directory exists and is a valid directory fs.stat( config_path, function( err, stats ) { if( err && err.code === "ENOENT" ) { process.stdout.write( "The given directory doesn't exists.\n".red ); } else if( err ) { // unknown error process.stdout.write( (err.message + "\n").red ); } else if( !stats.isDirectory() ) { process.stdout.write( "The given config directory is not an actual directory.\n".red ); } else { readConfigDir( config_path ); } } ); return; } // ask for config directory ask( "Where are your config files? ", function( c_path ) { readConfigDir( c_path ); } ); }
[ "function", "setup", "(", ")", "{", "// check if config directory is given", "if", "(", "_config_path", "!==", "-", "1", ")", "{", "// get path", "var", "config_path", "=", "path", ".", "resolve", "(", "process", ".", "argv", "[", "_config_path", "+", "1", "]", ")", ";", "// check if directory exists and is a valid directory", "fs", ".", "stat", "(", "config_path", ",", "function", "(", "err", ",", "stats", ")", "{", "if", "(", "err", "&&", "err", ".", "code", "===", "\"ENOENT\"", ")", "{", "process", ".", "stdout", ".", "write", "(", "\"The given directory doesn't exists.\\n\"", ".", "red", ")", ";", "}", "else", "if", "(", "err", ")", "{", "// unknown error", "process", ".", "stdout", ".", "write", "(", "(", "err", ".", "message", "+", "\"\\n\"", ")", ".", "red", ")", ";", "}", "else", "if", "(", "!", "stats", ".", "isDirectory", "(", ")", ")", "{", "process", ".", "stdout", ".", "write", "(", "\"The given config directory is not an actual directory.\\n\"", ".", "red", ")", ";", "}", "else", "{", "readConfigDir", "(", "config_path", ")", ";", "}", "}", ")", ";", "return", ";", "}", "// ask for config directory", "ask", "(", "\"Where are your config files? \"", ",", "function", "(", "c_path", ")", "{", "readConfigDir", "(", "c_path", ")", ";", "}", ")", ";", "}" ]
Starts the config files setup process. It first asks for the configuration file directory. It then fetches for all configuration files in the given directory and starts asking for the user values of each entry in each found file.
[ "Starts", "the", "config", "files", "setup", "process", ".", "It", "first", "asks", "for", "the", "configuration", "file", "directory", ".", "It", "then", "fetches", "for", "all", "configuration", "files", "in", "the", "given", "directory", "and", "starts", "asking", "for", "the", "user", "values", "of", "each", "entry", "in", "each", "found", "file", "." ]
39551c58d92a4ce065df25e6b9999b8495ca4833
https://github.com/SebastianOsuna/configure.js/blob/39551c58d92a4ce065df25e6b9999b8495ca4833/bin/configure.js#L106-L135
49,637
SebastianOsuna/configure.js
bin/configure.js
handleConfigEntry
function handleConfigEntry ( defaults, values, parent_name, cb ) { var entries = Object.keys( defaults ), c = 0; var cont = function () { // entry handling function if( c < entries.length ) { var key = entries[ c ], entry = defaults[ key ]; if ( typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean" || entry == undefined ) { ask( ( parent_name ? parent_name + "." + key.blue : key.blue ) + " (" + entry.toString().yellow + "): ", function ( newValue ) { if ( newValue === "" ) { newValue = defaults[ key ]; } values[ key ] = newValue; c++; cont(); // continue } ); } else if ( entry instanceof Array ) { // support for arrays var array = values[ key ] = [], _proto = defaults[ key ][ 0 ]; if ( _proto ) { var array_handler = function ( num ) { num = parseInt( num ); if( num ) { // this makes sure num > 0 var cc = -1; var array_item_handler = function () { cc++; if( cc < num ) { array.push( {} ); var i = array[ array.length - 1 ]; handleConfigEntry( _proto, i, ( parent_name ? parent_name + "." + key : key ) + "." + cc, array_item_handler ); } else { c++; cont(); // done with the array } }; array_item_handler(); // begin with the array } else { ask( "Number of entries for " + ( parent_name ? parent_name + "." + key.blue : key.blue ) + " ? ", array_handler ); } }; ask( "Number of entries for " + ( parent_name ? parent_name + "." + key.blue : key.blue ) + " ? ", array_handler ); } else { c++; cont(); } } else { values[ key ] = {}; // recurse down the object handleConfigEntry( defaults[ key ], values[ key ], ( parent_name ? parent_name + "." + key : key ), function () { c++; cont(); } ); } } else { if ( cb ) { cb(); // done :) } } }; // begin cont(); }
javascript
function handleConfigEntry ( defaults, values, parent_name, cb ) { var entries = Object.keys( defaults ), c = 0; var cont = function () { // entry handling function if( c < entries.length ) { var key = entries[ c ], entry = defaults[ key ]; if ( typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean" || entry == undefined ) { ask( ( parent_name ? parent_name + "." + key.blue : key.blue ) + " (" + entry.toString().yellow + "): ", function ( newValue ) { if ( newValue === "" ) { newValue = defaults[ key ]; } values[ key ] = newValue; c++; cont(); // continue } ); } else if ( entry instanceof Array ) { // support for arrays var array = values[ key ] = [], _proto = defaults[ key ][ 0 ]; if ( _proto ) { var array_handler = function ( num ) { num = parseInt( num ); if( num ) { // this makes sure num > 0 var cc = -1; var array_item_handler = function () { cc++; if( cc < num ) { array.push( {} ); var i = array[ array.length - 1 ]; handleConfigEntry( _proto, i, ( parent_name ? parent_name + "." + key : key ) + "." + cc, array_item_handler ); } else { c++; cont(); // done with the array } }; array_item_handler(); // begin with the array } else { ask( "Number of entries for " + ( parent_name ? parent_name + "." + key.blue : key.blue ) + " ? ", array_handler ); } }; ask( "Number of entries for " + ( parent_name ? parent_name + "." + key.blue : key.blue ) + " ? ", array_handler ); } else { c++; cont(); } } else { values[ key ] = {}; // recurse down the object handleConfigEntry( defaults[ key ], values[ key ], ( parent_name ? parent_name + "." + key : key ), function () { c++; cont(); } ); } } else { if ( cb ) { cb(); // done :) } } }; // begin cont(); }
[ "function", "handleConfigEntry", "(", "defaults", ",", "values", ",", "parent_name", ",", "cb", ")", "{", "var", "entries", "=", "Object", ".", "keys", "(", "defaults", ")", ",", "c", "=", "0", ";", "var", "cont", "=", "function", "(", ")", "{", "// entry handling function", "if", "(", "c", "<", "entries", ".", "length", ")", "{", "var", "key", "=", "entries", "[", "c", "]", ",", "entry", "=", "defaults", "[", "key", "]", ";", "if", "(", "typeof", "entry", "===", "\"string\"", "||", "typeof", "entry", "===", "\"number\"", "||", "typeof", "entry", "===", "\"boolean\"", "||", "entry", "==", "undefined", ")", "{", "ask", "(", "(", "parent_name", "?", "parent_name", "+", "\".\"", "+", "key", ".", "blue", ":", "key", ".", "blue", ")", "+", "\" (\"", "+", "entry", ".", "toString", "(", ")", ".", "yellow", "+", "\"): \"", ",", "function", "(", "newValue", ")", "{", "if", "(", "newValue", "===", "\"\"", ")", "{", "newValue", "=", "defaults", "[", "key", "]", ";", "}", "values", "[", "key", "]", "=", "newValue", ";", "c", "++", ";", "cont", "(", ")", ";", "// continue", "}", ")", ";", "}", "else", "if", "(", "entry", "instanceof", "Array", ")", "{", "// support for arrays", "var", "array", "=", "values", "[", "key", "]", "=", "[", "]", ",", "_proto", "=", "defaults", "[", "key", "]", "[", "0", "]", ";", "if", "(", "_proto", ")", "{", "var", "array_handler", "=", "function", "(", "num", ")", "{", "num", "=", "parseInt", "(", "num", ")", ";", "if", "(", "num", ")", "{", "// this makes sure num > 0", "var", "cc", "=", "-", "1", ";", "var", "array_item_handler", "=", "function", "(", ")", "{", "cc", "++", ";", "if", "(", "cc", "<", "num", ")", "{", "array", ".", "push", "(", "{", "}", ")", ";", "var", "i", "=", "array", "[", "array", ".", "length", "-", "1", "]", ";", "handleConfigEntry", "(", "_proto", ",", "i", ",", "(", "parent_name", "?", "parent_name", "+", "\".\"", "+", "key", ":", "key", ")", "+", "\".\"", "+", "cc", ",", "array_item_handler", ")", ";", "}", "else", "{", "c", "++", ";", "cont", "(", ")", ";", "// done with the array", "}", "}", ";", "array_item_handler", "(", ")", ";", "// begin with the array", "}", "else", "{", "ask", "(", "\"Number of entries for \"", "+", "(", "parent_name", "?", "parent_name", "+", "\".\"", "+", "key", ".", "blue", ":", "key", ".", "blue", ")", "+", "\" ? \"", ",", "array_handler", ")", ";", "}", "}", ";", "ask", "(", "\"Number of entries for \"", "+", "(", "parent_name", "?", "parent_name", "+", "\".\"", "+", "key", ".", "blue", ":", "key", ".", "blue", ")", "+", "\" ? \"", ",", "array_handler", ")", ";", "}", "else", "{", "c", "++", ";", "cont", "(", ")", ";", "}", "}", "else", "{", "values", "[", "key", "]", "=", "{", "}", ";", "// recurse down the object", "handleConfigEntry", "(", "defaults", "[", "key", "]", ",", "values", "[", "key", "]", ",", "(", "parent_name", "?", "parent_name", "+", "\".\"", "+", "key", ":", "key", ")", ",", "function", "(", ")", "{", "c", "++", ";", "cont", "(", ")", ";", "}", ")", ";", "}", "}", "else", "{", "if", "(", "cb", ")", "{", "cb", "(", ")", ";", "// done :)", "}", "}", "}", ";", "// begin", "cont", "(", ")", ";", "}" ]
Recursive handling of config object. It asks the user for values of the each attribute of the config.defaults object. If the user skips an attribute, the default value is taken. @param defaults Configuration default values. @param values Configuration user given values. @param parent_name Current config object parent name. @param cb Callback function. No arguments given.
[ "Recursive", "handling", "of", "config", "object", ".", "It", "asks", "the", "user", "for", "values", "of", "the", "each", "attribute", "of", "the", "config", ".", "defaults", "object", ".", "If", "the", "user", "skips", "an", "attribute", "the", "default", "value", "is", "taken", "." ]
39551c58d92a4ce065df25e6b9999b8495ca4833
https://github.com/SebastianOsuna/configure.js/blob/39551c58d92a4ce065df25e6b9999b8495ca4833/bin/configure.js#L145-L209
49,638
beeblebrox3/super-helpers
src/object/index.js
function (paths, obj, defaultValue = null) { if (!Array.isArray(paths)) { throw new Error("paths must be an array of strings"); } let res = defaultValue; paths.some(path => { const result = this.getFlattened(path, obj, defaultValue); if (result !== defaultValue) { res = result; return true; } return false; }); return res; }
javascript
function (paths, obj, defaultValue = null) { if (!Array.isArray(paths)) { throw new Error("paths must be an array of strings"); } let res = defaultValue; paths.some(path => { const result = this.getFlattened(path, obj, defaultValue); if (result !== defaultValue) { res = result; return true; } return false; }); return res; }
[ "function", "(", "paths", ",", "obj", ",", "defaultValue", "=", "null", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "paths", ")", ")", "{", "throw", "new", "Error", "(", "\"paths must be an array of strings\"", ")", ";", "}", "let", "res", "=", "defaultValue", ";", "paths", ".", "some", "(", "path", "=>", "{", "const", "result", "=", "this", ".", "getFlattened", "(", "path", ",", "obj", ",", "defaultValue", ")", ";", "if", "(", "result", "!==", "defaultValue", ")", "{", "res", "=", "result", ";", "return", "true", ";", "}", "return", "false", ";", "}", ")", ";", "return", "res", ";", "}" ]
Receives a list of paths and use getFlattened to get the first existent value @param {String[]} paths @param {Object} obj @param {any} defaultValue @return {any} @see getFlattened @memberof object
[ "Receives", "a", "list", "of", "paths", "and", "use", "getFlattened", "to", "get", "the", "first", "existent", "value" ]
15deaf3509bfe47817e6dd3ecd3e6879743b7dd9
https://github.com/beeblebrox3/super-helpers/blob/15deaf3509bfe47817e6dd3ecd3e6879743b7dd9/src/object/index.js#L49-L65
49,639
beeblebrox3/super-helpers
src/object/index.js
function (obj) { "use strict"; if (Object.getPrototypeOf(obj) !== Object.prototype) { throw Error("obj must be an Object"); } return Object.keys(obj)[0] || null; }
javascript
function (obj) { "use strict"; if (Object.getPrototypeOf(obj) !== Object.prototype) { throw Error("obj must be an Object"); } return Object.keys(obj)[0] || null; }
[ "function", "(", "obj", ")", "{", "\"use strict\"", ";", "if", "(", "Object", ".", "getPrototypeOf", "(", "obj", ")", "!==", "Object", ".", "prototype", ")", "{", "throw", "Error", "(", "\"obj must be an Object\"", ")", ";", "}", "return", "Object", ".", "keys", "(", "obj", ")", "[", "0", "]", "||", "null", ";", "}" ]
Get first key of an object or null if it doesn't have keys @param {Object} obj @return {*} @memberof object
[ "Get", "first", "key", "of", "an", "object", "or", "null", "if", "it", "doesn", "t", "have", "keys" ]
15deaf3509bfe47817e6dd3ecd3e6879743b7dd9
https://github.com/beeblebrox3/super-helpers/blob/15deaf3509bfe47817e6dd3ecd3e6879743b7dd9/src/object/index.js#L106-L114
49,640
vkiding/jud-vue-render
src/render/vue/modules/dom.js
function (key, styles) { key = camelToKebab(key) let stylesText = '' for (const k in styles) { if (styles.hasOwnProperty(k)) { stylesText += camelToKebab(k) + ':' + styles[k] + ';' } } const styleText = `@${key}{${stylesText}}` appendCss(styleText, 'dom-added-rules') }
javascript
function (key, styles) { key = camelToKebab(key) let stylesText = '' for (const k in styles) { if (styles.hasOwnProperty(k)) { stylesText += camelToKebab(k) + ':' + styles[k] + ';' } } const styleText = `@${key}{${stylesText}}` appendCss(styleText, 'dom-added-rules') }
[ "function", "(", "key", ",", "styles", ")", "{", "key", "=", "camelToKebab", "(", "key", ")", "let", "stylesText", "=", "''", "for", "(", "const", "k", "in", "styles", ")", "{", "if", "(", "styles", ".", "hasOwnProperty", "(", "k", ")", ")", "{", "stylesText", "+=", "camelToKebab", "(", "k", ")", "+", "':'", "+", "styles", "[", "k", "]", "+", "';'", "}", "}", "const", "styleText", "=", "`", "${", "key", "}", "${", "stylesText", "}", "`", "appendCss", "(", "styleText", ",", "'dom-added-rules'", ")", "}" ]
for adding fontFace @param {string} key fontFace @param {object} styles rules
[ "for", "adding", "fontFace" ]
07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47
https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/vue/modules/dom.js#L139-L149
49,641
lightningtgc/grunt-at-csstidy
tasks/csstidy.js
preHandleSrc
function preHandleSrc (cssSrc) { /* * fix like: .a{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e6529dda', endColorstr='#e6529dda', GradientType=0)\9;} * which has two semicolon( : ) will cause parse error. */ cssSrc = cssSrc.replace(/progid(\s)?:(\s)?/g, '#tidy1#'); /* * fix absolute url path like: * .a { background: url("http://www.qq.com/one.png");} * */ cssSrc = cssSrc.replace(/:\/\//g, '#tidy2#'); /* * fix base64 url like: * .a { background: url("data:image/png;base64,iVBOMVEX///////////////+g0jAqu8zdII=");} * */ cssSrc = cssSrc.replace(/data[\s\S]+?\)/g, function(match){ match = match.replace(/:/g, '#tidy3#'); match = match.replace(/;/g, '#tidy4#'); match = match.replace(/\//g, '#tidy5#'); return match; }); /* * fix multiple line comment include single comment // * eg: / * sth // another * / */ cssSrc = cssSrc.replace(/\/\*[\s\S]+?\*\//g, function(match){ // handle single comment // match = match.replace(/\/\//g, '#tidy6#'); return match; }); /* * fix single comment like: // something * It can't works in IE, and will cause parse error * update: handle single line for compressive case */ cssSrc = cssSrc.replace(/(^|[^:|'|"|\(])\/\/.+?(?=\n|\r|$)/g, function(match){ // Handle compressive file if (match.indexOf('{') === -1 || match.indexOf('}') === -1) { var targetMatch; //handle first line if (match.charAt(0) !== '/' ) { // remove first string and / and \ targetMatch = match.substr(1).replace(/\\|\//g, ''); return match.charAt(0) + '/*' + targetMatch + '*/'; } else { targetMatch = match.replace(/\\|\//g, ''); return '/*' + targetMatch + '*/'; } } else { throw new Error('There maybe some single comment // in this file.'); } }); return cssSrc; }
javascript
function preHandleSrc (cssSrc) { /* * fix like: .a{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e6529dda', endColorstr='#e6529dda', GradientType=0)\9;} * which has two semicolon( : ) will cause parse error. */ cssSrc = cssSrc.replace(/progid(\s)?:(\s)?/g, '#tidy1#'); /* * fix absolute url path like: * .a { background: url("http://www.qq.com/one.png");} * */ cssSrc = cssSrc.replace(/:\/\//g, '#tidy2#'); /* * fix base64 url like: * .a { background: url("data:image/png;base64,iVBOMVEX///////////////+g0jAqu8zdII=");} * */ cssSrc = cssSrc.replace(/data[\s\S]+?\)/g, function(match){ match = match.replace(/:/g, '#tidy3#'); match = match.replace(/;/g, '#tidy4#'); match = match.replace(/\//g, '#tidy5#'); return match; }); /* * fix multiple line comment include single comment // * eg: / * sth // another * / */ cssSrc = cssSrc.replace(/\/\*[\s\S]+?\*\//g, function(match){ // handle single comment // match = match.replace(/\/\//g, '#tidy6#'); return match; }); /* * fix single comment like: // something * It can't works in IE, and will cause parse error * update: handle single line for compressive case */ cssSrc = cssSrc.replace(/(^|[^:|'|"|\(])\/\/.+?(?=\n|\r|$)/g, function(match){ // Handle compressive file if (match.indexOf('{') === -1 || match.indexOf('}') === -1) { var targetMatch; //handle first line if (match.charAt(0) !== '/' ) { // remove first string and / and \ targetMatch = match.substr(1).replace(/\\|\//g, ''); return match.charAt(0) + '/*' + targetMatch + '*/'; } else { targetMatch = match.replace(/\\|\//g, ''); return '/*' + targetMatch + '*/'; } } else { throw new Error('There maybe some single comment // in this file.'); } }); return cssSrc; }
[ "function", "preHandleSrc", "(", "cssSrc", ")", "{", "/* \n * fix like: .a{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e6529dda', endColorstr='#e6529dda', GradientType=0)\\9;}\n * which has two semicolon( : ) will cause parse error.\n */", "cssSrc", "=", "cssSrc", ".", "replace", "(", "/", "progid(\\s)?:(\\s)?", "/", "g", ",", "'#tidy1#'", ")", ";", "/*\n * fix absolute url path like: \n * .a { background: url(\"http://www.qq.com/one.png\");} \n *\n */", "cssSrc", "=", "cssSrc", ".", "replace", "(", "/", ":\\/\\/", "/", "g", ",", "'#tidy2#'", ")", ";", "/*\n * fix base64 url like: \n * .a { background: url(\"data:image/png;base64,iVBOMVEX///////////////+g0jAqu8zdII=\");} \n *\n */", "cssSrc", "=", "cssSrc", ".", "replace", "(", "/", "data[\\s\\S]+?\\)", "/", "g", ",", "function", "(", "match", ")", "{", "match", "=", "match", ".", "replace", "(", "/", ":", "/", "g", ",", "'#tidy3#'", ")", ";", "match", "=", "match", ".", "replace", "(", "/", ";", "/", "g", ",", "'#tidy4#'", ")", ";", "match", "=", "match", ".", "replace", "(", "/", "\\/", "/", "g", ",", "'#tidy5#'", ")", ";", "return", "match", ";", "}", ")", ";", "/*\n * fix multiple line comment include single comment //\n * eg: / * sth // another * /\n */", "cssSrc", "=", "cssSrc", ".", "replace", "(", "/", "\\/\\*[\\s\\S]+?\\*\\/", "/", "g", ",", "function", "(", "match", ")", "{", "// handle single comment //", "match", "=", "match", ".", "replace", "(", "/", "\\/\\/", "/", "g", ",", "'#tidy6#'", ")", ";", "return", "match", ";", "}", ")", ";", "/*\n * fix single comment like: // something \n * It can't works in IE, and will cause parse error\n * update: handle single line for compressive case\n */", "cssSrc", "=", "cssSrc", ".", "replace", "(", "/", "(^|[^:|'|\"|\\(])\\/\\/.+?(?=\\n|\\r|$)", "/", "g", ",", "function", "(", "match", ")", "{", "// Handle compressive file", "if", "(", "match", ".", "indexOf", "(", "'{'", ")", "===", "-", "1", "||", "match", ".", "indexOf", "(", "'}'", ")", "===", "-", "1", ")", "{", "var", "targetMatch", ";", "//handle first line", "if", "(", "match", ".", "charAt", "(", "0", ")", "!==", "'/'", ")", "{", "// remove first string and / and \\ ", "targetMatch", "=", "match", ".", "substr", "(", "1", ")", ".", "replace", "(", "/", "\\\\|\\/", "/", "g", ",", "''", ")", ";", "return", "match", ".", "charAt", "(", "0", ")", "+", "'/*'", "+", "targetMatch", "+", "'*/'", ";", "}", "else", "{", "targetMatch", "=", "match", ".", "replace", "(", "/", "\\\\|\\/", "/", "g", ",", "''", ")", ";", "return", "'/*'", "+", "targetMatch", "+", "'*/'", ";", "}", "}", "else", "{", "throw", "new", "Error", "(", "'There maybe some single comment // in this file.'", ")", ";", "}", "}", ")", ";", "return", "cssSrc", ";", "}" ]
Handle special case
[ "Handle", "special", "case" ]
efdcf07f7e49b910be289e52834c6e2022b7dd97
https://github.com/lightningtgc/grunt-at-csstidy/blob/efdcf07f7e49b910be289e52834c6e2022b7dd97/tasks/csstidy.js#L25-L88
49,642
huafu/ember-marked
addon/components/code-section.js
function (code, language, bare) { var result; if (typeof hljs !== 'undefined') { if (language) { try { result = hljs.highlight(language, code, true); } catch (e) { Ember.warn( '[marked] Failing to highlight some code with language `' + language + '`, trying auto-detecting language (error: ' + e + ').' ); result = hljs.highlightAuto(code); } } else { result = hljs.highlightAuto(code); } result.value = '<pre><code>' + result.value + '</code></pre>'; if (bare) { return result; } else { return result.value; } } else { result = '<pre><code>' + (code || '').replace(/<>&/g, entitiesReplacer) + '</code></pre>'; if (bare) { return {value: result, language: null}; } else { return result; } } }
javascript
function (code, language, bare) { var result; if (typeof hljs !== 'undefined') { if (language) { try { result = hljs.highlight(language, code, true); } catch (e) { Ember.warn( '[marked] Failing to highlight some code with language `' + language + '`, trying auto-detecting language (error: ' + e + ').' ); result = hljs.highlightAuto(code); } } else { result = hljs.highlightAuto(code); } result.value = '<pre><code>' + result.value + '</code></pre>'; if (bare) { return result; } else { return result.value; } } else { result = '<pre><code>' + (code || '').replace(/<>&/g, entitiesReplacer) + '</code></pre>'; if (bare) { return {value: result, language: null}; } else { return result; } } }
[ "function", "(", "code", ",", "language", ",", "bare", ")", "{", "var", "result", ";", "if", "(", "typeof", "hljs", "!==", "'undefined'", ")", "{", "if", "(", "language", ")", "{", "try", "{", "result", "=", "hljs", ".", "highlight", "(", "language", ",", "code", ",", "true", ")", ";", "}", "catch", "(", "e", ")", "{", "Ember", ".", "warn", "(", "'[marked] Failing to highlight some code with language `'", "+", "language", "+", "'`, trying auto-detecting language (error: '", "+", "e", "+", "').'", ")", ";", "result", "=", "hljs", ".", "highlightAuto", "(", "code", ")", ";", "}", "}", "else", "{", "result", "=", "hljs", ".", "highlightAuto", "(", "code", ")", ";", "}", "result", ".", "value", "=", "'<pre><code>'", "+", "result", ".", "value", "+", "'</code></pre>'", ";", "if", "(", "bare", ")", "{", "return", "result", ";", "}", "else", "{", "return", "result", ".", "value", ";", "}", "}", "else", "{", "result", "=", "'<pre><code>'", "+", "(", "code", "||", "''", ")", ".", "replace", "(", "/", "<>&", "/", "g", ",", "entitiesReplacer", ")", "+", "'</code></pre>'", ";", "if", "(", "bare", ")", "{", "return", "{", "value", ":", "result", ",", "language", ":", "null", "}", ";", "}", "else", "{", "return", "result", ";", "}", "}", "}" ]
Highlighter function, using highlight.js if available @method highlight @param {String} code @param {String} [language] @param {Boolean} [bare=false] @returns {String|{value: String, language: String}}
[ "Highlighter", "function", "using", "highlight", ".", "js", "if", "available" ]
372f7aad36cfc5fd6fd9faaef8f561d692852d23
https://github.com/huafu/ember-marked/blob/372f7aad36cfc5fd6fd9faaef8f561d692852d23/addon/components/code-section.js#L88-L123
49,643
Antyfive/teo-logger
lib/logger.js
_parseErrors
function _parseErrors() { let errors = [].slice.call(arguments); let parsed = []; errors.forEach(err => { let message = (err instanceof Error) ? err.stack : err.toString(); parsed.push(message); }); return parsed; }
javascript
function _parseErrors() { let errors = [].slice.call(arguments); let parsed = []; errors.forEach(err => { let message = (err instanceof Error) ? err.stack : err.toString(); parsed.push(message); }); return parsed; }
[ "function", "_parseErrors", "(", ")", "{", "let", "errors", "=", "[", "]", ".", "slice", ".", "call", "(", "arguments", ")", ";", "let", "parsed", "=", "[", "]", ";", "errors", ".", "forEach", "(", "err", "=>", "{", "let", "message", "=", "(", "err", "instanceof", "Error", ")", "?", "err", ".", "stack", ":", "err", ".", "toString", "(", ")", ";", "parsed", ".", "push", "(", "message", ")", ";", "}", ")", ";", "return", "parsed", ";", "}" ]
Parses errors. Expects Error instance, or string with message @returns {Array} @private
[ "Parses", "errors", ".", "Expects", "Error", "instance", "or", "string", "with", "message" ]
5b632e1ddb939dc839181313ab2e23061d6c2db8
https://github.com/Antyfive/teo-logger/blob/5b632e1ddb939dc839181313ab2e23061d6c2db8/lib/logger.js#L18-L28
49,644
Antyfive/teo-logger
lib/logger.js
_log
function _log(message) { if (cluster.isMaster) { // write directly to the log file console.log(_format(message)); } else { // send to master cluster.worker.process.send({ type: "logging", data: { message: message, workerID: cluster.worker.id, pid: cluster.worker.process.pid } }); } }
javascript
function _log(message) { if (cluster.isMaster) { // write directly to the log file console.log(_format(message)); } else { // send to master cluster.worker.process.send({ type: "logging", data: { message: message, workerID: cluster.worker.id, pid: cluster.worker.process.pid } }); } }
[ "function", "_log", "(", "message", ")", "{", "if", "(", "cluster", ".", "isMaster", ")", "{", "// write directly to the log file", "console", ".", "log", "(", "_format", "(", "message", ")", ")", ";", "}", "else", "{", "// send to master", "cluster", ".", "worker", ".", "process", ".", "send", "(", "{", "type", ":", "\"logging\"", ",", "data", ":", "{", "message", ":", "message", ",", "workerID", ":", "cluster", ".", "worker", ".", "id", ",", "pid", ":", "cluster", ".", "worker", ".", "process", ".", "pid", "}", "}", ")", ";", "}", "}" ]
Logs message. Forwards message from child process to master @param {String} message @private
[ "Logs", "message", ".", "Forwards", "message", "from", "child", "process", "to", "master" ]
5b632e1ddb939dc839181313ab2e23061d6c2db8
https://github.com/Antyfive/teo-logger/blob/5b632e1ddb939dc839181313ab2e23061d6c2db8/lib/logger.js#L56-L72
49,645
crcn/mojo-views
lib/views/base/index.js
BaseView
function BaseView (properties, application) { // note that if application is not defined, this.application will // default to the default, global application. this.application = application; this._onParent = _.bind(this._onParent, this); SubindableObject.call(this, properties); /** * The main application that instantiated this view * @property application * @type {Application} */ this.initialize(); // ref back to this context for templates this["this"] = this; }
javascript
function BaseView (properties, application) { // note that if application is not defined, this.application will // default to the default, global application. this.application = application; this._onParent = _.bind(this._onParent, this); SubindableObject.call(this, properties); /** * The main application that instantiated this view * @property application * @type {Application} */ this.initialize(); // ref back to this context for templates this["this"] = this; }
[ "function", "BaseView", "(", "properties", ",", "application", ")", "{", "// note that if application is not defined, this.application will", "// default to the default, global application.", "this", ".", "application", "=", "application", ";", "this", ".", "_onParent", "=", "_", ".", "bind", "(", "this", ".", "_onParent", ",", "this", ")", ";", "SubindableObject", ".", "call", "(", "this", ",", "properties", ")", ";", "/**\n * The main application that instantiated this view\n * @property application\n * @type {Application}\n */", "this", ".", "initialize", "(", ")", ";", "// ref back to this context for templates", "this", "[", "\"this\"", "]", "=", "this", ";", "}" ]
Called when the view is rendered @event render Called when the view is remove @event remove
[ "Called", "when", "the", "view", "is", "rendered" ]
5c4899fb8f117f98ad02a34b714ebb0cc646caba
https://github.com/crcn/mojo-views/blob/5c4899fb8f117f98ad02a34b714ebb0cc646caba/lib/views/base/index.js#L31-L51
49,646
crcn/mojo-views
lib/views/base/index.js
function (data) { this.on("change:parent", this._onParent); // copy the data to this object. Note this shaves a TON // of time off initializing any view, especially list items if we // use this method over @setProperties data if (false) { for(var key in data) { this[key] = data[key]; } } // necessary to properly dispose this view so it can be recycled if (this.parent) this._onParent(this.parent); }
javascript
function (data) { this.on("change:parent", this._onParent); // copy the data to this object. Note this shaves a TON // of time off initializing any view, especially list items if we // use this method over @setProperties data if (false) { for(var key in data) { this[key] = data[key]; } } // necessary to properly dispose this view so it can be recycled if (this.parent) this._onParent(this.parent); }
[ "function", "(", "data", ")", "{", "this", ".", "on", "(", "\"change:parent\"", ",", "this", ".", "_onParent", ")", ";", "// copy the data to this object. Note this shaves a TON", "// of time off initializing any view, especially list items if we", "// use this method over @setProperties data", "if", "(", "false", ")", "{", "for", "(", "var", "key", "in", "data", ")", "{", "this", "[", "key", "]", "=", "data", "[", "key", "]", ";", "}", "}", "// necessary to properly dispose this view so it can be recycled", "if", "(", "this", ".", "parent", ")", "this", ".", "_onParent", "(", "this", ".", "parent", ")", ";", "}" ]
Called when the view is instantiated @method initialize @param {Object} options options passed when creating the view
[ "Called", "when", "the", "view", "is", "instantiated" ]
5c4899fb8f117f98ad02a34b714ebb0cc646caba
https://github.com/crcn/mojo-views/blob/5c4899fb8f117f98ad02a34b714ebb0cc646caba/lib/views/base/index.js#L96-L110
49,647
crcn/mojo-views
lib/views/base/index.js
function () { var path = [], cp = this; while (cp) { path.unshift(cp.name || cp.constructor.name); cp = cp.parent; } return path.join("."); }
javascript
function () { var path = [], cp = this; while (cp) { path.unshift(cp.name || cp.constructor.name); cp = cp.parent; } return path.join("."); }
[ "function", "(", ")", "{", "var", "path", "=", "[", "]", ",", "cp", "=", "this", ";", "while", "(", "cp", ")", "{", "path", ".", "unshift", "(", "cp", ".", "name", "||", "cp", ".", "constructor", ".", "name", ")", ";", "cp", "=", "cp", ".", "parent", ";", "}", "return", "path", ".", "join", "(", "\".\"", ")", ";", "}" ]
Returns the path to the view @method path
[ "Returns", "the", "path", "to", "the", "view" ]
5c4899fb8f117f98ad02a34b714ebb0cc646caba
https://github.com/crcn/mojo-views/blob/5c4899fb8f117f98ad02a34b714ebb0cc646caba/lib/views/base/index.js#L144-L153
49,648
crcn/mojo-views
lib/views/base/index.js
function () { // if rendered, then just return the fragment if (this._rendered) { return this.section.render(); } this._rendered = true; if (this._cleanupJanitor) { this._cleanupJanitor.dispose(); } if (!this.section) { this._createSection(); } this.willRender(); this.emit("render"); var fragment = this.section.render(); this.didRender(); this._updateVisibility(); return fragment; }
javascript
function () { // if rendered, then just return the fragment if (this._rendered) { return this.section.render(); } this._rendered = true; if (this._cleanupJanitor) { this._cleanupJanitor.dispose(); } if (!this.section) { this._createSection(); } this.willRender(); this.emit("render"); var fragment = this.section.render(); this.didRender(); this._updateVisibility(); return fragment; }
[ "function", "(", ")", "{", "// if rendered, then just return the fragment", "if", "(", "this", ".", "_rendered", ")", "{", "return", "this", ".", "section", ".", "render", "(", ")", ";", "}", "this", ".", "_rendered", "=", "true", ";", "if", "(", "this", ".", "_cleanupJanitor", ")", "{", "this", ".", "_cleanupJanitor", ".", "dispose", "(", ")", ";", "}", "if", "(", "!", "this", ".", "section", ")", "{", "this", ".", "_createSection", "(", ")", ";", "}", "this", ".", "willRender", "(", ")", ";", "this", ".", "emit", "(", "\"render\"", ")", ";", "var", "fragment", "=", "this", ".", "section", ".", "render", "(", ")", ";", "this", ".", "didRender", "(", ")", ";", "this", ".", "_updateVisibility", "(", ")", ";", "return", "fragment", ";", "}" ]
Renders the view @method render @return {Object} document fragment
[ "Renders", "the", "view" ]
5c4899fb8f117f98ad02a34b714ebb0cc646caba
https://github.com/crcn/mojo-views/blob/5c4899fb8f117f98ad02a34b714ebb0cc646caba/lib/views/base/index.js#L161-L187
49,649
crcn/mojo-views
lib/views/base/index.js
function (search) { if (!this.section) this.render(); var el = noselector(this.section.getChildNodes()); if (arguments.length) { return el.find(search).andSelf().filter(search); } return el; }
javascript
function (search) { if (!this.section) this.render(); var el = noselector(this.section.getChildNodes()); if (arguments.length) { return el.find(search).andSelf().filter(search); } return el; }
[ "function", "(", "search", ")", "{", "if", "(", "!", "this", ".", "section", ")", "this", ".", "render", "(", ")", ";", "var", "el", "=", "noselector", "(", "this", ".", "section", ".", "getChildNodes", "(", ")", ")", ";", "if", "(", "arguments", ".", "length", ")", "{", "return", "el", ".", "find", "(", "search", ")", ".", "andSelf", "(", ")", ".", "filter", "(", "search", ")", ";", "}", "return", "el", ";", "}" ]
jquery selector for elements owned by the view @method $ @param {String} selector
[ "jquery", "selector", "for", "elements", "owned", "by", "the", "view" ]
5c4899fb8f117f98ad02a34b714ebb0cc646caba
https://github.com/crcn/mojo-views/blob/5c4899fb8f117f98ad02a34b714ebb0cc646caba/lib/views/base/index.js#L248-L258
49,650
benderjs/dom-combiner
lib/combiner.js
merge
function merge( elem, callback ) { var old = find( destChildren, elem.name ), nl; // merge with old element if ( old ) { if ( typeof callback == 'function' ) { return callback( old ); } _.merge( old.attribs, elem.attribs ); if ( elem.children ) { combine( old, elem ); } // append new element } else { if ( dest.children ) { utils.appendChild( dest, elem ); } else { utils.prepend( destChildren[ 0 ], elem ); // fix for domutils issue elem.parent = destChildren[ 0 ].parent; destChildren.unshift( elem ); destChildren.splice( destChildren.indexOf( elem ) + 1, 0, nl ); } } }
javascript
function merge( elem, callback ) { var old = find( destChildren, elem.name ), nl; // merge with old element if ( old ) { if ( typeof callback == 'function' ) { return callback( old ); } _.merge( old.attribs, elem.attribs ); if ( elem.children ) { combine( old, elem ); } // append new element } else { if ( dest.children ) { utils.appendChild( dest, elem ); } else { utils.prepend( destChildren[ 0 ], elem ); // fix for domutils issue elem.parent = destChildren[ 0 ].parent; destChildren.unshift( elem ); destChildren.splice( destChildren.indexOf( elem ) + 1, 0, nl ); } } }
[ "function", "merge", "(", "elem", ",", "callback", ")", "{", "var", "old", "=", "find", "(", "destChildren", ",", "elem", ".", "name", ")", ",", "nl", ";", "// merge with old element", "if", "(", "old", ")", "{", "if", "(", "typeof", "callback", "==", "'function'", ")", "{", "return", "callback", "(", "old", ")", ";", "}", "_", ".", "merge", "(", "old", ".", "attribs", ",", "elem", ".", "attribs", ")", ";", "if", "(", "elem", ".", "children", ")", "{", "combine", "(", "old", ",", "elem", ")", ";", "}", "// append new element", "}", "else", "{", "if", "(", "dest", ".", "children", ")", "{", "utils", ".", "appendChild", "(", "dest", ",", "elem", ")", ";", "}", "else", "{", "utils", ".", "prepend", "(", "destChildren", "[", "0", "]", ",", "elem", ")", ";", "// fix for domutils issue", "elem", ".", "parent", "=", "destChildren", "[", "0", "]", ".", "parent", ";", "destChildren", ".", "unshift", "(", "elem", ")", ";", "destChildren", ".", "splice", "(", "destChildren", ".", "indexOf", "(", "elem", ")", "+", "1", ",", "0", ",", "nl", ")", ";", "}", "}", "}" ]
Merge element with equivalent found in destination @param {Object} elem Source element @param {Function} callback Callback called when equivalent found
[ "Merge", "element", "with", "equivalent", "found", "in", "destination" ]
6971337fff22668664906da757fc29b8a6f4cad1
https://github.com/benderjs/dom-combiner/blob/6971337fff22668664906da757fc29b8a6f4cad1/lib/combiner.js#L57-L84
49,651
benderjs/dom-combiner
lib/combiner.js
mergeDoctype
function mergeDoctype( elem ) { merge( elem, function( old ) { utils.replaceElement( old, elem ); destChildren[ destChildren.indexOf( old ) ] = elem; } ); }
javascript
function mergeDoctype( elem ) { merge( elem, function( old ) { utils.replaceElement( old, elem ); destChildren[ destChildren.indexOf( old ) ] = elem; } ); }
[ "function", "mergeDoctype", "(", "elem", ")", "{", "merge", "(", "elem", ",", "function", "(", "old", ")", "{", "utils", ".", "replaceElement", "(", "old", ",", "elem", ")", ";", "destChildren", "[", "destChildren", ".", "indexOf", "(", "old", ")", "]", "=", "elem", ";", "}", ")", ";", "}" ]
Merge doctype directives @param {Object} elem New doctype directive
[ "Merge", "doctype", "directives" ]
6971337fff22668664906da757fc29b8a6f4cad1
https://github.com/benderjs/dom-combiner/blob/6971337fff22668664906da757fc29b8a6f4cad1/lib/combiner.js#L90-L95
49,652
the-labo/the-resource-user
example/example-usage.js
signup
async function signup (username, password, options = {}) { let { email = null, profile = {}, roles = [] } = options let user = await User.create({ username, email }) user.sign = await UserSign.create({ user, password }) user.profile = await UserProfile.create({ user, profile }) user.roles = await UserRole.createBulk(roles.map((code) => ({ user, code }))) await user.save() return user }
javascript
async function signup (username, password, options = {}) { let { email = null, profile = {}, roles = [] } = options let user = await User.create({ username, email }) user.sign = await UserSign.create({ user, password }) user.profile = await UserProfile.create({ user, profile }) user.roles = await UserRole.createBulk(roles.map((code) => ({ user, code }))) await user.save() return user }
[ "async", "function", "signup", "(", "username", ",", "password", ",", "options", "=", "{", "}", ")", "{", "let", "{", "email", "=", "null", ",", "profile", "=", "{", "}", ",", "roles", "=", "[", "]", "}", "=", "options", "let", "user", "=", "await", "User", ".", "create", "(", "{", "username", ",", "email", "}", ")", "user", ".", "sign", "=", "await", "UserSign", ".", "create", "(", "{", "user", ",", "password", "}", ")", "user", ".", "profile", "=", "await", "UserProfile", ".", "create", "(", "{", "user", ",", "profile", "}", ")", "user", ".", "roles", "=", "await", "UserRole", ".", "createBulk", "(", "roles", ".", "map", "(", "(", "code", ")", "=>", "(", "{", "user", ",", "code", "}", ")", ")", ")", "await", "user", ".", "save", "(", ")", "return", "user", "}" ]
Signup an user
[ "Signup", "an", "user" ]
c11b720e7e29325bef8299729f7b29d638cb4888
https://github.com/the-labo/the-resource-user/blob/c11b720e7e29325bef8299729f7b29d638cb4888/example/example-usage.js#L29-L37
49,653
the-labo/the-resource-user
example/example-usage.js
signin
async function signin (username, password, options = {}) { let { agent } = options let user = await User.only({ username }) let sign = user && await UserSign.only({ user }) let valid = sign && await sign.testPassword(password) if (!valid) { throw new Error('Signin failed!') } await user.sync() session.signed = user return user }
javascript
async function signin (username, password, options = {}) { let { agent } = options let user = await User.only({ username }) let sign = user && await UserSign.only({ user }) let valid = sign && await sign.testPassword(password) if (!valid) { throw new Error('Signin failed!') } await user.sync() session.signed = user return user }
[ "async", "function", "signin", "(", "username", ",", "password", ",", "options", "=", "{", "}", ")", "{", "let", "{", "agent", "}", "=", "options", "let", "user", "=", "await", "User", ".", "only", "(", "{", "username", "}", ")", "let", "sign", "=", "user", "&&", "await", "UserSign", ".", "only", "(", "{", "user", "}", ")", "let", "valid", "=", "sign", "&&", "await", "sign", ".", "testPassword", "(", "password", ")", "if", "(", "!", "valid", ")", "{", "throw", "new", "Error", "(", "'Signin failed!'", ")", "}", "await", "user", ".", "sync", "(", ")", "session", ".", "signed", "=", "user", "return", "user", "}" ]
Start user session
[ "Start", "user", "session" ]
c11b720e7e29325bef8299729f7b29d638cb4888
https://github.com/the-labo/the-resource-user/blob/c11b720e7e29325bef8299729f7b29d638cb4888/example/example-usage.js#L40-L51
49,654
wunderbyte/grunt-spiritual-edbml
tasks/things/compiler.js
FunctionCompiler
function FunctionCompiler() { var _this; _classCallCheck(this, FunctionCompiler); _this = _possibleConstructorReturn(this, _getPrototypeOf(FunctionCompiler).call(this)); /** * Compile sequence. * @type {Array<function>} */ _this._sequence = [_this._uncomment, _this._validate, _this._extract, _this._direct, _this._compile, _this._definehead, _this._injecthead, _this._macromize]; /** * Options from Grunt. * @type {Map} */ _this._options = null; /** * Hm. */ _this._macros = null; /** * Mapping script tag attributes. * This may be put to future use. * @type {Map<string,string>} */ _this._directives = null; /** * Processing intstructions. * @type {Array<Instruction>} */ _this._instructions = null; /** * Compiled arguments list. * @type {Array<string>} */ _this._params = null; /** * Tracking imported functions. * @type {Map<string,string>} */ _this._functions = {}; /** * Did compilation fail just yet? * @type {boolean} */ _this._failed = false; return _this; }
javascript
function FunctionCompiler() { var _this; _classCallCheck(this, FunctionCompiler); _this = _possibleConstructorReturn(this, _getPrototypeOf(FunctionCompiler).call(this)); /** * Compile sequence. * @type {Array<function>} */ _this._sequence = [_this._uncomment, _this._validate, _this._extract, _this._direct, _this._compile, _this._definehead, _this._injecthead, _this._macromize]; /** * Options from Grunt. * @type {Map} */ _this._options = null; /** * Hm. */ _this._macros = null; /** * Mapping script tag attributes. * This may be put to future use. * @type {Map<string,string>} */ _this._directives = null; /** * Processing intstructions. * @type {Array<Instruction>} */ _this._instructions = null; /** * Compiled arguments list. * @type {Array<string>} */ _this._params = null; /** * Tracking imported functions. * @type {Map<string,string>} */ _this._functions = {}; /** * Did compilation fail just yet? * @type {boolean} */ _this._failed = false; return _this; }
[ "function", "FunctionCompiler", "(", ")", "{", "var", "_this", ";", "_classCallCheck", "(", "this", ",", "FunctionCompiler", ")", ";", "_this", "=", "_possibleConstructorReturn", "(", "this", ",", "_getPrototypeOf", "(", "FunctionCompiler", ")", ".", "call", "(", "this", ")", ")", ";", "/**\n * Compile sequence.\n * @type {Array<function>}\n */", "_this", ".", "_sequence", "=", "[", "_this", ".", "_uncomment", ",", "_this", ".", "_validate", ",", "_this", ".", "_extract", ",", "_this", ".", "_direct", ",", "_this", ".", "_compile", ",", "_this", ".", "_definehead", ",", "_this", ".", "_injecthead", ",", "_this", ".", "_macromize", "]", ";", "/**\n * Options from Grunt.\n * @type {Map}\n */", "_this", ".", "_options", "=", "null", ";", "/**\n * Hm.\n */", "_this", ".", "_macros", "=", "null", ";", "/**\n * Mapping script tag attributes.\n * This may be put to future use.\n * @type {Map<string,string>}\n */", "_this", ".", "_directives", "=", "null", ";", "/**\n * Processing intstructions.\n * @type {Array<Instruction>}\n */", "_this", ".", "_instructions", "=", "null", ";", "/**\n * Compiled arguments list.\n * @type {Array<string>}\n */", "_this", ".", "_params", "=", "null", ";", "/**\n * Tracking imported functions.\n * @type {Map<string,string>}\n */", "_this", ".", "_functions", "=", "{", "}", ";", "/**\n * Did compilation fail just yet?\n * @type {boolean}\n */", "_this", ".", "_failed", "=", "false", ";", "return", "_this", ";", "}" ]
Construction time again.
[ "Construction", "time", "again", "." ]
2ba0aa8042eceee917f1ee48c7881345df3bce46
https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/compiler.js#L523-L578
49,655
wunderbyte/grunt-spiritual-edbml
tasks/things/compiler.js
ScriptCompiler
function ScriptCompiler() { var _this4; _classCallCheck(this, ScriptCompiler); _this4 = _possibleConstructorReturn(this, _getPrototypeOf(ScriptCompiler).call(this)); _this4.inputs = {}; return _this4; }
javascript
function ScriptCompiler() { var _this4; _classCallCheck(this, ScriptCompiler); _this4 = _possibleConstructorReturn(this, _getPrototypeOf(ScriptCompiler).call(this)); _this4.inputs = {}; return _this4; }
[ "function", "ScriptCompiler", "(", ")", "{", "var", "_this4", ";", "_classCallCheck", "(", "this", ",", "ScriptCompiler", ")", ";", "_this4", "=", "_possibleConstructorReturn", "(", "this", ",", "_getPrototypeOf", "(", "ScriptCompiler", ")", ".", "call", "(", "this", ")", ")", ";", "_this4", ".", "inputs", "=", "{", "}", ";", "return", "_this4", ";", "}" ]
Map observed types. Add custom sequence. @param {string} key
[ "Map", "observed", "types", ".", "Add", "custom", "sequence", "." ]
2ba0aa8042eceee917f1ee48c7881345df3bce46
https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/compiler.js#L802-L810
49,656
wunderbyte/grunt-spiritual-edbml
tasks/things/compiler.js
strip
function strip(script) { script = this._stripout(script, '<!--', '-->'); script = this._stripout(script, '/*', '*/'); script = this._stripout(script, '^//', '\n'); return script; }
javascript
function strip(script) { script = this._stripout(script, '<!--', '-->'); script = this._stripout(script, '/*', '*/'); script = this._stripout(script, '^//', '\n'); return script; }
[ "function", "strip", "(", "script", ")", "{", "script", "=", "this", ".", "_stripout", "(", "script", ",", "'<!--'", ",", "'-->'", ")", ";", "script", "=", "this", ".", "_stripout", "(", "script", ",", "'/*'", ",", "'*/'", ")", ";", "script", "=", "this", ".", "_stripout", "(", "script", ",", "'^//'", ",", "'\\n'", ")", ";", "return", "script", ";", "}" ]
Strip HTML and JS comments. @param {string} script @returns {string}
[ "Strip", "HTML", "and", "JS", "comments", "." ]
2ba0aa8042eceee917f1ee48c7881345df3bce46
https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/compiler.js#L941-L946
49,657
wunderbyte/grunt-spiritual-edbml
tasks/things/compiler.js
Runner
function Runner() { _classCallCheck(this, Runner); this.firstline = false; this.lastline = false; this.firstchar = false; this.lastchar = false; this._line = null; this._index = -1; }
javascript
function Runner() { _classCallCheck(this, Runner); this.firstline = false; this.lastline = false; this.firstchar = false; this.lastchar = false; this._line = null; this._index = -1; }
[ "function", "Runner", "(", ")", "{", "_classCallCheck", "(", "this", ",", "Runner", ")", ";", "this", ".", "firstline", "=", "false", ";", "this", ".", "lastline", "=", "false", ";", "this", ".", "firstchar", "=", "false", ";", "this", ".", "lastchar", "=", "false", ";", "this", ".", "_line", "=", "null", ";", "this", ".", "_index", "=", "-", "1", ";", "}" ]
Let's go.
[ "Let", "s", "go", "." ]
2ba0aa8042eceee917f1ee48c7881345df3bce46
https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/compiler.js#L1061-L1070
49,658
wunderbyte/grunt-spiritual-edbml
tasks/things/compiler.js
Output
function Output() { var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; _classCallCheck(this, Output); this.body = body; this.temp = null; }
javascript
function Output() { var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; _classCallCheck(this, Output); this.body = body; this.temp = null; }
[ "function", "Output", "(", ")", "{", "var", "body", "=", "arguments", ".", "length", ">", "0", "&&", "arguments", "[", "0", "]", "!==", "undefined", "?", "arguments", "[", "0", "]", ":", "''", ";", "_classCallCheck", "(", "this", ",", "Output", ")", ";", "this", ".", "body", "=", "body", ";", "this", ".", "temp", "=", "null", ";", "}" ]
Collecting JS code.
[ "Collecting", "JS", "code", "." ]
2ba0aa8042eceee917f1ee48c7881345df3bce46
https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/compiler.js#L1722-L1729
49,659
andrewscwei/requiem
src/dom/getState.js
getState
function getState(element) { assertType(element, Node, false, 'Invalid element specified'); let state = element.state || element.getAttribute(Directive.STATE); if (!state || state === '') return null; else return state; }
javascript
function getState(element) { assertType(element, Node, false, 'Invalid element specified'); let state = element.state || element.getAttribute(Directive.STATE); if (!state || state === '') return null; else return state; }
[ "function", "getState", "(", "element", ")", "{", "assertType", "(", "element", ",", "Node", ",", "false", ",", "'Invalid element specified'", ")", ";", "let", "state", "=", "element", ".", "state", "||", "element", ".", "getAttribute", "(", "Directive", ".", "STATE", ")", ";", "if", "(", "!", "state", "||", "state", "===", "''", ")", "return", "null", ";", "else", "return", "state", ";", "}" ]
Gets the current state of a DOM element as defined by Directive.STATE. @param {Node} element - Target element. @return {string} State of the target element. @alias module:requiem~dom.getState
[ "Gets", "the", "current", "state", "of", "a", "DOM", "element", "as", "defined", "by", "Directive", ".", "STATE", "." ]
c4182bfffc9841c6de5718f689ad3c2060511777
https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getState.js#L17-L26
49,660
bertez/quenda
dist/quenda.js
function(step) { if (!step) { throw new Error('Not enough arguments'); } if (Array.isArray(step)) { step.forEach(function(s) { this.add(s); }, this); } else { if (step.nextDelay && step.nextDelay < 0) { throw new Error('nextDelay property must be greater than 0'); } if (step.fn && typeof(step.fn) !== 'function') { throw new Error('The property fn must be a function'); } if (step.autoDestroy && typeof(step.autoDestroy) !== 'boolean') { throw new Error('The property autoDestroy must be a boolean'); } if (step.preload && !Array.isArray(step.preload)) { throw new Error('The property preload must be an array of urls'); } this.steps.push(step); } return this; }
javascript
function(step) { if (!step) { throw new Error('Not enough arguments'); } if (Array.isArray(step)) { step.forEach(function(s) { this.add(s); }, this); } else { if (step.nextDelay && step.nextDelay < 0) { throw new Error('nextDelay property must be greater than 0'); } if (step.fn && typeof(step.fn) !== 'function') { throw new Error('The property fn must be a function'); } if (step.autoDestroy && typeof(step.autoDestroy) !== 'boolean') { throw new Error('The property autoDestroy must be a boolean'); } if (step.preload && !Array.isArray(step.preload)) { throw new Error('The property preload must be an array of urls'); } this.steps.push(step); } return this; }
[ "function", "(", "step", ")", "{", "if", "(", "!", "step", ")", "{", "throw", "new", "Error", "(", "'Not enough arguments'", ")", ";", "}", "if", "(", "Array", ".", "isArray", "(", "step", ")", ")", "{", "step", ".", "forEach", "(", "function", "(", "s", ")", "{", "this", ".", "add", "(", "s", ")", ";", "}", ",", "this", ")", ";", "}", "else", "{", "if", "(", "step", ".", "nextDelay", "&&", "step", ".", "nextDelay", "<", "0", ")", "{", "throw", "new", "Error", "(", "'nextDelay property must be greater than 0'", ")", ";", "}", "if", "(", "step", ".", "fn", "&&", "typeof", "(", "step", ".", "fn", ")", "!==", "'function'", ")", "{", "throw", "new", "Error", "(", "'The property fn must be a function'", ")", ";", "}", "if", "(", "step", ".", "autoDestroy", "&&", "typeof", "(", "step", ".", "autoDestroy", ")", "!==", "'boolean'", ")", "{", "throw", "new", "Error", "(", "'The property autoDestroy must be a boolean'", ")", ";", "}", "if", "(", "step", ".", "preload", "&&", "!", "Array", ".", "isArray", "(", "step", ".", "preload", ")", ")", "{", "throw", "new", "Error", "(", "'The property preload must be an array of urls'", ")", ";", "}", "this", ".", "steps", ".", "push", "(", "step", ")", ";", "}", "return", "this", ";", "}" ]
Adds a new step to this queue @param {Object} Step definition @return {Object} This queue instance
[ "Adds", "a", "new", "step", "to", "this", "queue" ]
63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3
https://github.com/bertez/quenda/blob/63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3/dist/quenda.js#L28-L58
49,661
bertez/quenda
dist/quenda.js
function(index) { var step; if (!this.steps[index]) { if (this.config.loop && this._loops < this.config.maxLoops) { this._loops++; step = this.steps[this._current = 0]; } else { return false; } } else { step = this.steps[index]; } if (step.preload && !step.preloaded) { this._handlePreload(step.preload, function() { step.preloaded = true; this._setNext(step.nextDelay); if(step.fn) { step.fn.call(this, step); } }.bind(this)); } else { this._setNext(step.nextDelay); if(step.fn) { step.fn.call(this, step); } } if (step.autoDestroy) { var i = this.steps.indexOf(step); this._current = i; this._recentDestroy = true; this.steps.splice(i, 1); } }
javascript
function(index) { var step; if (!this.steps[index]) { if (this.config.loop && this._loops < this.config.maxLoops) { this._loops++; step = this.steps[this._current = 0]; } else { return false; } } else { step = this.steps[index]; } if (step.preload && !step.preloaded) { this._handlePreload(step.preload, function() { step.preloaded = true; this._setNext(step.nextDelay); if(step.fn) { step.fn.call(this, step); } }.bind(this)); } else { this._setNext(step.nextDelay); if(step.fn) { step.fn.call(this, step); } } if (step.autoDestroy) { var i = this.steps.indexOf(step); this._current = i; this._recentDestroy = true; this.steps.splice(i, 1); } }
[ "function", "(", "index", ")", "{", "var", "step", ";", "if", "(", "!", "this", ".", "steps", "[", "index", "]", ")", "{", "if", "(", "this", ".", "config", ".", "loop", "&&", "this", ".", "_loops", "<", "this", ".", "config", ".", "maxLoops", ")", "{", "this", ".", "_loops", "++", ";", "step", "=", "this", ".", "steps", "[", "this", ".", "_current", "=", "0", "]", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "{", "step", "=", "this", ".", "steps", "[", "index", "]", ";", "}", "if", "(", "step", ".", "preload", "&&", "!", "step", ".", "preloaded", ")", "{", "this", ".", "_handlePreload", "(", "step", ".", "preload", ",", "function", "(", ")", "{", "step", ".", "preloaded", "=", "true", ";", "this", ".", "_setNext", "(", "step", ".", "nextDelay", ")", ";", "if", "(", "step", ".", "fn", ")", "{", "step", ".", "fn", ".", "call", "(", "this", ",", "step", ")", ";", "}", "}", ".", "bind", "(", "this", ")", ")", ";", "}", "else", "{", "this", ".", "_setNext", "(", "step", ".", "nextDelay", ")", ";", "if", "(", "step", ".", "fn", ")", "{", "step", ".", "fn", ".", "call", "(", "this", ",", "step", ")", ";", "}", "}", "if", "(", "step", ".", "autoDestroy", ")", "{", "var", "i", "=", "this", ".", "steps", ".", "indexOf", "(", "step", ")", ";", "this", ".", "_current", "=", "i", ";", "this", ".", "_recentDestroy", "=", "true", ";", "this", ".", "steps", ".", "splice", "(", "i", ",", "1", ")", ";", "}", "}" ]
Executes one element of the queue @param {number} index the element index
[ "Executes", "one", "element", "of", "the", "queue" ]
63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3
https://github.com/bertez/quenda/blob/63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3/dist/quenda.js#L118-L156
49,662
bertez/quenda
dist/quenda.js
function(nextDelay) { var delay = nextDelay || this.config.defaultDelay; if (delay && this._playing) { this._currentTimeout = setTimeout(function() { this._executeStep(++this._current); }.bind(this), delay); } }
javascript
function(nextDelay) { var delay = nextDelay || this.config.defaultDelay; if (delay && this._playing) { this._currentTimeout = setTimeout(function() { this._executeStep(++this._current); }.bind(this), delay); } }
[ "function", "(", "nextDelay", ")", "{", "var", "delay", "=", "nextDelay", "||", "this", ".", "config", ".", "defaultDelay", ";", "if", "(", "delay", "&&", "this", ".", "_playing", ")", "{", "this", ".", "_currentTimeout", "=", "setTimeout", "(", "function", "(", ")", "{", "this", ".", "_executeStep", "(", "++", "this", ".", "_current", ")", ";", "}", ".", "bind", "(", "this", ")", ",", "delay", ")", ";", "}", "}" ]
Sets the execution timeout of the next element in the queue @param {number} nextDelay the delay in ms
[ "Sets", "the", "execution", "timeout", "of", "the", "next", "element", "in", "the", "queue" ]
63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3
https://github.com/bertez/quenda/blob/63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3/dist/quenda.js#L161-L169
49,663
bertez/quenda
dist/quenda.js
function(images, callback) { var loaded = 0; images.forEach(function(src) { var image = new Image(); image.onload = function() { ++loaded; loaded === images.length && callback(); }; image.src = src; }); }
javascript
function(images, callback) { var loaded = 0; images.forEach(function(src) { var image = new Image(); image.onload = function() { ++loaded; loaded === images.length && callback(); }; image.src = src; }); }
[ "function", "(", "images", ",", "callback", ")", "{", "var", "loaded", "=", "0", ";", "images", ".", "forEach", "(", "function", "(", "src", ")", "{", "var", "image", "=", "new", "Image", "(", ")", ";", "image", ".", "onload", "=", "function", "(", ")", "{", "++", "loaded", ";", "loaded", "===", "images", ".", "length", "&&", "callback", "(", ")", ";", "}", ";", "image", ".", "src", "=", "src", ";", "}", ")", ";", "}" ]
Handles the image preload @param {Array} images array of image urls @param {Function} callback callback to execute after all the images are loaded
[ "Handles", "the", "image", "preload" ]
63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3
https://github.com/bertez/quenda/blob/63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3/dist/quenda.js#L175-L185
49,664
bertez/quenda
dist/quenda.js
function(config, name) { if (config && config !== Object(config)) { throw new Error('Config object should be a key/value object.'); } var defaultConfig = { loop: false, maxLoops: Infinity }; var instance = Object.create(Queue); this.queues.push(name ? { name: name, instance: instance } : { instance: instance }); merge(instance, { config: merge({}, defaultConfig, config), steps: [] }); return instance; }
javascript
function(config, name) { if (config && config !== Object(config)) { throw new Error('Config object should be a key/value object.'); } var defaultConfig = { loop: false, maxLoops: Infinity }; var instance = Object.create(Queue); this.queues.push(name ? { name: name, instance: instance } : { instance: instance }); merge(instance, { config: merge({}, defaultConfig, config), steps: [] }); return instance; }
[ "function", "(", "config", ",", "name", ")", "{", "if", "(", "config", "&&", "config", "!==", "Object", "(", "config", ")", ")", "{", "throw", "new", "Error", "(", "'Config object should be a key/value object.'", ")", ";", "}", "var", "defaultConfig", "=", "{", "loop", ":", "false", ",", "maxLoops", ":", "Infinity", "}", ";", "var", "instance", "=", "Object", ".", "create", "(", "Queue", ")", ";", "this", ".", "queues", ".", "push", "(", "name", "?", "{", "name", ":", "name", ",", "instance", ":", "instance", "}", ":", "{", "instance", ":", "instance", "}", ")", ";", "merge", "(", "instance", ",", "{", "config", ":", "merge", "(", "{", "}", ",", "defaultConfig", ",", "config", ")", ",", "steps", ":", "[", "]", "}", ")", ";", "return", "instance", ";", "}" ]
Create a new queue @param {Object} [config] The queue configuration @param {[type]} [name] The queue name @return {[type]} The queue instance
[ "Create", "a", "new", "queue" ]
63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3
https://github.com/bertez/quenda/blob/63d9adf3e5c22b9417b6fefd4d78f2cce58afbb3/dist/quenda.js#L230-L255
49,665
cli-kit/cli-help
lib/doc/doc.js
function(program) { this.cli = program; this.cmd = this.cli; if(process.env.CLI_TOOLKIT_HELP_CMD) { var alias = this.cli.finder.getCommandByName; var cmd = alias(process.env.CLI_TOOLKIT_HELP_CMD, this.cli.commands()); if(cmd) { this.cmd = cmd; } } this.eol = eol; this.format = fmt.TEXT_FORMAT; this.help2man = !!process.env.help2man; this.conf = this.cli.configure().help; this.vanilla = this.conf.vanilla; if(this.colon === undefined) { this.colon = typeof(this.conf.colon) === 'boolean' ? this.conf.colon : true; } this.messages = this.conf.messages; this.limit = this.conf.maximum ? this.conf.maximum : 80; this.usage = this.cli.usage(); this.delimiter = this.conf.delimiter ? this.conf.delimiter : ', '; this.assignment = this.conf.assignment ? this.conf.assignment : '='; this.align = this.conf.align || columns.COLUMN_ALIGN; this.collapse = this.conf.collapse; if(!~columns.align.indexOf(this.align)) { this.align = columns.COLUMN_ALIGN; } this.sections = sections.slice(0); var i, k; // custom unknown sections in help conf if(this.cmd.sections()) { var ckeys = Object.keys(this.cmd.sections()); // custom sections come after options var ind = this.sections.indexOf(manual.OPTIONS) + 1; for(i = 0;i < ckeys.length;i++) { k = ckeys[i].toLowerCase(); if(!~this.sections.indexOf(k)) { // inject into section list this.sections.splice(ind, 0, k); ind++; } } } this.padding = this.conf.indent; this.space = this.conf.space || repeat(this.padding); this.wraps = true; this.width = this.conf.width; // whether to use columns this.use = this.format === fmt.TEXT_FORMAT; this.headers = {}; for(k in headers) { this.headers[k] = headers[k]; } this.metrics = {}; this.getMetrics(); this.titles(); }
javascript
function(program) { this.cli = program; this.cmd = this.cli; if(process.env.CLI_TOOLKIT_HELP_CMD) { var alias = this.cli.finder.getCommandByName; var cmd = alias(process.env.CLI_TOOLKIT_HELP_CMD, this.cli.commands()); if(cmd) { this.cmd = cmd; } } this.eol = eol; this.format = fmt.TEXT_FORMAT; this.help2man = !!process.env.help2man; this.conf = this.cli.configure().help; this.vanilla = this.conf.vanilla; if(this.colon === undefined) { this.colon = typeof(this.conf.colon) === 'boolean' ? this.conf.colon : true; } this.messages = this.conf.messages; this.limit = this.conf.maximum ? this.conf.maximum : 80; this.usage = this.cli.usage(); this.delimiter = this.conf.delimiter ? this.conf.delimiter : ', '; this.assignment = this.conf.assignment ? this.conf.assignment : '='; this.align = this.conf.align || columns.COLUMN_ALIGN; this.collapse = this.conf.collapse; if(!~columns.align.indexOf(this.align)) { this.align = columns.COLUMN_ALIGN; } this.sections = sections.slice(0); var i, k; // custom unknown sections in help conf if(this.cmd.sections()) { var ckeys = Object.keys(this.cmd.sections()); // custom sections come after options var ind = this.sections.indexOf(manual.OPTIONS) + 1; for(i = 0;i < ckeys.length;i++) { k = ckeys[i].toLowerCase(); if(!~this.sections.indexOf(k)) { // inject into section list this.sections.splice(ind, 0, k); ind++; } } } this.padding = this.conf.indent; this.space = this.conf.space || repeat(this.padding); this.wraps = true; this.width = this.conf.width; // whether to use columns this.use = this.format === fmt.TEXT_FORMAT; this.headers = {}; for(k in headers) { this.headers[k] = headers[k]; } this.metrics = {}; this.getMetrics(); this.titles(); }
[ "function", "(", "program", ")", "{", "this", ".", "cli", "=", "program", ";", "this", ".", "cmd", "=", "this", ".", "cli", ";", "if", "(", "process", ".", "env", ".", "CLI_TOOLKIT_HELP_CMD", ")", "{", "var", "alias", "=", "this", ".", "cli", ".", "finder", ".", "getCommandByName", ";", "var", "cmd", "=", "alias", "(", "process", ".", "env", ".", "CLI_TOOLKIT_HELP_CMD", ",", "this", ".", "cli", ".", "commands", "(", ")", ")", ";", "if", "(", "cmd", ")", "{", "this", ".", "cmd", "=", "cmd", ";", "}", "}", "this", ".", "eol", "=", "eol", ";", "this", ".", "format", "=", "fmt", ".", "TEXT_FORMAT", ";", "this", ".", "help2man", "=", "!", "!", "process", ".", "env", ".", "help2man", ";", "this", ".", "conf", "=", "this", ".", "cli", ".", "configure", "(", ")", ".", "help", ";", "this", ".", "vanilla", "=", "this", ".", "conf", ".", "vanilla", ";", "if", "(", "this", ".", "colon", "===", "undefined", ")", "{", "this", ".", "colon", "=", "typeof", "(", "this", ".", "conf", ".", "colon", ")", "===", "'boolean'", "?", "this", ".", "conf", ".", "colon", ":", "true", ";", "}", "this", ".", "messages", "=", "this", ".", "conf", ".", "messages", ";", "this", ".", "limit", "=", "this", ".", "conf", ".", "maximum", "?", "this", ".", "conf", ".", "maximum", ":", "80", ";", "this", ".", "usage", "=", "this", ".", "cli", ".", "usage", "(", ")", ";", "this", ".", "delimiter", "=", "this", ".", "conf", ".", "delimiter", "?", "this", ".", "conf", ".", "delimiter", ":", "', '", ";", "this", ".", "assignment", "=", "this", ".", "conf", ".", "assignment", "?", "this", ".", "conf", ".", "assignment", ":", "'='", ";", "this", ".", "align", "=", "this", ".", "conf", ".", "align", "||", "columns", ".", "COLUMN_ALIGN", ";", "this", ".", "collapse", "=", "this", ".", "conf", ".", "collapse", ";", "if", "(", "!", "~", "columns", ".", "align", ".", "indexOf", "(", "this", ".", "align", ")", ")", "{", "this", ".", "align", "=", "columns", ".", "COLUMN_ALIGN", ";", "}", "this", ".", "sections", "=", "sections", ".", "slice", "(", "0", ")", ";", "var", "i", ",", "k", ";", "// custom unknown sections in help conf", "if", "(", "this", ".", "cmd", ".", "sections", "(", ")", ")", "{", "var", "ckeys", "=", "Object", ".", "keys", "(", "this", ".", "cmd", ".", "sections", "(", ")", ")", ";", "// custom sections come after options", "var", "ind", "=", "this", ".", "sections", ".", "indexOf", "(", "manual", ".", "OPTIONS", ")", "+", "1", ";", "for", "(", "i", "=", "0", ";", "i", "<", "ckeys", ".", "length", ";", "i", "++", ")", "{", "k", "=", "ckeys", "[", "i", "]", ".", "toLowerCase", "(", ")", ";", "if", "(", "!", "~", "this", ".", "sections", ".", "indexOf", "(", "k", ")", ")", "{", "// inject into section list", "this", ".", "sections", ".", "splice", "(", "ind", ",", "0", ",", "k", ")", ";", "ind", "++", ";", "}", "}", "}", "this", ".", "padding", "=", "this", ".", "conf", ".", "indent", ";", "this", ".", "space", "=", "this", ".", "conf", ".", "space", "||", "repeat", "(", "this", ".", "padding", ")", ";", "this", ".", "wraps", "=", "true", ";", "this", ".", "width", "=", "this", ".", "conf", ".", "width", ";", "// whether to use columns", "this", ".", "use", "=", "this", ".", "format", "===", "fmt", ".", "TEXT_FORMAT", ";", "this", ".", "headers", "=", "{", "}", ";", "for", "(", "k", "in", "headers", ")", "{", "this", ".", "headers", "[", "k", "]", "=", "headers", "[", "k", "]", ";", "}", "this", ".", "metrics", "=", "{", "}", ";", "this", ".", "getMetrics", "(", ")", ";", "this", ".", "titles", "(", ")", ";", "}" ]
Abstract super class for help documents. @param program The program instance.
[ "Abstract", "super", "class", "for", "help", "documents", "." ]
09613efdd753452b466d4deb7c5391c4926e3f04
https://github.com/cli-kit/cli-help/blob/09613efdd753452b466d4deb7c5391c4926e3f04/lib/doc/doc.js#L27-L87
49,666
Nazariglez/perenquen
lib/pixi/src/core/renderers/webgl/filters/AbstractFilter.js
AbstractFilter
function AbstractFilter(vertexSrc, fragmentSrc, uniforms) { /** * An array of shaders * @member {Shader[]} * @private */ this.shaders = []; /** * The extra padding that the filter might need * @member {number} */ this.padding = 0; /** * The uniforms as an object * @member {object} * @private */ this.uniforms = uniforms || {}; /** * The code of the vertex shader * @member {string[]} * @private */ this.vertexSrc = vertexSrc || DefaultShader.defaultVertexSrc; /** * The code of the frament shader * @member {string[]} * @private */ this.fragmentSrc = fragmentSrc || DefaultShader.defaultFragmentSrc; //TODO a reminder - would be cool to have lower res filters as this would give better performance. //typeof fragmentSrc === 'string' ? fragmentSrc.split('') : (fragmentSrc || []); }
javascript
function AbstractFilter(vertexSrc, fragmentSrc, uniforms) { /** * An array of shaders * @member {Shader[]} * @private */ this.shaders = []; /** * The extra padding that the filter might need * @member {number} */ this.padding = 0; /** * The uniforms as an object * @member {object} * @private */ this.uniforms = uniforms || {}; /** * The code of the vertex shader * @member {string[]} * @private */ this.vertexSrc = vertexSrc || DefaultShader.defaultVertexSrc; /** * The code of the frament shader * @member {string[]} * @private */ this.fragmentSrc = fragmentSrc || DefaultShader.defaultFragmentSrc; //TODO a reminder - would be cool to have lower res filters as this would give better performance. //typeof fragmentSrc === 'string' ? fragmentSrc.split('') : (fragmentSrc || []); }
[ "function", "AbstractFilter", "(", "vertexSrc", ",", "fragmentSrc", ",", "uniforms", ")", "{", "/**\n * An array of shaders\n * @member {Shader[]}\n * @private\n */", "this", ".", "shaders", "=", "[", "]", ";", "/**\n * The extra padding that the filter might need\n * @member {number}\n */", "this", ".", "padding", "=", "0", ";", "/**\n * The uniforms as an object\n * @member {object}\n * @private\n */", "this", ".", "uniforms", "=", "uniforms", "||", "{", "}", ";", "/**\n * The code of the vertex shader\n * @member {string[]}\n * @private\n */", "this", ".", "vertexSrc", "=", "vertexSrc", "||", "DefaultShader", ".", "defaultVertexSrc", ";", "/**\n * The code of the frament shader\n * @member {string[]}\n * @private\n */", "this", ".", "fragmentSrc", "=", "fragmentSrc", "||", "DefaultShader", ".", "defaultFragmentSrc", ";", "//TODO a reminder - would be cool to have lower res filters as this would give better performance.", "//typeof fragmentSrc === 'string' ? fragmentSrc.split('') : (fragmentSrc || []);", "}" ]
This is the base class for creating a PIXI filter. Currently only WebGL supports filters. If you want to make a custom filter this should be your base class. @class @memberof PIXI @param vertexSrc {string|string[]} The vertex shader source as an array of strings. @param fragmentSrc {string|string[]} The fragment shader source as an array of strings. @param uniforms {object} An object containing the uniforms for this filter.
[ "This", "is", "the", "base", "class", "for", "creating", "a", "PIXI", "filter", ".", "Currently", "only", "WebGL", "supports", "filters", ".", "If", "you", "want", "to", "make", "a", "custom", "filter", "this", "should", "be", "your", "base", "class", "." ]
e023964d05afeefebdcac4e2044819fdfa3899ae
https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/renderers/webgl/filters/AbstractFilter.js#L13-L55
49,667
sourcegraph/defnode.js
defnode.js
function(type, node) { return seen.indexOf(node) == -1 && ((type == 'AssignmentExpression' && node.right == expr) || (type == 'VariableDeclarator' && node.init == expr)); }
javascript
function(type, node) { return seen.indexOf(node) == -1 && ((type == 'AssignmentExpression' && node.right == expr) || (type == 'VariableDeclarator' && node.init == expr)); }
[ "function", "(", "type", ",", "node", ")", "{", "return", "seen", ".", "indexOf", "(", "node", ")", "==", "-", "1", "&&", "(", "(", "type", "==", "'AssignmentExpression'", "&&", "node", ".", "right", "==", "expr", ")", "||", "(", "type", "==", "'VariableDeclarator'", "&&", "node", ".", "init", "==", "expr", ")", ")", ";", "}" ]
Traverse to parent AssignmentExpressions to return all names in chained assignments.
[ "Traverse", "to", "parent", "AssignmentExpressions", "to", "return", "all", "names", "in", "chained", "assignments", "." ]
8808c966b813d1887f9aaf40643f5a196aafa71d
https://github.com/sourcegraph/defnode.js/blob/8808c966b813d1887f9aaf40643f5a196aafa71d/defnode.js#L170-L172
49,668
creationix/culvert
wrap-node-socket.js
wrapNodeSocket
function wrapNodeSocket(socket, reportError) { // Data traveling from node socket to consumer var incoming = makeChannel(); // Data traveling from consumer to node socket var outgoing = makeChannel(); var onDrain2 = wrapHandler(onReadable, onError); onTake = wrapHandler(onTake, onError); var paused = false; var ended = false; outgoing.take(onTake); socket.on("error", onError); socket.on("drain", wrap(onDrain, onError)); socket.on("readable", wrap(onReadable, onError)); socket.on("end", wrap(onEnd, onError)); function onError(err) { if (err.code === "EPIPE" || err.code === "ECONNRESET") { return onEnd(); } if (reportError) return reportError(err); console.error(err.stack); } function onTake(data) { if (ended) return; // console.log("TAKE", data); if (data === undefined) { ended = true; return socket.end(); } if (socket.write(data)) { outgoing.take(onTake); } else { if (!paused) paused = true; } } function onDrain() { if (paused) { paused = false; outgoing.take(onTake); } } function onEnd() { if (ended) return; ended = true; incoming.put(undefined); } function onReadable() { if (ended) return; while (true) { var chunk = socket.read(); // console.log("READ", chunk); if (!chunk) return; if (!incoming.put(chunk)) { incoming.drain(onDrain2); return; } } } return { put: outgoing.put, drain: outgoing.drain, take: incoming.take, }; }
javascript
function wrapNodeSocket(socket, reportError) { // Data traveling from node socket to consumer var incoming = makeChannel(); // Data traveling from consumer to node socket var outgoing = makeChannel(); var onDrain2 = wrapHandler(onReadable, onError); onTake = wrapHandler(onTake, onError); var paused = false; var ended = false; outgoing.take(onTake); socket.on("error", onError); socket.on("drain", wrap(onDrain, onError)); socket.on("readable", wrap(onReadable, onError)); socket.on("end", wrap(onEnd, onError)); function onError(err) { if (err.code === "EPIPE" || err.code === "ECONNRESET") { return onEnd(); } if (reportError) return reportError(err); console.error(err.stack); } function onTake(data) { if (ended) return; // console.log("TAKE", data); if (data === undefined) { ended = true; return socket.end(); } if (socket.write(data)) { outgoing.take(onTake); } else { if (!paused) paused = true; } } function onDrain() { if (paused) { paused = false; outgoing.take(onTake); } } function onEnd() { if (ended) return; ended = true; incoming.put(undefined); } function onReadable() { if (ended) return; while (true) { var chunk = socket.read(); // console.log("READ", chunk); if (!chunk) return; if (!incoming.put(chunk)) { incoming.drain(onDrain2); return; } } } return { put: outgoing.put, drain: outgoing.drain, take: incoming.take, }; }
[ "function", "wrapNodeSocket", "(", "socket", ",", "reportError", ")", "{", "// Data traveling from node socket to consumer", "var", "incoming", "=", "makeChannel", "(", ")", ";", "// Data traveling from consumer to node socket", "var", "outgoing", "=", "makeChannel", "(", ")", ";", "var", "onDrain2", "=", "wrapHandler", "(", "onReadable", ",", "onError", ")", ";", "onTake", "=", "wrapHandler", "(", "onTake", ",", "onError", ")", ";", "var", "paused", "=", "false", ";", "var", "ended", "=", "false", ";", "outgoing", ".", "take", "(", "onTake", ")", ";", "socket", ".", "on", "(", "\"error\"", ",", "onError", ")", ";", "socket", ".", "on", "(", "\"drain\"", ",", "wrap", "(", "onDrain", ",", "onError", ")", ")", ";", "socket", ".", "on", "(", "\"readable\"", ",", "wrap", "(", "onReadable", ",", "onError", ")", ")", ";", "socket", ".", "on", "(", "\"end\"", ",", "wrap", "(", "onEnd", ",", "onError", ")", ")", ";", "function", "onError", "(", "err", ")", "{", "if", "(", "err", ".", "code", "===", "\"EPIPE\"", "||", "err", ".", "code", "===", "\"ECONNRESET\"", ")", "{", "return", "onEnd", "(", ")", ";", "}", "if", "(", "reportError", ")", "return", "reportError", "(", "err", ")", ";", "console", ".", "error", "(", "err", ".", "stack", ")", ";", "}", "function", "onTake", "(", "data", ")", "{", "if", "(", "ended", ")", "return", ";", "// console.log(\"TAKE\", data);", "if", "(", "data", "===", "undefined", ")", "{", "ended", "=", "true", ";", "return", "socket", ".", "end", "(", ")", ";", "}", "if", "(", "socket", ".", "write", "(", "data", ")", ")", "{", "outgoing", ".", "take", "(", "onTake", ")", ";", "}", "else", "{", "if", "(", "!", "paused", ")", "paused", "=", "true", ";", "}", "}", "function", "onDrain", "(", ")", "{", "if", "(", "paused", ")", "{", "paused", "=", "false", ";", "outgoing", ".", "take", "(", "onTake", ")", ";", "}", "}", "function", "onEnd", "(", ")", "{", "if", "(", "ended", ")", "return", ";", "ended", "=", "true", ";", "incoming", ".", "put", "(", "undefined", ")", ";", "}", "function", "onReadable", "(", ")", "{", "if", "(", "ended", ")", "return", ";", "while", "(", "true", ")", "{", "var", "chunk", "=", "socket", ".", "read", "(", ")", ";", "// console.log(\"READ\", chunk);", "if", "(", "!", "chunk", ")", "return", ";", "if", "(", "!", "incoming", ".", "put", "(", "chunk", ")", ")", "{", "incoming", ".", "drain", "(", "onDrain2", ")", ";", "return", ";", "}", "}", "}", "return", "{", "put", ":", "outgoing", ".", "put", ",", "drain", ":", "outgoing", ".", "drain", ",", "take", ":", "incoming", ".", "take", ",", "}", ";", "}" ]
Given a duplex node stream, return a culvert duplex channel.
[ "Given", "a", "duplex", "node", "stream", "return", "a", "culvert", "duplex", "channel", "." ]
42b83894041cd7f8ee3993af0df65c1afe17b2c5
https://github.com/creationix/culvert/blob/42b83894041cd7f8ee3993af0df65c1afe17b2c5/wrap-node-socket.js#L6-L78
49,669
tylerwalters/aias
dist/aias.js
request
function request (type, url, data) { return new Promise(function (fulfill, reject) { // Set ajax to correct XHR type. Source: https://gist.github.com/jed/993585 var Xhr = window.XMLHttpRequest||ActiveXObject, req = new Xhr('MSXML2.XMLHTTP.3.0'); req.open(type, url, true); req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); req.onreadystatechange = function (e) { if (this.readyState === 4) { if (this.status === 200) { var res = prepareResponse(req.responseText); fulfill(res, req); } else { reject(new Error('Request responded with status ' + req.statusText)); } } }; req.send(data); }); }
javascript
function request (type, url, data) { return new Promise(function (fulfill, reject) { // Set ajax to correct XHR type. Source: https://gist.github.com/jed/993585 var Xhr = window.XMLHttpRequest||ActiveXObject, req = new Xhr('MSXML2.XMLHTTP.3.0'); req.open(type, url, true); req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); req.onreadystatechange = function (e) { if (this.readyState === 4) { if (this.status === 200) { var res = prepareResponse(req.responseText); fulfill(res, req); } else { reject(new Error('Request responded with status ' + req.statusText)); } } }; req.send(data); }); }
[ "function", "request", "(", "type", ",", "url", ",", "data", ")", "{", "return", "new", "Promise", "(", "function", "(", "fulfill", ",", "reject", ")", "{", "// Set ajax to correct XHR type. Source: https://gist.github.com/jed/993585", "var", "Xhr", "=", "window", ".", "XMLHttpRequest", "||", "ActiveXObject", ",", "req", "=", "new", "Xhr", "(", "'MSXML2.XMLHTTP.3.0'", ")", ";", "req", ".", "open", "(", "type", ",", "url", ",", "true", ")", ";", "req", ".", "setRequestHeader", "(", "'Content-type'", ",", "'application/x-www-form-urlencoded'", ")", ";", "req", ".", "onreadystatechange", "=", "function", "(", "e", ")", "{", "if", "(", "this", ".", "readyState", "===", "4", ")", "{", "if", "(", "this", ".", "status", "===", "200", ")", "{", "var", "res", "=", "prepareResponse", "(", "req", ".", "responseText", ")", ";", "fulfill", "(", "res", ",", "req", ")", ";", "}", "else", "{", "reject", "(", "new", "Error", "(", "'Request responded with status '", "+", "req", ".", "statusText", ")", ")", ";", "}", "}", "}", ";", "req", ".", "send", "(", "data", ")", ";", "}", ")", ";", "}" ]
Attempts to parse the response as JSON otherwise returns it untouched. @param {string} type The HTTP verb to be used. @param {string} url The url for the XHR request. @param {object} data Optional. The data to be passed with a POST or PUT request. @memberof aias
[ "Attempts", "to", "parse", "the", "response", "as", "JSON", "otherwise", "returns", "it", "untouched", "." ]
798011b6e3585296a8ead80f74b1f9f05ce02cdf
https://github.com/tylerwalters/aias/blob/798011b6e3585296a8ead80f74b1f9f05ce02cdf/dist/aias.js#L38-L59
49,670
PointSource/cordova-browsersync-primitives
startBrowserSync.js
monkeyPatch
function monkeyPatch() { var script = function() { window.__karma__ = true; (function patch() { if (typeof window.__bs === 'undefined') { window.setTimeout(patch, 500); } else { var oldCanSync = window.__bs.prototype.canSync; window.__bs.prototype.canSync = function(data, optPath) { data.url = window.location.pathname.substr(0, window.location.pathname.indexOf('/www')) + data.url.substr(data.url.indexOf('/www')) return oldCanSync.apply(this, [data, optPath]); }; } }()); }; return '<script>(' + script.toString() + '());</script>'; }
javascript
function monkeyPatch() { var script = function() { window.__karma__ = true; (function patch() { if (typeof window.__bs === 'undefined') { window.setTimeout(patch, 500); } else { var oldCanSync = window.__bs.prototype.canSync; window.__bs.prototype.canSync = function(data, optPath) { data.url = window.location.pathname.substr(0, window.location.pathname.indexOf('/www')) + data.url.substr(data.url.indexOf('/www')) return oldCanSync.apply(this, [data, optPath]); }; } }()); }; return '<script>(' + script.toString() + '());</script>'; }
[ "function", "monkeyPatch", "(", ")", "{", "var", "script", "=", "function", "(", ")", "{", "window", ".", "__karma__", "=", "true", ";", "(", "function", "patch", "(", ")", "{", "if", "(", "typeof", "window", ".", "__bs", "===", "'undefined'", ")", "{", "window", ".", "setTimeout", "(", "patch", ",", "500", ")", ";", "}", "else", "{", "var", "oldCanSync", "=", "window", ".", "__bs", ".", "prototype", ".", "canSync", ";", "window", ".", "__bs", ".", "prototype", ".", "canSync", "=", "function", "(", "data", ",", "optPath", ")", "{", "data", ".", "url", "=", "window", ".", "location", ".", "pathname", ".", "substr", "(", "0", ",", "window", ".", "location", ".", "pathname", ".", "indexOf", "(", "'/www'", ")", ")", "+", "data", ".", "url", ".", "substr", "(", "data", ".", "url", ".", "indexOf", "(", "'/www'", ")", ")", "return", "oldCanSync", ".", "apply", "(", "this", ",", "[", "data", ",", "optPath", "]", ")", ";", "}", ";", "}", "}", "(", ")", ")", ";", "}", ";", "return", "'<script>('", "+", "script", ".", "toString", "(", ")", "+", "'());</script>'", ";", "}" ]
Private function that adds the code snippet to deal with reloading files when they are served from platform folders
[ "Private", "function", "that", "adds", "the", "code", "snippet", "to", "deal", "with", "reloading", "files", "when", "they", "are", "served", "from", "platform", "folders" ]
2117d846d45d1d4a8978847ef6fd1708f33f0e20
https://github.com/PointSource/cordova-browsersync-primitives/blob/2117d846d45d1d4a8978847ef6fd1708f33f0e20/startBrowserSync.js#L12-L28
49,671
PointSource/cordova-browsersync-primitives
startBrowserSync.js
startBrowserSync
function startBrowserSync(cordovaDir, platforms, opts, cb) { var defaults = { logFileChanges: true, logConnections: true, open: false, snippetOptions: { rule: { match: /<\/body>/i, fn: function(snippet, match) { return monkeyPatch() + snippet + match; } } }, minify: false, watchOptions: {}, files: [], server: { baseDir: [], routes: {} } }; platforms.forEach(function(platform) { var www = getWWWFolder(platform); defaults.server.baseDir.push(path.join(www)); defaults.server.routes['/' + www] = path.join(cordovaDir, www); }); opts = opts || {}; if (typeof opts === 'function') { opts = opts(defaults); } else { for (var key in defaults) { if (typeof opts[key] === 'undefined') { opts[key] = defaults[key]; } } } var bsInstance = BrowserSync.create('cordova-browsersync'); bsInstance.init(opts, function(err, callbackBsInstance) { var urls = callbackBsInstance.options.getIn(['urls']); var servers = {}; ['local', 'external', 'tunnel'].forEach(function(type) { servers[type] = urls.get(type); }); cb(err, { bsInstance: bsInstance, servers: servers }); }); return bsInstance; }
javascript
function startBrowserSync(cordovaDir, platforms, opts, cb) { var defaults = { logFileChanges: true, logConnections: true, open: false, snippetOptions: { rule: { match: /<\/body>/i, fn: function(snippet, match) { return monkeyPatch() + snippet + match; } } }, minify: false, watchOptions: {}, files: [], server: { baseDir: [], routes: {} } }; platforms.forEach(function(platform) { var www = getWWWFolder(platform); defaults.server.baseDir.push(path.join(www)); defaults.server.routes['/' + www] = path.join(cordovaDir, www); }); opts = opts || {}; if (typeof opts === 'function') { opts = opts(defaults); } else { for (var key in defaults) { if (typeof opts[key] === 'undefined') { opts[key] = defaults[key]; } } } var bsInstance = BrowserSync.create('cordova-browsersync'); bsInstance.init(opts, function(err, callbackBsInstance) { var urls = callbackBsInstance.options.getIn(['urls']); var servers = {}; ['local', 'external', 'tunnel'].forEach(function(type) { servers[type] = urls.get(type); }); cb(err, { bsInstance: bsInstance, servers: servers }); }); return bsInstance; }
[ "function", "startBrowserSync", "(", "cordovaDir", ",", "platforms", ",", "opts", ",", "cb", ")", "{", "var", "defaults", "=", "{", "logFileChanges", ":", "true", ",", "logConnections", ":", "true", ",", "open", ":", "false", ",", "snippetOptions", ":", "{", "rule", ":", "{", "match", ":", "/", "<\\/body>", "/", "i", ",", "fn", ":", "function", "(", "snippet", ",", "match", ")", "{", "return", "monkeyPatch", "(", ")", "+", "snippet", "+", "match", ";", "}", "}", "}", ",", "minify", ":", "false", ",", "watchOptions", ":", "{", "}", ",", "files", ":", "[", "]", ",", "server", ":", "{", "baseDir", ":", "[", "]", ",", "routes", ":", "{", "}", "}", "}", ";", "platforms", ".", "forEach", "(", "function", "(", "platform", ")", "{", "var", "www", "=", "getWWWFolder", "(", "platform", ")", ";", "defaults", ".", "server", ".", "baseDir", ".", "push", "(", "path", ".", "join", "(", "www", ")", ")", ";", "defaults", ".", "server", ".", "routes", "[", "'/'", "+", "www", "]", "=", "path", ".", "join", "(", "cordovaDir", ",", "www", ")", ";", "}", ")", ";", "opts", "=", "opts", "||", "{", "}", ";", "if", "(", "typeof", "opts", "===", "'function'", ")", "{", "opts", "=", "opts", "(", "defaults", ")", ";", "}", "else", "{", "for", "(", "var", "key", "in", "defaults", ")", "{", "if", "(", "typeof", "opts", "[", "key", "]", "===", "'undefined'", ")", "{", "opts", "[", "key", "]", "=", "defaults", "[", "key", "]", ";", "}", "}", "}", "var", "bsInstance", "=", "BrowserSync", ".", "create", "(", "'cordova-browsersync'", ")", ";", "bsInstance", ".", "init", "(", "opts", ",", "function", "(", "err", ",", "callbackBsInstance", ")", "{", "var", "urls", "=", "callbackBsInstance", ".", "options", ".", "getIn", "(", "[", "'urls'", "]", ")", ";", "var", "servers", "=", "{", "}", ";", "[", "'local'", ",", "'external'", ",", "'tunnel'", "]", ".", "forEach", "(", "function", "(", "type", ")", "{", "servers", "[", "type", "]", "=", "urls", ".", "get", "(", "type", ")", ";", "}", ")", ";", "cb", "(", "err", ",", "{", "bsInstance", ":", "bsInstance", ",", "servers", ":", "servers", "}", ")", ";", "}", ")", ";", "return", "bsInstance", ";", "}" ]
Starts the browser sync server. @param {String} cordovaDir - File path to the root of the cordova project (where the platforms/ directory can be found) @param {Array} platforms - Array of strings, each of which is a Cordova platform name to serve. @param {Object} opts - Options Object to be passed to browserSync. If this is a function, the function is called with default values and should return the final options to be passed to browser-sync @param {Function} cb - A callback when server is ready, calls with (err, servr_hostname)
[ "Starts", "the", "browser", "sync", "server", "." ]
2117d846d45d1d4a8978847ef6fd1708f33f0e20
https://github.com/PointSource/cordova-browsersync-primitives/blob/2117d846d45d1d4a8978847ef6fd1708f33f0e20/startBrowserSync.js#L38-L92
49,672
danillouz/product-hunt
src/index.js
productHunt
function productHunt() { let queryParams = { }; return { /** * Sets the request query parameters to fetch the * most popular products from Product Hunt. * * @return {Object} `productHunt` module */ popular() { queryParams.filter = 'popular'; return this; }, /** * Sets the request query parameters to fetch the * newest products from Product Hunt. * * @return {Object} `productHunt` module */ newest() { queryParams.filter = 'newest'; return this; }, /** * Sets the request query parameters to fetch todays * products from Product Hunt. * * @return {Object} `productHunt` module */ today() { queryParams.page = 0; return this; }, /** * Sets the request query parameters to fetch * yesterdays products from Product Hunt. * * @return {Object} `productHunt` module */ yesterday() { queryParams.page = 1; return this; }, /** * Sets the request query parameters to fetch * Product Hunt products from `n` days ago. * * @param {Number} n - number of days * * @return {Object} `productHunt` module */ daysAgo(n) { const days = parseInt(n, 10); if (!isNaN(days)) { queryParams.page = days; } return this; }, /** * Executes the built request. * * @return {Promise} resolves to an Array of products */ exec() { const params = Object.assign( {}, DEFAULT_QUERY_PARAMS, queryParams ); const request = http.GET(API, params); queryParams = { }; return request; } }; }
javascript
function productHunt() { let queryParams = { }; return { /** * Sets the request query parameters to fetch the * most popular products from Product Hunt. * * @return {Object} `productHunt` module */ popular() { queryParams.filter = 'popular'; return this; }, /** * Sets the request query parameters to fetch the * newest products from Product Hunt. * * @return {Object} `productHunt` module */ newest() { queryParams.filter = 'newest'; return this; }, /** * Sets the request query parameters to fetch todays * products from Product Hunt. * * @return {Object} `productHunt` module */ today() { queryParams.page = 0; return this; }, /** * Sets the request query parameters to fetch * yesterdays products from Product Hunt. * * @return {Object} `productHunt` module */ yesterday() { queryParams.page = 1; return this; }, /** * Sets the request query parameters to fetch * Product Hunt products from `n` days ago. * * @param {Number} n - number of days * * @return {Object} `productHunt` module */ daysAgo(n) { const days = parseInt(n, 10); if (!isNaN(days)) { queryParams.page = days; } return this; }, /** * Executes the built request. * * @return {Promise} resolves to an Array of products */ exec() { const params = Object.assign( {}, DEFAULT_QUERY_PARAMS, queryParams ); const request = http.GET(API, params); queryParams = { }; return request; } }; }
[ "function", "productHunt", "(", ")", "{", "let", "queryParams", "=", "{", "}", ";", "return", "{", "/**\n\t\t * Sets the request query parameters to fetch the\n\t\t * most popular products from Product Hunt.\n\t\t *\n\t\t * @return {Object} `productHunt` module\n\t\t */", "popular", "(", ")", "{", "queryParams", ".", "filter", "=", "'popular'", ";", "return", "this", ";", "}", ",", "/**\n\t\t * Sets the request query parameters to fetch the\n\t\t * newest products from Product Hunt.\n\t\t *\n\t\t * @return {Object} `productHunt` module\n\t\t */", "newest", "(", ")", "{", "queryParams", ".", "filter", "=", "'newest'", ";", "return", "this", ";", "}", ",", "/**\n\t\t * Sets the request query parameters to fetch todays\n\t\t * products from Product Hunt.\n\t\t *\n\t\t * @return {Object} `productHunt` module\n\t\t */", "today", "(", ")", "{", "queryParams", ".", "page", "=", "0", ";", "return", "this", ";", "}", ",", "/**\n\t\t * Sets the request query parameters to fetch\n\t\t * yesterdays products from Product Hunt.\n\t\t *\n\t\t * @return {Object} `productHunt` module\n\t\t */", "yesterday", "(", ")", "{", "queryParams", ".", "page", "=", "1", ";", "return", "this", ";", "}", ",", "/**\n\t\t * Sets the request query parameters to fetch\n\t\t * Product Hunt products from `n` days ago.\n\t\t *\n\t\t * @param {Number} n - number of days\n\t\t *\n\t\t * @return {Object} `productHunt` module\n\t\t */", "daysAgo", "(", "n", ")", "{", "const", "days", "=", "parseInt", "(", "n", ",", "10", ")", ";", "if", "(", "!", "isNaN", "(", "days", ")", ")", "{", "queryParams", ".", "page", "=", "days", ";", "}", "return", "this", ";", "}", ",", "/**\n\t\t * Executes the built request.\n\t\t *\n\t\t * @return {Promise} resolves to an Array of products\n\t\t */", "exec", "(", ")", "{", "const", "params", "=", "Object", ".", "assign", "(", "{", "}", ",", "DEFAULT_QUERY_PARAMS", ",", "queryParams", ")", ";", "const", "request", "=", "http", ".", "GET", "(", "API", ",", "params", ")", ";", "queryParams", "=", "{", "}", ";", "return", "request", ";", "}", "}", ";", "}" ]
Creates interface to build requests to retrieve products from the public Product Hunt API. @return {Object} `productHunt` module
[ "Creates", "interface", "to", "build", "requests", "to", "retrieve", "products", "from", "the", "public", "Product", "Hunt", "API", "." ]
de7196db39365874055ad363cf3736de6de13856
https://github.com/danillouz/product-hunt/blob/de7196db39365874055ad363cf3736de6de13856/src/index.js#L17-L107
49,673
LaxarJS/karma-laxar
lib/index.js
readRequireConfig
function readRequireConfig( file ) { 'use strict'; var config = fs.readFileSync( file ); /*jshint -W054*/ var evaluate = new Function( 'var window = this;' + config + '; return require || window.require;' ); return evaluate.call( {} ); }
javascript
function readRequireConfig( file ) { 'use strict'; var config = fs.readFileSync( file ); /*jshint -W054*/ var evaluate = new Function( 'var window = this;' + config + '; return require || window.require;' ); return evaluate.call( {} ); }
[ "function", "readRequireConfig", "(", "file", ")", "{", "'use strict'", ";", "var", "config", "=", "fs", ".", "readFileSync", "(", "file", ")", ";", "/*jshint -W054*/", "var", "evaluate", "=", "new", "Function", "(", "'var window = this;'", "+", "config", "+", "'; return require || window.require;'", ")", ";", "return", "evaluate", ".", "call", "(", "{", "}", ")", ";", "}" ]
Evaluate the require_config.js file and return the configuration.
[ "Evaluate", "the", "require_config", ".", "js", "file", "and", "return", "the", "configuration", "." ]
959680d5ae6336bb0ca86ce77eab70fde087ae9b
https://github.com/LaxarJS/karma-laxar/blob/959680d5ae6336bb0ca86ce77eab70fde087ae9b/lib/index.js#L23-L29
49,674
ctrees/msfeature
lib/utils/detect-series.js
_detect
function _detect(eachFn, arr, iterator, mainCallback) { eachFn(arr, function (x, index, callback) { iterator(x, function (v, result) { if (v) { mainCallback(result || x); mainCallback = async.noop; } else { callback(); } }); }, function () { mainCallback(); }); }
javascript
function _detect(eachFn, arr, iterator, mainCallback) { eachFn(arr, function (x, index, callback) { iterator(x, function (v, result) { if (v) { mainCallback(result || x); mainCallback = async.noop; } else { callback(); } }); }, function () { mainCallback(); }); }
[ "function", "_detect", "(", "eachFn", ",", "arr", ",", "iterator", ",", "mainCallback", ")", "{", "eachFn", "(", "arr", ",", "function", "(", "x", ",", "index", ",", "callback", ")", "{", "iterator", "(", "x", ",", "function", "(", "v", ",", "result", ")", "{", "if", "(", "v", ")", "{", "mainCallback", "(", "result", "||", "x", ")", ";", "mainCallback", "=", "async", ".", "noop", ";", "}", "else", "{", "callback", "(", ")", ";", "}", "}", ")", ";", "}", ",", "function", "(", ")", "{", "mainCallback", "(", ")", ";", "}", ")", ";", "}" ]
From async.js, modified to return an optional result. @param eachFn @param arr @param iterator @param mainCallback @private
[ "From", "async", ".", "js", "modified", "to", "return", "an", "optional", "result", "." ]
5ee14fe11ade502ab2b47467717094ea9ea7b6ec
https://github.com/ctrees/msfeature/blob/5ee14fe11ade502ab2b47467717094ea9ea7b6ec/lib/utils/detect-series.js#L20-L33
49,675
tolokoban/ToloFrameWork
ker/mod/tfw.pointer-events.js
getCurrentTarget
function getCurrentTarget( slot ) { if( !G.target ) return null; for( var i = 0 ; i < G.target.length ; i++ ) { var target = G.target[i]; if( !slot || typeof target.slots[slot] === 'function' ) return target; } return null; }
javascript
function getCurrentTarget( slot ) { if( !G.target ) return null; for( var i = 0 ; i < G.target.length ; i++ ) { var target = G.target[i]; if( !slot || typeof target.slots[slot] === 'function' ) return target; } return null; }
[ "function", "getCurrentTarget", "(", "slot", ")", "{", "if", "(", "!", "G", ".", "target", ")", "return", "null", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "G", ".", "target", ".", "length", ";", "i", "++", ")", "{", "var", "target", "=", "G", ".", "target", "[", "i", "]", ";", "if", "(", "!", "slot", "||", "typeof", "target", ".", "slots", "[", "slot", "]", "===", "'function'", ")", "return", "target", ";", "}", "return", "null", ";", "}" ]
Return the first taget listening on this `slot`.
[ "Return", "the", "first", "taget", "listening", "on", "this", "slot", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.pointer-events.js#L359-L366
49,676
MeldCE/skemer
src/lib/skemer.js
validateNew
function validateNew(options) { options = validateOptions(options); //console.log('options after validation', util.inspect(options, {depth: null})); //return; //console.log('skemer.validateAdd called', arguments); return validateData.apply(this, [options, undefined].concat(Array.prototype.slice.call(arguments, 1))); }
javascript
function validateNew(options) { options = validateOptions(options); //console.log('options after validation', util.inspect(options, {depth: null})); //return; //console.log('skemer.validateAdd called', arguments); return validateData.apply(this, [options, undefined].concat(Array.prototype.slice.call(arguments, 1))); }
[ "function", "validateNew", "(", "options", ")", "{", "options", "=", "validateOptions", "(", "options", ")", ";", "//console.log('options after validation', util.inspect(options, {depth: null}));", "//return;", "//console.log('skemer.validateAdd called', arguments);", "return", "validateData", ".", "apply", "(", "this", ",", "[", "options", ",", "undefined", "]", ".", "concat", "(", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ")", ")", ";", "}" ]
Validate and merge new data based on the given schema. @param {Object} options An object containing the validation [`options`]{@link #options}, including the [`schema`]{@link #schema} @param {...*} newData Data to validate, merge and return @returns {*} Validated and merged data
[ "Validate", "and", "merge", "new", "data", "based", "on", "the", "given", "schema", "." ]
9ef7b00c7c96db5d13c368180b2f660e571de44c
https://github.com/MeldCE/skemer/blob/9ef7b00c7c96db5d13c368180b2f660e571de44c/src/lib/skemer.js#L740-L749
49,677
MeldCE/skemer
src/lib/skemer.js
function () { return validateData.apply(this, [this.options, undefined].concat(Array.prototype.slice.call(arguments))); }
javascript
function () { return validateData.apply(this, [this.options, undefined].concat(Array.prototype.slice.call(arguments))); }
[ "function", "(", ")", "{", "return", "validateData", ".", "apply", "(", "this", ",", "[", "this", ".", "options", ",", "undefined", "]", ".", "concat", "(", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ")", ")", ";", "}" ]
Validate and merge new data based on the stored schema. @param {...*} newData Data to validate, merge and return. If no data is given, a variable containing any default values, if configured, will be returned. @returns {*} Validated and merged data
[ "Validate", "and", "merge", "new", "data", "based", "on", "the", "stored", "schema", "." ]
9ef7b00c7c96db5d13c368180b2f660e571de44c
https://github.com/MeldCE/skemer/blob/9ef7b00c7c96db5d13c368180b2f660e571de44c/src/lib/skemer.js#L955-L958
49,678
redisjs/jsr-server
lib/command/server/slowlog.js
reset
function reset(req, res) { this.state.slowlog.reset(); res.send(null, Constants.OK); }
javascript
function reset(req, res) { this.state.slowlog.reset(); res.send(null, Constants.OK); }
[ "function", "reset", "(", "req", ",", "res", ")", "{", "this", ".", "state", ".", "slowlog", ".", "reset", "(", ")", ";", "res", ".", "send", "(", "null", ",", "Constants", ".", "OK", ")", ";", "}" ]
Respond to the RESET subcommand.
[ "Respond", "to", "the", "RESET", "subcommand", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/slowlog.js#L34-L37
49,679
redisjs/jsr-server
lib/command/server/slowlog.js
validate
function validate(cmd, args, info) { AbstractCommand.prototype.validate.apply(this, arguments); var sub = info.command.sub , scmd = ('' + sub.cmd) , args = sub.args , amount; if(scmd === Constants.SUBCOMMAND.slowlog.get.name && args.length) { if(args.length > 1) { throw new CommandArgLength(cmd, scmd); } amount = parseInt('' + args[0]); if(isNaN(amount)) { throw IntegerRange; } args[0] = amount; } }
javascript
function validate(cmd, args, info) { AbstractCommand.prototype.validate.apply(this, arguments); var sub = info.command.sub , scmd = ('' + sub.cmd) , args = sub.args , amount; if(scmd === Constants.SUBCOMMAND.slowlog.get.name && args.length) { if(args.length > 1) { throw new CommandArgLength(cmd, scmd); } amount = parseInt('' + args[0]); if(isNaN(amount)) { throw IntegerRange; } args[0] = amount; } }
[ "function", "validate", "(", "cmd", ",", "args", ",", "info", ")", "{", "AbstractCommand", ".", "prototype", ".", "validate", ".", "apply", "(", "this", ",", "arguments", ")", ";", "var", "sub", "=", "info", ".", "command", ".", "sub", ",", "scmd", "=", "(", "''", "+", "sub", ".", "cmd", ")", ",", "args", "=", "sub", ".", "args", ",", "amount", ";", "if", "(", "scmd", "===", "Constants", ".", "SUBCOMMAND", ".", "slowlog", ".", "get", ".", "name", "&&", "args", ".", "length", ")", "{", "if", "(", "args", ".", "length", ">", "1", ")", "{", "throw", "new", "CommandArgLength", "(", "cmd", ",", "scmd", ")", ";", "}", "amount", "=", "parseInt", "(", "''", "+", "args", "[", "0", "]", ")", ";", "if", "(", "isNaN", "(", "amount", ")", ")", "{", "throw", "IntegerRange", ";", "}", "args", "[", "0", "]", "=", "amount", ";", "}", "}" ]
Validate the SLOWLOG subcommands.
[ "Validate", "the", "SLOWLOG", "subcommands", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/slowlog.js#L42-L59
49,680
freeqaz/sassify-object
sassify.js
sassifyFn
function sassifyFn(rawObject) { var sassified = ''; Object.keys(rawObject).forEach(function iterateVariables(key) { var variable = rawObject[key]; var stringified = JSON.stringify(variable); // Trim off double quotes for CSS variables. stringified = stringified.substring(1, stringified.length - 1); sassified += '$' + key + ': ' + stringified + ';\n'; }); return sassified; }
javascript
function sassifyFn(rawObject) { var sassified = ''; Object.keys(rawObject).forEach(function iterateVariables(key) { var variable = rawObject[key]; var stringified = JSON.stringify(variable); // Trim off double quotes for CSS variables. stringified = stringified.substring(1, stringified.length - 1); sassified += '$' + key + ': ' + stringified + ';\n'; }); return sassified; }
[ "function", "sassifyFn", "(", "rawObject", ")", "{", "var", "sassified", "=", "''", ";", "Object", ".", "keys", "(", "rawObject", ")", ".", "forEach", "(", "function", "iterateVariables", "(", "key", ")", "{", "var", "variable", "=", "rawObject", "[", "key", "]", ";", "var", "stringified", "=", "JSON", ".", "stringify", "(", "variable", ")", ";", "// Trim off double quotes for CSS variables.", "stringified", "=", "stringified", ".", "substring", "(", "1", ",", "stringified", ".", "length", "-", "1", ")", ";", "sassified", "+=", "'$'", "+", "key", "+", "': '", "+", "stringified", "+", "';\\n'", ";", "}", ")", ";", "return", "sassified", ";", "}" ]
Converts a single-depth javascript object into SASS variables. @param {Object} rawObject Object to convert to SASS variables. @returns {string} Sass content with variables defined.
[ "Converts", "a", "single", "-", "depth", "javascript", "object", "into", "SASS", "variables", "." ]
a828e884dd7b588d7b7cf3f7b4c7302a7d9b789f
https://github.com/freeqaz/sassify-object/blob/a828e884dd7b588d7b7cf3f7b4c7302a7d9b789f/sassify.js#L10-L25
49,681
andrewscwei/requiem
src/helpers/noval.js
noval
function noval(value, recursive) { assertType(recursive, 'boolean', true, 'Invalid parameter: recursive'); if (recursive === undefined) recursive = false; if (value === undefined || value === null) { return true; } else if (typeof value === 'string') { return (value === ''); } else if (recursive && (value instanceof Array)) { let n = value.length; for (let i = 0; i < n; i++) { if (!noval(value[i], true)) return false; } return true; } else if (recursive && (typeof value === 'object') && (value.constructor === Object)) { for (let p in value) { if (!noval(value[p], true)) return false; } return true; } else { return false; } }
javascript
function noval(value, recursive) { assertType(recursive, 'boolean', true, 'Invalid parameter: recursive'); if (recursive === undefined) recursive = false; if (value === undefined || value === null) { return true; } else if (typeof value === 'string') { return (value === ''); } else if (recursive && (value instanceof Array)) { let n = value.length; for (let i = 0; i < n; i++) { if (!noval(value[i], true)) return false; } return true; } else if (recursive && (typeof value === 'object') && (value.constructor === Object)) { for (let p in value) { if (!noval(value[p], true)) return false; } return true; } else { return false; } }
[ "function", "noval", "(", "value", ",", "recursive", ")", "{", "assertType", "(", "recursive", ",", "'boolean'", ",", "true", ",", "'Invalid parameter: recursive'", ")", ";", "if", "(", "recursive", "===", "undefined", ")", "recursive", "=", "false", ";", "if", "(", "value", "===", "undefined", "||", "value", "===", "null", ")", "{", "return", "true", ";", "}", "else", "if", "(", "typeof", "value", "===", "'string'", ")", "{", "return", "(", "value", "===", "''", ")", ";", "}", "else", "if", "(", "recursive", "&&", "(", "value", "instanceof", "Array", ")", ")", "{", "let", "n", "=", "value", ".", "length", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "if", "(", "!", "noval", "(", "value", "[", "i", "]", ",", "true", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}", "else", "if", "(", "recursive", "&&", "(", "typeof", "value", "===", "'object'", ")", "&&", "(", "value", ".", "constructor", "===", "Object", ")", ")", "{", "for", "(", "let", "p", "in", "value", ")", "{", "if", "(", "!", "noval", "(", "value", "[", "p", "]", ",", "true", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Checks if a given value is equal to null. Option to specify recursion, which would further evaluate inner elements, such as when an Array or Object is specified. @param {*} value - Value to evaluate. @param {boolean} [recursive=false] - Specifies whether to recursively evaluate the supplied value's inner values (i.e. an Array or Object). @return {boolean} True if null, false otherwise. @alias module:requiem~helpers.noval
[ "Checks", "if", "a", "given", "value", "is", "equal", "to", "null", ".", "Option", "to", "specify", "recursion", "which", "would", "further", "evaluate", "inner", "elements", "such", "as", "when", "an", "Array", "or", "Object", "is", "specified", "." ]
c4182bfffc9841c6de5718f689ad3c2060511777
https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/helpers/noval.js#L21-L51
49,682
Psychopoulet/node-promfs
lib/extends/_filesToStream.js
_readContent
function _readContent (files, writeStream, separator) { return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => { const file = files.shift().trim(); return isFileProm(file).then((exists) => { const isPattern = -1 < separator.indexOf("{{filename}}"); return !exists ? _readContent(files, writeStream, separator) : Promise.resolve().then(() => { return !isPattern ? Promise.resolve() : new Promise((resolve, reject) => { writeStream.write(separator.replace("{{filename}}", basename(file)), (err) => { return err ? reject(err) : resolve(); }); }); }).then(() => { return new Promise((resolve, reject) => { const readStream = createReadStream(file); let error = false; readStream.once("error", (err) => { error = true; readStream.close(); reject(err); }).once("open", () => { readStream.pipe(writeStream, { "end": false }); }).once("close", () => { if (!error) { resolve(); } }); }); }).then(() => { return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => { return isPattern ? Promise.resolve() : new Promise((resolve, reject) => { writeStream.write(separator, (err) => { return err ? reject(err) : resolve(); }); }); }).then(() => { return _readContent(files, writeStream, separator); }); }); }); }); }
javascript
function _readContent (files, writeStream, separator) { return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => { const file = files.shift().trim(); return isFileProm(file).then((exists) => { const isPattern = -1 < separator.indexOf("{{filename}}"); return !exists ? _readContent(files, writeStream, separator) : Promise.resolve().then(() => { return !isPattern ? Promise.resolve() : new Promise((resolve, reject) => { writeStream.write(separator.replace("{{filename}}", basename(file)), (err) => { return err ? reject(err) : resolve(); }); }); }).then(() => { return new Promise((resolve, reject) => { const readStream = createReadStream(file); let error = false; readStream.once("error", (err) => { error = true; readStream.close(); reject(err); }).once("open", () => { readStream.pipe(writeStream, { "end": false }); }).once("close", () => { if (!error) { resolve(); } }); }); }).then(() => { return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => { return isPattern ? Promise.resolve() : new Promise((resolve, reject) => { writeStream.write(separator, (err) => { return err ? reject(err) : resolve(); }); }); }).then(() => { return _readContent(files, writeStream, separator); }); }); }); }); }
[ "function", "_readContent", "(", "files", ",", "writeStream", ",", "separator", ")", "{", "return", "0", ">=", "files", ".", "length", "?", "Promise", ".", "resolve", "(", ")", ":", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "(", ")", "=>", "{", "const", "file", "=", "files", ".", "shift", "(", ")", ".", "trim", "(", ")", ";", "return", "isFileProm", "(", "file", ")", ".", "then", "(", "(", "exists", ")", "=>", "{", "const", "isPattern", "=", "-", "1", "<", "separator", ".", "indexOf", "(", "\"{{filename}}\"", ")", ";", "return", "!", "exists", "?", "_readContent", "(", "files", ",", "writeStream", ",", "separator", ")", ":", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "(", ")", "=>", "{", "return", "!", "isPattern", "?", "Promise", ".", "resolve", "(", ")", ":", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "writeStream", ".", "write", "(", "separator", ".", "replace", "(", "\"{{filename}}\"", ",", "basename", "(", "file", ")", ")", ",", "(", "err", ")", "=>", "{", "return", "err", "?", "reject", "(", "err", ")", ":", "resolve", "(", ")", ";", "}", ")", ";", "}", ")", ";", "}", ")", ".", "then", "(", "(", ")", "=>", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "const", "readStream", "=", "createReadStream", "(", "file", ")", ";", "let", "error", "=", "false", ";", "readStream", ".", "once", "(", "\"error\"", ",", "(", "err", ")", "=>", "{", "error", "=", "true", ";", "readStream", ".", "close", "(", ")", ";", "reject", "(", "err", ")", ";", "}", ")", ".", "once", "(", "\"open\"", ",", "(", ")", "=>", "{", "readStream", ".", "pipe", "(", "writeStream", ",", "{", "\"end\"", ":", "false", "}", ")", ";", "}", ")", ".", "once", "(", "\"close\"", ",", "(", ")", "=>", "{", "if", "(", "!", "error", ")", "{", "resolve", "(", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}", ")", ".", "then", "(", "(", ")", "=>", "{", "return", "0", ">=", "files", ".", "length", "?", "Promise", ".", "resolve", "(", ")", ":", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "(", ")", "=>", "{", "return", "isPattern", "?", "Promise", ".", "resolve", "(", ")", ":", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "writeStream", ".", "write", "(", "separator", ",", "(", "err", ")", "=>", "{", "return", "err", "?", "reject", "(", "err", ")", ":", "resolve", "(", ")", ";", "}", ")", ";", "}", ")", ";", "}", ")", ".", "then", "(", "(", ")", "=>", "{", "return", "_readContent", "(", "files", ",", "writeStream", ",", "separator", ")", ";", "}", ")", ";", "}", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
methods Specific to "filesToString" method, read all files content @param {Array} files : files to read @param {stream.Transform} writeStream : stream to send data @param {string} separator : used to separate content (can be "") @returns {Promise} Operation's result
[ "methods", "Specific", "to", "filesToString", "method", "read", "all", "files", "content" ]
016e272fc58c6ef6eae5ea551a0e8873f0ac20cc
https://github.com/Psychopoulet/node-promfs/blob/016e272fc58c6ef6eae5ea551a0e8873f0ac20cc/lib/extends/_filesToStream.js#L24-L92
49,683
redisjs/jsr-store
lib/command/hash.js
hsetnx
function hsetnx(key, field, value, req) { var val = this.getKey(key, req) , exists = this.hexists(key, field, req); if(!val) { val = new HashMap(); this.setKey(key, val, undefined, undefined, undefined, req); } if(!exists) { // set on the hashmap val.setKey(field, value); } return exists ? 0 : 1; }
javascript
function hsetnx(key, field, value, req) { var val = this.getKey(key, req) , exists = this.hexists(key, field, req); if(!val) { val = new HashMap(); this.setKey(key, val, undefined, undefined, undefined, req); } if(!exists) { // set on the hashmap val.setKey(field, value); } return exists ? 0 : 1; }
[ "function", "hsetnx", "(", "key", ",", "field", ",", "value", ",", "req", ")", "{", "var", "val", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ",", "exists", "=", "this", ".", "hexists", "(", "key", ",", "field", ",", "req", ")", ";", "if", "(", "!", "val", ")", "{", "val", "=", "new", "HashMap", "(", ")", ";", "this", ".", "setKey", "(", "key", ",", "val", ",", "undefined", ",", "undefined", ",", "undefined", ",", "req", ")", ";", "}", "if", "(", "!", "exists", ")", "{", "// set on the hashmap", "val", ".", "setKey", "(", "field", ",", "value", ")", ";", "}", "return", "exists", "?", "0", ":", "1", ";", "}" ]
Sets field in the hash stored at key to value, only if field does not yet exist.
[ "Sets", "field", "in", "the", "hash", "stored", "at", "key", "to", "value", "only", "if", "field", "does", "not", "yet", "exist", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L34-L46
49,684
redisjs/jsr-store
lib/command/hash.js
hget
function hget(key, field, req) { // get at db level var val = this.getKey(key, req); if(!val) return null; // get at hash level val = val.getKey(field) if(!val) return null; return val; }
javascript
function hget(key, field, req) { // get at db level var val = this.getKey(key, req); if(!val) return null; // get at hash level val = val.getKey(field) if(!val) return null; return val; }
[ "function", "hget", "(", "key", ",", "field", ",", "req", ")", "{", "// get at db level", "var", "val", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ";", "if", "(", "!", "val", ")", "return", "null", ";", "// get at hash level", "val", "=", "val", ".", "getKey", "(", "field", ")", "if", "(", "!", "val", ")", "return", "null", ";", "return", "val", ";", "}" ]
Get the value of a hash field.
[ "Get", "the", "value", "of", "a", "hash", "field", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L51-L59
49,685
redisjs/jsr-store
lib/command/hash.js
hexists
function hexists(key, field, req) { var val = this.getKey(key, req); if(!val) return 0; return val.keyExists(field); }
javascript
function hexists(key, field, req) { var val = this.getKey(key, req); if(!val) return 0; return val.keyExists(field); }
[ "function", "hexists", "(", "key", ",", "field", ",", "req", ")", "{", "var", "val", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ";", "if", "(", "!", "val", ")", "return", "0", ";", "return", "val", ".", "keyExists", "(", "field", ")", ";", "}" ]
Determine if a hash field exists.
[ "Determine", "if", "a", "hash", "field", "exists", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L64-L68
49,686
redisjs/jsr-store
lib/command/hash.js
hgetall
function hgetall(key, req) { var val = this.getKey(key, req) , list = []; if(!val) return list; val.getKeys().forEach(function(k) { list.push(k, '' + val.getKey(k)); }); return list; }
javascript
function hgetall(key, req) { var val = this.getKey(key, req) , list = []; if(!val) return list; val.getKeys().forEach(function(k) { list.push(k, '' + val.getKey(k)); }); return list; }
[ "function", "hgetall", "(", "key", ",", "req", ")", "{", "var", "val", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ",", "list", "=", "[", "]", ";", "if", "(", "!", "val", ")", "return", "list", ";", "val", ".", "getKeys", "(", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "list", ".", "push", "(", "k", ",", "''", "+", "val", ".", "getKey", "(", "k", ")", ")", ";", "}", ")", ";", "return", "list", ";", "}" ]
Get all the fields and values in a hash.
[ "Get", "all", "the", "fields", "and", "values", "in", "a", "hash", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L73-L82
49,687
redisjs/jsr-store
lib/command/hash.js
hkeys
function hkeys(key, req) { var val = this.getKey(key, req); if(!val) return []; return val.getKeys(); }
javascript
function hkeys(key, req) { var val = this.getKey(key, req); if(!val) return []; return val.getKeys(); }
[ "function", "hkeys", "(", "key", ",", "req", ")", "{", "var", "val", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ";", "if", "(", "!", "val", ")", "return", "[", "]", ";", "return", "val", ".", "getKeys", "(", ")", ";", "}" ]
Get all the fields in a hash.
[ "Get", "all", "the", "fields", "in", "a", "hash", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L87-L91
49,688
redisjs/jsr-store
lib/command/hash.js
hlen
function hlen(key, req) { var val = this.getKey(key, req); if(!val) return 0; return val.hlen(); }
javascript
function hlen(key, req) { var val = this.getKey(key, req); if(!val) return 0; return val.hlen(); }
[ "function", "hlen", "(", "key", ",", "req", ")", "{", "var", "val", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ";", "if", "(", "!", "val", ")", "return", "0", ";", "return", "val", ".", "hlen", "(", ")", ";", "}" ]
Get the number of fields in a hash.
[ "Get", "the", "number", "of", "fields", "in", "a", "hash", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L96-L100
49,689
redisjs/jsr-store
lib/command/hash.js
hdel
function hdel(key /* field-1, field-N, req */) { var args = slice.call(arguments, 1) , req = typeof args[args.length - 1] === 'object' ? args.pop() : null , val = this.getKey(key, req) , deleted = 0 , i; // nothing at key if(!val) return 0; for(i = 0;i < args.length;i++) { deleted += val.delKey(args[i]); } if(val.hlen() === 0) { this.delKey(key, req); } return deleted; }
javascript
function hdel(key /* field-1, field-N, req */) { var args = slice.call(arguments, 1) , req = typeof args[args.length - 1] === 'object' ? args.pop() : null , val = this.getKey(key, req) , deleted = 0 , i; // nothing at key if(!val) return 0; for(i = 0;i < args.length;i++) { deleted += val.delKey(args[i]); } if(val.hlen() === 0) { this.delKey(key, req); } return deleted; }
[ "function", "hdel", "(", "key", "/* field-1, field-N, req */", ")", "{", "var", "args", "=", "slice", ".", "call", "(", "arguments", ",", "1", ")", ",", "req", "=", "typeof", "args", "[", "args", ".", "length", "-", "1", "]", "===", "'object'", "?", "args", ".", "pop", "(", ")", ":", "null", ",", "val", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ",", "deleted", "=", "0", ",", "i", ";", "// nothing at key", "if", "(", "!", "val", ")", "return", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "deleted", "+=", "val", ".", "delKey", "(", "args", "[", "i", "]", ")", ";", "}", "if", "(", "val", ".", "hlen", "(", ")", "===", "0", ")", "{", "this", ".", "delKey", "(", "key", ",", "req", ")", ";", "}", "return", "deleted", ";", "}" ]
Delete one or more hash fields.
[ "Delete", "one", "or", "more", "hash", "fields", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L118-L138
49,690
redisjs/jsr-store
lib/command/hash.js
hmget
function hmget(key /* field-1, field-N, req */) { var args = slice.call(arguments, 1) , req = typeof args[args.length - 1] === 'object' ? args.pop() : null , val = this.getKey(key, req) , value , list = [] , i; for(i = 0;i < args.length;i++) { if(!val) { list.push(null); continue; } value = val.getKey(args[i]) list.push(value !== undefined ? value : null); } return list; }
javascript
function hmget(key /* field-1, field-N, req */) { var args = slice.call(arguments, 1) , req = typeof args[args.length - 1] === 'object' ? args.pop() : null , val = this.getKey(key, req) , value , list = [] , i; for(i = 0;i < args.length;i++) { if(!val) { list.push(null); continue; } value = val.getKey(args[i]) list.push(value !== undefined ? value : null); } return list; }
[ "function", "hmget", "(", "key", "/* field-1, field-N, req */", ")", "{", "var", "args", "=", "slice", ".", "call", "(", "arguments", ",", "1", ")", ",", "req", "=", "typeof", "args", "[", "args", ".", "length", "-", "1", "]", "===", "'object'", "?", "args", ".", "pop", "(", ")", ":", "null", ",", "val", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ",", "value", ",", "list", "=", "[", "]", ",", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "val", ")", "{", "list", ".", "push", "(", "null", ")", ";", "continue", ";", "}", "value", "=", "val", ".", "getKey", "(", "args", "[", "i", "]", ")", "list", ".", "push", "(", "value", "!==", "undefined", "?", "value", ":", "null", ")", ";", "}", "return", "list", ";", "}" ]
Returns the values associated with the specified fields in the hash stored at key.
[ "Returns", "the", "values", "associated", "with", "the", "specified", "fields", "in", "the", "hash", "stored", "at", "key", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L144-L161
49,691
redisjs/jsr-store
lib/command/hash.js
hmset
function hmset(key /* field-1, value-1, field-N, value-N, req */) { var args = slice.call(arguments, 1) , req = typeof args[args.length - 1] === 'object' ? args.pop() : null , val = this.getKey(key, req) , i; if(!val) { val = new HashMap(); this.setKey(key, val, undefined, undefined, undefined, req); } for(i = 0;i < args.length;i+=2) { val.setKey(args[i], args[i + 1]); } return OK; }
javascript
function hmset(key /* field-1, value-1, field-N, value-N, req */) { var args = slice.call(arguments, 1) , req = typeof args[args.length - 1] === 'object' ? args.pop() : null , val = this.getKey(key, req) , i; if(!val) { val = new HashMap(); this.setKey(key, val, undefined, undefined, undefined, req); } for(i = 0;i < args.length;i+=2) { val.setKey(args[i], args[i + 1]); } return OK; }
[ "function", "hmset", "(", "key", "/* field-1, value-1, field-N, value-N, req */", ")", "{", "var", "args", "=", "slice", ".", "call", "(", "arguments", ",", "1", ")", ",", "req", "=", "typeof", "args", "[", "args", ".", "length", "-", "1", "]", "===", "'object'", "?", "args", ".", "pop", "(", ")", ":", "null", ",", "val", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ",", "i", ";", "if", "(", "!", "val", ")", "{", "val", "=", "new", "HashMap", "(", ")", ";", "this", ".", "setKey", "(", "key", ",", "val", ",", "undefined", ",", "undefined", ",", "undefined", ",", "req", ")", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "+=", "2", ")", "{", "val", ".", "setKey", "(", "args", "[", "i", "]", ",", "args", "[", "i", "+", "1", "]", ")", ";", "}", "return", "OK", ";", "}" ]
Sets the specified fields to their respective values in the hash stored at key.
[ "Sets", "the", "specified", "fields", "to", "their", "respective", "values", "in", "the", "hash", "stored", "at", "key", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L167-L182
49,692
redisjs/jsr-store
lib/command/hash.js
hincrbyfloat
function hincrbyfloat(key, field, amount, req) { var map = this.getKey(key, req) , val; if(!map) { map = new HashMap(); this.setKey(key, map, undefined, undefined, undefined, req); } val = utils.strtofloat(map.getKey(field)); amount = utils.strtofloat(amount); val += amount; map.setKey(field, val); // store as number and return a number, // the command implementation should coerce the result // to a string for a bulk string reply return val; }
javascript
function hincrbyfloat(key, field, amount, req) { var map = this.getKey(key, req) , val; if(!map) { map = new HashMap(); this.setKey(key, map, undefined, undefined, undefined, req); } val = utils.strtofloat(map.getKey(field)); amount = utils.strtofloat(amount); val += amount; map.setKey(field, val); // store as number and return a number, // the command implementation should coerce the result // to a string for a bulk string reply return val; }
[ "function", "hincrbyfloat", "(", "key", ",", "field", ",", "amount", ",", "req", ")", "{", "var", "map", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ",", "val", ";", "if", "(", "!", "map", ")", "{", "map", "=", "new", "HashMap", "(", ")", ";", "this", ".", "setKey", "(", "key", ",", "map", ",", "undefined", ",", "undefined", ",", "undefined", ",", "req", ")", ";", "}", "val", "=", "utils", ".", "strtofloat", "(", "map", ".", "getKey", "(", "field", ")", ")", ";", "amount", "=", "utils", ".", "strtofloat", "(", "amount", ")", ";", "val", "+=", "amount", ";", "map", ".", "setKey", "(", "field", ",", "val", ")", ";", "// store as number and return a number,", "// the command implementation should coerce the result", "// to a string for a bulk string reply", "return", "val", ";", "}" ]
Increment the specified field of hash stored at key, and representing a floating point number, by the specified increment.
[ "Increment", "the", "specified", "field", "of", "hash", "stored", "at", "key", "and", "representing", "a", "floating", "point", "number", "by", "the", "specified", "increment", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L188-L203
49,693
redisjs/jsr-store
lib/command/hash.js
hincrby
function hincrby(key, field, amount, req) { var map = this.getKey(key, req) , val; if(!map) { map = new HashMap(); this.setKey(key, map, undefined, undefined, undefined, req); } val = utils.strtoint(map.getKey(field)); amount = utils.strtoint(amount); val += amount; map.setKey(field, val); return val; }
javascript
function hincrby(key, field, amount, req) { var map = this.getKey(key, req) , val; if(!map) { map = new HashMap(); this.setKey(key, map, undefined, undefined, undefined, req); } val = utils.strtoint(map.getKey(field)); amount = utils.strtoint(amount); val += amount; map.setKey(field, val); return val; }
[ "function", "hincrby", "(", "key", ",", "field", ",", "amount", ",", "req", ")", "{", "var", "map", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ",", "val", ";", "if", "(", "!", "map", ")", "{", "map", "=", "new", "HashMap", "(", ")", ";", "this", ".", "setKey", "(", "key", ",", "map", ",", "undefined", ",", "undefined", ",", "undefined", ",", "req", ")", ";", "}", "val", "=", "utils", ".", "strtoint", "(", "map", ".", "getKey", "(", "field", ")", ")", ";", "amount", "=", "utils", ".", "strtoint", "(", "amount", ")", ";", "val", "+=", "amount", ";", "map", ".", "setKey", "(", "field", ",", "val", ")", ";", "return", "val", ";", "}" ]
Increments the number stored at field in the hash stored at key by increment.
[ "Increments", "the", "number", "stored", "at", "field", "in", "the", "hash", "stored", "at", "key", "by", "increment", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/hash.js#L209-L221
49,694
nanowizard/vec23
src/Vec3.js
function(v) { if (v instanceof Vec3) { return new Vec3(this.x + v.x, this.y + v.y, this.z + v.z); } else if(v instanceof Vec2){ return new Vec3(this.x + v.x, this.y + v.y, this.z); } else if(typeof v === 'number') { return new Vec3(this.x + v, this.y + v, this.z + v); } else { throw new TypeError('Invalid argument', v); } }
javascript
function(v) { if (v instanceof Vec3) { return new Vec3(this.x + v.x, this.y + v.y, this.z + v.z); } else if(v instanceof Vec2){ return new Vec3(this.x + v.x, this.y + v.y, this.z); } else if(typeof v === 'number') { return new Vec3(this.x + v, this.y + v, this.z + v); } else { throw new TypeError('Invalid argument', v); } }
[ "function", "(", "v", ")", "{", "if", "(", "v", "instanceof", "Vec3", ")", "{", "return", "new", "Vec3", "(", "this", ".", "x", "+", "v", ".", "x", ",", "this", ".", "y", "+", "v", ".", "y", ",", "this", ".", "z", "+", "v", ".", "z", ")", ";", "}", "else", "if", "(", "v", "instanceof", "Vec2", ")", "{", "return", "new", "Vec3", "(", "this", ".", "x", "+", "v", ".", "x", ",", "this", ".", "y", "+", "v", ".", "y", ",", "this", ".", "z", ")", ";", "}", "else", "if", "(", "typeof", "v", "===", "'number'", ")", "{", "return", "new", "Vec3", "(", "this", ".", "x", "+", "v", ",", "this", ".", "y", "+", "v", ",", "this", ".", "z", "+", "v", ")", ";", "}", "else", "{", "throw", "new", "TypeError", "(", "'Invalid argument'", ",", "v", ")", ";", "}", "}" ]
Adds the vector to a vector or Number and returns a new vector. @memberof Vec3# @param {Vec3|Vec2|Number} v vector or Number to add. @returns {Vec3} resulting vector
[ "Adds", "the", "vector", "to", "a", "vector", "or", "Number", "and", "returns", "a", "new", "vector", "." ]
e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364
https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L38-L51
49,695
nanowizard/vec23
src/Vec3.js
function() { return { theta: Math.atan2(this.z, this.x), phi: Math.asin(this.y / this.length()) }; }
javascript
function() { return { theta: Math.atan2(this.z, this.x), phi: Math.asin(this.y / this.length()) }; }
[ "function", "(", ")", "{", "return", "{", "theta", ":", "Math", ".", "atan2", "(", "this", ".", "z", ",", "this", ".", "x", ")", ",", "phi", ":", "Math", ".", "asin", "(", "this", ".", "y", "/", "this", ".", "length", "(", ")", ")", "}", ";", "}" ]
Computes the theta & phi angles of the vector. @memberof Vec3# @returns {object} ret @returns {Number} ret.theta - angle from the xz plane @returns {Number} ret.phi - angle from the y axis
[ "Computes", "the", "theta", "&", "phi", "angles", "of", "the", "vector", "." ]
e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364
https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L359-L364
49,696
nanowizard/vec23
src/Vec3.js
function(dec) { if(!dec){ dec = 2; } return '{x: ' + this.x.toFixed(dec) + ', y: ' + this.y.toFixed(dec) + ', z: ' + this.z.toFixed(dec) + '}'; }
javascript
function(dec) { if(!dec){ dec = 2; } return '{x: ' + this.x.toFixed(dec) + ', y: ' + this.y.toFixed(dec) + ', z: ' + this.z.toFixed(dec) + '}'; }
[ "function", "(", "dec", ")", "{", "if", "(", "!", "dec", ")", "{", "dec", "=", "2", ";", "}", "return", "'{x: '", "+", "this", ".", "x", ".", "toFixed", "(", "dec", ")", "+", "', y: '", "+", "this", ".", "y", ".", "toFixed", "(", "dec", ")", "+", "', z: '", "+", "this", ".", "z", ".", "toFixed", "(", "dec", ")", "+", "'}'", ";", "}" ]
Converts the vector to a string representation. @memberof Vec3# @param {Number} [dec=2] - number of decimal places to round to (default is 2) @returns {string} string of the form {x: <x value>, y: <y value>, z: <z value>}
[ "Converts", "the", "vector", "to", "a", "string", "representation", "." ]
e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364
https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L399-L404
49,697
nanowizard/vec23
src/Vec3.js
function() { return new Vec3(Math.round(this.x), Math.round(this.y), Math.round(this.z)); }
javascript
function() { return new Vec3(Math.round(this.x), Math.round(this.y), Math.round(this.z)); }
[ "function", "(", ")", "{", "return", "new", "Vec3", "(", "Math", ".", "round", "(", "this", ".", "x", ")", ",", "Math", ".", "round", "(", "this", ".", "y", ")", ",", "Math", ".", "round", "(", "this", ".", "z", ")", ")", ";", "}" ]
Creates a new vector with each of the current x, y and z components rounded to the nearest whole Number. @memberof Vec3# @returns {Vec3}
[ "Creates", "a", "new", "vector", "with", "each", "of", "the", "current", "x", "y", "and", "z", "components", "rounded", "to", "the", "nearest", "whole", "Number", "." ]
e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364
https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L418-L420
49,698
nanowizard/vec23
src/Vec3.js
function(m){ return new Vec3( this.x*m[0][0]+this.y*m[0][1]+this.z*m[0][2], this.x*m[1][0]+this.y*m[1][1]+this.z*m[1][2], this.x*m[2][0]+this.y*m[2][1]+this.z*m[2][2] ); }
javascript
function(m){ return new Vec3( this.x*m[0][0]+this.y*m[0][1]+this.z*m[0][2], this.x*m[1][0]+this.y*m[1][1]+this.z*m[1][2], this.x*m[2][0]+this.y*m[2][1]+this.z*m[2][2] ); }
[ "function", "(", "m", ")", "{", "return", "new", "Vec3", "(", "this", ".", "x", "*", "m", "[", "0", "]", "[", "0", "]", "+", "this", ".", "y", "*", "m", "[", "0", "]", "[", "1", "]", "+", "this", ".", "z", "*", "m", "[", "0", "]", "[", "2", "]", ",", "this", ".", "x", "*", "m", "[", "1", "]", "[", "0", "]", "+", "this", ".", "y", "*", "m", "[", "1", "]", "[", "1", "]", "+", "this", ".", "z", "*", "m", "[", "1", "]", "[", "2", "]", ",", "this", ".", "x", "*", "m", "[", "2", "]", "[", "0", "]", "+", "this", ".", "y", "*", "m", "[", "2", "]", "[", "1", "]", "+", "this", ".", "z", "*", "m", "[", "2", "]", "[", "2", "]", ")", ";", "}" ]
Creates a new vector converting the vector to a new coordinate frame. @memberof Vec3# @param {Array} m - Coordinate system matrix of the form [[xx,xy,xz],[yx,yy,yz],[zx,zy,zz]] @returns {Vec3}
[ "Creates", "a", "new", "vector", "converting", "the", "vector", "to", "a", "new", "coordinate", "frame", "." ]
e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364
https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L454-L460
49,699
nanowizard/vec23
src/Vec3.js
function(m){ var x = this.x; var y = this.y; var z = this.z; this.x = x*m[0][0]+y*m[0][1]+z*m[0][2]; this.y = x*m[1][0]+y*m[1][1]+z*m[1][2]; this.z = x*m[2][0]+y*m[2][1]+z*m[2][2]; return this; }
javascript
function(m){ var x = this.x; var y = this.y; var z = this.z; this.x = x*m[0][0]+y*m[0][1]+z*m[0][2]; this.y = x*m[1][0]+y*m[1][1]+z*m[1][2]; this.z = x*m[2][0]+y*m[2][1]+z*m[2][2]; return this; }
[ "function", "(", "m", ")", "{", "var", "x", "=", "this", ".", "x", ";", "var", "y", "=", "this", ".", "y", ";", "var", "z", "=", "this", ".", "z", ";", "this", ".", "x", "=", "x", "*", "m", "[", "0", "]", "[", "0", "]", "+", "y", "*", "m", "[", "0", "]", "[", "1", "]", "+", "z", "*", "m", "[", "0", "]", "[", "2", "]", ";", "this", ".", "y", "=", "x", "*", "m", "[", "1", "]", "[", "0", "]", "+", "y", "*", "m", "[", "1", "]", "[", "1", "]", "+", "z", "*", "m", "[", "1", "]", "[", "2", "]", ";", "this", ".", "z", "=", "x", "*", "m", "[", "2", "]", "[", "0", "]", "+", "y", "*", "m", "[", "2", "]", "[", "1", "]", "+", "z", "*", "m", "[", "2", "]", "[", "2", "]", ";", "return", "this", ";", "}" ]
Converts this vector to a new coordinate frame. @memberof Vec3# @param {Array} m - Coordinate system matrix of the form [[Xx,Xy,Xz],[Yx,Yy,Yz],[Zx,Zy,Zz]] @returns {Vec3}
[ "Converts", "this", "vector", "to", "a", "new", "coordinate", "frame", "." ]
e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364
https://github.com/nanowizard/vec23/blob/e9ac7698d7cf96aeabd3d67cb48b8b1e5b6e8364/src/Vec3.js#L467-L475