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
45,100
evsheffield/node-donedone-api
lib/donedone-api.js
function(releaseBuildInfo, cb) { orderNumbers = releaseBuildInfo.order_numbers_ready_for_next_release.join(','); // Trigger an error when there are no issues that are ready to release if('' === orderNumbers) { cb('Cannot create release build, there are no issues marked as "Ready for Next Release".'); } else { exports.getPeopleInProject(subdomain, username, passwordOrAPIToken, id, function(err, respData) { cb(err, respData); }); } }
javascript
function(releaseBuildInfo, cb) { orderNumbers = releaseBuildInfo.order_numbers_ready_for_next_release.join(','); // Trigger an error when there are no issues that are ready to release if('' === orderNumbers) { cb('Cannot create release build, there are no issues marked as "Ready for Next Release".'); } else { exports.getPeopleInProject(subdomain, username, passwordOrAPIToken, id, function(err, respData) { cb(err, respData); }); } }
[ "function", "(", "releaseBuildInfo", ",", "cb", ")", "{", "orderNumbers", "=", "releaseBuildInfo", ".", "order_numbers_ready_for_next_release", ".", "join", "(", "','", ")", ";", "// Trigger an error when there are no issues that are ready to release", "if", "(", "''", "===", "orderNumbers", ")", "{", "cb", "(", "'Cannot create release build, there are no issues marked as \"Ready for Next Release\".'", ")", ";", "}", "else", "{", "exports", ".", "getPeopleInProject", "(", "subdomain", ",", "username", ",", "passwordOrAPIToken", ",", "id", ",", "function", "(", "err", ",", "respData", ")", "{", "cb", "(", "err", ",", "respData", ")", ";", "}", ")", ";", "}", "}" ]
Get people in the project
[ "Get", "people", "in", "the", "project" ]
9b1d8ddb86c4fe654509e9191fc7d666334c4a03
https://github.com/evsheffield/node-donedone-api/blob/9b1d8ddb86c4fe654509e9191fc7d666334c4a03/lib/donedone-api.js#L311-L322
45,101
evsheffield/node-donedone-api
lib/donedone-api.js
function(peopleInProject, cb) { userIdsToCc = _.pluck(peopleInProject, 'id').join(','); exports.getProject(subdomain, username, passwordOrAPIToken, id, function(err, respData) { cb(err, respData); }); }
javascript
function(peopleInProject, cb) { userIdsToCc = _.pluck(peopleInProject, 'id').join(','); exports.getProject(subdomain, username, passwordOrAPIToken, id, function(err, respData) { cb(err, respData); }); }
[ "function", "(", "peopleInProject", ",", "cb", ")", "{", "userIdsToCc", "=", "_", ".", "pluck", "(", "peopleInProject", ",", "'id'", ")", ".", "join", "(", "','", ")", ";", "exports", ".", "getProject", "(", "subdomain", ",", "username", ",", "passwordOrAPIToken", ",", "id", ",", "function", "(", "err", ",", "respData", ")", "{", "cb", "(", "err", ",", "respData", ")", ";", "}", ")", ";", "}" ]
Get project information so we can include the project title in the email body.
[ "Get", "project", "information", "so", "we", "can", "include", "the", "project", "title", "in", "the", "email", "body", "." ]
9b1d8ddb86c4fe654509e9191fc7d666334c4a03
https://github.com/evsheffield/node-donedone-api/blob/9b1d8ddb86c4fe654509e9191fc7d666334c4a03/lib/donedone-api.js#L324-L329
45,102
evsheffield/node-donedone-api
lib/donedone-api.js
function(projectInfo, cb) { projectTitle = projectInfo.title; if(projectTitle) { emailBody = emailBody.replace('{{Project Name}}', projectTitle); } exports.createReleaseBuildForProject(subdomain, username, passwordOrAPIToken, id, orderNumbers, title, description, emailBody, userIdsToCc, function(err, respData) { cb(err, respData); }); }
javascript
function(projectInfo, cb) { projectTitle = projectInfo.title; if(projectTitle) { emailBody = emailBody.replace('{{Project Name}}', projectTitle); } exports.createReleaseBuildForProject(subdomain, username, passwordOrAPIToken, id, orderNumbers, title, description, emailBody, userIdsToCc, function(err, respData) { cb(err, respData); }); }
[ "function", "(", "projectInfo", ",", "cb", ")", "{", "projectTitle", "=", "projectInfo", ".", "title", ";", "if", "(", "projectTitle", ")", "{", "emailBody", "=", "emailBody", ".", "replace", "(", "'{{Project Name}}'", ",", "projectTitle", ")", ";", "}", "exports", ".", "createReleaseBuildForProject", "(", "subdomain", ",", "username", ",", "passwordOrAPIToken", ",", "id", ",", "orderNumbers", ",", "title", ",", "description", ",", "emailBody", ",", "userIdsToCc", ",", "function", "(", "err", ",", "respData", ")", "{", "cb", "(", "err", ",", "respData", ")", ";", "}", ")", ";", "}" ]
Create a release build for the retrieved items, sent to the indicated people
[ "Create", "a", "release", "build", "for", "the", "retrieved", "items", "sent", "to", "the", "indicated", "people" ]
9b1d8ddb86c4fe654509e9191fc7d666334c4a03
https://github.com/evsheffield/node-donedone-api/blob/9b1d8ddb86c4fe654509e9191fc7d666334c4a03/lib/donedone-api.js#L331-L339
45,103
emmetio/math-expression
lib/parser.js
op1
function op1(value, priority) { if (value === MINUS) { priority += 2; } return new Token(OP1, value, priority); }
javascript
function op1(value, priority) { if (value === MINUS) { priority += 2; } return new Token(OP1, value, priority); }
[ "function", "op1", "(", "value", ",", "priority", ")", "{", "if", "(", "value", "===", "MINUS", ")", "{", "priority", "+=", "2", ";", "}", "return", "new", "Token", "(", "OP1", ",", "value", ",", "priority", ")", ";", "}" ]
Unary operator factory @param {Number} value Operator character code @param {Number} priority Operator execution priority @return {Token[]}
[ "Unary", "operator", "factory" ]
31dc028f80c27b5b00be9395e35ebd07c9cd8862
https://github.com/emmetio/math-expression/blob/31dc028f80c27b5b00be9395e35ebd07c9cd8862/lib/parser.js#L285-L290
45,104
emmetio/math-expression
lib/parser.js
op2
function op2(value, priority) { if (value === MULTIPLY) { priority += 1; } else if (value === DIVIDE || value === INT_DIVIDE) { priority += 2; } return new Token(OP2, value, priority); }
javascript
function op2(value, priority) { if (value === MULTIPLY) { priority += 1; } else if (value === DIVIDE || value === INT_DIVIDE) { priority += 2; } return new Token(OP2, value, priority); }
[ "function", "op2", "(", "value", ",", "priority", ")", "{", "if", "(", "value", "===", "MULTIPLY", ")", "{", "priority", "+=", "1", ";", "}", "else", "if", "(", "value", "===", "DIVIDE", "||", "value", "===", "INT_DIVIDE", ")", "{", "priority", "+=", "2", ";", "}", "return", "new", "Token", "(", "OP2", ",", "value", ",", "priority", ")", ";", "}" ]
Binary operator factory @param {Number} value Operator character code @param {Number} priority Operator execution priority @return {Token[]}
[ "Binary", "operator", "factory" ]
31dc028f80c27b5b00be9395e35ebd07c9cd8862
https://github.com/emmetio/math-expression/blob/31dc028f80c27b5b00be9395e35ebd07c9cd8862/lib/parser.js#L298-L306
45,105
throneteki/throneteki-deck-helper
lib/formatDeckAsShortCards.js
formatDeckAsShortCards
function formatDeckAsShortCards(deck) { var newDeck = { _id: deck._id, name: deck.name, username: deck.username, lastUpdated: deck.lastUpdated, faction: { name: deck.faction.name, value: deck.faction.value } }; if (deck.agenda) { newDeck.agenda = { code: deck.agenda.code }; } newDeck.bannerCards = (deck.bannerCards || []).map(function (card) { return { code: card.code }; }); newDeck.drawCards = formatCards(deck.drawCards || []); newDeck.plotCards = formatCards(deck.plotCards || []); newDeck.rookeryCards = formatCards(deck.rookeryCards || []); return newDeck; }
javascript
function formatDeckAsShortCards(deck) { var newDeck = { _id: deck._id, name: deck.name, username: deck.username, lastUpdated: deck.lastUpdated, faction: { name: deck.faction.name, value: deck.faction.value } }; if (deck.agenda) { newDeck.agenda = { code: deck.agenda.code }; } newDeck.bannerCards = (deck.bannerCards || []).map(function (card) { return { code: card.code }; }); newDeck.drawCards = formatCards(deck.drawCards || []); newDeck.plotCards = formatCards(deck.plotCards || []); newDeck.rookeryCards = formatCards(deck.rookeryCards || []); return newDeck; }
[ "function", "formatDeckAsShortCards", "(", "deck", ")", "{", "var", "newDeck", "=", "{", "_id", ":", "deck", ".", "_id", ",", "name", ":", "deck", ".", "name", ",", "username", ":", "deck", ".", "username", ",", "lastUpdated", ":", "deck", ".", "lastUpdated", ",", "faction", ":", "{", "name", ":", "deck", ".", "faction", ".", "name", ",", "value", ":", "deck", ".", "faction", ".", "value", "}", "}", ";", "if", "(", "deck", ".", "agenda", ")", "{", "newDeck", ".", "agenda", "=", "{", "code", ":", "deck", ".", "agenda", ".", "code", "}", ";", "}", "newDeck", ".", "bannerCards", "=", "(", "deck", ".", "bannerCards", "||", "[", "]", ")", ".", "map", "(", "function", "(", "card", ")", "{", "return", "{", "code", ":", "card", ".", "code", "}", ";", "}", ")", ";", "newDeck", ".", "drawCards", "=", "formatCards", "(", "deck", ".", "drawCards", "||", "[", "]", ")", ";", "newDeck", ".", "plotCards", "=", "formatCards", "(", "deck", ".", "plotCards", "||", "[", "]", ")", ";", "newDeck", ".", "rookeryCards", "=", "formatCards", "(", "deck", ".", "rookeryCards", "||", "[", "]", ")", ";", "return", "newDeck", ";", "}" ]
Creates a clone of the existing deck with only card codes instead of full card data.
[ "Creates", "a", "clone", "of", "the", "existing", "deck", "with", "only", "card", "codes", "instead", "of", "full", "card", "data", "." ]
700280f5747b99d626c8ea6033064bd01f93da60
https://github.com/throneteki/throneteki-deck-helper/blob/700280f5747b99d626c8ea6033064bd01f93da60/lib/formatDeckAsShortCards.js#L7-L28
45,106
goliatone/core.io-express-server
lib/middleware/poweredBy.js
poweredBy
function poweredBy(app, config) { config = extend({}, defaults, config); if(config.disablePoweredBy) { return app.disable('x-powered-by'); } if(config.poweredBy === false) { return; } app.use(function xPoweredBy(req, res, next) { res.header('x-powered-by', config.poweredBy); next(); }); }
javascript
function poweredBy(app, config) { config = extend({}, defaults, config); if(config.disablePoweredBy) { return app.disable('x-powered-by'); } if(config.poweredBy === false) { return; } app.use(function xPoweredBy(req, res, next) { res.header('x-powered-by', config.poweredBy); next(); }); }
[ "function", "poweredBy", "(", "app", ",", "config", ")", "{", "config", "=", "extend", "(", "{", "}", ",", "defaults", ",", "config", ")", ";", "if", "(", "config", ".", "disablePoweredBy", ")", "{", "return", "app", ".", "disable", "(", "'x-powered-by'", ")", ";", "}", "if", "(", "config", ".", "poweredBy", "===", "false", ")", "{", "return", ";", "}", "app", ".", "use", "(", "function", "xPoweredBy", "(", "req", ",", "res", ",", "next", ")", "{", "res", ".", "header", "(", "'x-powered-by'", ",", "config", ".", "poweredBy", ")", ";", "next", "(", ")", ";", "}", ")", ";", "}" ]
The configuration object will be the module's configuration object. We probably want to create an entry for this specific middleware... @param {Express} app Express application @param {Object} config Configuration object
[ "The", "configuration", "object", "will", "be", "the", "module", "s", "configuration", "object", ".", "We", "probably", "want", "to", "create", "an", "entry", "for", "this", "specific", "middleware", "..." ]
920225b923eaf1f142cd0ee1db78a208f8ecdbe2
https://github.com/goliatone/core.io-express-server/blob/920225b923eaf1f142cd0ee1db78a208f8ecdbe2/lib/middleware/poweredBy.js#L17-L33
45,107
mesmotronic/conbo
lib/conbo.js
function(namespace) { if (!namespace || !conbo.isString(namespace)) { conbo.warn('First parameter must be the namespace string, received', namespace); return; } if (!__namespaces[namespace]) { __namespaces[namespace] = new conbo.Namespace(); } var ns = __namespaces[namespace], params = conbo.rest(arguments), func = params.pop() ; if (conbo.isFunction(func)) { var obj = func.apply(ns, params); if (conbo.isObject(obj) && !conbo.isArray(obj)) { ns.import(obj); } } return ns; }
javascript
function(namespace) { if (!namespace || !conbo.isString(namespace)) { conbo.warn('First parameter must be the namespace string, received', namespace); return; } if (!__namespaces[namespace]) { __namespaces[namespace] = new conbo.Namespace(); } var ns = __namespaces[namespace], params = conbo.rest(arguments), func = params.pop() ; if (conbo.isFunction(func)) { var obj = func.apply(ns, params); if (conbo.isObject(obj) && !conbo.isArray(obj)) { ns.import(obj); } } return ns; }
[ "function", "(", "namespace", ")", "{", "if", "(", "!", "namespace", "||", "!", "conbo", ".", "isString", "(", "namespace", ")", ")", "{", "conbo", ".", "warn", "(", "'First parameter must be the namespace string, received'", ",", "namespace", ")", ";", "return", ";", "}", "if", "(", "!", "__namespaces", "[", "namespace", "]", ")", "{", "__namespaces", "[", "namespace", "]", "=", "new", "conbo", ".", "Namespace", "(", ")", ";", "}", "var", "ns", "=", "__namespaces", "[", "namespace", "]", ",", "params", "=", "conbo", ".", "rest", "(", "arguments", ")", ",", "func", "=", "params", ".", "pop", "(", ")", ";", "if", "(", "conbo", ".", "isFunction", "(", "func", ")", ")", "{", "var", "obj", "=", "func", ".", "apply", "(", "ns", ",", "params", ")", ";", "if", "(", "conbo", ".", "isObject", "(", "obj", ")", "&&", "!", "conbo", ".", "isArray", "(", "obj", ")", ")", "{", "ns", ".", "import", "(", "obj", ")", ";", "}", "}", "return", "ns", ";", "}" ]
ConboJS is a lightweight MVx application framework for JavaScript featuring dependency injection, context and encapsulation, data binding, command pattern and an event model which enables callback scoping and consistent event handling All ConboJS classes, methods and properties live within the conbo namespace @namespace conbo Create or access a ConboJS namespace @variation 2 @function conbo @param {string} namespace - The selected namespace @param {...*} [globals] - Globals to minify followed by function to execute, with each of the globals as parameters @returns {conbo.Namespace} @example // Conbo can replace the standard minification pattern with modular namespace definitions // If an Object is returned, its contents will be added to the namespace conbo('com.example.namespace', window, document, conbo, function(window, document, conbo, undefined) { // The executed function is scoped to the namespace var ns = this; // ... Your code here ... // Optionally, return an Object containing values to be added to the namespace return { MyApp, MyView }; }); @example // Retrieve a namespace and import classes defined elsewhere var ns = conbo('com.example.namespace'); ns.import({ MyApp, MyView });
[ "ConboJS", "is", "a", "lightweight", "MVx", "application", "framework", "for", "JavaScript", "featuring", "dependency", "injection", "context", "and", "encapsulation", "data", "binding", "command", "pattern", "and", "an", "event", "model", "which", "enables", "callback", "scoping", "and", "consistent", "event", "handling" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L84-L113
45,108
mesmotronic/conbo
lib/conbo.js
function(obj, propName, value) { if (conbo.isAccessor(obj, propName)) return; if (arguments.length < 3) value = obj[propName]; var enumerable = propName.indexOf('_') != 0; var internalName = '__'+propName; __definePrivateProperty(obj, internalName, value); var getter = function() { return this[internalName]; }; var setter = function(newValue) { if (!conbo.isEqual(newValue, this[internalName])) { this[internalName] = newValue; __dispatchChange(this, propName); } }; Object.defineProperty(obj, propName, {enumerable:enumerable, configurable:true, get:getter, set:setter}); }
javascript
function(obj, propName, value) { if (conbo.isAccessor(obj, propName)) return; if (arguments.length < 3) value = obj[propName]; var enumerable = propName.indexOf('_') != 0; var internalName = '__'+propName; __definePrivateProperty(obj, internalName, value); var getter = function() { return this[internalName]; }; var setter = function(newValue) { if (!conbo.isEqual(newValue, this[internalName])) { this[internalName] = newValue; __dispatchChange(this, propName); } }; Object.defineProperty(obj, propName, {enumerable:enumerable, configurable:true, get:getter, set:setter}); }
[ "function", "(", "obj", ",", "propName", ",", "value", ")", "{", "if", "(", "conbo", ".", "isAccessor", "(", "obj", ",", "propName", ")", ")", "return", ";", "if", "(", "arguments", ".", "length", "<", "3", ")", "value", "=", "obj", "[", "propName", "]", ";", "var", "enumerable", "=", "propName", ".", "indexOf", "(", "'_'", ")", "!=", "0", ";", "var", "internalName", "=", "'__'", "+", "propName", ";", "__definePrivateProperty", "(", "obj", ",", "internalName", ",", "value", ")", ";", "var", "getter", "=", "function", "(", ")", "{", "return", "this", "[", "internalName", "]", ";", "}", ";", "var", "setter", "=", "function", "(", "newValue", ")", "{", "if", "(", "!", "conbo", ".", "isEqual", "(", "newValue", ",", "this", "[", "internalName", "]", ")", ")", "{", "this", "[", "internalName", "]", "=", "newValue", ";", "__dispatchChange", "(", "this", ",", "propName", ")", ";", "}", "}", ";", "Object", ".", "defineProperty", "(", "obj", ",", "propName", ",", "{", "enumerable", ":", "enumerable", ",", "configurable", ":", "true", ",", "get", ":", "getter", ",", "set", ":", "setter", "}", ")", ";", "}" ]
Creates a property which can be bound to DOM elements and others @param {Object} obj - The EventDispatcher object on which the property will be defined @param {string} propName - The name of the property to be defined @param {*} [value] - The initial value of the property (optional) @private
[ "Creates", "a", "property", "which", "can", "be", "bound", "to", "DOM", "elements", "and", "others" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L365-L390
45,109
mesmotronic/conbo
lib/conbo.js
function(obj) { var regExp = arguments[1]; var keys = regExp instanceof RegExp ? conbo.filter(conbo.keys(obj), function(key) { return regExp.test(key); }) : (arguments.length > 1 ? conbo.rest(arguments) : conbo.keys(obj)); keys.forEach(function(key) { var descriptor = Object.getOwnPropertyDescriptor(obj, key) || {value:obj[key], configurable:true, writable:true}; descriptor.enumerable = false; Object.defineProperty(obj, key, descriptor); }); }
javascript
function(obj) { var regExp = arguments[1]; var keys = regExp instanceof RegExp ? conbo.filter(conbo.keys(obj), function(key) { return regExp.test(key); }) : (arguments.length > 1 ? conbo.rest(arguments) : conbo.keys(obj)); keys.forEach(function(key) { var descriptor = Object.getOwnPropertyDescriptor(obj, key) || {value:obj[key], configurable:true, writable:true}; descriptor.enumerable = false; Object.defineProperty(obj, key, descriptor); }); }
[ "function", "(", "obj", ")", "{", "var", "regExp", "=", "arguments", "[", "1", "]", ";", "var", "keys", "=", "regExp", "instanceof", "RegExp", "?", "conbo", ".", "filter", "(", "conbo", ".", "keys", "(", "obj", ")", ",", "function", "(", "key", ")", "{", "return", "regExp", ".", "test", "(", "key", ")", ";", "}", ")", ":", "(", "arguments", ".", "length", ">", "1", "?", "conbo", ".", "rest", "(", "arguments", ")", ":", "conbo", ".", "keys", "(", "obj", ")", ")", ";", "keys", ".", "forEach", "(", "function", "(", "key", ")", "{", "var", "descriptor", "=", "Object", ".", "getOwnPropertyDescriptor", "(", "obj", ",", "key", ")", "||", "{", "value", ":", "obj", "[", "key", "]", ",", "configurable", ":", "true", ",", "writable", ":", "true", "}", ";", "descriptor", ".", "enumerable", "=", "false", ";", "Object", ".", "defineProperty", "(", "obj", ",", "key", ",", "descriptor", ")", ";", "}", ")", ";", "}" ]
Convert enumerable properties of the specified object into non-enumerable ones @private
[ "Convert", "enumerable", "properties", "of", "the", "specified", "object", "into", "non", "-", "enumerable", "ones" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L424-L440
45,110
mesmotronic/conbo
lib/conbo.js
function(value) { if (value == undefined) return conbo.identity; if (conbo.isFunction(value)) return value; return conbo.property(value); }
javascript
function(value) { if (value == undefined) return conbo.identity; if (conbo.isFunction(value)) return value; return conbo.property(value); }
[ "function", "(", "value", ")", "{", "if", "(", "value", "==", "undefined", ")", "return", "conbo", ".", "identity", ";", "if", "(", "conbo", ".", "isFunction", "(", "value", ")", ")", "return", "value", ";", "return", "conbo", ".", "property", "(", "value", ")", ";", "}" ]
An internal function to generate lookup iterators. @private
[ "An", "internal", "function", "to", "generate", "lookup", "iterators", "." ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L847-L852
45,111
mesmotronic/conbo
lib/conbo.js
function(type, handler, scope) { if (!this.__queue || !(type in this.__queue) || !this.__queue[type].length) { return false; } var filtered = this.__queue[type].filter(function(queued) { return (!handler || queued.handler == handler) && (!scope || queued.scope == scope); }); return !!filtered.length; }
javascript
function(type, handler, scope) { if (!this.__queue || !(type in this.__queue) || !this.__queue[type].length) { return false; } var filtered = this.__queue[type].filter(function(queued) { return (!handler || queued.handler == handler) && (!scope || queued.scope == scope); }); return !!filtered.length; }
[ "function", "(", "type", ",", "handler", ",", "scope", ")", "{", "if", "(", "!", "this", ".", "__queue", "||", "!", "(", "type", "in", "this", ".", "__queue", ")", "||", "!", "this", ".", "__queue", "[", "type", "]", ".", "length", ")", "{", "return", "false", ";", "}", "var", "filtered", "=", "this", ".", "__queue", "[", "type", "]", ".", "filter", "(", "function", "(", "queued", ")", "{", "return", "(", "!", "handler", "||", "queued", ".", "handler", "==", "handler", ")", "&&", "(", "!", "scope", "||", "queued", ".", "scope", "==", "scope", ")", ";", "}", ")", ";", "return", "!", "!", "filtered", ".", "length", ";", "}" ]
Does this object have an event listener of the specified type? @param {string} type - Type of event (e.g. 'change') @param {Function} [handler] - Function that should be called @param {Object} [scope] - The scope in which the handler is set to run @returns {boolean} True if this object has the specified event listener, false if it does not
[ "Does", "this", "object", "have", "an", "event", "listener", "of", "the", "specified", "type?" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L3994-L4007
45,112
mesmotronic/conbo
lib/conbo.js
function(event) { if (!(event instanceof conbo.Event)) { throw new Error('event parameter is not an instance of conbo.Event'); } if (!this.__queue || (!(event.type in this.__queue) && !this.__queue.all)) return this; if (!event.target) event.target = this; event.currentTarget = this; var queue = conbo.union(this.__queue[event.type] || [], this.__queue.all || []); if (!queue || !queue.length) return this; for (var i=0, length=queue.length; i<length; ++i) { var value = queue[i]; var returnValue = value.handler.call(value.scope || this, event); if (value.once) EventDispatcher__removeEventListener.call(this, event.type, value.handler, value.scope); if (event.immediatePropagationStopped) break; } return this; }
javascript
function(event) { if (!(event instanceof conbo.Event)) { throw new Error('event parameter is not an instance of conbo.Event'); } if (!this.__queue || (!(event.type in this.__queue) && !this.__queue.all)) return this; if (!event.target) event.target = this; event.currentTarget = this; var queue = conbo.union(this.__queue[event.type] || [], this.__queue.all || []); if (!queue || !queue.length) return this; for (var i=0, length=queue.length; i<length; ++i) { var value = queue[i]; var returnValue = value.handler.call(value.scope || this, event); if (value.once) EventDispatcher__removeEventListener.call(this, event.type, value.handler, value.scope); if (event.immediatePropagationStopped) break; } return this; }
[ "function", "(", "event", ")", "{", "if", "(", "!", "(", "event", "instanceof", "conbo", ".", "Event", ")", ")", "{", "throw", "new", "Error", "(", "'event parameter is not an instance of conbo.Event'", ")", ";", "}", "if", "(", "!", "this", ".", "__queue", "||", "(", "!", "(", "event", ".", "type", "in", "this", ".", "__queue", ")", "&&", "!", "this", ".", "__queue", ".", "all", ")", ")", "return", "this", ";", "if", "(", "!", "event", ".", "target", ")", "event", ".", "target", "=", "this", ";", "event", ".", "currentTarget", "=", "this", ";", "var", "queue", "=", "conbo", ".", "union", "(", "this", ".", "__queue", "[", "event", ".", "type", "]", "||", "[", "]", ",", "this", ".", "__queue", ".", "all", "||", "[", "]", ")", ";", "if", "(", "!", "queue", "||", "!", "queue", ".", "length", ")", "return", "this", ";", "for", "(", "var", "i", "=", "0", ",", "length", "=", "queue", ".", "length", ";", "i", "<", "length", ";", "++", "i", ")", "{", "var", "value", "=", "queue", "[", "i", "]", ";", "var", "returnValue", "=", "value", ".", "handler", ".", "call", "(", "value", ".", "scope", "||", "this", ",", "event", ")", ";", "if", "(", "value", ".", "once", ")", "EventDispatcher__removeEventListener", ".", "call", "(", "this", ",", "event", ".", "type", ",", "value", ".", "handler", ",", "value", ".", "scope", ")", ";", "if", "(", "event", ".", "immediatePropagationStopped", ")", "break", ";", "}", "return", "this", ";", "}" ]
Dispatch the event to listeners @param {conbo.Event} event - The event to dispatch @returns {conbo.EventDispatcher} A reference to this class instance
[ "Dispatch", "the", "event", "to", "listeners" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4014-L4038
45,113
mesmotronic/conbo
lib/conbo.js
function(contextClass, cloneSingletons, cloneCommands) { contextClass || (contextClass = conbo.Context); return new contextClass ({ context: this, app: this.app, namespace: this.namespace, commands: cloneCommands ? conbo.clone(this.__commands) : undefined, singletons: cloneSingletons ? conbo.clone(this.__singletons) : undefined }); }
javascript
function(contextClass, cloneSingletons, cloneCommands) { contextClass || (contextClass = conbo.Context); return new contextClass ({ context: this, app: this.app, namespace: this.namespace, commands: cloneCommands ? conbo.clone(this.__commands) : undefined, singletons: cloneSingletons ? conbo.clone(this.__singletons) : undefined }); }
[ "function", "(", "contextClass", ",", "cloneSingletons", ",", "cloneCommands", ")", "{", "contextClass", "||", "(", "contextClass", "=", "conbo", ".", "Context", ")", ";", "return", "new", "contextClass", "(", "{", "context", ":", "this", ",", "app", ":", "this", ".", "app", ",", "namespace", ":", "this", ".", "namespace", ",", "commands", ":", "cloneCommands", "?", "conbo", ".", "clone", "(", "this", ".", "__commands", ")", ":", "undefined", ",", "singletons", ":", "cloneSingletons", "?", "conbo", ".", "clone", "(", "this", ".", "__singletons", ")", ":", "undefined", "}", ")", ";", "}" ]
Create a new subcontext that shares the same application and namespace as this one @param {class} [contextClass] - The context class to use (default: conbo.Context) @param {boolean} [cloneSingletons] - Should this Context's singletons be duplicated on the new subcontext? (default: false) @param {boolean} [cloneCommands] - Should this Context's commands be duplicated on the new subcontext? (default: false) @returns {conbo.Context}
[ "Create", "a", "new", "subcontext", "that", "shares", "the", "same", "application", "and", "namespace", "as", "this", "one" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4288-L4299
45,114
mesmotronic/conbo
lib/conbo.js
function(eventType, commandClass) { if (!eventType) throw new Error('eventType cannot be undefined'); if (!commandClass) throw new Error('commandClass for '+eventType+' cannot be undefined'); if (this.__commands[eventType] && this.__commands[eventType].indexOf(commandClass) != -1) { return this; } this.__commands[eventType] = this.__commands[eventType] || []; this.__commands[eventType].push(commandClass); return this; }
javascript
function(eventType, commandClass) { if (!eventType) throw new Error('eventType cannot be undefined'); if (!commandClass) throw new Error('commandClass for '+eventType+' cannot be undefined'); if (this.__commands[eventType] && this.__commands[eventType].indexOf(commandClass) != -1) { return this; } this.__commands[eventType] = this.__commands[eventType] || []; this.__commands[eventType].push(commandClass); return this; }
[ "function", "(", "eventType", ",", "commandClass", ")", "{", "if", "(", "!", "eventType", ")", "throw", "new", "Error", "(", "'eventType cannot be undefined'", ")", ";", "if", "(", "!", "commandClass", ")", "throw", "new", "Error", "(", "'commandClass for '", "+", "eventType", "+", "' cannot be undefined'", ")", ";", "if", "(", "this", ".", "__commands", "[", "eventType", "]", "&&", "this", ".", "__commands", "[", "eventType", "]", ".", "indexOf", "(", "commandClass", ")", "!=", "-", "1", ")", "{", "return", "this", ";", "}", "this", ".", "__commands", "[", "eventType", "]", "=", "this", ".", "__commands", "[", "eventType", "]", "||", "[", "]", ";", "this", ".", "__commands", "[", "eventType", "]", ".", "push", "(", "commandClass", ")", ";", "return", "this", ";", "}" ]
Map specified Command class the given event @param {string} eventType - The name of the event @param {class} commandClass - The command class to instantiate when the event is dispatched
[ "Map", "specified", "Command", "class", "the", "given", "event" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4306-L4320
45,115
mesmotronic/conbo
lib/conbo.js
function(eventType, commandClass) { if (!eventType) throw new Error('eventType cannot be undefined'); if (commandClass === undefined) { delete this.__commands[eventType]; return this; } if (!this.__commands[eventType]) return; var index = this.__commands[eventType].indexOf(commandClass); if (index == -1) return; this.__commands[eventType].splice(index, 1); return this; }
javascript
function(eventType, commandClass) { if (!eventType) throw new Error('eventType cannot be undefined'); if (commandClass === undefined) { delete this.__commands[eventType]; return this; } if (!this.__commands[eventType]) return; var index = this.__commands[eventType].indexOf(commandClass); if (index == -1) return; this.__commands[eventType].splice(index, 1); return this; }
[ "function", "(", "eventType", ",", "commandClass", ")", "{", "if", "(", "!", "eventType", ")", "throw", "new", "Error", "(", "'eventType cannot be undefined'", ")", ";", "if", "(", "commandClass", "===", "undefined", ")", "{", "delete", "this", ".", "__commands", "[", "eventType", "]", ";", "return", "this", ";", "}", "if", "(", "!", "this", ".", "__commands", "[", "eventType", "]", ")", "return", ";", "var", "index", "=", "this", ".", "__commands", "[", "eventType", "]", ".", "indexOf", "(", "commandClass", ")", ";", "if", "(", "index", "==", "-", "1", ")", "return", ";", "this", ".", "__commands", "[", "eventType", "]", ".", "splice", "(", "index", ",", "1", ")", ";", "return", "this", ";", "}" ]
Unmap specified Command class from given event
[ "Unmap", "specified", "Command", "class", "from", "given", "event" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4325-L4341
45,116
mesmotronic/conbo
lib/conbo.js
function(propertyName, singletonClass) { if (!propertyName) throw new Error('propertyName cannot be undefined'); if (singletonClass === undefined) { conbo.warn('singletonClass for '+propertyName+' is undefined'); } if (conbo.isClass(singletonClass)) { var args = conbo.rest(arguments); if (args.length == 1 && singletonClass.prototype instanceof conbo.ConboClass) { args.push(this); } this.__singletons[propertyName] = new (Function.prototype.bind.apply(singletonClass, args)) } else { this.__singletons[propertyName] = singletonClass; } return this; }
javascript
function(propertyName, singletonClass) { if (!propertyName) throw new Error('propertyName cannot be undefined'); if (singletonClass === undefined) { conbo.warn('singletonClass for '+propertyName+' is undefined'); } if (conbo.isClass(singletonClass)) { var args = conbo.rest(arguments); if (args.length == 1 && singletonClass.prototype instanceof conbo.ConboClass) { args.push(this); } this.__singletons[propertyName] = new (Function.prototype.bind.apply(singletonClass, args)) } else { this.__singletons[propertyName] = singletonClass; } return this; }
[ "function", "(", "propertyName", ",", "singletonClass", ")", "{", "if", "(", "!", "propertyName", ")", "throw", "new", "Error", "(", "'propertyName cannot be undefined'", ")", ";", "if", "(", "singletonClass", "===", "undefined", ")", "{", "conbo", ".", "warn", "(", "'singletonClass for '", "+", "propertyName", "+", "' is undefined'", ")", ";", "}", "if", "(", "conbo", ".", "isClass", "(", "singletonClass", ")", ")", "{", "var", "args", "=", "conbo", ".", "rest", "(", "arguments", ")", ";", "if", "(", "args", ".", "length", "==", "1", "&&", "singletonClass", ".", "prototype", "instanceof", "conbo", ".", "ConboClass", ")", "{", "args", ".", "push", "(", "this", ")", ";", "}", "this", ".", "__singletons", "[", "propertyName", "]", "=", "new", "(", "Function", ".", "prototype", ".", "bind", ".", "apply", "(", "singletonClass", ",", "args", ")", ")", "}", "else", "{", "this", ".", "__singletons", "[", "propertyName", "]", "=", "singletonClass", ";", "}", "return", "this", ";", "}" ]
Map class instance to a property name To inject a property into a class, register the property name with the Context and declare the value as undefined in your class to enable it to be injected at run time @example context.mapSingleton('myProperty', MyModel); @example myProperty: undefined
[ "Map", "class", "instance", "to", "a", "property", "name" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4353-L4379
45,117
mesmotronic/conbo
lib/conbo.js
function(obj) { var scope = this; for (var a in scope.__singletons) { if (a in obj) { (function(value) { Object.defineProperty(obj, a, { configurable: true, get: function() { return value; } }); })(scope.__singletons[a]); } } return this; }
javascript
function(obj) { var scope = this; for (var a in scope.__singletons) { if (a in obj) { (function(value) { Object.defineProperty(obj, a, { configurable: true, get: function() { return value; } }); })(scope.__singletons[a]); } } return this; }
[ "function", "(", "obj", ")", "{", "var", "scope", "=", "this", ";", "for", "(", "var", "a", "in", "scope", ".", "__singletons", ")", "{", "if", "(", "a", "in", "obj", ")", "{", "(", "function", "(", "value", ")", "{", "Object", ".", "defineProperty", "(", "obj", ",", "a", ",", "{", "configurable", ":", "true", ",", "get", ":", "function", "(", ")", "{", "return", "value", ";", "}", "}", ")", ";", "}", ")", "(", "scope", ".", "__singletons", "[", "a", "]", ")", ";", "}", "}", "return", "this", ";", "}" ]
Inject singleton instances into specified object @param obj {Object} The object to inject singletons into
[ "Inject", "singleton", "instances", "into", "specified", "object" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4431-L4451
45,118
mesmotronic/conbo
lib/conbo.js
function(obj) { for (var a in this.__singletons) { if (a in obj) { Object.defineProperty(obj, a, { configurable: true, value: undefined }); } } return this; }
javascript
function(obj) { for (var a in this.__singletons) { if (a in obj) { Object.defineProperty(obj, a, { configurable: true, value: undefined }); } } return this; }
[ "function", "(", "obj", ")", "{", "for", "(", "var", "a", "in", "this", ".", "__singletons", ")", "{", "if", "(", "a", "in", "obj", ")", "{", "Object", ".", "defineProperty", "(", "obj", ",", "a", ",", "{", "configurable", ":", "true", ",", "value", ":", "undefined", "}", ")", ";", "}", "}", "return", "this", ";", "}" ]
Set all singleton instances on the specified object to undefined @param obj {Object} The object to remove singletons from
[ "Set", "all", "singleton", "instances", "on", "the", "specified", "object", "to", "undefined" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4458-L4473
45,119
mesmotronic/conbo
lib/conbo.js
function() { conbo.assign(this, { __commands: undefined, __singletons: undefined, __app: undefined, __namespace: undefined, __parentContext: undefined }); this.removeEventListener(); return this; }
javascript
function() { conbo.assign(this, { __commands: undefined, __singletons: undefined, __app: undefined, __namespace: undefined, __parentContext: undefined }); this.removeEventListener(); return this; }
[ "function", "(", ")", "{", "conbo", ".", "assign", "(", "this", ",", "{", "__commands", ":", "undefined", ",", "__singletons", ":", "undefined", ",", "__app", ":", "undefined", ",", "__namespace", ":", "undefined", ",", "__parentContext", ":", "undefined", "}", ")", ";", "this", ".", "removeEventListener", "(", ")", ";", "return", "this", ";", "}" ]
Clears all commands and singletons, and removes all listeners
[ "Clears", "all", "commands", "and", "singletons", "and", "removes", "all", "listeners" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4478-L4492
45,120
mesmotronic/conbo
lib/conbo.js
function(item) { var items = conbo.toArray(arguments); if (items.length) { this.source.push.apply(this.source, this.__applyItemClass(items)); this.__updateBindings(items); this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.ADD)); this.dispatchChange('length'); } return this.length; }
javascript
function(item) { var items = conbo.toArray(arguments); if (items.length) { this.source.push.apply(this.source, this.__applyItemClass(items)); this.__updateBindings(items); this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.ADD)); this.dispatchChange('length'); } return this.length; }
[ "function", "(", "item", ")", "{", "var", "items", "=", "conbo", ".", "toArray", "(", "arguments", ")", ";", "if", "(", "items", ".", "length", ")", "{", "this", ".", "source", ".", "push", ".", "apply", "(", "this", ".", "source", ",", "this", ".", "__applyItemClass", "(", "items", ")", ")", ";", "this", ".", "__updateBindings", "(", "items", ")", ";", "this", ".", "dispatchEvent", "(", "new", "conbo", ".", "ConboEvent", "(", "conbo", ".", "ConboEvent", ".", "ADD", ")", ")", ";", "this", ".", "dispatchChange", "(", "'length'", ")", ";", "}", "return", "this", ".", "length", ";", "}" ]
Add an item to the end of the collection.
[ "Add", "an", "item", "to", "the", "end", "of", "the", "collection", "." ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4731-L4744
45,121
mesmotronic/conbo
lib/conbo.js
function() { if (!this.length) return; var item = this.source.pop(); this.__updateBindings(item, false); this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.REMOVE)); this.dispatchChange('length'); return item; }
javascript
function() { if (!this.length) return; var item = this.source.pop(); this.__updateBindings(item, false); this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.REMOVE)); this.dispatchChange('length'); return item; }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "length", ")", "return", ";", "var", "item", "=", "this", ".", "source", ".", "pop", "(", ")", ";", "this", ".", "__updateBindings", "(", "item", ",", "false", ")", ";", "this", ".", "dispatchEvent", "(", "new", "conbo", ".", "ConboEvent", "(", "conbo", ".", "ConboEvent", ".", "REMOVE", ")", ")", ";", "this", ".", "dispatchChange", "(", "'length'", ")", ";", "return", "item", ";", "}" ]
Remove an item from the end of the collection.
[ "Remove", "an", "item", "from", "the", "end", "of", "the", "collection", "." ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4749-L4760
45,122
mesmotronic/conbo
lib/conbo.js
function(begin, length) { begin || (begin = 0); if (conbo.isUndefined(length)) length = this.length; return new conbo.List({source:this.source.slice(begin, length)}); }
javascript
function(begin, length) { begin || (begin = 0); if (conbo.isUndefined(length)) length = this.length; return new conbo.List({source:this.source.slice(begin, length)}); }
[ "function", "(", "begin", ",", "length", ")", "{", "begin", "||", "(", "begin", "=", "0", ")", ";", "if", "(", "conbo", ".", "isUndefined", "(", "length", ")", ")", "length", "=", "this", ".", "length", ";", "return", "new", "conbo", ".", "List", "(", "{", "source", ":", "this", ".", "source", ".", "slice", "(", "begin", ",", "length", ")", "}", ")", ";", "}" ]
Slice out a sub-array of items from the collection.
[ "Slice", "out", "a", "sub", "-", "array", "of", "items", "from", "the", "collection", "." ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4797-L4803
45,123
mesmotronic/conbo
lib/conbo.js
function(begin, length) { begin || (begin = 0); if (conbo.isUndefined(length)) length = this.length; var inserts = conbo.rest(arguments,2); var items = this.source.splice.apply(this.source, [begin, length].concat(inserts)); if (items.length) this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.REMOVE)); if (inserts.length) this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.ADD)); if (items.length || inserts.length) { this.dispatchChange('length'); } return new conbo.List({source:items}); }
javascript
function(begin, length) { begin || (begin = 0); if (conbo.isUndefined(length)) length = this.length; var inserts = conbo.rest(arguments,2); var items = this.source.splice.apply(this.source, [begin, length].concat(inserts)); if (items.length) this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.REMOVE)); if (inserts.length) this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.ADD)); if (items.length || inserts.length) { this.dispatchChange('length'); } return new conbo.List({source:items}); }
[ "function", "(", "begin", ",", "length", ")", "{", "begin", "||", "(", "begin", "=", "0", ")", ";", "if", "(", "conbo", ".", "isUndefined", "(", "length", ")", ")", "length", "=", "this", ".", "length", ";", "var", "inserts", "=", "conbo", ".", "rest", "(", "arguments", ",", "2", ")", ";", "var", "items", "=", "this", ".", "source", ".", "splice", ".", "apply", "(", "this", ".", "source", ",", "[", "begin", ",", "length", "]", ".", "concat", "(", "inserts", ")", ")", ";", "if", "(", "items", ".", "length", ")", "this", ".", "dispatchEvent", "(", "new", "conbo", ".", "ConboEvent", "(", "conbo", ".", "ConboEvent", ".", "REMOVE", ")", ")", ";", "if", "(", "inserts", ".", "length", ")", "this", ".", "dispatchEvent", "(", "new", "conbo", ".", "ConboEvent", "(", "conbo", ".", "ConboEvent", ".", "ADD", ")", ")", ";", "if", "(", "items", ".", "length", "||", "inserts", ".", "length", ")", "{", "this", ".", "dispatchChange", "(", "'length'", ")", ";", "}", "return", "new", "conbo", ".", "List", "(", "{", "source", ":", "items", "}", ")", ";", "}" ]
Splice out a sub-array of items from the collection.
[ "Splice", "out", "a", "sub", "-", "array", "of", "items", "from", "the", "collection", "." ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4808-L4825
45,124
mesmotronic/conbo
lib/conbo.js
function(compareFunction) { this.source.sort(compareFunction); this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.CHANGE)); return this; }
javascript
function(compareFunction) { this.source.sort(compareFunction); this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.CHANGE)); return this; }
[ "function", "(", "compareFunction", ")", "{", "this", ".", "source", ".", "sort", "(", "compareFunction", ")", ";", "this", ".", "dispatchEvent", "(", "new", "conbo", ".", "ConboEvent", "(", "conbo", ".", "ConboEvent", ".", "CHANGE", ")", ")", ";", "return", "this", ";", "}" ]
Force the collection to re-sort itself. @param {Function} [compareFunction] - Compare function to determine sort order
[ "Force", "the", "collection", "to", "re", "-", "sort", "itself", "." ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4864-L4870
45,125
mesmotronic/conbo
lib/conbo.js
function(items, enabled) { var method = enabled === false ? 'removeEventListener' : 'addEventListener'; items = (conbo.isArray(items) ? items : [items]).slice(); while (items.length) { var item = items.pop(); if (item instanceof conbo.EventDispatcher) { item[method](conbo.ConboEvent.CHANGE, this.dispatchEvent, this); } } }
javascript
function(items, enabled) { var method = enabled === false ? 'removeEventListener' : 'addEventListener'; items = (conbo.isArray(items) ? items : [items]).slice(); while (items.length) { var item = items.pop(); if (item instanceof conbo.EventDispatcher) { item[method](conbo.ConboEvent.CHANGE, this.dispatchEvent, this); } } }
[ "function", "(", "items", ",", "enabled", ")", "{", "var", "method", "=", "enabled", "===", "false", "?", "'removeEventListener'", ":", "'addEventListener'", ";", "items", "=", "(", "conbo", ".", "isArray", "(", "items", ")", "?", "items", ":", "[", "items", "]", ")", ".", "slice", "(", ")", ";", "while", "(", "items", ".", "length", ")", "{", "var", "item", "=", "items", ".", "pop", "(", ")", ";", "if", "(", "item", "instanceof", "conbo", ".", "EventDispatcher", ")", "{", "item", "[", "method", "]", "(", "conbo", ".", "ConboEvent", ".", "CHANGE", ",", "this", ".", "dispatchEvent", ",", "this", ")", ";", "}", "}", "}" ]
Listen to the events of Bindable values so we can detect changes @param {any} models @param {Boolean} enabled @private
[ "Listen", "to", "the", "events", "of", "Bindable", "values", "so", "we", "can", "detect", "changes" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L4904-L4919
45,126
mesmotronic/conbo
lib/conbo.js
function() { var el = this.__obj; var a = {}; if (el) { conbo.forEach(el.attributes, function(p) { a[conbo.toCamelCase(p.name)] = p.value; }); } return a; }
javascript
function() { var el = this.__obj; var a = {}; if (el) { conbo.forEach(el.attributes, function(p) { a[conbo.toCamelCase(p.name)] = p.value; }); } return a; }
[ "function", "(", ")", "{", "var", "el", "=", "this", ".", "__obj", ";", "var", "a", "=", "{", "}", ";", "if", "(", "el", ")", "{", "conbo", ".", "forEach", "(", "el", ".", "attributes", ",", "function", "(", "p", ")", "{", "a", "[", "conbo", ".", "toCamelCase", "(", "p", ".", "name", ")", "]", "=", "p", ".", "value", ";", "}", ")", ";", "}", "return", "a", ";", "}" ]
Returns object containing the value of all attributes on a DOM element @returns {Object} @example ep.attributes; // results in something like {src:"foo/bar.jpg"}
[ "Returns", "object", "containing", "the", "value", "of", "all", "attributes", "on", "a", "DOM", "element" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7103-L7117
45,127
mesmotronic/conbo
lib/conbo.js
function(obj) { var el = this.__obj; if (el && obj) { conbo.forEach(obj, function(value, name) { el.setAttribute(conbo.toKebabCase(name), value); }); } return this; }
javascript
function(obj) { var el = this.__obj; if (el && obj) { conbo.forEach(obj, function(value, name) { el.setAttribute(conbo.toKebabCase(name), value); }); } return this; }
[ "function", "(", "obj", ")", "{", "var", "el", "=", "this", ".", "__obj", ";", "if", "(", "el", "&&", "obj", ")", "{", "conbo", ".", "forEach", "(", "obj", ",", "function", "(", "value", ",", "name", ")", "{", "el", ".", "setAttribute", "(", "conbo", ".", "toKebabCase", "(", "name", ")", ",", "value", ")", ";", "}", ")", ";", "}", "return", "this", ";", "}" ]
Sets the attributes on a DOM element from an Object, converting camelCase to kebab-case, if needed @param {Element} obj - Object containing the attributes to set @returns {conbo.ElementProxy} @example ep.setAttributes({foo:1, bar:"red"});
[ "Sets", "the", "attributes", "on", "a", "DOM", "element", "from", "an", "Object", "converting", "camelCase", "to", "kebab", "-", "case", "if", "needed" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7128-L7141
45,128
mesmotronic/conbo
lib/conbo.js
function(className) { var el = this.__obj; return el instanceof Element && className ? el.classList.contains(className) : false; }
javascript
function(className) { var el = this.__obj; return el instanceof Element && className ? el.classList.contains(className) : false; }
[ "function", "(", "className", ")", "{", "var", "el", "=", "this", ".", "__obj", ";", "return", "el", "instanceof", "Element", "&&", "className", "?", "el", ".", "classList", ".", "contains", "(", "className", ")", ":", "false", ";", "}" ]
Is this element using the specified CSS class? @param {string} className - CSS class name @returns {boolean}
[ "Is", "this", "element", "using", "the", "specified", "CSS", "class?" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7245-L7252
45,129
mesmotronic/conbo
lib/conbo.js
function(selector) { var el = this.__obj; if (el) { var matchesFn; ['matches','webkitMatchesSelector','mozMatchesSelector','msMatchesSelector','oMatchesSelector'].some(function(fn) { if (typeof document.body[fn] == 'function') { matchesFn = fn; return true; } return false; }); var parent; // traverse parents while (el) { parent = el.parentElement; if (parent && parent[matchesFn](selector)) { return parent; } el = parent; } } }
javascript
function(selector) { var el = this.__obj; if (el) { var matchesFn; ['matches','webkitMatchesSelector','mozMatchesSelector','msMatchesSelector','oMatchesSelector'].some(function(fn) { if (typeof document.body[fn] == 'function') { matchesFn = fn; return true; } return false; }); var parent; // traverse parents while (el) { parent = el.parentElement; if (parent && parent[matchesFn](selector)) { return parent; } el = parent; } } }
[ "function", "(", "selector", ")", "{", "var", "el", "=", "this", ".", "__obj", ";", "if", "(", "el", ")", "{", "var", "matchesFn", ";", "[", "'matches'", ",", "'webkitMatchesSelector'", ",", "'mozMatchesSelector'", ",", "'msMatchesSelector'", ",", "'oMatchesSelector'", "]", ".", "some", "(", "function", "(", "fn", ")", "{", "if", "(", "typeof", "document", ".", "body", "[", "fn", "]", "==", "'function'", ")", "{", "matchesFn", "=", "fn", ";", "return", "true", ";", "}", "return", "false", ";", "}", ")", ";", "var", "parent", ";", "// traverse parents\r", "while", "(", "el", ")", "{", "parent", "=", "el", ".", "parentElement", ";", "if", "(", "parent", "&&", "parent", "[", "matchesFn", "]", "(", "selector", ")", ")", "{", "return", "parent", ";", "}", "el", "=", "parent", ";", "}", "}", "}" ]
Finds the closest parent element matching the specified selector @param {string} selector - Query selector @returns {Element}
[ "Finds", "the", "closest", "parent", "element", "matching", "the", "specified", "selector" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7260-L7294
45,130
mesmotronic/conbo
lib/conbo.js
function(el) { var attrs = conbo.assign({}, this.attributes); if (this.id && !el.id) { attrs.id = this.id; } el.classList.add('cb-glimpse'); el.cbGlimpse = this; for (var attr in attrs) { el.setAttribute(conbo.toKebabCase(attr), attrs[attr]); } if (this.style) { el.style = conbo.assign(el.style, this.style); } __definePrivateProperty(this, '__el', el); return this; }
javascript
function(el) { var attrs = conbo.assign({}, this.attributes); if (this.id && !el.id) { attrs.id = this.id; } el.classList.add('cb-glimpse'); el.cbGlimpse = this; for (var attr in attrs) { el.setAttribute(conbo.toKebabCase(attr), attrs[attr]); } if (this.style) { el.style = conbo.assign(el.style, this.style); } __definePrivateProperty(this, '__el', el); return this; }
[ "function", "(", "el", ")", "{", "var", "attrs", "=", "conbo", ".", "assign", "(", "{", "}", ",", "this", ".", "attributes", ")", ";", "if", "(", "this", ".", "id", "&&", "!", "el", ".", "id", ")", "{", "attrs", ".", "id", "=", "this", ".", "id", ";", "}", "el", ".", "classList", ".", "add", "(", "'cb-glimpse'", ")", ";", "el", ".", "cbGlimpse", "=", "this", ";", "for", "(", "var", "attr", "in", "attrs", ")", "{", "el", ".", "setAttribute", "(", "conbo", ".", "toKebabCase", "(", "attr", ")", ",", "attrs", "[", "attr", "]", ")", ";", "}", "if", "(", "this", ".", "style", ")", "{", "el", ".", "style", "=", "conbo", ".", "assign", "(", "el", ".", "style", ",", "this", ".", "style", ")", ";", "}", "__definePrivateProperty", "(", "this", ",", "'__el'", ",", "el", ")", ";", "return", "this", ";", "}" ]
Set this View's element @private
[ "Set", "this", "View", "s", "element" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7410-L7435
45,131
mesmotronic/conbo
lib/conbo.js
function(selector, deep) { if (this.el) { var results = conbo.toArray(this.el.querySelectorAll(selector)); if (!deep) { var views = this.el.querySelectorAll('.cb-view, [cb-view], [cb-app]'); // Remove elements in child Views conbo.forEach(views, function(el) { var els = conbo.toArray(el.querySelectorAll(selector)); results = conbo.difference(results, els.concat(el)); }); } return results; } return []; }
javascript
function(selector, deep) { if (this.el) { var results = conbo.toArray(this.el.querySelectorAll(selector)); if (!deep) { var views = this.el.querySelectorAll('.cb-view, [cb-view], [cb-app]'); // Remove elements in child Views conbo.forEach(views, function(el) { var els = conbo.toArray(el.querySelectorAll(selector)); results = conbo.difference(results, els.concat(el)); }); } return results; } return []; }
[ "function", "(", "selector", ",", "deep", ")", "{", "if", "(", "this", ".", "el", ")", "{", "var", "results", "=", "conbo", ".", "toArray", "(", "this", ".", "el", ".", "querySelectorAll", "(", "selector", ")", ")", ";", "if", "(", "!", "deep", ")", "{", "var", "views", "=", "this", ".", "el", ".", "querySelectorAll", "(", "'.cb-view, [cb-view], [cb-app]'", ")", ";", "// Remove elements in child Views\r", "conbo", ".", "forEach", "(", "views", ",", "function", "(", "el", ")", "{", "var", "els", "=", "conbo", ".", "toArray", "(", "el", ".", "querySelectorAll", "(", "selector", ")", ")", ";", "results", "=", "conbo", ".", "difference", "(", "results", ",", "els", ".", "concat", "(", "el", ")", ")", ";", "}", ")", ";", "}", "return", "results", ";", "}", "return", "[", "]", ";", "}" ]
Uses querySelectorAll to find all matching elements contained within the current View's element, but not within the elements of child Views @param {string} selector - The selector to use @param {boolean} deep - Include elements in child Views? @returns {Array} All elements matching the selector
[ "Uses", "querySelectorAll", "to", "find", "all", "matching", "elements", "contained", "within", "the", "current", "View", "s", "element", "but", "not", "within", "the", "elements", "of", "child", "Views" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7706-L7728
45,132
mesmotronic/conbo
lib/conbo.js
function() { try { var el = this.el; if (el.parentNode) { el.parentNode.removeChild(el); this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.DETACH)); } } catch(e) {} return this; }
javascript
function() { try { var el = this.el; if (el.parentNode) { el.parentNode.removeChild(el); this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.DETACH)); } } catch(e) {} return this; }
[ "function", "(", ")", "{", "try", "{", "var", "el", "=", "this", ".", "el", ";", "if", "(", "el", ".", "parentNode", ")", "{", "el", ".", "parentNode", ".", "removeChild", "(", "el", ")", ";", "this", ".", "dispatchEvent", "(", "new", "conbo", ".", "ConboEvent", "(", "conbo", ".", "ConboEvent", ".", "DETACH", ")", ")", ";", "}", "}", "catch", "(", "e", ")", "{", "}", "return", "this", ";", "}" ]
Take the View's element element out of the DOM @returns {this}
[ "Take", "the", "View", "s", "element", "element", "out", "of", "the", "DOM" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7734-L7749
45,133
mesmotronic/conbo
lib/conbo.js
function() { this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.REMOVE)); if (this.data) { this.data = undefined; } if (this.subcontext && this.subcontext != this.context) { this.subcontext.destroy(); this.subcontext = undefined; } if (this.context) { this.context .uninjectSingletons(this) .removeEventListener(undefined, undefined, this) ; this.context = undefined; } var children = this.querySelectorAll('.cb-view', true); while (children.length) { var child = children.pop(); try { child.cbView.remove(); } catch (e) {} } this.unbindView() .detach() .removeEventListener() .destroy() ; return this; }
javascript
function() { this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.REMOVE)); if (this.data) { this.data = undefined; } if (this.subcontext && this.subcontext != this.context) { this.subcontext.destroy(); this.subcontext = undefined; } if (this.context) { this.context .uninjectSingletons(this) .removeEventListener(undefined, undefined, this) ; this.context = undefined; } var children = this.querySelectorAll('.cb-view', true); while (children.length) { var child = children.pop(); try { child.cbView.remove(); } catch (e) {} } this.unbindView() .detach() .removeEventListener() .destroy() ; return this; }
[ "function", "(", ")", "{", "this", ".", "dispatchEvent", "(", "new", "conbo", ".", "ConboEvent", "(", "conbo", ".", "ConboEvent", ".", "REMOVE", ")", ")", ";", "if", "(", "this", ".", "data", ")", "{", "this", ".", "data", "=", "undefined", ";", "}", "if", "(", "this", ".", "subcontext", "&&", "this", ".", "subcontext", "!=", "this", ".", "context", ")", "{", "this", ".", "subcontext", ".", "destroy", "(", ")", ";", "this", ".", "subcontext", "=", "undefined", ";", "}", "if", "(", "this", ".", "context", ")", "{", "this", ".", "context", ".", "uninjectSingletons", "(", "this", ")", ".", "removeEventListener", "(", "undefined", ",", "undefined", ",", "this", ")", ";", "this", ".", "context", "=", "undefined", ";", "}", "var", "children", "=", "this", ".", "querySelectorAll", "(", "'.cb-view'", ",", "true", ")", ";", "while", "(", "children", ".", "length", ")", "{", "var", "child", "=", "children", ".", "pop", "(", ")", ";", "try", "{", "child", ".", "cbView", ".", "remove", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "}", "}", "this", ".", "unbindView", "(", ")", ".", "detach", "(", ")", ".", "removeEventListener", "(", ")", ".", "destroy", "(", ")", ";", "return", "this", ";", "}" ]
Remove and destroy this View by taking the element out of the DOM, unbinding it, removing all event listeners and removing the View from its Context. You should use a REMOVE event handler to destroy any event listeners, timers or other persistent code you may have added. @returns {this}
[ "Remove", "and", "destroy", "this", "View", "by", "taking", "the", "element", "out", "of", "the", "DOM", "unbinding", "it", "removing", "all", "event", "listeners", "and", "removing", "the", "View", "from", "its", "Context", "." ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7761-L7803
45,134
mesmotronic/conbo
lib/conbo.js
function(view) { if (arguments.length > 1) { conbo.forEach(arguments, function(view, index, list) { this.appendView(view); }, this); return this; } if (typeof view === 'function') { view = new view(this.context); } if (!(view instanceof conbo.View)) { throw new Error('Parameter must be conbo.View class or instance of it'); } this.body.appendChild(view.el); return this; }
javascript
function(view) { if (arguments.length > 1) { conbo.forEach(arguments, function(view, index, list) { this.appendView(view); }, this); return this; } if (typeof view === 'function') { view = new view(this.context); } if (!(view instanceof conbo.View)) { throw new Error('Parameter must be conbo.View class or instance of it'); } this.body.appendChild(view.el); return this; }
[ "function", "(", "view", ")", "{", "if", "(", "arguments", ".", "length", ">", "1", ")", "{", "conbo", ".", "forEach", "(", "arguments", ",", "function", "(", "view", ",", "index", ",", "list", ")", "{", "this", ".", "appendView", "(", "view", ")", ";", "}", ",", "this", ")", ";", "return", "this", ";", "}", "if", "(", "typeof", "view", "===", "'function'", ")", "{", "view", "=", "new", "view", "(", "this", ".", "context", ")", ";", "}", "if", "(", "!", "(", "view", "instanceof", "conbo", ".", "View", ")", ")", "{", "throw", "new", "Error", "(", "'Parameter must be conbo.View class or instance of it'", ")", ";", "}", "this", ".", "body", ".", "appendChild", "(", "view", ".", "el", ")", ";", "return", "this", ";", "}" ]
Append this DOM element from one View class instance this class instances DOM element @param {conbo.View|Function} view - The View instance to append @returns {this}
[ "Append", "this", "DOM", "element", "from", "one", "View", "class", "instance", "this", "class", "instances", "DOM", "element" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7812-L7838
45,135
mesmotronic/conbo
lib/conbo.js
function(view) { if (arguments.length > 1) { conbo.forEach(arguments, function(view, index, list) { this.prependView(view); }, this); return this; } if (typeof view === 'function') { view = new view(this.context); } if (!(view instanceof conbo.View)) { throw new Error('Parameter must be conbo.View class or instance of it'); } var firstChild = this.body.firstChild; firstChild ? this.body.insertBefore(view.el, firstChild) : this.appendView(view); return this; }
javascript
function(view) { if (arguments.length > 1) { conbo.forEach(arguments, function(view, index, list) { this.prependView(view); }, this); return this; } if (typeof view === 'function') { view = new view(this.context); } if (!(view instanceof conbo.View)) { throw new Error('Parameter must be conbo.View class or instance of it'); } var firstChild = this.body.firstChild; firstChild ? this.body.insertBefore(view.el, firstChild) : this.appendView(view); return this; }
[ "function", "(", "view", ")", "{", "if", "(", "arguments", ".", "length", ">", "1", ")", "{", "conbo", ".", "forEach", "(", "arguments", ",", "function", "(", "view", ",", "index", ",", "list", ")", "{", "this", ".", "prependView", "(", "view", ")", ";", "}", ",", "this", ")", ";", "return", "this", ";", "}", "if", "(", "typeof", "view", "===", "'function'", ")", "{", "view", "=", "new", "view", "(", "this", ".", "context", ")", ";", "}", "if", "(", "!", "(", "view", "instanceof", "conbo", ".", "View", ")", ")", "{", "throw", "new", "Error", "(", "'Parameter must be conbo.View class or instance of it'", ")", ";", "}", "var", "firstChild", "=", "this", ".", "body", ".", "firstChild", ";", "firstChild", "?", "this", ".", "body", ".", "insertBefore", "(", "view", ".", "el", ",", "firstChild", ")", ":", "this", ".", "appendView", "(", "view", ")", ";", "return", "this", ";", "}" ]
Prepend this DOM element from one View class instance this class instances DOM element @param {conbo.View} view - The View instance to preppend @returns {this}
[ "Prepend", "this", "DOM", "element", "from", "one", "View", "class", "instance", "this", "class", "instances", "DOM", "element" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7847-L7877
45,136
mesmotronic/conbo
lib/conbo.js
function() { var template = this.template; if (!!this.templateUrl) { this.loadTemplate(); } else { if (conbo.isFunction(template)) { template = template(this); } var el = this.el; if (conbo.isString(template)) { el.innerHTML = this.__parseTemplate(template); } else if (/{{(.+?)}}/.test(el.textContent)) { el.innerHTML = this.__parseTemplate(el.innerHTML); } this.__initView(); } return this; }
javascript
function() { var template = this.template; if (!!this.templateUrl) { this.loadTemplate(); } else { if (conbo.isFunction(template)) { template = template(this); } var el = this.el; if (conbo.isString(template)) { el.innerHTML = this.__parseTemplate(template); } else if (/{{(.+?)}}/.test(el.textContent)) { el.innerHTML = this.__parseTemplate(el.innerHTML); } this.__initView(); } return this; }
[ "function", "(", ")", "{", "var", "template", "=", "this", ".", "template", ";", "if", "(", "!", "!", "this", ".", "templateUrl", ")", "{", "this", ".", "loadTemplate", "(", ")", ";", "}", "else", "{", "if", "(", "conbo", ".", "isFunction", "(", "template", ")", ")", "{", "template", "=", "template", "(", "this", ")", ";", "}", "var", "el", "=", "this", ".", "el", ";", "if", "(", "conbo", ".", "isString", "(", "template", ")", ")", "{", "el", ".", "innerHTML", "=", "this", ".", "__parseTemplate", "(", "template", ")", ";", "}", "else", "if", "(", "/", "{{(.+?)}}", "/", ".", "test", "(", "el", ".", "textContent", ")", ")", "{", "el", ".", "innerHTML", "=", "this", ".", "__parseTemplate", "(", "el", ".", "innerHTML", ")", ";", "}", "this", ".", "__initView", "(", ")", ";", "}", "return", "this", ";", "}" ]
Initialize the View's template, either by loading the templateUrl or using the contents of the template property, if either exist @returns {this}
[ "Initialize", "the", "View", "s", "template", "either", "by", "loading", "the", "templateUrl", "or", "using", "the", "contents", "of", "the", "template", "property", "if", "either", "exist" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7908-L7938
45,137
mesmotronic/conbo
lib/conbo.js
function(url) { url || (url = this.templateUrl); var el = this.body; this.unbindView(); if (this.templateCacheEnabled !== false && View__templateCache[url]) { el.innerHTML = View__templateCache[url]; this.__initView(); return this; } var resultHandler = function(event) { var result = this.__parseTemplate(event.result); if (this.templateCacheEnabled !== false) { View__templateCache[url] = result; } el.innerHTML = result; this.__initView(); }; var faultHandler = function(event) { el.innerHTML = ''; this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.TEMPLATE_ERROR)); this.__initView(); }; conbo .httpRequest({url:url, dataType:'text'}) .then(resultHandler.bind(this), faultHandler.bind(this)) ; return this; }
javascript
function(url) { url || (url = this.templateUrl); var el = this.body; this.unbindView(); if (this.templateCacheEnabled !== false && View__templateCache[url]) { el.innerHTML = View__templateCache[url]; this.__initView(); return this; } var resultHandler = function(event) { var result = this.__parseTemplate(event.result); if (this.templateCacheEnabled !== false) { View__templateCache[url] = result; } el.innerHTML = result; this.__initView(); }; var faultHandler = function(event) { el.innerHTML = ''; this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.TEMPLATE_ERROR)); this.__initView(); }; conbo .httpRequest({url:url, dataType:'text'}) .then(resultHandler.bind(this), faultHandler.bind(this)) ; return this; }
[ "function", "(", "url", ")", "{", "url", "||", "(", "url", "=", "this", ".", "templateUrl", ")", ";", "var", "el", "=", "this", ".", "body", ";", "this", ".", "unbindView", "(", ")", ";", "if", "(", "this", ".", "templateCacheEnabled", "!==", "false", "&&", "View__templateCache", "[", "url", "]", ")", "{", "el", ".", "innerHTML", "=", "View__templateCache", "[", "url", "]", ";", "this", ".", "__initView", "(", ")", ";", "return", "this", ";", "}", "var", "resultHandler", "=", "function", "(", "event", ")", "{", "var", "result", "=", "this", ".", "__parseTemplate", "(", "event", ".", "result", ")", ";", "if", "(", "this", ".", "templateCacheEnabled", "!==", "false", ")", "{", "View__templateCache", "[", "url", "]", "=", "result", ";", "}", "el", ".", "innerHTML", "=", "result", ";", "this", ".", "__initView", "(", ")", ";", "}", ";", "var", "faultHandler", "=", "function", "(", "event", ")", "{", "el", ".", "innerHTML", "=", "''", ";", "this", ".", "dispatchEvent", "(", "new", "conbo", ".", "ConboEvent", "(", "conbo", ".", "ConboEvent", ".", "TEMPLATE_ERROR", ")", ")", ";", "this", ".", "__initView", "(", ")", ";", "}", ";", "conbo", ".", "httpRequest", "(", "{", "url", ":", "url", ",", "dataType", ":", "'text'", "}", ")", ".", "then", "(", "resultHandler", ".", "bind", "(", "this", ")", ",", "faultHandler", ".", "bind", "(", "this", ")", ")", ";", "return", "this", ";", "}" ]
Load HTML template and use it to populate this View's element @param {string} [url] - The URL to which the request is sent @returns {this}
[ "Load", "HTML", "template", "and", "use", "it", "to", "populate", "this", "View", "s", "element" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L7946-L7989
45,138
mesmotronic/conbo
lib/conbo.js
function(command, data, method, resultClass) { var scope = this; data = conbo.clone(data || {}); command = this.parseUrl(command, data); data = this.encodeFunction(data, method); return new Promise(function(resolve, reject) { conbo.httpRequest ({ data: data, type: method || 'GET', headers: scope.headers, url: (scope.rootUrl+command).replace(/\/$/, ''), contentType: scope.contentType || conbo.CONTENT_TYPE_JSON, dataType: scope.dataType, dataFilter: scope.decodeFunction, resultClass: resultClass || scope.resultClass, makeObjectsBindable: scope.makeObjectsBindable }) .then(function(event) { scope.dispatchEvent(event); resolve(event); }) .catch(function(event) { scope.dispatchEvent(event); reject(event); }); }); }
javascript
function(command, data, method, resultClass) { var scope = this; data = conbo.clone(data || {}); command = this.parseUrl(command, data); data = this.encodeFunction(data, method); return new Promise(function(resolve, reject) { conbo.httpRequest ({ data: data, type: method || 'GET', headers: scope.headers, url: (scope.rootUrl+command).replace(/\/$/, ''), contentType: scope.contentType || conbo.CONTENT_TYPE_JSON, dataType: scope.dataType, dataFilter: scope.decodeFunction, resultClass: resultClass || scope.resultClass, makeObjectsBindable: scope.makeObjectsBindable }) .then(function(event) { scope.dispatchEvent(event); resolve(event); }) .catch(function(event) { scope.dispatchEvent(event); reject(event); }); }); }
[ "function", "(", "command", ",", "data", ",", "method", ",", "resultClass", ")", "{", "var", "scope", "=", "this", ";", "data", "=", "conbo", ".", "clone", "(", "data", "||", "{", "}", ")", ";", "command", "=", "this", ".", "parseUrl", "(", "command", ",", "data", ")", ";", "data", "=", "this", ".", "encodeFunction", "(", "data", ",", "method", ")", ";", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "conbo", ".", "httpRequest", "(", "{", "data", ":", "data", ",", "type", ":", "method", "||", "'GET'", ",", "headers", ":", "scope", ".", "headers", ",", "url", ":", "(", "scope", ".", "rootUrl", "+", "command", ")", ".", "replace", "(", "/", "\\/$", "/", ",", "''", ")", ",", "contentType", ":", "scope", ".", "contentType", "||", "conbo", ".", "CONTENT_TYPE_JSON", ",", "dataType", ":", "scope", ".", "dataType", ",", "dataFilter", ":", "scope", ".", "decodeFunction", ",", "resultClass", ":", "resultClass", "||", "scope", ".", "resultClass", ",", "makeObjectsBindable", ":", "scope", ".", "makeObjectsBindable", "}", ")", ".", "then", "(", "function", "(", "event", ")", "{", "scope", ".", "dispatchEvent", "(", "event", ")", ";", "resolve", "(", "event", ")", ";", "}", ")", ".", "catch", "(", "function", "(", "event", ")", "{", "scope", ".", "dispatchEvent", "(", "event", ")", ";", "reject", "(", "event", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Call a method of the web service using the specified verb @param {string} command - The name of the command @param {Object} [data] - Object containing the data to send to the web service @param {string} [method=GET] - GET, POST, etc (default: GET) @param {Class} [resultClass] - Optional @returns {Promise}
[ "Call", "a", "method", "of", "the", "web", "service", "using", "the", "specified", "verb" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L8695-L8728
45,139
mesmotronic/conbo
lib/conbo.js
function(command, method, resultClass) { if (conbo.isObject(command)) { method = command.method; resultClass = command.resultClass; command = command.command; } this[conbo.toCamelCase(command)] = function(data) { return this.call(command, data, method, resultClass); }; return this; }
javascript
function(command, method, resultClass) { if (conbo.isObject(command)) { method = command.method; resultClass = command.resultClass; command = command.command; } this[conbo.toCamelCase(command)] = function(data) { return this.call(command, data, method, resultClass); }; return this; }
[ "function", "(", "command", ",", "method", ",", "resultClass", ")", "{", "if", "(", "conbo", ".", "isObject", "(", "command", ")", ")", "{", "method", "=", "command", ".", "method", ";", "resultClass", "=", "command", ".", "resultClass", ";", "command", "=", "command", ".", "command", ";", "}", "this", "[", "conbo", ".", "toCamelCase", "(", "command", ")", "]", "=", "function", "(", "data", ")", "{", "return", "this", ".", "call", "(", "command", ",", "data", ",", "method", ",", "resultClass", ")", ";", "}", ";", "return", "this", ";", "}" ]
Call a method of the web service using the DELETE verb @memberof conbo.HttpService.prototype @method delete @param {string} command - The name of the command @param {Object} [data] - Object containing the data to send to the web service @param {Class} [resultClass] - Optional @returns {Promise} Add one or more remote commands as methods of this class instance @param {string} command - The name of the command @param {string} [method=GET] - GET, POST, etc (default: GET) @param {Class} [resultClass] - Optional
[ "Call", "a", "method", "of", "the", "web", "service", "using", "the", "DELETE", "verb" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L8791-L8806
45,140
mesmotronic/conbo
lib/conbo.js
function(url, data) { var parsedUrl = url, matches = parsedUrl.match(/:\b\w+\b/g); if (!!matches) { matches.forEach(function(key) { key = key.substr(1); if (!(key in data)) { throw new Error('Property "'+key+'" required but not found in data'); } }); } conbo.keys(data).forEach(function(key) { var regExp = new RegExp(':\\b'+key+'\\b', 'g'); if (regExp.test(parsedUrl)) { parsedUrl = parsedUrl.replace(regExp, data[key]); delete data[key]; } }); return parsedUrl; }
javascript
function(url, data) { var parsedUrl = url, matches = parsedUrl.match(/:\b\w+\b/g); if (!!matches) { matches.forEach(function(key) { key = key.substr(1); if (!(key in data)) { throw new Error('Property "'+key+'" required but not found in data'); } }); } conbo.keys(data).forEach(function(key) { var regExp = new RegExp(':\\b'+key+'\\b', 'g'); if (regExp.test(parsedUrl)) { parsedUrl = parsedUrl.replace(regExp, data[key]); delete data[key]; } }); return parsedUrl; }
[ "function", "(", "url", ",", "data", ")", "{", "var", "parsedUrl", "=", "url", ",", "matches", "=", "parsedUrl", ".", "match", "(", "/", ":\\b\\w+\\b", "/", "g", ")", ";", "if", "(", "!", "!", "matches", ")", "{", "matches", ".", "forEach", "(", "function", "(", "key", ")", "{", "key", "=", "key", ".", "substr", "(", "1", ")", ";", "if", "(", "!", "(", "key", "in", "data", ")", ")", "{", "throw", "new", "Error", "(", "'Property \"'", "+", "key", "+", "'\" required but not found in data'", ")", ";", "}", "}", ")", ";", "}", "conbo", ".", "keys", "(", "data", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "var", "regExp", "=", "new", "RegExp", "(", "':\\\\b'", "+", "key", "+", "'\\\\b'", ",", "'g'", ")", ";", "if", "(", "regExp", ".", "test", "(", "parsedUrl", ")", ")", "{", "parsedUrl", "=", "parsedUrl", ".", "replace", "(", "regExp", ",", "data", "[", "key", "]", ")", ";", "delete", "data", "[", "key", "]", ";", "}", "}", ")", ";", "return", "parsedUrl", ";", "}" ]
Splice data into URL and remove spliced properties from data object
[ "Splice", "data", "into", "URL", "and", "remove", "spliced", "properties", "from", "data", "object" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L8842-L8872
45,141
mesmotronic/conbo
lib/conbo.js
function(fragment, options) { options || (options = {}); fragment = this.__getFragment(fragment); if (this.fragment === fragment) { return; } var location = this.location; this.fragment = fragment; if (options.replace) { var href = location.href.replace(/(javascript:|#).*$/, ''); location.replace(href + '#!/' + fragment); } else { location.hash = '#!/' + fragment; } if (options.trigger) { this.__loadUrl(fragment); } return this; }
javascript
function(fragment, options) { options || (options = {}); fragment = this.__getFragment(fragment); if (this.fragment === fragment) { return; } var location = this.location; this.fragment = fragment; if (options.replace) { var href = location.href.replace(/(javascript:|#).*$/, ''); location.replace(href + '#!/' + fragment); } else { location.hash = '#!/' + fragment; } if (options.trigger) { this.__loadUrl(fragment); } return this; }
[ "function", "(", "fragment", ",", "options", ")", "{", "options", "||", "(", "options", "=", "{", "}", ")", ";", "fragment", "=", "this", ".", "__getFragment", "(", "fragment", ")", ";", "if", "(", "this", ".", "fragment", "===", "fragment", ")", "{", "return", ";", "}", "var", "location", "=", "this", ".", "location", ";", "this", ".", "fragment", "=", "fragment", ";", "if", "(", "options", ".", "replace", ")", "{", "var", "href", "=", "location", ".", "href", ".", "replace", "(", "/", "(javascript:|#).*$", "/", ",", "''", ")", ";", "location", ".", "replace", "(", "href", "+", "'#!/'", "+", "fragment", ")", ";", "}", "else", "{", "location", ".", "hash", "=", "'#!/'", "+", "fragment", ";", "}", "if", "(", "options", ".", "trigger", ")", "{", "this", ".", "__loadUrl", "(", "fragment", ")", ";", "}", "return", "this", ";", "}" ]
Set the current path @param {string} path - The path @param {}
[ "Set", "the", "current", "path" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L9111-L9141
45,142
mesmotronic/conbo
lib/conbo.js
function(fragmentOverride) { var fragment = this.fragment = this.__getFragment(fragmentOverride); var matched = conbo.some(this.handlers, function(handler) { if (handler.route.test(fragment)) { handler.callback(fragment); return true; } }); if (!matched) { this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.FAULT)); } return matched; }
javascript
function(fragmentOverride) { var fragment = this.fragment = this.__getFragment(fragmentOverride); var matched = conbo.some(this.handlers, function(handler) { if (handler.route.test(fragment)) { handler.callback(fragment); return true; } }); if (!matched) { this.dispatchEvent(new conbo.ConboEvent(conbo.ConboEvent.FAULT)); } return matched; }
[ "function", "(", "fragmentOverride", ")", "{", "var", "fragment", "=", "this", ".", "fragment", "=", "this", ".", "__getFragment", "(", "fragmentOverride", ")", ";", "var", "matched", "=", "conbo", ".", "some", "(", "this", ".", "handlers", ",", "function", "(", "handler", ")", "{", "if", "(", "handler", ".", "route", ".", "test", "(", "fragment", ")", ")", "{", "handler", ".", "callback", "(", "fragment", ")", ";", "return", "true", ";", "}", "}", ")", ";", "if", "(", "!", "matched", ")", "{", "this", ".", "dispatchEvent", "(", "new", "conbo", ".", "ConboEvent", "(", "conbo", ".", "ConboEvent", ".", "FAULT", ")", ")", ";", "}", "return", "matched", ";", "}" ]
Attempt to load the current URL fragment @private @returns {boolean} Whether or not the path is a valid route
[ "Attempt", "to", "load", "the", "current", "URL", "fragment" ]
339df613eefc48e054e115337079573ad842f717
https://github.com/mesmotronic/conbo/blob/339df613eefc48e054e115337079573ad842f717/lib/conbo.js#L9173-L9192
45,143
openmason/aonx
lib/aonx.js
_postHandlers
function _postHandlers() { // any authentication checks first if(config.authentication.enabled) { logger.info(pkgname + " authentication to API's enabled"); app.all(config.api.path, function(req, res, next) { if(config.authentication.ignores && req.params) { // check if the params is in ignores list var matches = _.filter(req.params, function(param) { return _.find(config.authentication.ignores, function(ignore) { return param.indexOf(ignore)==0; }); }); if(matches && matches.length>0) { logger.debug(pkgname+"ignored auth for param:" + matches); return next(); } } if(req.loggedIn) { return next(); // auth success go to next } else { return next(error(401, 'unauthorized access')); } }); } // install api checks if(config.api.keycheck) { logger.info(pkgname + " keycheck to API's enabled"); // here we validate the API key app.all(config.api.path, function(req, res, next){ var key = req.query[config.api.KEYNAME] || req.body[config.api.KEYNAME]; // key isnt present if (!key) return next(error(400, 'api key required')); // key is invalid if (!~config.api.keys.indexOf(key)) return next(error(401, 'invalid api key')); // all good, store req.key for route access req.key = key; next(); }); } // jsonp support for delete, put & post (partial post) if(config.server.jsonp) { logger.info(pkgname + " jsonp support on api's enabled"); // check if callback is there along with method app.all(config.api.path, function(req, res, next) { if(req.query && req.query['callback'] && req.query['_method']) { // lets rewrite the method, especially PUT/DELETE/POST req.method=req.query['_method']; logger.debug(pkgname + "jsonp request converted:"+req.query); } next(); }); } var api = { index: function(req,res) { res.json({app:config.app.title, version:config.app.version}); } }; global.apiresource = app.resource('api', api); logger.info(pkgname + " api handler added"); logger.debug(pkgname + "init complete"); }
javascript
function _postHandlers() { // any authentication checks first if(config.authentication.enabled) { logger.info(pkgname + " authentication to API's enabled"); app.all(config.api.path, function(req, res, next) { if(config.authentication.ignores && req.params) { // check if the params is in ignores list var matches = _.filter(req.params, function(param) { return _.find(config.authentication.ignores, function(ignore) { return param.indexOf(ignore)==0; }); }); if(matches && matches.length>0) { logger.debug(pkgname+"ignored auth for param:" + matches); return next(); } } if(req.loggedIn) { return next(); // auth success go to next } else { return next(error(401, 'unauthorized access')); } }); } // install api checks if(config.api.keycheck) { logger.info(pkgname + " keycheck to API's enabled"); // here we validate the API key app.all(config.api.path, function(req, res, next){ var key = req.query[config.api.KEYNAME] || req.body[config.api.KEYNAME]; // key isnt present if (!key) return next(error(400, 'api key required')); // key is invalid if (!~config.api.keys.indexOf(key)) return next(error(401, 'invalid api key')); // all good, store req.key for route access req.key = key; next(); }); } // jsonp support for delete, put & post (partial post) if(config.server.jsonp) { logger.info(pkgname + " jsonp support on api's enabled"); // check if callback is there along with method app.all(config.api.path, function(req, res, next) { if(req.query && req.query['callback'] && req.query['_method']) { // lets rewrite the method, especially PUT/DELETE/POST req.method=req.query['_method']; logger.debug(pkgname + "jsonp request converted:"+req.query); } next(); }); } var api = { index: function(req,res) { res.json({app:config.app.title, version:config.app.version}); } }; global.apiresource = app.resource('api', api); logger.info(pkgname + " api handler added"); logger.debug(pkgname + "init complete"); }
[ "function", "_postHandlers", "(", ")", "{", "// any authentication checks first", "if", "(", "config", ".", "authentication", ".", "enabled", ")", "{", "logger", ".", "info", "(", "pkgname", "+", "\" authentication to API's enabled\"", ")", ";", "app", ".", "all", "(", "config", ".", "api", ".", "path", ",", "function", "(", "req", ",", "res", ",", "next", ")", "{", "if", "(", "config", ".", "authentication", ".", "ignores", "&&", "req", ".", "params", ")", "{", "// check if the params is in ignores list", "var", "matches", "=", "_", ".", "filter", "(", "req", ".", "params", ",", "function", "(", "param", ")", "{", "return", "_", ".", "find", "(", "config", ".", "authentication", ".", "ignores", ",", "function", "(", "ignore", ")", "{", "return", "param", ".", "indexOf", "(", "ignore", ")", "==", "0", ";", "}", ")", ";", "}", ")", ";", "if", "(", "matches", "&&", "matches", ".", "length", ">", "0", ")", "{", "logger", ".", "debug", "(", "pkgname", "+", "\"ignored auth for param:\"", "+", "matches", ")", ";", "return", "next", "(", ")", ";", "}", "}", "if", "(", "req", ".", "loggedIn", ")", "{", "return", "next", "(", ")", ";", "// auth success go to next", "}", "else", "{", "return", "next", "(", "error", "(", "401", ",", "'unauthorized access'", ")", ")", ";", "}", "}", ")", ";", "}", "// install api checks", "if", "(", "config", ".", "api", ".", "keycheck", ")", "{", "logger", ".", "info", "(", "pkgname", "+", "\" keycheck to API's enabled\"", ")", ";", "// here we validate the API key ", "app", ".", "all", "(", "config", ".", "api", ".", "path", ",", "function", "(", "req", ",", "res", ",", "next", ")", "{", "var", "key", "=", "req", ".", "query", "[", "config", ".", "api", ".", "KEYNAME", "]", "||", "req", ".", "body", "[", "config", ".", "api", ".", "KEYNAME", "]", ";", "// key isnt present", "if", "(", "!", "key", ")", "return", "next", "(", "error", "(", "400", ",", "'api key required'", ")", ")", ";", "// key is invalid", "if", "(", "!", "~", "config", ".", "api", ".", "keys", ".", "indexOf", "(", "key", ")", ")", "return", "next", "(", "error", "(", "401", ",", "'invalid api key'", ")", ")", ";", "// all good, store req.key for route access", "req", ".", "key", "=", "key", ";", "next", "(", ")", ";", "}", ")", ";", "}", "// jsonp support for delete, put & post (partial post)", "if", "(", "config", ".", "server", ".", "jsonp", ")", "{", "logger", ".", "info", "(", "pkgname", "+", "\" jsonp support on api's enabled\"", ")", ";", "// check if callback is there along with method", "app", ".", "all", "(", "config", ".", "api", ".", "path", ",", "function", "(", "req", ",", "res", ",", "next", ")", "{", "if", "(", "req", ".", "query", "&&", "req", ".", "query", "[", "'callback'", "]", "&&", "req", ".", "query", "[", "'_method'", "]", ")", "{", "// lets rewrite the method, especially PUT/DELETE/POST", "req", ".", "method", "=", "req", ".", "query", "[", "'_method'", "]", ";", "logger", ".", "debug", "(", "pkgname", "+", "\"jsonp request converted:\"", "+", "req", ".", "query", ")", ";", "}", "next", "(", ")", ";", "}", ")", ";", "}", "var", "api", "=", "{", "index", ":", "function", "(", "req", ",", "res", ")", "{", "res", ".", "json", "(", "{", "app", ":", "config", ".", "app", ".", "title", ",", "version", ":", "config", ".", "app", ".", "version", "}", ")", ";", "}", "}", ";", "global", ".", "apiresource", "=", "app", ".", "resource", "(", "'api'", ",", "api", ")", ";", "logger", ".", "info", "(", "pkgname", "+", "\" api handler added\"", ")", ";", "logger", ".", "debug", "(", "pkgname", "+", "\"init complete\"", ")", ";", "}" ]
all post handlers go here
[ "all", "post", "handlers", "go", "here" ]
e224668b6f5a3e939535e82218e17e00412cc39a
https://github.com/openmason/aonx/blob/e224668b6f5a3e939535e82218e17e00412cc39a/lib/aonx.js#L205-L271
45,144
openmason/aonx
lib/aonx.js
_errorHandlers
function _errorHandlers() { // middleware with an arity of 4 are considered // error handling middleware. When you next(err) // it will be passed through the defined middleware // in order, but ONLY those with an arity of 4, ignoring // regular middleware. app.use(function(err, req, res, next){ logger.error(err); console.trace(); if(req.accepts('html') || req.is('html')) { res.status(err.status || 500); res.render('500', { error: err }); return; } res.send(err.status || 500, { error: err.message }); }); // our custom JSON 404 middleware. Since it's placed last // it will be the last middleware called, if all others // invoke next() and do not respond. app.use(function(req, res) { logger.error('Failed to locate:'+req.url); console.trace(); if(req.accepts('html') || req.is('html')) { res.status(404); res.render('404', { url: req.url }); return; } res.send(404, { error: "can't find the resource" }); }); }
javascript
function _errorHandlers() { // middleware with an arity of 4 are considered // error handling middleware. When you next(err) // it will be passed through the defined middleware // in order, but ONLY those with an arity of 4, ignoring // regular middleware. app.use(function(err, req, res, next){ logger.error(err); console.trace(); if(req.accepts('html') || req.is('html')) { res.status(err.status || 500); res.render('500', { error: err }); return; } res.send(err.status || 500, { error: err.message }); }); // our custom JSON 404 middleware. Since it's placed last // it will be the last middleware called, if all others // invoke next() and do not respond. app.use(function(req, res) { logger.error('Failed to locate:'+req.url); console.trace(); if(req.accepts('html') || req.is('html')) { res.status(404); res.render('404', { url: req.url }); return; } res.send(404, { error: "can't find the resource" }); }); }
[ "function", "_errorHandlers", "(", ")", "{", "// middleware with an arity of 4 are considered", "// error handling middleware. When you next(err)", "// it will be passed through the defined middleware", "// in order, but ONLY those with an arity of 4, ignoring", "// regular middleware.", "app", ".", "use", "(", "function", "(", "err", ",", "req", ",", "res", ",", "next", ")", "{", "logger", ".", "error", "(", "err", ")", ";", "console", ".", "trace", "(", ")", ";", "if", "(", "req", ".", "accepts", "(", "'html'", ")", "||", "req", ".", "is", "(", "'html'", ")", ")", "{", "res", ".", "status", "(", "err", ".", "status", "||", "500", ")", ";", "res", ".", "render", "(", "'500'", ",", "{", "error", ":", "err", "}", ")", ";", "return", ";", "}", "res", ".", "send", "(", "err", ".", "status", "||", "500", ",", "{", "error", ":", "err", ".", "message", "}", ")", ";", "}", ")", ";", "// our custom JSON 404 middleware. Since it's placed last", "// it will be the last middleware called, if all others", "// invoke next() and do not respond.", "app", ".", "use", "(", "function", "(", "req", ",", "res", ")", "{", "logger", ".", "error", "(", "'Failed to locate:'", "+", "req", ".", "url", ")", ";", "console", ".", "trace", "(", ")", ";", "if", "(", "req", ".", "accepts", "(", "'html'", ")", "||", "req", ".", "is", "(", "'html'", ")", ")", "{", "res", ".", "status", "(", "404", ")", ";", "res", ".", "render", "(", "'404'", ",", "{", "url", ":", "req", ".", "url", "}", ")", ";", "return", ";", "}", "res", ".", "send", "(", "404", ",", "{", "error", ":", "\"can't find the resource\"", "}", ")", ";", "}", ")", ";", "}" ]
register these error handlers in the express configuration
[ "register", "these", "error", "handlers", "in", "the", "express", "configuration" ]
e224668b6f5a3e939535e82218e17e00412cc39a
https://github.com/openmason/aonx/blob/e224668b6f5a3e939535e82218e17e00412cc39a/lib/aonx.js#L287-L317
45,145
voorhoede/voorhoede-ocelot-formatter
lib/render-code.js
getCode
function getCode(code, language) { if (prism.languages.hasOwnProperty(language)) { code = prism.highlight(code, prism.languages[language]); return `<pre class="language-${language}"><code>${code}</code></pre>`; } else { return `<pre class="language-unknown"><code>${code}</code></pre>`; } }
javascript
function getCode(code, language) { if (prism.languages.hasOwnProperty(language)) { code = prism.highlight(code, prism.languages[language]); return `<pre class="language-${language}"><code>${code}</code></pre>`; } else { return `<pre class="language-unknown"><code>${code}</code></pre>`; } }
[ "function", "getCode", "(", "code", ",", "language", ")", "{", "if", "(", "prism", ".", "languages", ".", "hasOwnProperty", "(", "language", ")", ")", "{", "code", "=", "prism", ".", "highlight", "(", "code", ",", "prism", ".", "languages", "[", "language", "]", ")", ";", "return", "`", "${", "language", "}", "${", "code", "}", "`", ";", "}", "else", "{", "return", "`", "${", "code", "}", "`", ";", "}", "}" ]
adds `json` to global `prism.languages` instance
[ "adds", "json", "to", "global", "prism", ".", "languages", "instance" ]
b0dc3c6cd0d1e956974a51129def29ce9d27d030
https://github.com/voorhoede/voorhoede-ocelot-formatter/blob/b0dc3c6cd0d1e956974a51129def29ce9d27d030/lib/render-code.js#L4-L11
45,146
socialally/air
lib/air/children.js
children
function children(selector) { var arr = [], slice = this.slice, nodes, matches; this.each(function(el) { nodes = slice.call(el.childNodes); // only include elements nodes = nodes.filter(function(n) { if(n instanceof Element) { return n;} }) // filter direct descendants by selector if(selector) { matches = slice.call(el.querySelectorAll(selector)); for(var i = 0;i < nodes.length;i++) { if(~matches.indexOf(nodes[i])) { arr.push(nodes[i]); } } // get all direct descendants }else{ arr = arr.concat(nodes); } }); return this.air(arr); }
javascript
function children(selector) { var arr = [], slice = this.slice, nodes, matches; this.each(function(el) { nodes = slice.call(el.childNodes); // only include elements nodes = nodes.filter(function(n) { if(n instanceof Element) { return n;} }) // filter direct descendants by selector if(selector) { matches = slice.call(el.querySelectorAll(selector)); for(var i = 0;i < nodes.length;i++) { if(~matches.indexOf(nodes[i])) { arr.push(nodes[i]); } } // get all direct descendants }else{ arr = arr.concat(nodes); } }); return this.air(arr); }
[ "function", "children", "(", "selector", ")", "{", "var", "arr", "=", "[", "]", ",", "slice", "=", "this", ".", "slice", ",", "nodes", ",", "matches", ";", "this", ".", "each", "(", "function", "(", "el", ")", "{", "nodes", "=", "slice", ".", "call", "(", "el", ".", "childNodes", ")", ";", "// only include elements", "nodes", "=", "nodes", ".", "filter", "(", "function", "(", "n", ")", "{", "if", "(", "n", "instanceof", "Element", ")", "{", "return", "n", ";", "}", "}", ")", "// filter direct descendants by selector", "if", "(", "selector", ")", "{", "matches", "=", "slice", ".", "call", "(", "el", ".", "querySelectorAll", "(", "selector", ")", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "~", "matches", ".", "indexOf", "(", "nodes", "[", "i", "]", ")", ")", "{", "arr", ".", "push", "(", "nodes", "[", "i", "]", ")", ";", "}", "}", "// get all direct descendants", "}", "else", "{", "arr", "=", "arr", ".", "concat", "(", "nodes", ")", ";", "}", "}", ")", ";", "return", "this", ".", "air", "(", "arr", ")", ";", "}" ]
Get the children of each element in the set of matched elements, optionally filtering by selector.
[ "Get", "the", "children", "of", "each", "element", "in", "the", "set", "of", "matched", "elements", "optionally", "filtering", "by", "selector", "." ]
a3d94de58aaa4930a425fbcc7266764bf6ca8ca6
https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/children.js#L5-L27
45,147
mchalapuk/hyper-text-slider
lib/utils/dom.spec-helper.js
getSibling
function getSibling(node, relativeIndex) { var parent = node.parentNode; if (parent === null) { return null; } var currentIndex = parent.childNodes.indexOf(node); var siblingIndex = currentIndex + relativeIndex; if (siblingIndex < 0 || siblingIndex > parent.childNodes.length - 1) { return null; } return parent.childNodes[siblingIndex]; }
javascript
function getSibling(node, relativeIndex) { var parent = node.parentNode; if (parent === null) { return null; } var currentIndex = parent.childNodes.indexOf(node); var siblingIndex = currentIndex + relativeIndex; if (siblingIndex < 0 || siblingIndex > parent.childNodes.length - 1) { return null; } return parent.childNodes[siblingIndex]; }
[ "function", "getSibling", "(", "node", ",", "relativeIndex", ")", "{", "var", "parent", "=", "node", ".", "parentNode", ";", "if", "(", "parent", "===", "null", ")", "{", "return", "null", ";", "}", "var", "currentIndex", "=", "parent", ".", "childNodes", ".", "indexOf", "(", "node", ")", ";", "var", "siblingIndex", "=", "currentIndex", "+", "relativeIndex", ";", "if", "(", "siblingIndex", "<", "0", "||", "siblingIndex", ">", "parent", ".", "childNodes", ".", "length", "-", "1", ")", "{", "return", "null", ";", "}", "return", "parent", ".", "childNodes", "[", "siblingIndex", "]", ";", "}" ]
returns a sibling of given node
[ "returns", "a", "sibling", "of", "given", "node" ]
2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4
https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/utils/dom.spec-helper.js#L115-L126
45,148
wmluke/grunt-inline-angular-templates
tasks/inline_angular_templates.js
function (rawHtml) { var matchKeys = Object.keys(options.unescape); if (matchKeys.length === 0) { return rawHtml; } var pattern = new RegExp('(' + matchKeys.join('|') + ')', 'g'); return rawHtml.replace(pattern, function (match) { return options.unescape[match]; }); }
javascript
function (rawHtml) { var matchKeys = Object.keys(options.unescape); if (matchKeys.length === 0) { return rawHtml; } var pattern = new RegExp('(' + matchKeys.join('|') + ')', 'g'); return rawHtml.replace(pattern, function (match) { return options.unescape[match]; }); }
[ "function", "(", "rawHtml", ")", "{", "var", "matchKeys", "=", "Object", ".", "keys", "(", "options", ".", "unescape", ")", ";", "if", "(", "matchKeys", ".", "length", "===", "0", ")", "{", "return", "rawHtml", ";", "}", "var", "pattern", "=", "new", "RegExp", "(", "'('", "+", "matchKeys", ".", "join", "(", "'|'", ")", "+", "')'", ",", "'g'", ")", ";", "return", "rawHtml", ".", "replace", "(", "pattern", ",", "function", "(", "match", ")", "{", "return", "options", ".", "unescape", "[", "match", "]", ";", "}", ")", ";", "}" ]
Replace characters according to 'unescape' option
[ "Replace", "characters", "according", "to", "unescape", "option" ]
335ddff1e5c12e1526579936939211f9b8f37f28
https://github.com/wmluke/grunt-inline-angular-templates/blob/335ddff1e5c12e1526579936939211f9b8f37f28/tasks/inline_angular_templates.js#L26-L35
45,149
renancouto/json2sass
lib/json2sass.js
readFile
function readFile(file) { try { file = require(path.relative(__dirname, file)); } catch (err) { return err; } return file; }
javascript
function readFile(file) { try { file = require(path.relative(__dirname, file)); } catch (err) { return err; } return file; }
[ "function", "readFile", "(", "file", ")", "{", "try", "{", "file", "=", "require", "(", "path", ".", "relative", "(", "__dirname", ",", "file", ")", ")", ";", "}", "catch", "(", "err", ")", "{", "return", "err", ";", "}", "return", "file", ";", "}" ]
read json file @param {string} file [json file] @return {string} [json content]
[ "read", "json", "file" ]
dda57d99a1d7d031fd8dba8b28f3b304019f5983
https://github.com/renancouto/json2sass/blob/dda57d99a1d7d031fd8dba8b28f3b304019f5983/lib/json2sass.js#L14-L22
45,150
renancouto/json2sass
lib/json2sass.js
writeFile
function writeFile(input, output, type) { var json = readFile(input), content = getContent(json, type); fs.writeFile(output, content, function (err) { if (err) { throw err; } console.log('The file "' + output + '" was written successfully!'); }); }
javascript
function writeFile(input, output, type) { var json = readFile(input), content = getContent(json, type); fs.writeFile(output, content, function (err) { if (err) { throw err; } console.log('The file "' + output + '" was written successfully!'); }); }
[ "function", "writeFile", "(", "input", ",", "output", ",", "type", ")", "{", "var", "json", "=", "readFile", "(", "input", ")", ",", "content", "=", "getContent", "(", "json", ",", "type", ")", ";", "fs", ".", "writeFile", "(", "output", ",", "content", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "throw", "err", ";", "}", "console", ".", "log", "(", "'The file \"'", "+", "output", "+", "'\" was written successfully!'", ")", ";", "}", ")", ";", "}" ]
write json content to file @param {string} input [input file] @param {string} output [output file] @param {string} type [file type: sass || scss]
[ "write", "json", "content", "to", "file" ]
dda57d99a1d7d031fd8dba8b28f3b304019f5983
https://github.com/renancouto/json2sass/blob/dda57d99a1d7d031fd8dba8b28f3b304019f5983/lib/json2sass.js#L84-L95
45,151
theboyWhoCriedWoolf/transition-manager
src/parsers/dataParser.js
_extractActions
function _extractActions( opts ) { // main properties const data = opts.data, configState = opts.stateData, stateView = opts.stateView, stateName = opts.stateName; // new defined properties let stateTransitions = [], viewData = opts.viewData, appDataView, action, statePrefix; forein( configState.actions, ( prop, actionName ) => { statePrefix = (stateName+ '->' +actionName); appDataView = data[ prop.target ].view; // Return action data for FSM action = { action : actionName, target : prop.target, _id : statePrefix }; // return ViewData for View manager and append all views viewData[ statePrefix ] = { currentView : stateView, nextView : appDataView, linkedVTransModules : _extractTransitions( prop, stateView, appDataView ), name : actionName }; // // assign fsm action to state stateTransitions[ stateTransitions.length ] = action; }); return { stateTransitions : stateTransitions, viewData : viewData }; }
javascript
function _extractActions( opts ) { // main properties const data = opts.data, configState = opts.stateData, stateView = opts.stateView, stateName = opts.stateName; // new defined properties let stateTransitions = [], viewData = opts.viewData, appDataView, action, statePrefix; forein( configState.actions, ( prop, actionName ) => { statePrefix = (stateName+ '->' +actionName); appDataView = data[ prop.target ].view; // Return action data for FSM action = { action : actionName, target : prop.target, _id : statePrefix }; // return ViewData for View manager and append all views viewData[ statePrefix ] = { currentView : stateView, nextView : appDataView, linkedVTransModules : _extractTransitions( prop, stateView, appDataView ), name : actionName }; // // assign fsm action to state stateTransitions[ stateTransitions.length ] = action; }); return { stateTransitions : stateTransitions, viewData : viewData }; }
[ "function", "_extractActions", "(", "opts", ")", "{", "// main properties", "const", "data", "=", "opts", ".", "data", ",", "configState", "=", "opts", ".", "stateData", ",", "stateView", "=", "opts", ".", "stateView", ",", "stateName", "=", "opts", ".", "stateName", ";", "// new defined properties", "let", "stateTransitions", "=", "[", "]", ",", "viewData", "=", "opts", ".", "viewData", ",", "appDataView", ",", "action", ",", "statePrefix", ";", "forein", "(", "configState", ".", "actions", ",", "(", "prop", ",", "actionName", ")", "=>", "{", "statePrefix", "=", "(", "stateName", "+", "'->'", "+", "actionName", ")", ";", "appDataView", "=", "data", "[", "prop", ".", "target", "]", ".", "view", ";", "// Return action data for FSM", "action", "=", "{", "action", ":", "actionName", ",", "target", ":", "prop", ".", "target", ",", "_id", ":", "statePrefix", "}", ";", "// return ViewData for View manager and append all views", "viewData", "[", "statePrefix", "]", "=", "{", "currentView", ":", "stateView", ",", "nextView", ":", "appDataView", ",", "linkedVTransModules", ":", "_extractTransitions", "(", "prop", ",", "stateView", ",", "appDataView", ")", ",", "name", ":", "actionName", "}", ";", "// // assign fsm action to state", "stateTransitions", "[", "stateTransitions", ".", "length", "]", "=", "action", ";", "}", ")", ";", "return", "{", "stateTransitions", ":", "stateTransitions", ",", "viewData", ":", "viewData", "}", ";", "}" ]
extract the actual transition data for the state @param {object} configState - state data @return {array} transition array - FSM
[ "extract", "the", "actual", "transition", "data", "for", "the", "state" ]
a20fda0bb07c0098bf709ea03770b1ee2a855655
https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/parsers/dataParser.js#L14-L54
45,152
theboyWhoCriedWoolf/transition-manager
src/parsers/dataParser.js
_extractTransitions
function _extractTransitions( prop, stateView, nextView ) { var groupedTransitions = []; if( prop.transitions ) { // if more transitions exist, add them groupedTransitions = prop.transitions.map( ( transitionObject ) => { return transitionObject; }); } prop.views = unique( prop.views, [ stateView, nextView ] ); groupedTransitions.unshift( { transitionType : prop.transitionType, views : prop.views } ); return groupedTransitions; }
javascript
function _extractTransitions( prop, stateView, nextView ) { var groupedTransitions = []; if( prop.transitions ) { // if more transitions exist, add them groupedTransitions = prop.transitions.map( ( transitionObject ) => { return transitionObject; }); } prop.views = unique( prop.views, [ stateView, nextView ] ); groupedTransitions.unshift( { transitionType : prop.transitionType, views : prop.views } ); return groupedTransitions; }
[ "function", "_extractTransitions", "(", "prop", ",", "stateView", ",", "nextView", ")", "{", "var", "groupedTransitions", "=", "[", "]", ";", "if", "(", "prop", ".", "transitions", ")", "{", "// if more transitions exist, add them", "groupedTransitions", "=", "prop", ".", "transitions", ".", "map", "(", "(", "transitionObject", ")", "=>", "{", "return", "transitionObject", ";", "}", ")", ";", "}", "prop", ".", "views", "=", "unique", "(", "prop", ".", "views", ",", "[", "stateView", ",", "nextView", "]", ")", ";", "groupedTransitions", ".", "unshift", "(", "{", "transitionType", ":", "prop", ".", "transitionType", ",", "views", ":", "prop", ".", "views", "}", ")", ";", "return", "groupedTransitions", ";", "}" ]
extract transition information and extract data if transition information is an array of transitions @param {onbject} prop @param {string} stateView - id of state view @param {string} nextView - id of view this transition goes to @return {array} array of transitions fot this action
[ "extract", "transition", "information", "and", "extract", "data", "if", "transition", "information", "is", "an", "array", "of", "transitions" ]
a20fda0bb07c0098bf709ea03770b1ee2a855655
https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/parsers/dataParser.js#L65-L76
45,153
bline/remix
lib/remix.js
ReMix
function ReMix(name) { var args = _.flatten(_.toArray(arguments)); if (_.isString(name) || _.isNull(name) || _.isUndefined(name)) args = args.slice(1); else name = undefined; /** * Unique id used for storing data in RegExp objects * @private */ this._id = genguid(); /** * Current instance options * @private */ this._opt = {}; /** * Stores current unresolved specification * @private */ this._specs = []; /** * Tracking data for relating namespace to match index * @private */ this._matches = []; /** * This ReMix's name * @private */ this._name = name; /** * Used when composing ReMix objects or named RegExp objects. {@link module:lib/remix#scope} * @private */ this._namestack = []; /** * Used to track position when executing regular expression * @private */ this._lastIndex = 0; if (name) this._namestack.push(name); this.options(ReMix.defaultOptions); if (args.length) this.add(args); }
javascript
function ReMix(name) { var args = _.flatten(_.toArray(arguments)); if (_.isString(name) || _.isNull(name) || _.isUndefined(name)) args = args.slice(1); else name = undefined; /** * Unique id used for storing data in RegExp objects * @private */ this._id = genguid(); /** * Current instance options * @private */ this._opt = {}; /** * Stores current unresolved specification * @private */ this._specs = []; /** * Tracking data for relating namespace to match index * @private */ this._matches = []; /** * This ReMix's name * @private */ this._name = name; /** * Used when composing ReMix objects or named RegExp objects. {@link module:lib/remix#scope} * @private */ this._namestack = []; /** * Used to track position when executing regular expression * @private */ this._lastIndex = 0; if (name) this._namestack.push(name); this.options(ReMix.defaultOptions); if (args.length) this.add(args); }
[ "function", "ReMix", "(", "name", ")", "{", "var", "args", "=", "_", ".", "flatten", "(", "_", ".", "toArray", "(", "arguments", ")", ")", ";", "if", "(", "_", ".", "isString", "(", "name", ")", "||", "_", ".", "isNull", "(", "name", ")", "||", "_", ".", "isUndefined", "(", "name", ")", ")", "args", "=", "args", ".", "slice", "(", "1", ")", ";", "else", "name", "=", "undefined", ";", "/**\n * Unique id used for storing data in RegExp objects\n * @private\n */", "this", ".", "_id", "=", "genguid", "(", ")", ";", "/**\n * Current instance options\n * @private\n */", "this", ".", "_opt", "=", "{", "}", ";", "/**\n * Stores current unresolved specification\n * @private\n */", "this", ".", "_specs", "=", "[", "]", ";", "/**\n * Tracking data for relating namespace to match index\n * @private\n */", "this", ".", "_matches", "=", "[", "]", ";", "/**\n * This ReMix's name\n * @private\n */", "this", ".", "_name", "=", "name", ";", "/**\n * Used when composing ReMix objects or named RegExp objects. {@link module:lib/remix#scope}\n * @private\n */", "this", ".", "_namestack", "=", "[", "]", ";", "/**\n * Used to track position when executing regular expression\n * @private\n */", "this", ".", "_lastIndex", "=", "0", ";", "if", "(", "name", ")", "this", ".", "_namestack", ".", "push", "(", "name", ")", ";", "this", ".", "options", "(", "ReMix", ".", "defaultOptions", ")", ";", "if", "(", "args", ".", "length", ")", "this", ".", "add", "(", "args", ")", ";", "}" ]
Construct a new `ReMix` object. The name sets this ReMix's name. The name is used when returning matches. All sub-child matches are namespaced based on the hierarchy of names. `name` is optional. Any arguments after `name` are passed to {@link ReMix#add}. @constructor @alias ReMix @public @param {ReMix~Name} [name] - The name for this ReMix object. @param {ReMix~Spec} spec - Specification for this ReMix object. @example var a1 = new ReMix('a1'), a2 = new ReMix('a2'), str = "foobar"; a1.options({nsDelimiter: '/'}); a1.add({foo: /foo/}); a2.add({bar: /bar/}); a1.add(a2); console.log(a1.exec(str)); // [['foo'], 'a1/foo', 0, 3] console.log(a1.exec(str)); // [['foo'], 'a1/a2/bar', 1, 6]
[ "Construct", "a", "new", "ReMix", "object", "." ]
0b8a00b95d0c9b756e8451d2f1be7d69451236b8
https://github.com/bline/remix/blob/0b8a00b95d0c9b756e8451d2f1be7d69451236b8/lib/remix.js#L51-L97
45,154
vid/SenseBase
lib/form-query.js
shouldFilter
function shouldFilter(filters, anno) { for (var i = filters.length - 1; i > -1; i--) { var filter = filters[i]; if (filter.type === anno.type) { if (_.isEqual(filter.position, anno.position)) { if (anno.isA && anno.isA === 'Date') { var filterDate = new Date(filter.value), fieldDate = new Date(anno.typed.Date); if (filter.operator === '<') { return fieldDate < filterDate; } else if (filter.operator === '>') { return fieldDate > filterDate; } else { return filterDate === fieldDate; } } } else { return filter.value == anno.value; } } } return false; }
javascript
function shouldFilter(filters, anno) { for (var i = filters.length - 1; i > -1; i--) { var filter = filters[i]; if (filter.type === anno.type) { if (_.isEqual(filter.position, anno.position)) { if (anno.isA && anno.isA === 'Date') { var filterDate = new Date(filter.value), fieldDate = new Date(anno.typed.Date); if (filter.operator === '<') { return fieldDate < filterDate; } else if (filter.operator === '>') { return fieldDate > filterDate; } else { return filterDate === fieldDate; } } } else { return filter.value == anno.value; } } } return false; }
[ "function", "shouldFilter", "(", "filters", ",", "anno", ")", "{", "for", "(", "var", "i", "=", "filters", ".", "length", "-", "1", ";", "i", ">", "-", "1", ";", "i", "--", ")", "{", "var", "filter", "=", "filters", "[", "i", "]", ";", "if", "(", "filter", ".", "type", "===", "anno", ".", "type", ")", "{", "if", "(", "_", ".", "isEqual", "(", "filter", ".", "position", ",", "anno", ".", "position", ")", ")", "{", "if", "(", "anno", ".", "isA", "&&", "anno", ".", "isA", "===", "'Date'", ")", "{", "var", "filterDate", "=", "new", "Date", "(", "filter", ".", "value", ")", ",", "fieldDate", "=", "new", "Date", "(", "anno", ".", "typed", ".", "Date", ")", ";", "if", "(", "filter", ".", "operator", "===", "'<'", ")", "{", "return", "fieldDate", "<", "filterDate", ";", "}", "else", "if", "(", "filter", ".", "operator", "===", "'>'", ")", "{", "return", "fieldDate", ">", "filterDate", ";", "}", "else", "{", "return", "filterDate", "===", "fieldDate", ";", "}", "}", "}", "else", "{", "return", "filter", ".", "value", "==", "anno", ".", "value", ";", "}", "}", "}", "return", "false", ";", "}" ]
Return true if this field should be filtered out
[ "Return", "true", "if", "this", "field", "should", "be", "filtered", "out" ]
d60bcf28239e7dde437d8a6bdae41a6921dcd05b
https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/form-query.js#L36-L57
45,155
leoselig/grunt-concat-deps
tasks/concat_deps.js
function(name) { var match = null; list.forEach(function(file) { if(_.indexOf(file.modules, name) >= 0) { match = file; return false; } }); return match; }
javascript
function(name) { var match = null; list.forEach(function(file) { if(_.indexOf(file.modules, name) >= 0) { match = file; return false; } }); return match; }
[ "function", "(", "name", ")", "{", "var", "match", "=", "null", ";", "list", ".", "forEach", "(", "function", "(", "file", ")", "{", "if", "(", "_", ".", "indexOf", "(", "file", ".", "modules", ",", "name", ")", ">=", "0", ")", "{", "match", "=", "file", ";", "return", "false", ";", "}", "}", ")", ";", "return", "match", ";", "}" ]
Gets the file object info for one of its modules name
[ "Gets", "the", "file", "object", "info", "for", "one", "of", "its", "modules", "name" ]
9ad4964f4396b48b994684ae08bb73c0e62a69ea
https://github.com/leoselig/grunt-concat-deps/blob/9ad4964f4396b48b994684ae08bb73c0e62a69ea/tasks/concat_deps.js#L63-L72
45,156
leoselig/grunt-concat-deps
tasks/concat_deps.js
function(module) { if (!module) { return; } var file = fileByModules(module); Array.prototype.push.apply(seen, file.modules); file.requires.forEach(function(module) { // Ignore resoled modules and dependencies in own file if((_.indexOf(resolved, module) < 0) && (_.indexOf(file.modules, module) < 0)) { // Catch circular dependencies if(_.indexOf(seen, module) < 0) { resolve(module); } else { grunt.fail.fatal('Circular dependency detected:\n\t' + file.modules.join(', ') + ' depend on ' + module, 1); } } }); Array.prototype.push.apply(resolved, file.modules); }
javascript
function(module) { if (!module) { return; } var file = fileByModules(module); Array.prototype.push.apply(seen, file.modules); file.requires.forEach(function(module) { // Ignore resoled modules and dependencies in own file if((_.indexOf(resolved, module) < 0) && (_.indexOf(file.modules, module) < 0)) { // Catch circular dependencies if(_.indexOf(seen, module) < 0) { resolve(module); } else { grunt.fail.fatal('Circular dependency detected:\n\t' + file.modules.join(', ') + ' depend on ' + module, 1); } } }); Array.prototype.push.apply(resolved, file.modules); }
[ "function", "(", "module", ")", "{", "if", "(", "!", "module", ")", "{", "return", ";", "}", "var", "file", "=", "fileByModules", "(", "module", ")", ";", "Array", ".", "prototype", ".", "push", ".", "apply", "(", "seen", ",", "file", ".", "modules", ")", ";", "file", ".", "requires", ".", "forEach", "(", "function", "(", "module", ")", "{", "// Ignore resoled modules and dependencies in own file", "if", "(", "(", "_", ".", "indexOf", "(", "resolved", ",", "module", ")", "<", "0", ")", "&&", "(", "_", ".", "indexOf", "(", "file", ".", "modules", ",", "module", ")", "<", "0", ")", ")", "{", "// Catch circular dependencies", "if", "(", "_", ".", "indexOf", "(", "seen", ",", "module", ")", "<", "0", ")", "{", "resolve", "(", "module", ")", ";", "}", "else", "{", "grunt", ".", "fail", ".", "fatal", "(", "'Circular dependency detected:\\n\\t'", "+", "file", ".", "modules", ".", "join", "(", "', '", ")", "+", "' depend on '", "+", "module", ",", "1", ")", ";", "}", "}", "}", ")", ";", "Array", ".", "prototype", ".", "push", ".", "apply", "(", "resolved", ",", "file", ".", "modules", ")", ";", "}" ]
Resolves a module and its dependencies
[ "Resolves", "a", "module", "and", "its", "dependencies" ]
9ad4964f4396b48b994684ae08bb73c0e62a69ea
https://github.com/leoselig/grunt-concat-deps/blob/9ad4964f4396b48b994684ae08bb73c0e62a69ea/tasks/concat_deps.js#L75-L98
45,157
warehouseai/warehouse-models
lib/index.js
WarehouseModels
function WarehouseModels(datastar) { this.Build = require('./build')(datastar, this); this.BuildFile = require('./build-file')(datastar, this); this.BuildHead = require('./build-head')(datastar, this); this.Package = require('./package')(datastar, this); this.PackageCache = require('./package-cache')(datastar, this); this.Version = require('./version')(datastar, this); this.Dependent = require('./dependent')(datastar, this); this.DependentOf = require('./dependent-of')(datastar, this); this.ReleaseLine = require('./release-line')(datastar, this); this.ReleaseLineHead = require('./release-line-head')(datastar, this); this.ReleaseLineDep = require('./release-line-dep')(datastar, this); }
javascript
function WarehouseModels(datastar) { this.Build = require('./build')(datastar, this); this.BuildFile = require('./build-file')(datastar, this); this.BuildHead = require('./build-head')(datastar, this); this.Package = require('./package')(datastar, this); this.PackageCache = require('./package-cache')(datastar, this); this.Version = require('./version')(datastar, this); this.Dependent = require('./dependent')(datastar, this); this.DependentOf = require('./dependent-of')(datastar, this); this.ReleaseLine = require('./release-line')(datastar, this); this.ReleaseLineHead = require('./release-line-head')(datastar, this); this.ReleaseLineDep = require('./release-line-dep')(datastar, this); }
[ "function", "WarehouseModels", "(", "datastar", ")", "{", "this", ".", "Build", "=", "require", "(", "'./build'", ")", "(", "datastar", ",", "this", ")", ";", "this", ".", "BuildFile", "=", "require", "(", "'./build-file'", ")", "(", "datastar", ",", "this", ")", ";", "this", ".", "BuildHead", "=", "require", "(", "'./build-head'", ")", "(", "datastar", ",", "this", ")", ";", "this", ".", "Package", "=", "require", "(", "'./package'", ")", "(", "datastar", ",", "this", ")", ";", "this", ".", "PackageCache", "=", "require", "(", "'./package-cache'", ")", "(", "datastar", ",", "this", ")", ";", "this", ".", "Version", "=", "require", "(", "'./version'", ")", "(", "datastar", ",", "this", ")", ";", "this", ".", "Dependent", "=", "require", "(", "'./dependent'", ")", "(", "datastar", ",", "this", ")", ";", "this", ".", "DependentOf", "=", "require", "(", "'./dependent-of'", ")", "(", "datastar", ",", "this", ")", ";", "this", ".", "ReleaseLine", "=", "require", "(", "'./release-line'", ")", "(", "datastar", ",", "this", ")", ";", "this", ".", "ReleaseLineHead", "=", "require", "(", "'./release-line-head'", ")", "(", "datastar", ",", "this", ")", ";", "this", ".", "ReleaseLineDep", "=", "require", "(", "'./release-line-dep'", ")", "(", "datastar", ",", "this", ")", ";", "}" ]
Make a predictable constructor based object and pass in the context with datastar because we are adding all of the models to this parent `WarehouseModels` constructor and they should have access to each other if needed @param {Datastar} datastar Instance of Datastar
[ "Make", "a", "predictable", "constructor", "based", "object", "and", "pass", "in", "the", "context", "with", "datastar", "because", "we", "are", "adding", "all", "of", "the", "models", "to", "this", "parent", "WarehouseModels", "constructor", "and", "they", "should", "have", "access", "to", "each", "other", "if", "needed" ]
ee65aa759adc6a7f83f4b02608a4e74fe562aa89
https://github.com/warehouseai/warehouse-models/blob/ee65aa759adc6a7f83f4b02608a4e74fe562aa89/lib/index.js#L24-L36
45,158
KyperTech/matter
lib/utils/token.js
_delete
function _delete() { // Remove string token cookiesUtil.deleteCookie(_config2.default.tokenName); // Remove user data envStorage.removeItem(_config2.default.tokenDataName); _logger2.default.log({ description: 'Token was removed.', func: 'delete', obj: 'token' }); }
javascript
function _delete() { // Remove string token cookiesUtil.deleteCookie(_config2.default.tokenName); // Remove user data envStorage.removeItem(_config2.default.tokenDataName); _logger2.default.log({ description: 'Token was removed.', func: 'delete', obj: 'token' }); }
[ "function", "_delete", "(", ")", "{", "// Remove string token", "cookiesUtil", ".", "deleteCookie", "(", "_config2", ".", "default", ".", "tokenName", ")", ";", "// Remove user data", "envStorage", ".", "removeItem", "(", "_config2", ".", "default", ".", "tokenDataName", ")", ";", "_logger2", ".", "default", ".", "log", "(", "{", "description", ":", "'Token was removed.'", ",", "func", ":", "'delete'", ",", "obj", ":", "'token'", "}", ")", ";", "}" ]
Delete token data
[ "Delete", "token", "data" ]
2a8f2fce565fd66d3718a40f35ed857b044e6483
https://github.com/KyperTech/matter/blob/2a8f2fce565fd66d3718a40f35ed857b044e6483/lib/utils/token.js#L104-L113
45,159
vadr-vr/VR-Analytics-JSCore
index.js
initVadRAnalytics
function initVadRAnalytics(params){ timeManager.init(); dataCollector.init(); dataManager.init(); deviceData.init(); user.init(); initState = true; // set initial params if provided _setParams(params); }
javascript
function initVadRAnalytics(params){ timeManager.init(); dataCollector.init(); dataManager.init(); deviceData.init(); user.init(); initState = true; // set initial params if provided _setParams(params); }
[ "function", "initVadRAnalytics", "(", "params", ")", "{", "timeManager", ".", "init", "(", ")", ";", "dataCollector", ".", "init", "(", ")", ";", "dataManager", ".", "init", "(", ")", ";", "deviceData", ".", "init", "(", ")", ";", "user", ".", "init", "(", ")", ";", "initState", "=", "true", ";", "// set initial params if provided", "_setParams", "(", "params", ")", ";", "}" ]
inits the vadr analytics core for a new application @param {*} params default event configuration and extra session metadata
[ "inits", "the", "vadr", "analytics", "core", "for", "a", "new", "application" ]
7e4a493c824c2c1716360dcb6a3bfecfede5df3b
https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/index.js#L26-L39
45,160
vadr-vr/VR-Analytics-JSCore
index.js
_setParams
function _setParams(params){ if(params){ // set the data collection params if(params.defaultEvents){ for (let i = 0; i < params.defaultEvents.length; i++){ dataCollector.configureEventCollection( params.defaultEvents[i].name, params.defaultEvents[i].status, params.defaultEvents[i].timePeriod ); } } // set the session Info if(params.sessionInfo){ for(let i = 0; i < params.sessionInfo.length; i++){ dataManager.addSessionExtra( params.sessionInfo[i].key, params.sessionInfo[i].value ); } } // set pauseOnHeadsetRemove if('pauseOnHeadsetRemove' in params){ timeManager.setRemoveHeadsetPausesPlay(!!params['pauseOnHeadsetRemove']); } } }
javascript
function _setParams(params){ if(params){ // set the data collection params if(params.defaultEvents){ for (let i = 0; i < params.defaultEvents.length; i++){ dataCollector.configureEventCollection( params.defaultEvents[i].name, params.defaultEvents[i].status, params.defaultEvents[i].timePeriod ); } } // set the session Info if(params.sessionInfo){ for(let i = 0; i < params.sessionInfo.length; i++){ dataManager.addSessionExtra( params.sessionInfo[i].key, params.sessionInfo[i].value ); } } // set pauseOnHeadsetRemove if('pauseOnHeadsetRemove' in params){ timeManager.setRemoveHeadsetPausesPlay(!!params['pauseOnHeadsetRemove']); } } }
[ "function", "_setParams", "(", "params", ")", "{", "if", "(", "params", ")", "{", "// set the data collection params", "if", "(", "params", ".", "defaultEvents", ")", "{", "for", "(", "let", "i", "=", "0", ";", "i", "<", "params", ".", "defaultEvents", ".", "length", ";", "i", "++", ")", "{", "dataCollector", ".", "configureEventCollection", "(", "params", ".", "defaultEvents", "[", "i", "]", ".", "name", ",", "params", ".", "defaultEvents", "[", "i", "]", ".", "status", ",", "params", ".", "defaultEvents", "[", "i", "]", ".", "timePeriod", ")", ";", "}", "}", "// set the session Info", "if", "(", "params", ".", "sessionInfo", ")", "{", "for", "(", "let", "i", "=", "0", ";", "i", "<", "params", ".", "sessionInfo", ".", "length", ";", "i", "++", ")", "{", "dataManager", ".", "addSessionExtra", "(", "params", ".", "sessionInfo", "[", "i", "]", ".", "key", ",", "params", ".", "sessionInfo", "[", "i", "]", ".", "value", ")", ";", "}", "}", "// set pauseOnHeadsetRemove", "if", "(", "'pauseOnHeadsetRemove'", "in", "params", ")", "{", "timeManager", ".", "setRemoveHeadsetPausesPlay", "(", "!", "!", "params", "[", "'pauseOnHeadsetRemove'", "]", ")", ";", "}", "}", "}" ]
set the params for the application @param {Object} params @param {Object[]} params.defaultEvents array containing the configuretion for default events @param {Object[]} params.sessionInfo array containing the meta data for session
[ "set", "the", "params", "for", "the", "application" ]
7e4a493c824c2c1716360dcb6a3bfecfede5df3b
https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/index.js#L46-L88
45,161
vid/SenseBase
lib/auth.js
authedByUsername
function authedByUsername(username) { return _.first(_.where(context.authed, { username: username})); }
javascript
function authedByUsername(username) { return _.first(_.where(context.authed, { username: username})); }
[ "function", "authedByUsername", "(", "username", ")", "{", "return", "_", ".", "first", "(", "_", ".", "where", "(", "context", ".", "authed", ",", "{", "username", ":", "username", "}", ")", ")", ";", "}" ]
Retrieve a user record by their username.
[ "Retrieve", "a", "user", "record", "by", "their", "username", "." ]
d60bcf28239e7dde437d8a6bdae41a6921dcd05b
https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/auth.js#L71-L73
45,162
serg-io/backbone-sdb
backbone-sdb.js
httpRequest
function httpRequest(options, body, callback) { // The `processResponse` callback should only be called once. The [http docs](http://nodejs.org/api/http.html#http_event_close_1) // say that a 'close' event can be fired after the 'end' event has been fired. To ensure that the `processResponse` callback // is called only once it is wrapped by `_.once()` var processResponse = _.once(function(error, responseBody, httpResponse) { if (!error && httpResponse && httpResponse.statusCode !== 200) error = httpResponse.statusCode; if (_.isFunction(callback)) callback(error, responseBody, httpResponse); }); var request = http.request(options, function(httpResponse) { var responseBody = ''; httpResponse.on('data', function(data) { responseBody += data.toString(); // 'data' can be a String or a Buffer object }).on('close', function(error) { processResponse(error, responseBody, httpResponse); }).on('end', function() { processResponse(undefined, responseBody, httpResponse); }); }).on('error', processResponse); if (!_.isEmpty(body)) request.write(body); request.end(); }
javascript
function httpRequest(options, body, callback) { // The `processResponse` callback should only be called once. The [http docs](http://nodejs.org/api/http.html#http_event_close_1) // say that a 'close' event can be fired after the 'end' event has been fired. To ensure that the `processResponse` callback // is called only once it is wrapped by `_.once()` var processResponse = _.once(function(error, responseBody, httpResponse) { if (!error && httpResponse && httpResponse.statusCode !== 200) error = httpResponse.statusCode; if (_.isFunction(callback)) callback(error, responseBody, httpResponse); }); var request = http.request(options, function(httpResponse) { var responseBody = ''; httpResponse.on('data', function(data) { responseBody += data.toString(); // 'data' can be a String or a Buffer object }).on('close', function(error) { processResponse(error, responseBody, httpResponse); }).on('end', function() { processResponse(undefined, responseBody, httpResponse); }); }).on('error', processResponse); if (!_.isEmpty(body)) request.write(body); request.end(); }
[ "function", "httpRequest", "(", "options", ",", "body", ",", "callback", ")", "{", "// The `processResponse` callback should only be called once. The [http docs](http://nodejs.org/api/http.html#http_event_close_1)", "// say that a 'close' event can be fired after the 'end' event has been fired. To ensure that the `processResponse` callback", "// is called only once it is wrapped by `_.once()`", "var", "processResponse", "=", "_", ".", "once", "(", "function", "(", "error", ",", "responseBody", ",", "httpResponse", ")", "{", "if", "(", "!", "error", "&&", "httpResponse", "&&", "httpResponse", ".", "statusCode", "!==", "200", ")", "error", "=", "httpResponse", ".", "statusCode", ";", "if", "(", "_", ".", "isFunction", "(", "callback", ")", ")", "callback", "(", "error", ",", "responseBody", ",", "httpResponse", ")", ";", "}", ")", ";", "var", "request", "=", "http", ".", "request", "(", "options", ",", "function", "(", "httpResponse", ")", "{", "var", "responseBody", "=", "''", ";", "httpResponse", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "responseBody", "+=", "data", ".", "toString", "(", ")", ";", "// 'data' can be a String or a Buffer object", "}", ")", ".", "on", "(", "'close'", ",", "function", "(", "error", ")", "{", "processResponse", "(", "error", ",", "responseBody", ",", "httpResponse", ")", ";", "}", ")", ".", "on", "(", "'end'", ",", "function", "(", ")", "{", "processResponse", "(", "undefined", ",", "responseBody", ",", "httpResponse", ")", ";", "}", ")", ";", "}", ")", ".", "on", "(", "'error'", ",", "processResponse", ")", ";", "if", "(", "!", "_", ".", "isEmpty", "(", "body", ")", ")", "request", ".", "write", "(", "body", ")", ";", "request", ".", "end", "(", ")", ";", "}" ]
This is the method that send the actual HTTP requests, caches the response, and executes the callback after the response has been received. @method httpRequest @private @param {Object} options The [HTTP options](http://nodejs.org/api/http.html#http_http_request_options_callback) to use when sending the request. @param {Buffer|String} body The request's body. Must be a [Buffer](http://nodejs.org/api/buffer.html) or a String. Set it to `null`, `undefined`, `false`, or `''` to send a request with no body (a `GET` request for instance). @param {Function} [callback] Callback function to call after the response has been received.
[ "This", "is", "the", "method", "that", "send", "the", "actual", "HTTP", "requests", "caches", "the", "response", "and", "executes", "the", "callback", "after", "the", "response", "has", "been", "received", "." ]
aa43a854470aa28d72d8b4d19c603d91283788b9
https://github.com/serg-io/backbone-sdb/blob/aa43a854470aa28d72d8b4d19c603d91283788b9/backbone-sdb.js#L513-L535
45,163
serg-io/backbone-sdb
backbone-sdb.js
getEC2IAMRole
function getEC2IAMRole(callback) { httpRequest({host: EC2_METADATA_HOST, path: SECURITY_CREDENTIALS_RESOURCE}, null, function(error, role, httpResponse) { callback(error, _.isString(role) ? role.trim() : role, httpResponse); }); }
javascript
function getEC2IAMRole(callback) { httpRequest({host: EC2_METADATA_HOST, path: SECURITY_CREDENTIALS_RESOURCE}, null, function(error, role, httpResponse) { callback(error, _.isString(role) ? role.trim() : role, httpResponse); }); }
[ "function", "getEC2IAMRole", "(", "callback", ")", "{", "httpRequest", "(", "{", "host", ":", "EC2_METADATA_HOST", ",", "path", ":", "SECURITY_CREDENTIALS_RESOURCE", "}", ",", "null", ",", "function", "(", "error", ",", "role", ",", "httpResponse", ")", "{", "callback", "(", "error", ",", "_", ".", "isString", "(", "role", ")", "?", "role", ".", "trim", "(", ")", ":", "role", ",", "httpResponse", ")", ";", "}", ")", ";", "}" ]
Gets the EC2 IAM role name from the metadata service. @method getEC2IAMRole @private @param {Function} callback Callback function that receives the role returned by the metadata service.
[ "Gets", "the", "EC2", "IAM", "role", "name", "from", "the", "metadata", "service", "." ]
aa43a854470aa28d72d8b4d19c603d91283788b9
https://github.com/serg-io/backbone-sdb/blob/aa43a854470aa28d72d8b4d19c603d91283788b9/backbone-sdb.js#L544-L548
45,164
serg-io/backbone-sdb
backbone-sdb.js
getEC2IAMSecurityCredentials
function getEC2IAMSecurityCredentials(role, callback) { httpRequest({host: EC2_METADATA_HOST, path: SECURITY_CREDENTIALS_RESOURCE + role}, null, function(error, jsonStr, httpResponse) { var credentials; try { credentials = JSON.parse(jsonStr); } catch (parseError) { if (!error) error = parseError; } callback(error, credentials, httpResponse); }); }
javascript
function getEC2IAMSecurityCredentials(role, callback) { httpRequest({host: EC2_METADATA_HOST, path: SECURITY_CREDENTIALS_RESOURCE + role}, null, function(error, jsonStr, httpResponse) { var credentials; try { credentials = JSON.parse(jsonStr); } catch (parseError) { if (!error) error = parseError; } callback(error, credentials, httpResponse); }); }
[ "function", "getEC2IAMSecurityCredentials", "(", "role", ",", "callback", ")", "{", "httpRequest", "(", "{", "host", ":", "EC2_METADATA_HOST", ",", "path", ":", "SECURITY_CREDENTIALS_RESOURCE", "+", "role", "}", ",", "null", ",", "function", "(", "error", ",", "jsonStr", ",", "httpResponse", ")", "{", "var", "credentials", ";", "try", "{", "credentials", "=", "JSON", ".", "parse", "(", "jsonStr", ")", ";", "}", "catch", "(", "parseError", ")", "{", "if", "(", "!", "error", ")", "error", "=", "parseError", ";", "}", "callback", "(", "error", ",", "credentials", ",", "httpResponse", ")", ";", "}", ")", ";", "}" ]
Gets the security credentials from the metadata service. @method getEC2IAMSecurityCredentials @private @param {String} role IAM role name. @param {Function} callback Callback function that receives the parsed credentials object returned by the metadata service.
[ "Gets", "the", "security", "credentials", "from", "the", "metadata", "service", "." ]
aa43a854470aa28d72d8b4d19c603d91283788b9
https://github.com/serg-io/backbone-sdb/blob/aa43a854470aa28d72d8b4d19c603d91283788b9/backbone-sdb.js#L558-L569
45,165
serg-io/backbone-sdb
backbone-sdb.js
needsToLoadEC2IAMRoleCredentials
function needsToLoadEC2IAMRoleCredentials() { if (!accessKey || !secretKey) return true; if (credentialsExpiration === null) return false; return (credentialsExpiration.getTime() - Date.now()) < CREDENTIALS_EXPIRATION_THRESHOLD; }
javascript
function needsToLoadEC2IAMRoleCredentials() { if (!accessKey || !secretKey) return true; if (credentialsExpiration === null) return false; return (credentialsExpiration.getTime() - Date.now()) < CREDENTIALS_EXPIRATION_THRESHOLD; }
[ "function", "needsToLoadEC2IAMRoleCredentials", "(", ")", "{", "if", "(", "!", "accessKey", "||", "!", "secretKey", ")", "return", "true", ";", "if", "(", "credentialsExpiration", "===", "null", ")", "return", "false", ";", "return", "(", "credentialsExpiration", ".", "getTime", "(", ")", "-", "Date", ".", "now", "(", ")", ")", "<", "CREDENTIALS_EXPIRATION_THRESHOLD", ";", "}" ]
Helper function that returns `true` if getting the security credentials from the metadata service is needed or `false` otherwise. @method needsToLoadEC2IAMRoleCredentials @private
[ "Helper", "function", "that", "returns", "true", "if", "getting", "the", "security", "credentials", "from", "the", "metadata", "service", "is", "needed", "or", "false", "otherwise", "." ]
aa43a854470aa28d72d8b4d19c603d91283788b9
https://github.com/serg-io/backbone-sdb/blob/aa43a854470aa28d72d8b4d19c603d91283788b9/backbone-sdb.js#L577-L581
45,166
jriecken/asset-smasher
lib/asset-smasher.js
function (cb) { this.reset(); var bundle = this.bundle; var self = this; async.waterfall([ function (wfCb) { if (self.noclean) { wfCb(); } else { // Remove the output directory if it exists existsCompat(self.outputTo, function (exists) { if (exists) { if (self.verbose) { console.log('compileAssets: removing output directory: ' + self.outputTo); } rimraf(self.outputTo, wfCb); } else { wfCb(); } }); } }, function (wfCb) { if (self.verbose) { console.log('compileAssets: starting asset discovery phase.'); } executePhase(self.phases.discovery, bundle, wfCb); }, function (b, wfCb) { if (self.verbose) { console.log('compileAssets: starting compilation phase.'); } try { // Get the correct order of asset dependencies var orderedAssets = bundle.getProcessingOrder().map(function (assetFilePath) { return bundle.getAsset(assetFilePath); }); async.eachSeries(orderedAssets, function (asset, eachCb) { setImmediateCompat(function() { executePhase(self.phases.compilation, asset, eachCb); }); }, wfCb); } catch (e) { wfCb(e); } }, function (wfCb) { if (self.verbose) { console.log('compileAssets: starting post-compilation phase.'); } async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) { executePhase(self.phases.postCompilation, asset, eachCb); }, wfCb); }, function (wfCb) { if (self.verbose) { console.log('compileAssets: starting output phase.'); } async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) { executePhase(self.phases.output, asset, eachCb); }, wfCb); } ], cb); }
javascript
function (cb) { this.reset(); var bundle = this.bundle; var self = this; async.waterfall([ function (wfCb) { if (self.noclean) { wfCb(); } else { // Remove the output directory if it exists existsCompat(self.outputTo, function (exists) { if (exists) { if (self.verbose) { console.log('compileAssets: removing output directory: ' + self.outputTo); } rimraf(self.outputTo, wfCb); } else { wfCb(); } }); } }, function (wfCb) { if (self.verbose) { console.log('compileAssets: starting asset discovery phase.'); } executePhase(self.phases.discovery, bundle, wfCb); }, function (b, wfCb) { if (self.verbose) { console.log('compileAssets: starting compilation phase.'); } try { // Get the correct order of asset dependencies var orderedAssets = bundle.getProcessingOrder().map(function (assetFilePath) { return bundle.getAsset(assetFilePath); }); async.eachSeries(orderedAssets, function (asset, eachCb) { setImmediateCompat(function() { executePhase(self.phases.compilation, asset, eachCb); }); }, wfCb); } catch (e) { wfCb(e); } }, function (wfCb) { if (self.verbose) { console.log('compileAssets: starting post-compilation phase.'); } async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) { executePhase(self.phases.postCompilation, asset, eachCb); }, wfCb); }, function (wfCb) { if (self.verbose) { console.log('compileAssets: starting output phase.'); } async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) { executePhase(self.phases.output, asset, eachCb); }, wfCb); } ], cb); }
[ "function", "(", "cb", ")", "{", "this", ".", "reset", "(", ")", ";", "var", "bundle", "=", "this", ".", "bundle", ";", "var", "self", "=", "this", ";", "async", ".", "waterfall", "(", "[", "function", "(", "wfCb", ")", "{", "if", "(", "self", ".", "noclean", ")", "{", "wfCb", "(", ")", ";", "}", "else", "{", "// Remove the output directory if it exists", "existsCompat", "(", "self", ".", "outputTo", ",", "function", "(", "exists", ")", "{", "if", "(", "exists", ")", "{", "if", "(", "self", ".", "verbose", ")", "{", "console", ".", "log", "(", "'compileAssets: removing output directory: '", "+", "self", ".", "outputTo", ")", ";", "}", "rimraf", "(", "self", ".", "outputTo", ",", "wfCb", ")", ";", "}", "else", "{", "wfCb", "(", ")", ";", "}", "}", ")", ";", "}", "}", ",", "function", "(", "wfCb", ")", "{", "if", "(", "self", ".", "verbose", ")", "{", "console", ".", "log", "(", "'compileAssets: starting asset discovery phase.'", ")", ";", "}", "executePhase", "(", "self", ".", "phases", ".", "discovery", ",", "bundle", ",", "wfCb", ")", ";", "}", ",", "function", "(", "b", ",", "wfCb", ")", "{", "if", "(", "self", ".", "verbose", ")", "{", "console", ".", "log", "(", "'compileAssets: starting compilation phase.'", ")", ";", "}", "try", "{", "// Get the correct order of asset dependencies", "var", "orderedAssets", "=", "bundle", ".", "getProcessingOrder", "(", ")", ".", "map", "(", "function", "(", "assetFilePath", ")", "{", "return", "bundle", ".", "getAsset", "(", "assetFilePath", ")", ";", "}", ")", ";", "async", ".", "eachSeries", "(", "orderedAssets", ",", "function", "(", "asset", ",", "eachCb", ")", "{", "setImmediateCompat", "(", "function", "(", ")", "{", "executePhase", "(", "self", ".", "phases", ".", "compilation", ",", "asset", ",", "eachCb", ")", ";", "}", ")", ";", "}", ",", "wfCb", ")", ";", "}", "catch", "(", "e", ")", "{", "wfCb", "(", "e", ")", ";", "}", "}", ",", "function", "(", "wfCb", ")", "{", "if", "(", "self", ".", "verbose", ")", "{", "console", ".", "log", "(", "'compileAssets: starting post-compilation phase.'", ")", ";", "}", "async", ".", "eachLimit", "(", "bundle", ".", "getAllAssets", "(", ")", ",", "50", ",", "function", "(", "asset", ",", "eachCb", ")", "{", "executePhase", "(", "self", ".", "phases", ".", "postCompilation", ",", "asset", ",", "eachCb", ")", ";", "}", ",", "wfCb", ")", ";", "}", ",", "function", "(", "wfCb", ")", "{", "if", "(", "self", ".", "verbose", ")", "{", "console", ".", "log", "(", "'compileAssets: starting output phase.'", ")", ";", "}", "async", ".", "eachLimit", "(", "bundle", ".", "getAllAssets", "(", ")", ",", "50", ",", "function", "(", "asset", ",", "eachCb", ")", "{", "executePhase", "(", "self", ".", "phases", ".", "output", ",", "asset", ",", "eachCb", ")", ";", "}", ",", "wfCb", ")", ";", "}", "]", ",", "cb", ")", ";", "}" ]
Compile all the assets according to the options
[ "Compile", "all", "the", "assets", "according", "to", "the", "options" ]
c627449b01f5da892683895915f74baa9994a475
https://github.com/jriecken/asset-smasher/blob/c627449b01f5da892683895915f74baa9994a475/lib/asset-smasher.js#L168-L230
45,167
jriecken/asset-smasher
lib/asset-smasher.js
function (cb) { this.reset(); var bundle = this.bundle; var self = this; async.waterfall([ function (wfCb) { if (self.verbose) { console.log('findAssets: starting discovery phase'); } executePhase(self.phases.discovery, bundle, wfCb); }, function (b, wfCb) { if (self.verbose) { console.log('findAssets: starting name transformation phase'); } async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) { executePhase(self.phases.nameTransformation, asset, eachCb); }, wfCb); } ], cb); }
javascript
function (cb) { this.reset(); var bundle = this.bundle; var self = this; async.waterfall([ function (wfCb) { if (self.verbose) { console.log('findAssets: starting discovery phase'); } executePhase(self.phases.discovery, bundle, wfCb); }, function (b, wfCb) { if (self.verbose) { console.log('findAssets: starting name transformation phase'); } async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) { executePhase(self.phases.nameTransformation, asset, eachCb); }, wfCb); } ], cb); }
[ "function", "(", "cb", ")", "{", "this", ".", "reset", "(", ")", ";", "var", "bundle", "=", "this", ".", "bundle", ";", "var", "self", "=", "this", ";", "async", ".", "waterfall", "(", "[", "function", "(", "wfCb", ")", "{", "if", "(", "self", ".", "verbose", ")", "{", "console", ".", "log", "(", "'findAssets: starting discovery phase'", ")", ";", "}", "executePhase", "(", "self", ".", "phases", ".", "discovery", ",", "bundle", ",", "wfCb", ")", ";", "}", ",", "function", "(", "b", ",", "wfCb", ")", "{", "if", "(", "self", ".", "verbose", ")", "{", "console", ".", "log", "(", "'findAssets: starting name transformation phase'", ")", ";", "}", "async", ".", "eachLimit", "(", "bundle", ".", "getAllAssets", "(", ")", ",", "50", ",", "function", "(", "asset", ",", "eachCb", ")", "{", "executePhase", "(", "self", ".", "phases", ".", "nameTransformation", ",", "asset", ",", "eachCb", ")", ";", "}", ",", "wfCb", ")", ";", "}", "]", ",", "cb", ")", ";", "}" ]
Find, but do not compile all the assets according to the options.
[ "Find", "but", "do", "not", "compile", "all", "the", "assets", "according", "to", "the", "options", "." ]
c627449b01f5da892683895915f74baa9994a475
https://github.com/jriecken/asset-smasher/blob/c627449b01f5da892683895915f74baa9994a475/lib/asset-smasher.js#L292-L312
45,168
jriecken/asset-smasher
lib/asset-smasher.js
function () { var bundle = this.bundle; var order = bundle.getProcessingOrder(); return order.map(function (file ) { return bundle.getAsset(file).logicalPath; }); }
javascript
function () { var bundle = this.bundle; var order = bundle.getProcessingOrder(); return order.map(function (file ) { return bundle.getAsset(file).logicalPath; }); }
[ "function", "(", ")", "{", "var", "bundle", "=", "this", ".", "bundle", ";", "var", "order", "=", "bundle", ".", "getProcessingOrder", "(", ")", ";", "return", "order", ".", "map", "(", "function", "(", "file", ")", "{", "return", "bundle", ".", "getAsset", "(", "file", ")", ".", "logicalPath", ";", "}", ")", ";", "}" ]
Get a list of logical paths in the order that the assets will be processed in
[ "Get", "a", "list", "of", "logical", "paths", "in", "the", "order", "that", "the", "assets", "will", "be", "processed", "in" ]
c627449b01f5da892683895915f74baa9994a475
https://github.com/jriecken/asset-smasher/blob/c627449b01f5da892683895915f74baa9994a475/lib/asset-smasher.js#L346-L352
45,169
binduwavell/generator-alfresco-common
lib/mem-fs-utils.js
function (storeOrEditor, path) { debug('Checking if ' + path + ' exists in the in-memory store.'); var retv = false; this.processInMemoryStore(storeOrEditor, file => { debug('Evaluating ' + file.path + ' in state ' + file.state + ' with content length ' + (file && file.contents ? file.contents.length : 'unknown')); if (file.path.indexOf(path) === 0 && file.contents !== null && file.state !== 'deleted') { debug('FOUND'); retv = true; } }); debug('RESULT ' + retv); return retv; }
javascript
function (storeOrEditor, path) { debug('Checking if ' + path + ' exists in the in-memory store.'); var retv = false; this.processInMemoryStore(storeOrEditor, file => { debug('Evaluating ' + file.path + ' in state ' + file.state + ' with content length ' + (file && file.contents ? file.contents.length : 'unknown')); if (file.path.indexOf(path) === 0 && file.contents !== null && file.state !== 'deleted') { debug('FOUND'); retv = true; } }); debug('RESULT ' + retv); return retv; }
[ "function", "(", "storeOrEditor", ",", "path", ")", "{", "debug", "(", "'Checking if '", "+", "path", "+", "' exists in the in-memory store.'", ")", ";", "var", "retv", "=", "false", ";", "this", ".", "processInMemoryStore", "(", "storeOrEditor", ",", "file", "=>", "{", "debug", "(", "'Evaluating '", "+", "file", ".", "path", "+", "' in state '", "+", "file", ".", "state", "+", "' with content length '", "+", "(", "file", "&&", "file", ".", "contents", "?", "file", ".", "contents", ".", "length", ":", "'unknown'", ")", ")", ";", "if", "(", "file", ".", "path", ".", "indexOf", "(", "path", ")", "===", "0", "&&", "file", ".", "contents", "!==", "null", "&&", "file", ".", "state", "!==", "'deleted'", ")", "{", "debug", "(", "'FOUND'", ")", ";", "retv", "=", "true", ";", "}", "}", ")", ";", "debug", "(", "'RESULT '", "+", "retv", ")", ";", "return", "retv", ";", "}" ]
Check if a path exists in the provided memfs Store. As memfs only stores files (and not paths) we simply make sure we find at least one valid file with the provided path as a prefix (or complete match). I'm not aware of @param {!Store|!EditionInterface} storeOrEditor @param {string} file path or folder path
[ "Check", "if", "a", "path", "exists", "in", "the", "provided", "memfs", "Store", "." ]
d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4
https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/mem-fs-utils.js#L16-L28
45,170
binduwavell/generator-alfresco-common
lib/mem-fs-utils.js
function (storeOrEditor, from, to) { debug('Performing inMemoryCopy from ' + from + ' to ' + to + '.'); var fromLen = from.length; this.processInMemoryStore(storeOrEditor, (file, store) => { var idx = file.path.indexOf(from); if (idx === 0 && file.contents !== null && file.state !== 'deleted') { var absTo = path.join(to, file.path.substr(fromLen)); // exact match so we are copying a single file and not a folder if (fromLen === file.path.length) { absTo = path.join(to, path.basename(file.path)); } debug('CREATING COPY IN-MEMORY: ' + absTo); var newFile = store.get(absTo); newFile.contents = file.contents; newFile.state = 'modified'; store.add(newFile); } }); }
javascript
function (storeOrEditor, from, to) { debug('Performing inMemoryCopy from ' + from + ' to ' + to + '.'); var fromLen = from.length; this.processInMemoryStore(storeOrEditor, (file, store) => { var idx = file.path.indexOf(from); if (idx === 0 && file.contents !== null && file.state !== 'deleted') { var absTo = path.join(to, file.path.substr(fromLen)); // exact match so we are copying a single file and not a folder if (fromLen === file.path.length) { absTo = path.join(to, path.basename(file.path)); } debug('CREATING COPY IN-MEMORY: ' + absTo); var newFile = store.get(absTo); newFile.contents = file.contents; newFile.state = 'modified'; store.add(newFile); } }); }
[ "function", "(", "storeOrEditor", ",", "from", ",", "to", ")", "{", "debug", "(", "'Performing inMemoryCopy from '", "+", "from", "+", "' to '", "+", "to", "+", "'.'", ")", ";", "var", "fromLen", "=", "from", ".", "length", ";", "this", ".", "processInMemoryStore", "(", "storeOrEditor", ",", "(", "file", ",", "store", ")", "=>", "{", "var", "idx", "=", "file", ".", "path", ".", "indexOf", "(", "from", ")", ";", "if", "(", "idx", "===", "0", "&&", "file", ".", "contents", "!==", "null", "&&", "file", ".", "state", "!==", "'deleted'", ")", "{", "var", "absTo", "=", "path", ".", "join", "(", "to", ",", "file", ".", "path", ".", "substr", "(", "fromLen", ")", ")", ";", "// exact match so we are copying a single file and not a folder", "if", "(", "fromLen", "===", "file", ".", "path", ".", "length", ")", "{", "absTo", "=", "path", ".", "join", "(", "to", ",", "path", ".", "basename", "(", "file", ".", "path", ")", ")", ";", "}", "debug", "(", "'CREATING COPY IN-MEMORY: '", "+", "absTo", ")", ";", "var", "newFile", "=", "store", ".", "get", "(", "absTo", ")", ";", "newFile", ".", "contents", "=", "file", ".", "contents", ";", "newFile", ".", "state", "=", "'modified'", ";", "store", ".", "add", "(", "newFile", ")", ";", "}", "}", ")", ";", "}" ]
Given the path for a virtual file or folder and a destination path perform a copy completely within mem-fs. @param {!Store|!EditionInterface} storeOrEditor @param {string} from - file path or folder path @param {string} to - folder path
[ "Given", "the", "path", "for", "a", "virtual", "file", "or", "folder", "and", "a", "destination", "path", "perform", "a", "copy", "completely", "within", "mem", "-", "fs", "." ]
d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4
https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/mem-fs-utils.js#L38-L56
45,171
binduwavell/generator-alfresco-common
lib/mem-fs-utils.js
function (storeOrEditor, from, to) { debug('Performing inMemoryMove from ' + from + ' to ' + to); var store = (storeOrEditor && storeOrEditor.store ? storeOrEditor.store : storeOrEditor); var memFsEditor = require('mem-fs-editor').create(store); var fromLen = from.length; store.each(function (file) { var idx = file.path.indexOf(from); if (idx === 0 && file.contents !== null && file.state !== 'deleted') { var absTo = path.join(to, file.path.substr(fromLen)); // exact match so we are copying a single file and not a folder if (fromLen === file.path.length) { absTo = path.join(to, path.basename(file.path)); } debug('IN-MEMORY MOVING FROM: ' + file.path + ' TO: ' + absTo); memFsEditor.move(file.path, absTo); } }); }
javascript
function (storeOrEditor, from, to) { debug('Performing inMemoryMove from ' + from + ' to ' + to); var store = (storeOrEditor && storeOrEditor.store ? storeOrEditor.store : storeOrEditor); var memFsEditor = require('mem-fs-editor').create(store); var fromLen = from.length; store.each(function (file) { var idx = file.path.indexOf(from); if (idx === 0 && file.contents !== null && file.state !== 'deleted') { var absTo = path.join(to, file.path.substr(fromLen)); // exact match so we are copying a single file and not a folder if (fromLen === file.path.length) { absTo = path.join(to, path.basename(file.path)); } debug('IN-MEMORY MOVING FROM: ' + file.path + ' TO: ' + absTo); memFsEditor.move(file.path, absTo); } }); }
[ "function", "(", "storeOrEditor", ",", "from", ",", "to", ")", "{", "debug", "(", "'Performing inMemoryMove from '", "+", "from", "+", "' to '", "+", "to", ")", ";", "var", "store", "=", "(", "storeOrEditor", "&&", "storeOrEditor", ".", "store", "?", "storeOrEditor", ".", "store", ":", "storeOrEditor", ")", ";", "var", "memFsEditor", "=", "require", "(", "'mem-fs-editor'", ")", ".", "create", "(", "store", ")", ";", "var", "fromLen", "=", "from", ".", "length", ";", "store", ".", "each", "(", "function", "(", "file", ")", "{", "var", "idx", "=", "file", ".", "path", ".", "indexOf", "(", "from", ")", ";", "if", "(", "idx", "===", "0", "&&", "file", ".", "contents", "!==", "null", "&&", "file", ".", "state", "!==", "'deleted'", ")", "{", "var", "absTo", "=", "path", ".", "join", "(", "to", ",", "file", ".", "path", ".", "substr", "(", "fromLen", ")", ")", ";", "// exact match so we are copying a single file and not a folder", "if", "(", "fromLen", "===", "file", ".", "path", ".", "length", ")", "{", "absTo", "=", "path", ".", "join", "(", "to", ",", "path", ".", "basename", "(", "file", ".", "path", ")", ")", ";", "}", "debug", "(", "'IN-MEMORY MOVING FROM: '", "+", "file", ".", "path", "+", "' TO: '", "+", "absTo", ")", ";", "memFsEditor", ".", "move", "(", "file", ".", "path", ",", "absTo", ")", ";", "}", "}", ")", ";", "}" ]
Given the path for a virtual file or folder and a destination path perform a move completely within mem-fs. @param {!Store|!EditionInterface} storeOrEditor @param {string} from - file path or folder path @param {string} to - folder path
[ "Given", "the", "path", "for", "a", "virtual", "file", "or", "folder", "and", "a", "destination", "path", "perform", "a", "move", "completely", "within", "mem", "-", "fs", "." ]
d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4
https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/mem-fs-utils.js#L66-L83
45,172
binduwavell/generator-alfresco-common
lib/mem-fs-utils.js
function (storeOrEditor, logFn) { debug('Dumping contents of in-memory store.'); var logFunc = logFn || console.log; this.processInMemoryStore(storeOrEditor, file => { logFunc.call(this, file.path + ' [STATE:' + file.state + ']'); /* logFunc.call(this, JSON.stringify(file, function (k, v) { if (k === '_contents') { if (undefined !== v) { return 'data'; } } return v; })); */ }); }
javascript
function (storeOrEditor, logFn) { debug('Dumping contents of in-memory store.'); var logFunc = logFn || console.log; this.processInMemoryStore(storeOrEditor, file => { logFunc.call(this, file.path + ' [STATE:' + file.state + ']'); /* logFunc.call(this, JSON.stringify(file, function (k, v) { if (k === '_contents') { if (undefined !== v) { return 'data'; } } return v; })); */ }); }
[ "function", "(", "storeOrEditor", ",", "logFn", ")", "{", "debug", "(", "'Dumping contents of in-memory store.'", ")", ";", "var", "logFunc", "=", "logFn", "||", "console", ".", "log", ";", "this", ".", "processInMemoryStore", "(", "storeOrEditor", ",", "file", "=>", "{", "logFunc", ".", "call", "(", "this", ",", "file", ".", "path", "+", "' [STATE:'", "+", "file", ".", "state", "+", "']'", ")", ";", "/*\n logFunc.call(this, JSON.stringify(file, function (k, v) {\n if (k === '_contents') {\n if (undefined !== v) {\n return 'data';\n }\n }\n return v;\n }));\n */", "}", ")", ";", "}" ]
Log file path and sate information via a log function or console.log if not provided. @param {!Store|!EditionInterface} storeOrEditor @param {(Function|undefined)} logFn
[ "Log", "file", "path", "and", "sate", "information", "via", "a", "log", "function", "or", "console", ".", "log", "if", "not", "provided", "." ]
d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4
https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/mem-fs-utils.js#L91-L107
45,173
vid/SenseBase
web/dashboard/dashboard.js
processReconcile
function processReconcile(field, toSet, setSep, reconcileSet) { // process validated updates if (reconcileSet) { reconcileSet.forEach(function(t) { var s = { uri: t.uri }; s[toSet] = t.setVal; context.pubsub.item.save(s); }); return; } }
javascript
function processReconcile(field, toSet, setSep, reconcileSet) { // process validated updates if (reconcileSet) { reconcileSet.forEach(function(t) { var s = { uri: t.uri }; s[toSet] = t.setVal; context.pubsub.item.save(s); }); return; } }
[ "function", "processReconcile", "(", "field", ",", "toSet", ",", "setSep", ",", "reconcileSet", ")", "{", "// process validated updates", "if", "(", "reconcileSet", ")", "{", "reconcileSet", ".", "forEach", "(", "function", "(", "t", ")", "{", "var", "s", "=", "{", "uri", ":", "t", ".", "uri", "}", ";", "s", "[", "toSet", "]", "=", "t", ".", "setVal", ";", "context", ".", "pubsub", ".", "item", ".", "save", "(", "s", ")", ";", "}", ")", ";", "return", ";", "}", "}" ]
process validated updates
[ "process", "validated", "updates" ]
d60bcf28239e7dde437d8a6bdae41a6921dcd05b
https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/dashboard/dashboard.js#L190-L200
45,174
jonschlinkert/question-cache
index.js
Questions
function Questions(options) { if (!(this instanceof Questions)) { return new Questions(options); } debug('initializing from <%s>', __filename); Options.call(this, utils.omitEmpty(options || {})); use(this); this.initQuestions(this.options); }
javascript
function Questions(options) { if (!(this instanceof Questions)) { return new Questions(options); } debug('initializing from <%s>', __filename); Options.call(this, utils.omitEmpty(options || {})); use(this); this.initQuestions(this.options); }
[ "function", "Questions", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Questions", ")", ")", "{", "return", "new", "Questions", "(", "options", ")", ";", "}", "debug", "(", "'initializing from <%s>'", ",", "__filename", ")", ";", "Options", ".", "call", "(", "this", ",", "utils", ".", "omitEmpty", "(", "options", "||", "{", "}", ")", ")", ";", "use", "(", "this", ")", ";", "this", ".", "initQuestions", "(", "this", ".", "options", ")", ";", "}" ]
Create an instance of `Questions` with the given `options`. ```js var Questions = new Questions(options); ``` @param {Object} `options` question cache options @api public
[ "Create", "an", "instance", "of", "Questions", "with", "the", "given", "options", "." ]
85e4f1e00be1f230c435101f70c5da4227ce51ff
https://github.com/jonschlinkert/question-cache/blob/85e4f1e00be1f230c435101f70c5da4227ce51ff/index.js#L27-L35
45,175
usecanvas/share-js-stream
index.js
ShareJSStream
function ShareJSStream(ws, options) { options = options || {}; options.keepAlive = options.keepAlive !== undefined ? options.keepAlive : KEEP_ALIVE; this.debug = options.debug === true; this.ws = ws; this.headers = this.ws.upgradeReq.headers; this.remoteAddress = this.ws.upgradeReq.connection.remoteAddress; if (this.debug) { this.logger = logfmt.namespace({ ns: 'share-js-stream' }); } Duplex.call(this, { objectMode: true }); /** * Send a `null` message to the ws so that the connection is kept alive. * * This may not be necessary on all platforms. * * @method keepAlive * @private */ this.keepAlive = function keepAlive() { this.log({ evt: 'keepAlive' }); this.ws.send(null); }.bind(this); /** * Handle a closed ws client. * * This is called when the `close` event is emitted on the ws client. It: * * - Clears the keep alive interval (if there is one) * - Pushes `null` to end the stream * - Emits `close` on the stream * * @method onWsClose * @private * @param {Number} code the reason code for why the client was closed * @param {String} message a message accompanying the close */ this.onWsClose = function onWsClose(code, message) { if (this.keepAliveInterval) { clearInterval(this.keepAliveInterval); } this.log({ evt: 'wsClose', code: code, message: message }); this.push(null); this.emit('close'); }.bind(this); /** * Push a message received on the ws client as an object to the stream. * * If JSON parsing of the message fails, an error event will be emitted on the * stream. * * @method onWsMessage * @private * @param {String} msg a JSON-encoded message received on the ws client */ this.onWsMessage = function onWsMessage(msg) { this.log({ evt: 'wsMessage', msg: msg }); try { msg = JSON.parse(msg); } catch(_) { var err = new Error('Client sent invalid JSON'); err.code = CLOSE_UNSUPPORTED; this.emit('error', err); return; } this.push(msg); }.bind(this); /** * Handle the stream ending by closing the ws client connection. * * @method onStreamEnd * @private */ this.onStreamEnd = function onStreamEnd() { this.log({ evt: 'streamEnd' }); this.ws.close(CLOSE_NORMAL); }.bind(this); /** * Handle a stream error by closing the ws client connection. * * @method onStreamError * @private * @param {Error} err the error emitted on the stream */ this.onStreamError = function onStreamError(err) { this.log({ evt: 'streamError', err: err.message }); this.ws.close(err.code || CLOSE_ERROR, err.message); }.bind(this); this.ws.on('close', this.onWsClose); this.ws.on('message', this.onWsMessage); this.on('error', this.onStreamError); this.on('end', this.onStreamEnd); if (options.keepAlive) { this.keepAliveInterval = setInterval(this.keepAlive, options.keepAlive); } }
javascript
function ShareJSStream(ws, options) { options = options || {}; options.keepAlive = options.keepAlive !== undefined ? options.keepAlive : KEEP_ALIVE; this.debug = options.debug === true; this.ws = ws; this.headers = this.ws.upgradeReq.headers; this.remoteAddress = this.ws.upgradeReq.connection.remoteAddress; if (this.debug) { this.logger = logfmt.namespace({ ns: 'share-js-stream' }); } Duplex.call(this, { objectMode: true }); /** * Send a `null` message to the ws so that the connection is kept alive. * * This may not be necessary on all platforms. * * @method keepAlive * @private */ this.keepAlive = function keepAlive() { this.log({ evt: 'keepAlive' }); this.ws.send(null); }.bind(this); /** * Handle a closed ws client. * * This is called when the `close` event is emitted on the ws client. It: * * - Clears the keep alive interval (if there is one) * - Pushes `null` to end the stream * - Emits `close` on the stream * * @method onWsClose * @private * @param {Number} code the reason code for why the client was closed * @param {String} message a message accompanying the close */ this.onWsClose = function onWsClose(code, message) { if (this.keepAliveInterval) { clearInterval(this.keepAliveInterval); } this.log({ evt: 'wsClose', code: code, message: message }); this.push(null); this.emit('close'); }.bind(this); /** * Push a message received on the ws client as an object to the stream. * * If JSON parsing of the message fails, an error event will be emitted on the * stream. * * @method onWsMessage * @private * @param {String} msg a JSON-encoded message received on the ws client */ this.onWsMessage = function onWsMessage(msg) { this.log({ evt: 'wsMessage', msg: msg }); try { msg = JSON.parse(msg); } catch(_) { var err = new Error('Client sent invalid JSON'); err.code = CLOSE_UNSUPPORTED; this.emit('error', err); return; } this.push(msg); }.bind(this); /** * Handle the stream ending by closing the ws client connection. * * @method onStreamEnd * @private */ this.onStreamEnd = function onStreamEnd() { this.log({ evt: 'streamEnd' }); this.ws.close(CLOSE_NORMAL); }.bind(this); /** * Handle a stream error by closing the ws client connection. * * @method onStreamError * @private * @param {Error} err the error emitted on the stream */ this.onStreamError = function onStreamError(err) { this.log({ evt: 'streamError', err: err.message }); this.ws.close(err.code || CLOSE_ERROR, err.message); }.bind(this); this.ws.on('close', this.onWsClose); this.ws.on('message', this.onWsMessage); this.on('error', this.onStreamError); this.on('end', this.onStreamEnd); if (options.keepAlive) { this.keepAliveInterval = setInterval(this.keepAlive, options.keepAlive); } }
[ "function", "ShareJSStream", "(", "ws", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "options", ".", "keepAlive", "=", "options", ".", "keepAlive", "!==", "undefined", "?", "options", ".", "keepAlive", ":", "KEEP_ALIVE", ";", "this", ".", "debug", "=", "options", ".", "debug", "===", "true", ";", "this", ".", "ws", "=", "ws", ";", "this", ".", "headers", "=", "this", ".", "ws", ".", "upgradeReq", ".", "headers", ";", "this", ".", "remoteAddress", "=", "this", ".", "ws", ".", "upgradeReq", ".", "connection", ".", "remoteAddress", ";", "if", "(", "this", ".", "debug", ")", "{", "this", ".", "logger", "=", "logfmt", ".", "namespace", "(", "{", "ns", ":", "'share-js-stream'", "}", ")", ";", "}", "Duplex", ".", "call", "(", "this", ",", "{", "objectMode", ":", "true", "}", ")", ";", "/**\n * Send a `null` message to the ws so that the connection is kept alive.\n *\n * This may not be necessary on all platforms.\n *\n * @method keepAlive\n * @private\n */", "this", ".", "keepAlive", "=", "function", "keepAlive", "(", ")", "{", "this", ".", "log", "(", "{", "evt", ":", "'keepAlive'", "}", ")", ";", "this", ".", "ws", ".", "send", "(", "null", ")", ";", "}", ".", "bind", "(", "this", ")", ";", "/**\n * Handle a closed ws client.\n *\n * This is called when the `close` event is emitted on the ws client. It:\n *\n * - Clears the keep alive interval (if there is one)\n * - Pushes `null` to end the stream\n * - Emits `close` on the stream\n *\n * @method onWsClose\n * @private\n * @param {Number} code the reason code for why the client was closed\n * @param {String} message a message accompanying the close\n */", "this", ".", "onWsClose", "=", "function", "onWsClose", "(", "code", ",", "message", ")", "{", "if", "(", "this", ".", "keepAliveInterval", ")", "{", "clearInterval", "(", "this", ".", "keepAliveInterval", ")", ";", "}", "this", ".", "log", "(", "{", "evt", ":", "'wsClose'", ",", "code", ":", "code", ",", "message", ":", "message", "}", ")", ";", "this", ".", "push", "(", "null", ")", ";", "this", ".", "emit", "(", "'close'", ")", ";", "}", ".", "bind", "(", "this", ")", ";", "/**\n * Push a message received on the ws client as an object to the stream.\n *\n * If JSON parsing of the message fails, an error event will be emitted on the\n * stream.\n *\n * @method onWsMessage\n * @private\n * @param {String} msg a JSON-encoded message received on the ws client\n */", "this", ".", "onWsMessage", "=", "function", "onWsMessage", "(", "msg", ")", "{", "this", ".", "log", "(", "{", "evt", ":", "'wsMessage'", ",", "msg", ":", "msg", "}", ")", ";", "try", "{", "msg", "=", "JSON", ".", "parse", "(", "msg", ")", ";", "}", "catch", "(", "_", ")", "{", "var", "err", "=", "new", "Error", "(", "'Client sent invalid JSON'", ")", ";", "err", ".", "code", "=", "CLOSE_UNSUPPORTED", ";", "this", ".", "emit", "(", "'error'", ",", "err", ")", ";", "return", ";", "}", "this", ".", "push", "(", "msg", ")", ";", "}", ".", "bind", "(", "this", ")", ";", "/**\n * Handle the stream ending by closing the ws client connection.\n *\n * @method onStreamEnd\n * @private\n */", "this", ".", "onStreamEnd", "=", "function", "onStreamEnd", "(", ")", "{", "this", ".", "log", "(", "{", "evt", ":", "'streamEnd'", "}", ")", ";", "this", ".", "ws", ".", "close", "(", "CLOSE_NORMAL", ")", ";", "}", ".", "bind", "(", "this", ")", ";", "/**\n * Handle a stream error by closing the ws client connection.\n *\n * @method onStreamError\n * @private\n * @param {Error} err the error emitted on the stream\n */", "this", ".", "onStreamError", "=", "function", "onStreamError", "(", "err", ")", "{", "this", ".", "log", "(", "{", "evt", ":", "'streamError'", ",", "err", ":", "err", ".", "message", "}", ")", ";", "this", ".", "ws", ".", "close", "(", "err", ".", "code", "||", "CLOSE_ERROR", ",", "err", ".", "message", ")", ";", "}", ".", "bind", "(", "this", ")", ";", "this", ".", "ws", ".", "on", "(", "'close'", ",", "this", ".", "onWsClose", ")", ";", "this", ".", "ws", ".", "on", "(", "'message'", ",", "this", ".", "onWsMessage", ")", ";", "this", ".", "on", "(", "'error'", ",", "this", ".", "onStreamError", ")", ";", "this", ".", "on", "(", "'end'", ",", "this", ".", "onStreamEnd", ")", ";", "if", "(", "options", ".", "keepAlive", ")", "{", "this", ".", "keepAliveInterval", "=", "setInterval", "(", "this", ".", "keepAlive", ",", "options", ".", "keepAlive", ")", ";", "}", "}" ]
A Stream for managing communication between a ShareJS client and a ws client var ShareJSStream = require('share-js-stream'); var WsServer = require('ws').Server; var http = require('http'); var livedb = require('livedb'); var shareServer = require('share').server.createClient({ backend: livedb.client(livedb.memory()) }); http.createServer().listen(process.env.PORT, function onListen() { var wsServer = new WsServer({ server: this }); wsServer.on('connection', onConnection); }); function onConnection(conn) { var stream = new ShareJSStream(conn); shareServer.listen(stream); } @class ShareJSStream @extends Duplex @constructor @param {WebSocket} ws a websocket connection @param {Object} [options] options for configuring the stream @param {Number} [options.keepAlive=30000] a keep alive interval (in ms) on which the stream will send a `null` message to the client
[ "A", "Stream", "for", "managing", "communication", "between", "a", "ShareJS", "client", "and", "a", "ws", "client" ]
6fae58dcbab7d15b22efe0e19c7f510b48de231c
https://github.com/usecanvas/share-js-stream/blob/6fae58dcbab7d15b22efe0e19c7f510b48de231c/index.js#L41-L151
45,176
tombenke/datafile
dist/schemas/index.js
loadSchema
function loadSchema(schemaBasePath, fullSchemaFileName) { var scfPath = fullSchemaFileName.split('/'); var schemaFileName = scfPath[scfPath.length - 1]; var mainSchema = null; // First, register() the main schemas you plan to use. try { mainSchema = _jsYaml2.default.load(_fs2.default.readFileSync(_path2.default.resolve(schemaBasePath, schemaFileName), 'utf-8')); var missingSchemas = js.register(mainSchema); // Next, load the missing sub-schemas recursively missingSchemas.forEach(function (missingSchema) { loadSchema(schemaBasePath, missingSchema); }); } catch (err) { //console.log(err) } return mainSchema; }
javascript
function loadSchema(schemaBasePath, fullSchemaFileName) { var scfPath = fullSchemaFileName.split('/'); var schemaFileName = scfPath[scfPath.length - 1]; var mainSchema = null; // First, register() the main schemas you plan to use. try { mainSchema = _jsYaml2.default.load(_fs2.default.readFileSync(_path2.default.resolve(schemaBasePath, schemaFileName), 'utf-8')); var missingSchemas = js.register(mainSchema); // Next, load the missing sub-schemas recursively missingSchemas.forEach(function (missingSchema) { loadSchema(schemaBasePath, missingSchema); }); } catch (err) { //console.log(err) } return mainSchema; }
[ "function", "loadSchema", "(", "schemaBasePath", ",", "fullSchemaFileName", ")", "{", "var", "scfPath", "=", "fullSchemaFileName", ".", "split", "(", "'/'", ")", ";", "var", "schemaFileName", "=", "scfPath", "[", "scfPath", ".", "length", "-", "1", "]", ";", "var", "mainSchema", "=", "null", ";", "// First, register() the main schemas you plan to use.", "try", "{", "mainSchema", "=", "_jsYaml2", ".", "default", ".", "load", "(", "_fs2", ".", "default", ".", "readFileSync", "(", "_path2", ".", "default", ".", "resolve", "(", "schemaBasePath", ",", "schemaFileName", ")", ",", "'utf-8'", ")", ")", ";", "var", "missingSchemas", "=", "js", ".", "register", "(", "mainSchema", ")", ";", "// Next, load the missing sub-schemas recursively", "missingSchemas", ".", "forEach", "(", "function", "(", "missingSchema", ")", "{", "loadSchema", "(", "schemaBasePath", ",", "missingSchema", ")", ";", "}", ")", ";", "}", "catch", "(", "err", ")", "{", "//console.log(err)", "}", "return", "mainSchema", ";", "}" ]
Load the named JSON schema @arg {String} schemaFileName - The name of the schema file @return {Object} - The loaded schema @function Load the JSON schema validator module and create a validator object
[ "Load", "the", "named", "JSON", "schema" ]
658a02142a9f80cc889e5074e91fc19d5ffc6f1a
https://github.com/tombenke/datafile/blob/658a02142a9f80cc889e5074e91fc19d5ffc6f1a/dist/schemas/index.js#L44-L63
45,177
briancsparks/serverassist
ra-scripts/models/partner.js
function(argv, context, callback) { return MongoClient.connect(mongoHost, function(err, db) { if (err) { return sg.die(err, callback, 'upsertPartner.MongoClient.connect'); } var partnersDb = db.collection('partners'); var partnerId = argvGet(argv, 'partner-id,partner'); var item = {}; _.each(argv, (value, key) => { sg.setOnn(item, ['$set', sg.toCamelCase(key)], sg.smartValue(value)); }); everbose(2, `Upserting partner: ${partnerId}`); return partnersDb.updateOne({partnerId}, item, {upsert:true}, function(err, result) { if (err) { console.error(err); } db.close(); return callback(err, result.result); }); }); }
javascript
function(argv, context, callback) { return MongoClient.connect(mongoHost, function(err, db) { if (err) { return sg.die(err, callback, 'upsertPartner.MongoClient.connect'); } var partnersDb = db.collection('partners'); var partnerId = argvGet(argv, 'partner-id,partner'); var item = {}; _.each(argv, (value, key) => { sg.setOnn(item, ['$set', sg.toCamelCase(key)], sg.smartValue(value)); }); everbose(2, `Upserting partner: ${partnerId}`); return partnersDb.updateOne({partnerId}, item, {upsert:true}, function(err, result) { if (err) { console.error(err); } db.close(); return callback(err, result.result); }); }); }
[ "function", "(", "argv", ",", "context", ",", "callback", ")", "{", "return", "MongoClient", ".", "connect", "(", "mongoHost", ",", "function", "(", "err", ",", "db", ")", "{", "if", "(", "err", ")", "{", "return", "sg", ".", "die", "(", "err", ",", "callback", ",", "'upsertPartner.MongoClient.connect'", ")", ";", "}", "var", "partnersDb", "=", "db", ".", "collection", "(", "'partners'", ")", ";", "var", "partnerId", "=", "argvGet", "(", "argv", ",", "'partner-id,partner'", ")", ";", "var", "item", "=", "{", "}", ";", "_", ".", "each", "(", "argv", ",", "(", "value", ",", "key", ")", "=>", "{", "sg", ".", "setOnn", "(", "item", ",", "[", "'$set'", ",", "sg", ".", "toCamelCase", "(", "key", ")", "]", ",", "sg", ".", "smartValue", "(", "value", ")", ")", ";", "}", ")", ";", "everbose", "(", "2", ",", "`", "${", "partnerId", "}", "`", ")", ";", "return", "partnersDb", ".", "updateOne", "(", "{", "partnerId", "}", ",", "item", ",", "{", "upsert", ":", "true", "}", ",", "function", "(", "err", ",", "result", ")", "{", "if", "(", "err", ")", "{", "console", ".", "error", "(", "err", ")", ";", "}", "db", ".", "close", "(", ")", ";", "return", "callback", "(", "err", ",", "result", ".", "result", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Just insert one partner without any intelligence on inserting a project
[ "Just", "insert", "one", "partner", "without", "any", "intelligence", "on", "inserting", "a", "project" ]
f966832aae287f502cce53a71f5129b962ada8a3
https://github.com/briancsparks/serverassist/blob/f966832aae287f502cce53a71f5129b962ada8a3/ra-scripts/models/partner.js#L26-L47
45,178
chapmanu/hb
lib/services/instagram/stream.js
function(service, credentials, accounts, keywords) { Stream.call(this, service, credentials, accounts, keywords); // Set up instagram-node-lib Insta.set('client_id', credentials.client_id); Insta.set('client_secret', credentials.client_secret); // Set api endpoint URL for subscriber this.api_endpoint = 'https://api.instagram.com/v1/subscriptions/'; // Initialize subscriber object this.subscriber = new Subscriber(credentials, this.callback_url(), this.api_endpoint); // Initialize responder this.responder = new Responder(); // Start listening for incoming process.nextTick(function() { this.delegateResponder(); }.bind(this)); }
javascript
function(service, credentials, accounts, keywords) { Stream.call(this, service, credentials, accounts, keywords); // Set up instagram-node-lib Insta.set('client_id', credentials.client_id); Insta.set('client_secret', credentials.client_secret); // Set api endpoint URL for subscriber this.api_endpoint = 'https://api.instagram.com/v1/subscriptions/'; // Initialize subscriber object this.subscriber = new Subscriber(credentials, this.callback_url(), this.api_endpoint); // Initialize responder this.responder = new Responder(); // Start listening for incoming process.nextTick(function() { this.delegateResponder(); }.bind(this)); }
[ "function", "(", "service", ",", "credentials", ",", "accounts", ",", "keywords", ")", "{", "Stream", ".", "call", "(", "this", ",", "service", ",", "credentials", ",", "accounts", ",", "keywords", ")", ";", "// Set up instagram-node-lib", "Insta", ".", "set", "(", "'client_id'", ",", "credentials", ".", "client_id", ")", ";", "Insta", ".", "set", "(", "'client_secret'", ",", "credentials", ".", "client_secret", ")", ";", "// Set api endpoint URL for subscriber", "this", ".", "api_endpoint", "=", "'https://api.instagram.com/v1/subscriptions/'", ";", "// Initialize subscriber object", "this", ".", "subscriber", "=", "new", "Subscriber", "(", "credentials", ",", "this", ".", "callback_url", "(", ")", ",", "this", ".", "api_endpoint", ")", ";", "// Initialize responder", "this", ".", "responder", "=", "new", "Responder", "(", ")", ";", "// Start listening for incoming", "process", ".", "nextTick", "(", "function", "(", ")", "{", "this", ".", "delegateResponder", "(", ")", ";", "}", ".", "bind", "(", "this", ")", ")", ";", "}" ]
Manages the streaming connection to Instagram @constructor @extends Stream
[ "Manages", "the", "streaming", "connection", "to", "Instagram" ]
5edd8de89c7c5fdffc3df0c627513889220f7d51
https://github.com/chapmanu/hb/blob/5edd8de89c7c5fdffc3df0c627513889220f7d51/lib/services/instagram/stream.js#L16-L37
45,179
brianbrunner/yowl
lib/bot.js
logError
function logError(message, err, context, event) { var current_err = err; while (current_err) { var next_err = current_err._previous; delete current_err._previous; if (current_err.stack) { console.error(current_err.stack); } else { console.error(current_err); } current_err = next_err; } // TODO add cli options for logging out context and event as well }
javascript
function logError(message, err, context, event) { var current_err = err; while (current_err) { var next_err = current_err._previous; delete current_err._previous; if (current_err.stack) { console.error(current_err.stack); } else { console.error(current_err); } current_err = next_err; } // TODO add cli options for logging out context and event as well }
[ "function", "logError", "(", "message", ",", "err", ",", "context", ",", "event", ")", "{", "var", "current_err", "=", "err", ";", "while", "(", "current_err", ")", "{", "var", "next_err", "=", "current_err", ".", "_previous", ";", "delete", "current_err", ".", "_previous", ";", "if", "(", "current_err", ".", "stack", ")", "{", "console", ".", "error", "(", "current_err", ".", "stack", ")", ";", "}", "else", "{", "console", ".", "error", "(", "current_err", ")", ";", "}", "current_err", "=", "next_err", ";", "}", "// TODO add cli options for logging out context and event as well", "}" ]
Log Errors With Some Textual Context
[ "Log", "Errors", "With", "Some", "Textual", "Context" ]
35d6764f4cc6c4a3487eca18a12fd8ca567d4293
https://github.com/brianbrunner/yowl/blob/35d6764f4cc6c4a3487eca18a12fd8ca567d4293/lib/bot.js#L192-L205
45,180
mchalapuk/hyper-text-slider
lib/polyfills/dom-token-list.js
Polyfill
function Polyfill(object, key) { nodsl.check(typeof object === 'object', 'object must be an object; got ', object); nodsl.check(typeof key === 'string', 'key must be a string; got ', key); nodsl.check(typeof object[key] === 'string', 'object.', key, ' must be a string; got ', object[key]); var that = this; that.add = function() { var tokens = [].slice.apply(arguments); tokens.forEach(function(token, i) { nodsl.check(typeof token === 'string', 'tokens[', i, '] must be a string; got ', token); }); object[key] += (object[key].length ?' ' :'') + tokens.join(' '); }; that.remove = function(token) { nodsl.check(typeof token === 'string', 'token must be a string; got ', token); object[key] = object[key].replace(new RegExp('\\b'+ token +'\\b\\s*'), '').replace(/^\\s*/, ''); }; that.contains = function(token) { nodsl.check(typeof token === 'string', 'token must be a string; got ', token); return object[key].search(new RegExp('\\b'+ token +'\\b')) !== -1; }; Object.defineProperty(that, 'length', { get: function() { return (object[key].match(/[^\s]+/g) || []).length; }, }); return that; }
javascript
function Polyfill(object, key) { nodsl.check(typeof object === 'object', 'object must be an object; got ', object); nodsl.check(typeof key === 'string', 'key must be a string; got ', key); nodsl.check(typeof object[key] === 'string', 'object.', key, ' must be a string; got ', object[key]); var that = this; that.add = function() { var tokens = [].slice.apply(arguments); tokens.forEach(function(token, i) { nodsl.check(typeof token === 'string', 'tokens[', i, '] must be a string; got ', token); }); object[key] += (object[key].length ?' ' :'') + tokens.join(' '); }; that.remove = function(token) { nodsl.check(typeof token === 'string', 'token must be a string; got ', token); object[key] = object[key].replace(new RegExp('\\b'+ token +'\\b\\s*'), '').replace(/^\\s*/, ''); }; that.contains = function(token) { nodsl.check(typeof token === 'string', 'token must be a string; got ', token); return object[key].search(new RegExp('\\b'+ token +'\\b')) !== -1; }; Object.defineProperty(that, 'length', { get: function() { return (object[key].match(/[^\s]+/g) || []).length; }, }); return that; }
[ "function", "Polyfill", "(", "object", ",", "key", ")", "{", "nodsl", ".", "check", "(", "typeof", "object", "===", "'object'", ",", "'object must be an object; got '", ",", "object", ")", ";", "nodsl", ".", "check", "(", "typeof", "key", "===", "'string'", ",", "'key must be a string; got '", ",", "key", ")", ";", "nodsl", ".", "check", "(", "typeof", "object", "[", "key", "]", "===", "'string'", ",", "'object.'", ",", "key", ",", "' must be a string; got '", ",", "object", "[", "key", "]", ")", ";", "var", "that", "=", "this", ";", "that", ".", "add", "=", "function", "(", ")", "{", "var", "tokens", "=", "[", "]", ".", "slice", ".", "apply", "(", "arguments", ")", ";", "tokens", ".", "forEach", "(", "function", "(", "token", ",", "i", ")", "{", "nodsl", ".", "check", "(", "typeof", "token", "===", "'string'", ",", "'tokens['", ",", "i", ",", "'] must be a string; got '", ",", "token", ")", ";", "}", ")", ";", "object", "[", "key", "]", "+=", "(", "object", "[", "key", "]", ".", "length", "?", "' '", ":", "''", ")", "+", "tokens", ".", "join", "(", "' '", ")", ";", "}", ";", "that", ".", "remove", "=", "function", "(", "token", ")", "{", "nodsl", ".", "check", "(", "typeof", "token", "===", "'string'", ",", "'token must be a string; got '", ",", "token", ")", ";", "object", "[", "key", "]", "=", "object", "[", "key", "]", ".", "replace", "(", "new", "RegExp", "(", "'\\\\b'", "+", "token", "+", "'\\\\b\\\\s*'", ")", ",", "''", ")", ".", "replace", "(", "/", "^\\\\s*", "/", ",", "''", ")", ";", "}", ";", "that", ".", "contains", "=", "function", "(", "token", ")", "{", "nodsl", ".", "check", "(", "typeof", "token", "===", "'string'", ",", "'token must be a string; got '", ",", "token", ")", ";", "return", "object", "[", "key", "]", ".", "search", "(", "new", "RegExp", "(", "'\\\\b'", "+", "token", "+", "'\\\\b'", ")", ")", "!==", "-", "1", ";", "}", ";", "Object", ".", "defineProperty", "(", "that", ",", "'length'", ",", "{", "get", ":", "function", "(", ")", "{", "return", "(", "object", "[", "key", "]", ".", "match", "(", "/", "[^\\s]+", "/", "g", ")", "||", "[", "]", ")", ".", "length", ";", "}", ",", "}", ")", ";", "return", "that", ";", "}" ]
Constructs Polyfill of DOMTokenList. The list will be represented as a string located in given **object** under property of name **key**. @see https://developer.mozilla.org/pl/docs/Web/API/DOMTokenList
[ "Constructs", "Polyfill", "of", "DOMTokenList", "." ]
2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4
https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/polyfills/dom-token-list.js#L34-L63
45,181
onechiporenko/jsonium
index.js
_isArrayOfObjects
function _isArrayOfObjects(value) { if (!Array.isArray(value)) { return false; } var l = value.length; var _type, cond; for (var i = 0; i < l; i++) { _type = typeof value[i]; cond = _type === 'function' || _type === 'object' && !!value[i]; if (!cond) { return false; } } return true; }
javascript
function _isArrayOfObjects(value) { if (!Array.isArray(value)) { return false; } var l = value.length; var _type, cond; for (var i = 0; i < l; i++) { _type = typeof value[i]; cond = _type === 'function' || _type === 'object' && !!value[i]; if (!cond) { return false; } } return true; }
[ "function", "_isArrayOfObjects", "(", "value", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "value", ")", ")", "{", "return", "false", ";", "}", "var", "l", "=", "value", ".", "length", ";", "var", "_type", ",", "cond", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "_type", "=", "typeof", "value", "[", "i", "]", ";", "cond", "=", "_type", "===", "'function'", "||", "_type", "===", "'object'", "&&", "!", "!", "value", "[", "i", "]", ";", "if", "(", "!", "cond", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Check if value is an array of objects @param {*} value @returns {boolean} @private
[ "Check", "if", "value", "is", "an", "array", "of", "objects" ]
50059570f58fecebb9e139b4766d03064416a4c4
https://github.com/onechiporenko/jsonium/blob/50059570f58fecebb9e139b4766d03064416a4c4/index.js#L20-L34
45,182
onechiporenko/jsonium
index.js
_get
function _get(obj, path) { var subpathes = path.split('.'); while (subpathes.length) { var subpath = subpathes.shift(); obj = obj[subpath]; if (!obj) { return obj; } } return obj; }
javascript
function _get(obj, path) { var subpathes = path.split('.'); while (subpathes.length) { var subpath = subpathes.shift(); obj = obj[subpath]; if (!obj) { return obj; } } return obj; }
[ "function", "_get", "(", "obj", ",", "path", ")", "{", "var", "subpathes", "=", "path", ".", "split", "(", "'.'", ")", ";", "while", "(", "subpathes", ".", "length", ")", "{", "var", "subpath", "=", "subpathes", ".", "shift", "(", ")", ";", "obj", "=", "obj", "[", "subpath", "]", ";", "if", "(", "!", "obj", ")", "{", "return", "obj", ";", "}", "}", "return", "obj", ";", "}" ]
Get object's value by provided nested path @param {object} obj @param {string} path @returns {*} @private
[ "Get", "object", "s", "value", "by", "provided", "nested", "path" ]
50059570f58fecebb9e139b4766d03064416a4c4
https://github.com/onechiporenko/jsonium/blob/50059570f58fecebb9e139b4766d03064416a4c4/index.js#L44-L54
45,183
onechiporenko/jsonium
index.js
_set
function _set(obj, path, value) { var subpathes = path.split('.'); while (subpathes.length - 1) { obj = obj[subpathes.shift()]; } obj[subpathes.shift()] = value; }
javascript
function _set(obj, path, value) { var subpathes = path.split('.'); while (subpathes.length - 1) { obj = obj[subpathes.shift()]; } obj[subpathes.shift()] = value; }
[ "function", "_set", "(", "obj", ",", "path", ",", "value", ")", "{", "var", "subpathes", "=", "path", ".", "split", "(", "'.'", ")", ";", "while", "(", "subpathes", ".", "length", "-", "1", ")", "{", "obj", "=", "obj", "[", "subpathes", ".", "shift", "(", ")", "]", ";", "}", "obj", "[", "subpathes", ".", "shift", "(", ")", "]", "=", "value", ";", "}" ]
Set object's value by provided nested path @param {object} obj @param {string} path @param {*} value @private
[ "Set", "object", "s", "value", "by", "provided", "nested", "path" ]
50059570f58fecebb9e139b4766d03064416a4c4
https://github.com/onechiporenko/jsonium/blob/50059570f58fecebb9e139b4766d03064416a4c4/index.js#L64-L70
45,184
onechiporenko/jsonium
index.js
_has
function _has(obj, path) { var subpathes = path.split('.'); while (subpathes.length) { var subpath = subpathes.shift(); if (!obj.hasOwnProperty(subpath)) { return false; } obj = obj[subpath]; } return true; }
javascript
function _has(obj, path) { var subpathes = path.split('.'); while (subpathes.length) { var subpath = subpathes.shift(); if (!obj.hasOwnProperty(subpath)) { return false; } obj = obj[subpath]; } return true; }
[ "function", "_has", "(", "obj", ",", "path", ")", "{", "var", "subpathes", "=", "path", ".", "split", "(", "'.'", ")", ";", "while", "(", "subpathes", ".", "length", ")", "{", "var", "subpath", "=", "subpathes", ".", "shift", "(", ")", ";", "if", "(", "!", "obj", ".", "hasOwnProperty", "(", "subpath", ")", ")", "{", "return", "false", ";", "}", "obj", "=", "obj", "[", "subpath", "]", ";", "}", "return", "true", ";", "}" ]
Check if object has provided nested path @param {object} obj @param {string} path @returns {boolean} @private
[ "Check", "if", "object", "has", "provided", "nested", "path" ]
50059570f58fecebb9e139b4766d03064416a4c4
https://github.com/onechiporenko/jsonium/blob/50059570f58fecebb9e139b4766d03064416a4c4/index.js#L80-L90
45,185
cliffano/couchpenter
lib/cli.js
exec
function exec() { // NOTE: pardon this cli target to Couchpenter methods mapping, // needed to preserve backward compatibility w/ v0.1.x const FUNCTIONS = { setup: 'setUp', 'setup-db': 'setUpDatabases', 'setup-doc': 'setUpDocuments', 'setup-doc-overwrite': 'setUpDocumentsOverwrite', teardown: 'tearDown', 'teardown-db': 'tearDownDatabases', 'teardown-doc': 'tearDownDocuments', reset: 'reset', 'reset-db': 'resetDatabases', 'reset-doc': 'resetDocuments', clean: 'clean', 'clean-db': 'cleanDatabases', 'warm-view': 'warmViews', 'live-deploy-view': 'liveDeployView' }; var actions = { commands: { init: { action: _init } } }; _.keys(FUNCTIONS).forEach(function (task) { actions.commands[task] = { action: _task(FUNCTIONS[task]) }; }); cli.command(__dirname, actions); }
javascript
function exec() { // NOTE: pardon this cli target to Couchpenter methods mapping, // needed to preserve backward compatibility w/ v0.1.x const FUNCTIONS = { setup: 'setUp', 'setup-db': 'setUpDatabases', 'setup-doc': 'setUpDocuments', 'setup-doc-overwrite': 'setUpDocumentsOverwrite', teardown: 'tearDown', 'teardown-db': 'tearDownDatabases', 'teardown-doc': 'tearDownDocuments', reset: 'reset', 'reset-db': 'resetDatabases', 'reset-doc': 'resetDocuments', clean: 'clean', 'clean-db': 'cleanDatabases', 'warm-view': 'warmViews', 'live-deploy-view': 'liveDeployView' }; var actions = { commands: { init: { action: _init } } }; _.keys(FUNCTIONS).forEach(function (task) { actions.commands[task] = { action: _task(FUNCTIONS[task]) }; }); cli.command(__dirname, actions); }
[ "function", "exec", "(", ")", "{", "// NOTE: pardon this cli target to Couchpenter methods mapping,", "// needed to preserve backward compatibility w/ v0.1.x", "const", "FUNCTIONS", "=", "{", "setup", ":", "'setUp'", ",", "'setup-db'", ":", "'setUpDatabases'", ",", "'setup-doc'", ":", "'setUpDocuments'", ",", "'setup-doc-overwrite'", ":", "'setUpDocumentsOverwrite'", ",", "teardown", ":", "'tearDown'", ",", "'teardown-db'", ":", "'tearDownDatabases'", ",", "'teardown-doc'", ":", "'tearDownDocuments'", ",", "reset", ":", "'reset'", ",", "'reset-db'", ":", "'resetDatabases'", ",", "'reset-doc'", ":", "'resetDocuments'", ",", "clean", ":", "'clean'", ",", "'clean-db'", ":", "'cleanDatabases'", ",", "'warm-view'", ":", "'warmViews'", ",", "'live-deploy-view'", ":", "'liveDeployView'", "}", ";", "var", "actions", "=", "{", "commands", ":", "{", "init", ":", "{", "action", ":", "_init", "}", "}", "}", ";", "_", ".", "keys", "(", "FUNCTIONS", ")", ".", "forEach", "(", "function", "(", "task", ")", "{", "actions", ".", "commands", "[", "task", "]", "=", "{", "action", ":", "_task", "(", "FUNCTIONS", "[", "task", "]", ")", "}", ";", "}", ")", ";", "cli", ".", "command", "(", "__dirname", ",", "actions", ")", ";", "}" ]
Execute Couchpenter CLI.
[ "Execute", "Couchpenter", "CLI", "." ]
00cce387da2f39e4b276b27b0bacb073caa80453
https://github.com/cliffano/couchpenter/blob/00cce387da2f39e4b276b27b0bacb073caa80453/lib/cli.js#L30-L62
45,186
nodejitsu/contour
pagelets/pagelet.js
use
function use(brand) { return function branding(file) { var branded = file.replace('{{brand}}', brand); return fs.existsSync(branded) ? branded : file.replace('{{brand}}', 'nodejitsu'); }; }
javascript
function use(brand) { return function branding(file) { var branded = file.replace('{{brand}}', brand); return fs.existsSync(branded) ? branded : file.replace('{{brand}}', 'nodejitsu'); }; }
[ "function", "use", "(", "brand", ")", "{", "return", "function", "branding", "(", "file", ")", "{", "var", "branded", "=", "file", ".", "replace", "(", "'{{brand}}'", ",", "brand", ")", ";", "return", "fs", ".", "existsSync", "(", "branded", ")", "?", "branded", ":", "file", ".", "replace", "(", "'{{brand}}'", ",", "'nodejitsu'", ")", ";", "}", ";", "}" ]
Return a mapping function with preset brand, will default to nodejitsu files if the requested branded file does not exist. @param {String} brand @returns {Function} mapper @api private
[ "Return", "a", "mapping", "function", "with", "preset", "brand", "will", "default", "to", "nodejitsu", "files", "if", "the", "requested", "branded", "file", "does", "not", "exist", "." ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/pagelet.js#L18-L23
45,187
nodejitsu/contour
pagelets/pagelet.js
get
function get(done) { this.define(); done(undefined, this.mixin({}, this.defaults, this.data, this.merge( this.data, this.queue.discharge(this.name) ))); }
javascript
function get(done) { this.define(); done(undefined, this.mixin({}, this.defaults, this.data, this.merge( this.data, this.queue.discharge(this.name) ))); }
[ "function", "get", "(", "done", ")", "{", "this", ".", "define", "(", ")", ";", "done", "(", "undefined", ",", "this", ".", "mixin", "(", "{", "}", ",", "this", ".", "defaults", ",", "this", ".", "data", ",", "this", ".", "merge", "(", "this", ".", "data", ",", "this", ".", "queue", ".", "discharge", "(", "this", ".", "name", ")", ")", ")", ")", ";", "}" ]
Provide data to the template render method. Can be called sync and async. @param {Function} done completion callback @api private
[ "Provide", "data", "to", "the", "template", "render", "method", ".", "Can", "be", "called", "sync", "and", "async", "." ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/pagelet.js#L154-L160
45,188
nodejitsu/contour
pagelets/pagelet.js
use
function use(namespace, name, fn) { name = name || this.name; this.temper.require('handlebars').registerHelper( namespace + '-' + name, fn ); return this; }
javascript
function use(namespace, name, fn) { name = name || this.name; this.temper.require('handlebars').registerHelper( namespace + '-' + name, fn ); return this; }
[ "function", "use", "(", "namespace", ",", "name", ",", "fn", ")", "{", "name", "=", "name", "||", "this", ".", "name", ";", "this", ".", "temper", ".", "require", "(", "'handlebars'", ")", ".", "registerHelper", "(", "namespace", "+", "'-'", "+", "name", ",", "fn", ")", ";", "return", "this", ";", "}" ]
Register provided helper with handlebars. @param {String} namespace Name of the Pagelet the helper was registered from. @param {String} name Registered name @param {Function} fn Handlebars helper @api public
[ "Register", "provided", "helper", "with", "handlebars", "." ]
0828e9bd25ef1eeb97ea231c447118d9867021b6
https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/pagelet.js#L170-L178
45,189
taskrjs/fly-util
src/bind.js
reduce
function reduce (m) { if (Array.isArray(m)) { try { const module = m[0].module ? m[0].module : m[0] _("register bind %o", module) return require(module) } catch (_) { return reduce(m.slice(1)) } } else return reduce([m]) }
javascript
function reduce (m) { if (Array.isArray(m)) { try { const module = m[0].module ? m[0].module : m[0] _("register bind %o", module) return require(module) } catch (_) { return reduce(m.slice(1)) } } else return reduce([m]) }
[ "function", "reduce", "(", "m", ")", "{", "if", "(", "Array", ".", "isArray", "(", "m", ")", ")", "{", "try", "{", "const", "module", "=", "m", "[", "0", "]", ".", "module", "?", "m", "[", "0", "]", ".", "module", ":", "m", "[", "0", "]", "_", "(", "\"register bind %o\"", ",", "module", ")", "return", "require", "(", "module", ")", "}", "catch", "(", "_", ")", "{", "return", "reduce", "(", "m", ".", "slice", "(", "1", ")", ")", "}", "}", "else", "return", "reduce", "(", "[", "m", "]", ")", "}" ]
Try require each module until we don't error. @param {String} module name
[ "Try", "require", "each", "module", "until", "we", "don", "t", "error", "." ]
976c0fbec697b2c3de7b2b90b75f2eb66a83de24
https://github.com/taskrjs/fly-util/blob/976c0fbec697b2c3de7b2b90b75f2eb66a83de24/src/bind.js#L21-L29
45,190
stealjs/live-reload
live.js
teardown
function teardown(moduleName, e, moduleNames) { var moduleNames = moduleNames || {}; if(disposeModule(moduleName, e, moduleNames)) { // Delete the module and call teardown on its parents as well. var parents = loader.getDependants(moduleName); for(var i = 0, len = parents.length; i < len; i++) { teardown(parents[i], e, moduleNames); } } return moduleNames; }
javascript
function teardown(moduleName, e, moduleNames) { var moduleNames = moduleNames || {}; if(disposeModule(moduleName, e, moduleNames)) { // Delete the module and call teardown on its parents as well. var parents = loader.getDependants(moduleName); for(var i = 0, len = parents.length; i < len; i++) { teardown(parents[i], e, moduleNames); } } return moduleNames; }
[ "function", "teardown", "(", "moduleName", ",", "e", ",", "moduleNames", ")", "{", "var", "moduleNames", "=", "moduleNames", "||", "{", "}", ";", "if", "(", "disposeModule", "(", "moduleName", ",", "e", ",", "moduleNames", ")", ")", "{", "// Delete the module and call teardown on its parents as well.", "var", "parents", "=", "loader", ".", "getDependants", "(", "moduleName", ")", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "parents", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "teardown", "(", "parents", "[", "i", "]", ",", "e", ",", "moduleNames", ")", ";", "}", "}", "return", "moduleNames", ";", "}" ]
Teardown a module name by deleting it and all of its parent modules.
[ "Teardown", "a", "module", "name", "by", "deleting", "it", "and", "all", "of", "its", "parent", "modules", "." ]
904f929ddbf5f1d4346c5ef13e61b9cbb7b71d52
https://github.com/stealjs/live-reload/blob/904f929ddbf5f1d4346c5ef13e61b9cbb7b71d52/live.js#L116-L129
45,191
rasouli100/twimap
lib/twimap.js
config_mail_box
function config_mail_box(config) { imap = new Imap({ user:config.user, password:config.password, host:config.host, port:config.port, secure:config.secure }); }
javascript
function config_mail_box(config) { imap = new Imap({ user:config.user, password:config.password, host:config.host, port:config.port, secure:config.secure }); }
[ "function", "config_mail_box", "(", "config", ")", "{", "imap", "=", "new", "Imap", "(", "{", "user", ":", "config", ".", "user", ",", "password", ":", "config", ".", "password", ",", "host", ":", "config", ".", "host", ",", "port", ":", "config", ".", "port", ",", "secure", ":", "config", ".", "secure", "}", ")", ";", "}" ]
Configs imap account from which must fetch the twitter e-mails @param config object containing information of imap account (user, password, host, port, secure boolean flag)
[ "Configs", "imap", "account", "from", "which", "must", "fetch", "the", "twitter", "e", "-", "mails" ]
90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7
https://github.com/rasouli100/twimap/blob/90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7/lib/twimap.js#L21-L30
45,192
rasouli100/twimap
lib/twimap.js
get_new_followers
function get_new_followers(since, cb, cberr) { get_inbox(since); _callback = cb; _callback_err = cberr; }
javascript
function get_new_followers(since, cb, cberr) { get_inbox(since); _callback = cb; _callback_err = cberr; }
[ "function", "get_new_followers", "(", "since", ",", "cb", ",", "cberr", ")", "{", "get_inbox", "(", "since", ")", ";", "_callback", "=", "cb", ";", "_callback_err", "=", "cberr", ";", "}" ]
returns followers asynchronously @param since date from which to look for followers e-mails @param cb callback function when there is a result @param cberr callback function on error
[ "returns", "followers", "asynchronously" ]
90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7
https://github.com/rasouli100/twimap/blob/90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7/lib/twimap.js#L40-L44
45,193
MiguelCastillo/bit-loader
example/bundler/src/bundler.js
bundlerFactory
function bundlerFactory(loader, options) { function bundlerDelegate(modules) { return bundler(loader, options || {}, modules); } bundlerDelegate.bundle = function(names) { return loader.fetch(names).then(bundlerDelegate); }; return bundlerDelegate; }
javascript
function bundlerFactory(loader, options) { function bundlerDelegate(modules) { return bundler(loader, options || {}, modules); } bundlerDelegate.bundle = function(names) { return loader.fetch(names).then(bundlerDelegate); }; return bundlerDelegate; }
[ "function", "bundlerFactory", "(", "loader", ",", "options", ")", "{", "function", "bundlerDelegate", "(", "modules", ")", "{", "return", "bundler", "(", "loader", ",", "options", "||", "{", "}", ",", "modules", ")", ";", "}", "bundlerDelegate", ".", "bundle", "=", "function", "(", "names", ")", "{", "return", "loader", ".", "fetch", "(", "names", ")", ".", "then", "(", "bundlerDelegate", ")", ";", "}", ";", "return", "bundlerDelegate", ";", "}" ]
Convenience factory for specifying the instance of bit loader to bundle up
[ "Convenience", "factory", "for", "specifying", "the", "instance", "of", "bit", "loader", "to", "bundle", "up" ]
da9d18952d87014fdb09e7a8320a24cbf1c2b436
https://github.com/MiguelCastillo/bit-loader/blob/da9d18952d87014fdb09e7a8320a24cbf1c2b436/example/bundler/src/bundler.js#L8-L18
45,194
MiguelCastillo/bit-loader
example/bundler/src/bundler.js
bundler
function bundler(loader, options, modules) { var stack = modules.slice(0); var mods = []; var finished = {}; function processModule(mod) { if (finished.hasOwnProperty(mod.id)) { return; } mod = loader.getModule(mod.id); // browser pack chunk var browserpack = { id : mod.id, source : mod.source, deps : {} }; // Gather up all dependencies var i, length, dep; for (i = 0, length = mod.deps.length; i < length; i++) { dep = mod.deps[i]; stack.push(dep); browserpack.deps[dep.id] = dep.id; } finished[mod.id] = browserpack; mods.unshift(browserpack); } // Process all modules while (stack.length) { processModule(stack.pop()); } var stream = browserPack(options).setEncoding("utf8"); var promise = pstream(stream); stream.end(JSON.stringify(mods)); return promise; }
javascript
function bundler(loader, options, modules) { var stack = modules.slice(0); var mods = []; var finished = {}; function processModule(mod) { if (finished.hasOwnProperty(mod.id)) { return; } mod = loader.getModule(mod.id); // browser pack chunk var browserpack = { id : mod.id, source : mod.source, deps : {} }; // Gather up all dependencies var i, length, dep; for (i = 0, length = mod.deps.length; i < length; i++) { dep = mod.deps[i]; stack.push(dep); browserpack.deps[dep.id] = dep.id; } finished[mod.id] = browserpack; mods.unshift(browserpack); } // Process all modules while (stack.length) { processModule(stack.pop()); } var stream = browserPack(options).setEncoding("utf8"); var promise = pstream(stream); stream.end(JSON.stringify(mods)); return promise; }
[ "function", "bundler", "(", "loader", ",", "options", ",", "modules", ")", "{", "var", "stack", "=", "modules", ".", "slice", "(", "0", ")", ";", "var", "mods", "=", "[", "]", ";", "var", "finished", "=", "{", "}", ";", "function", "processModule", "(", "mod", ")", "{", "if", "(", "finished", ".", "hasOwnProperty", "(", "mod", ".", "id", ")", ")", "{", "return", ";", "}", "mod", "=", "loader", ".", "getModule", "(", "mod", ".", "id", ")", ";", "// browser pack chunk", "var", "browserpack", "=", "{", "id", ":", "mod", ".", "id", ",", "source", ":", "mod", ".", "source", ",", "deps", ":", "{", "}", "}", ";", "// Gather up all dependencies", "var", "i", ",", "length", ",", "dep", ";", "for", "(", "i", "=", "0", ",", "length", "=", "mod", ".", "deps", ".", "length", ";", "i", "<", "length", ";", "i", "++", ")", "{", "dep", "=", "mod", ".", "deps", "[", "i", "]", ";", "stack", ".", "push", "(", "dep", ")", ";", "browserpack", ".", "deps", "[", "dep", ".", "id", "]", "=", "dep", ".", "id", ";", "}", "finished", "[", "mod", ".", "id", "]", "=", "browserpack", ";", "mods", ".", "unshift", "(", "browserpack", ")", ";", "}", "// Process all modules", "while", "(", "stack", ".", "length", ")", "{", "processModule", "(", "stack", ".", "pop", "(", ")", ")", ";", "}", "var", "stream", "=", "browserPack", "(", "options", ")", ".", "setEncoding", "(", "\"utf8\"", ")", ";", "var", "promise", "=", "pstream", "(", "stream", ")", ";", "stream", ".", "end", "(", "JSON", ".", "stringify", "(", "mods", ")", ")", ";", "return", "promise", ";", "}" ]
Bundles up incoming modules. This will process all dependencies and will create a bundle using browser-pack. @returns {Promise} When resolve, the full bundle buffer is returned
[ "Bundles", "up", "incoming", "modules", ".", "This", "will", "process", "all", "dependencies", "and", "will", "create", "a", "bundle", "using", "browser", "-", "pack", "." ]
da9d18952d87014fdb09e7a8320a24cbf1c2b436
https://github.com/MiguelCastillo/bit-loader/blob/da9d18952d87014fdb09e7a8320a24cbf1c2b436/example/bundler/src/bundler.js#L27-L68
45,195
binduwavell/generator-alfresco-common
lib/java-properties.js
isCommentLine
function isCommentLine (line) { var isCmnt = commentRE.test(line); if (isCmnt) { debug('removing comment: %s', line); } return !isCmnt; }
javascript
function isCommentLine (line) { var isCmnt = commentRE.test(line); if (isCmnt) { debug('removing comment: %s', line); } return !isCmnt; }
[ "function", "isCommentLine", "(", "line", ")", "{", "var", "isCmnt", "=", "commentRE", ".", "test", "(", "line", ")", ";", "if", "(", "isCmnt", ")", "{", "debug", "(", "'removing comment: %s'", ",", "line", ")", ";", "}", "return", "!", "isCmnt", ";", "}" ]
Detects if a line is a comment. @param {string} line @returns {boolean}
[ "Detects", "if", "a", "line", "is", "a", "comment", "." ]
d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4
https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/java-properties.js#L61-L67
45,196
binduwavell/generator-alfresco-common
lib/java-properties.js
extractKeyValue
function extractKeyValue (line) { var kv = { key: undefined, value: undefined, }; var matches = kvRE.exec(line); if (matches !== null && matches.length === 3) { kv.key = matches[1]; kv.value = matches[2]; } return kv; }
javascript
function extractKeyValue (line) { var kv = { key: undefined, value: undefined, }; var matches = kvRE.exec(line); if (matches !== null && matches.length === 3) { kv.key = matches[1]; kv.value = matches[2]; } return kv; }
[ "function", "extractKeyValue", "(", "line", ")", "{", "var", "kv", "=", "{", "key", ":", "undefined", ",", "value", ":", "undefined", ",", "}", ";", "var", "matches", "=", "kvRE", ".", "exec", "(", "line", ")", ";", "if", "(", "matches", "!==", "null", "&&", "matches", ".", "length", "===", "3", ")", "{", "kv", ".", "key", "=", "matches", "[", "1", "]", ";", "kv", ".", "value", "=", "matches", "[", "2", "]", ";", "}", "return", "kv", ";", "}" ]
Uses a regular expression to extract a key and value from the line. @param {string} line @returns {{key: undefined, value: undefined}}
[ "Uses", "a", "regular", "expression", "to", "extract", "a", "key", "and", "value", "from", "the", "line", "." ]
d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4
https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/java-properties.js#L76-L89
45,197
binduwavell/generator-alfresco-common
lib/java-properties.js
processLine
function processLine (instance, acc, line) { debug('processing: %s', line); // if previous line was continued then capture this line verbatim // of course we need to handle if this is also a continuation too if (instance.key) { var hasCont = hasNewlineContinuation(line); if (hasCont) { debug('removing line continuation'); line = removeContinuation(line); } line = unescape(line); debug('saving %s=>%s', instance.key, line); acc[instance.key] += line; if (!hasCont) { instance.key = undefined; } } else { var kv = extractKeyValue(line); kv.key = unescape(kv.key); if (hasNewlineContinuation(kv.value)) { debug('removing line continuation'); kv.value = removeContinuation(kv.value); instance.key = kv.key; } kv.value = unescape(kv.value); debug('saving %s=>%s', kv.key, kv.value); acc[kv.key] = kv.value; } return acc; }
javascript
function processLine (instance, acc, line) { debug('processing: %s', line); // if previous line was continued then capture this line verbatim // of course we need to handle if this is also a continuation too if (instance.key) { var hasCont = hasNewlineContinuation(line); if (hasCont) { debug('removing line continuation'); line = removeContinuation(line); } line = unescape(line); debug('saving %s=>%s', instance.key, line); acc[instance.key] += line; if (!hasCont) { instance.key = undefined; } } else { var kv = extractKeyValue(line); kv.key = unescape(kv.key); if (hasNewlineContinuation(kv.value)) { debug('removing line continuation'); kv.value = removeContinuation(kv.value); instance.key = kv.key; } kv.value = unescape(kv.value); debug('saving %s=>%s', kv.key, kv.value); acc[kv.key] = kv.value; } return acc; }
[ "function", "processLine", "(", "instance", ",", "acc", ",", "line", ")", "{", "debug", "(", "'processing: %s'", ",", "line", ")", ";", "// if previous line was continued then capture this line verbatim", "// of course we need to handle if this is also a continuation too", "if", "(", "instance", ".", "key", ")", "{", "var", "hasCont", "=", "hasNewlineContinuation", "(", "line", ")", ";", "if", "(", "hasCont", ")", "{", "debug", "(", "'removing line continuation'", ")", ";", "line", "=", "removeContinuation", "(", "line", ")", ";", "}", "line", "=", "unescape", "(", "line", ")", ";", "debug", "(", "'saving %s=>%s'", ",", "instance", ".", "key", ",", "line", ")", ";", "acc", "[", "instance", ".", "key", "]", "+=", "line", ";", "if", "(", "!", "hasCont", ")", "{", "instance", ".", "key", "=", "undefined", ";", "}", "}", "else", "{", "var", "kv", "=", "extractKeyValue", "(", "line", ")", ";", "kv", ".", "key", "=", "unescape", "(", "kv", ".", "key", ")", ";", "if", "(", "hasNewlineContinuation", "(", "kv", ".", "value", ")", ")", "{", "debug", "(", "'removing line continuation'", ")", ";", "kv", ".", "value", "=", "removeContinuation", "(", "kv", ".", "value", ")", ";", "instance", ".", "key", "=", "kv", ".", "key", ";", "}", "kv", ".", "value", "=", "unescape", "(", "kv", ".", "value", ")", ";", "debug", "(", "'saving %s=>%s'", ",", "kv", ".", "key", ",", "kv", ".", "value", ")", ";", "acc", "[", "kv", ".", "key", "]", "=", "kv", ".", "value", ";", "}", "return", "acc", ";", "}" ]
This method is called with each non-blank and non-comment line from the properties file. It builds up the object representation of the properties data in the accumulator. It uses instance object to store state when lines are being continued. @param {Object} instance @param {Object} acc @param {string} line @returns {Object}
[ "This", "method", "is", "called", "with", "each", "non", "-", "blank", "and", "non", "-", "comment", "line", "from", "the", "properties", "file", ".", "It", "builds", "up", "the", "object", "representation", "of", "the", "properties", "data", "in", "the", "accumulator", ".", "It", "uses", "instance", "object", "to", "store", "state", "when", "lines", "are", "being", "continued", "." ]
d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4
https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/java-properties.js#L113-L142
45,198
binduwavell/generator-alfresco-common
lib/java-properties.js
unescape
function unescape (line) { var retv = _.replace(line, propEscapeRE, '$1'); retv = _.replace(line, unicodeEscapeRE, function (m) { return String.fromCharCode(parseInt(m, 16)); }); if (retv !== line) { debug('removed escapes from: %s => %s', line, retv); } return retv; }
javascript
function unescape (line) { var retv = _.replace(line, propEscapeRE, '$1'); retv = _.replace(line, unicodeEscapeRE, function (m) { return String.fromCharCode(parseInt(m, 16)); }); if (retv !== line) { debug('removed escapes from: %s => %s', line, retv); } return retv; }
[ "function", "unescape", "(", "line", ")", "{", "var", "retv", "=", "_", ".", "replace", "(", "line", ",", "propEscapeRE", ",", "'$1'", ")", ";", "retv", "=", "_", ".", "replace", "(", "line", ",", "unicodeEscapeRE", ",", "function", "(", "m", ")", "{", "return", "String", ".", "fromCharCode", "(", "parseInt", "(", "m", ",", "16", ")", ")", ";", "}", ")", ";", "if", "(", "retv", "!==", "line", ")", "{", "debug", "(", "'removed escapes from: %s => %s'", ",", "line", ",", "retv", ")", ";", "}", "return", "retv", ";", "}" ]
Resolve property esacpe sequences in a line. Also resolves unicode escapes. @param {string} line @returns {string}
[ "Resolve", "property", "esacpe", "sequences", "in", "a", "line", ".", "Also", "resolves", "unicode", "escapes", "." ]
d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4
https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/java-properties.js#L183-L192
45,199
feedhenry/fh-mbaas-client
index.js
function(environment, mbaasConfig) { if (!client) { client = new MbaasClient(environment, mbaasConfig); } //Deprecated module.exports.app = client.app; module.exports.admin = client.admin; }
javascript
function(environment, mbaasConfig) { if (!client) { client = new MbaasClient(environment, mbaasConfig); } //Deprecated module.exports.app = client.app; module.exports.admin = client.admin; }
[ "function", "(", "environment", ",", "mbaasConfig", ")", "{", "if", "(", "!", "client", ")", "{", "client", "=", "new", "MbaasClient", "(", "environment", ",", "mbaasConfig", ")", ";", "}", "//Deprecated", "module", ".", "exports", ".", "app", "=", "client", ".", "app", ";", "module", ".", "exports", ".", "admin", "=", "client", ".", "admin", ";", "}" ]
Deprecated, try not to use it. Use MbaasClient instead.
[ "Deprecated", "try", "not", "to", "use", "it", ".", "Use", "MbaasClient", "instead", "." ]
2d5a9cbb32e1b2464d71ffa18513358fea388859
https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/index.js#L9-L16