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
partition
stringclasses
1 value
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
isBuf
function isBuf(obj) { return ( (withNativeBuffer && commonjsGlobal.Buffer.isBuffer(obj)) || (withNativeArrayBuffer && (obj instanceof commonjsGlobal.ArrayBuffer || isView(obj))) ); }
javascript
function isBuf(obj) { return ( (withNativeBuffer && commonjsGlobal.Buffer.isBuffer(obj)) || (withNativeArrayBuffer && (obj instanceof commonjsGlobal.ArrayBuffer || isView(obj))) ); }
[ "function", "isBuf", "(", "obj", ")", "{", "return", "(", "(", "withNativeBuffer", "&&", "commonjsGlobal", ".", "Buffer", ".", "isBuffer", "(", "obj", ")", ")", "||", "(", "withNativeArrayBuffer", "&&", "(", "obj", "instanceof", "commonjsGlobal", ".", "ArrayBuffer", "||", "isView", "(", "obj", ")", ")", ")", ")", ";", "}" ]
Returns true if obj is a buffer or an arraybuffer. @api private
[ "Returns", "true", "if", "obj", "is", "a", "buffer", "or", "an", "arraybuffer", "." ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L1003-L1008
train
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
hasBinary
function hasBinary(obj) { if (!obj || typeof obj !== "object") { return false; } if (isarray(obj)) { for (var i = 0, l = obj.length; i < l; i++) { if (hasBinary(obj[i])) { return true; } } return false; } if ( (typeof Buffer === "function" && Buffer.isBuffer && Buffer.isBuffer(obj)) || (typeof ArrayBuffer === "function" && obj instanceof ArrayBuffer) || (withNativeBlob$1 && obj instanceof Blob) || (withNativeFile$1 && obj instanceof File) ) { return true; } // see: https://github.com/Automattic/has-binary/pull/4 if (obj.toJSON && typeof obj.toJSON === "function" && arguments.length === 1) { return hasBinary(obj.toJSON(), true); } for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) { return true; } } return false; }
javascript
function hasBinary(obj) { if (!obj || typeof obj !== "object") { return false; } if (isarray(obj)) { for (var i = 0, l = obj.length; i < l; i++) { if (hasBinary(obj[i])) { return true; } } return false; } if ( (typeof Buffer === "function" && Buffer.isBuffer && Buffer.isBuffer(obj)) || (typeof ArrayBuffer === "function" && obj instanceof ArrayBuffer) || (withNativeBlob$1 && obj instanceof Blob) || (withNativeFile$1 && obj instanceof File) ) { return true; } // see: https://github.com/Automattic/has-binary/pull/4 if (obj.toJSON && typeof obj.toJSON === "function" && arguments.length === 1) { return hasBinary(obj.toJSON(), true); } for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) { return true; } } return false; }
[ "function", "hasBinary", "(", "obj", ")", "{", "if", "(", "!", "obj", "||", "typeof", "obj", "!==", "\"object\"", ")", "{", "return", "false", ";", "}", "if", "(", "isarray", "(", "obj", ")", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "obj", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "hasBinary", "(", "obj", "[", "i", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "if", "(", "(", "typeof", "Buffer", "===", "\"function\"", "&&", "Buffer", ".", "isBuffer", "&&", "Buffer", ".", "isBuffer", "(", "obj", ")", ")", "||", "(", "typeof", "ArrayBuffer", "===", "\"function\"", "&&", "obj", "instanceof", "ArrayBuffer", ")", "||", "(", "withNativeBlob$1", "&&", "obj", "instanceof", "Blob", ")", "||", "(", "withNativeFile$1", "&&", "obj", "instanceof", "File", ")", ")", "{", "return", "true", ";", "}", "if", "(", "obj", ".", "toJSON", "&&", "typeof", "obj", ".", "toJSON", "===", "\"function\"", "&&", "arguments", ".", "length", "===", "1", ")", "{", "return", "hasBinary", "(", "obj", ".", "toJSON", "(", ")", ",", "true", ")", ";", "}", "for", "(", "var", "key", "in", "obj", ")", "{", "if", "(", "Object", ".", "prototype", ".", "hasOwnProperty", ".", "call", "(", "obj", ",", "key", ")", "&&", "hasBinary", "(", "obj", "[", "key", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks for binary data. Supports Buffer, ArrayBuffer, Blob and File. @param {Object} anything @api public
[ "Checks", "for", "binary", "data", "." ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L1680-L1715
train
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
function(obj) { var str = ""; for (var i in obj) { if (obj.hasOwnProperty(i)) { if (str.length) str += "&"; str += encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]); } } return str; }
javascript
function(obj) { var str = ""; for (var i in obj) { if (obj.hasOwnProperty(i)) { if (str.length) str += "&"; str += encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]); } } return str; }
[ "function", "(", "obj", ")", "{", "var", "str", "=", "\"\"", ";", "for", "(", "var", "i", "in", "obj", ")", "{", "if", "(", "obj", ".", "hasOwnProperty", "(", "i", ")", ")", "{", "if", "(", "str", ".", "length", ")", "str", "+=", "\"&\"", ";", "str", "+=", "encodeURIComponent", "(", "i", ")", "+", "\"=\"", "+", "encodeURIComponent", "(", "obj", "[", "i", "]", ")", ";", "}", "}", "return", "str", ";", "}" ]
Compiles a querystring Returns string representation of the object @param {Object} @api private
[ "Compiles", "a", "querystring", "Returns", "string", "representation", "of", "the", "object" ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L2982-L2993
train
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
Polling
function Polling(opts) { var forceBase64 = opts && opts.forceBase64; if (!hasXHR2 || forceBase64) { this.supportsBinary = false; } transport.call(this, opts); }
javascript
function Polling(opts) { var forceBase64 = opts && opts.forceBase64; if (!hasXHR2 || forceBase64) { this.supportsBinary = false; } transport.call(this, opts); }
[ "function", "Polling", "(", "opts", ")", "{", "var", "forceBase64", "=", "opts", "&&", "opts", ".", "forceBase64", ";", "if", "(", "!", "hasXHR2", "||", "forceBase64", ")", "{", "this", ".", "supportsBinary", "=", "false", ";", "}", "transport", ".", "call", "(", "this", ",", "opts", ")", ";", "}" ]
Polling interface. @param {Object} opts @api private
[ "Polling", "interface", "." ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L3120-L3126
train
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
onerror
function onerror(err) { var error = new Error("probe error: " + err); error.transport = transport$$1.name; freezeTransport(); debug$5('probe transport "%s" failed because of error: %s', name, err); self.emit("upgradeError", error); }
javascript
function onerror(err) { var error = new Error("probe error: " + err); error.transport = transport$$1.name; freezeTransport(); debug$5('probe transport "%s" failed because of error: %s', name, err); self.emit("upgradeError", error); }
[ "function", "onerror", "(", "err", ")", "{", "var", "error", "=", "new", "Error", "(", "\"probe error: \"", "+", "err", ")", ";", "error", ".", "transport", "=", "transport$$1", ".", "name", ";", "freezeTransport", "(", ")", ";", "debug$5", "(", "'probe transport \"%s\" failed because of error: %s'", ",", "name", ",", "err", ")", ";", "self", ".", "emit", "(", "\"upgradeError\"", ",", "error", ")", ";", "}" ]
Handle any error that happens while probing
[ "Handle", "any", "error", "that", "happens", "while", "probing" ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L4674-L4683
train
adobe/react-twist-webpack-plugin
src/convertRuleToCondition.js
convertRuleToCondition
function convertRuleToCondition(rule) { if (!rule || typeof rule !== 'object' || !Object.keys(rule).length) { return rule; } if (Array.isArray(rule)) { return rule.map(convertRuleToCondition); } const condition = {}; // We allow certain properties... ALLOWED_PROPERTIES.forEach((prop) => { if (rule[prop]) { condition[prop] = convertRuleToCondition(rule[prop]); } }); // We prohibit certain properties... PROHIBITIED_PROPERTIES.forEach((prop) => { if (rule[prop]) { throw new Error(`Webpack rules added in a Twist library cannot contain the property "${prop}". ` + `Try to reformulate your rule with ${ALLOWED_PROPERTIES.join('/')}.`); } }); // And the rest we ignore, because they're needed for a Rule but not a Condition. return condition; }
javascript
function convertRuleToCondition(rule) { if (!rule || typeof rule !== 'object' || !Object.keys(rule).length) { return rule; } if (Array.isArray(rule)) { return rule.map(convertRuleToCondition); } const condition = {}; // We allow certain properties... ALLOWED_PROPERTIES.forEach((prop) => { if (rule[prop]) { condition[prop] = convertRuleToCondition(rule[prop]); } }); // We prohibit certain properties... PROHIBITIED_PROPERTIES.forEach((prop) => { if (rule[prop]) { throw new Error(`Webpack rules added in a Twist library cannot contain the property "${prop}". ` + `Try to reformulate your rule with ${ALLOWED_PROPERTIES.join('/')}.`); } }); // And the rest we ignore, because they're needed for a Rule but not a Condition. return condition; }
[ "function", "convertRuleToCondition", "(", "rule", ")", "{", "if", "(", "!", "rule", "||", "typeof", "rule", "!==", "'object'", "||", "!", "Object", ".", "keys", "(", "rule", ")", ".", "length", ")", "{", "return", "rule", ";", "}", "if", "(", "Array", ".", "isArray", "(", "rule", ")", ")", "{", "return", "rule", ".", "map", "(", "convertRuleToCondition", ")", ";", "}", "const", "condition", "=", "{", "}", ";", "ALLOWED_PROPERTIES", ".", "forEach", "(", "(", "prop", ")", "=>", "{", "if", "(", "rule", "[", "prop", "]", ")", "{", "condition", "[", "prop", "]", "=", "convertRuleToCondition", "(", "rule", "[", "prop", "]", ")", ";", "}", "}", ")", ";", "PROHIBITIED_PROPERTIES", ".", "forEach", "(", "(", "prop", ")", "=>", "{", "if", "(", "rule", "[", "prop", "]", ")", "{", "throw", "new", "Error", "(", "`", "${", "prop", "}", "`", "+", "`", "${", "ALLOWED_PROPERTIES", ".", "join", "(", "'/'", ")", "}", "`", ")", ";", "}", "}", ")", ";", "return", "condition", ";", "}" ]
Create a Webpack Condition from a Webpack Rule by stripping out any nested Rule properties, keeping only the conditions in which the rule would be applied. In other words, the return value of this function could be passed to `exclude` on another rule, to exclude only the files matched by the input rule. @param {Rule} rule @return {Condition}
[ "Create", "a", "Webpack", "Condition", "from", "a", "Webpack", "Rule", "by", "stripping", "out", "any", "nested", "Rule", "properties", "keeping", "only", "the", "conditions", "in", "which", "the", "rule", "would", "be", "applied", ".", "In", "other", "words", "the", "return", "value", "of", "this", "function", "could", "be", "passed", "to", "exclude", "on", "another", "rule", "to", "exclude", "only", "the", "files", "matched", "by", "the", "input", "rule", "." ]
499949d69931904eb5a2b7ef12cf9c1848ce6241
https://github.com/adobe/react-twist-webpack-plugin/blob/499949d69931904eb5a2b7ef12cf9c1848ce6241/src/convertRuleToCondition.js#L33-L56
train
carsdotcom/windshieldjs
lib/processRoutes.js
processRoutes
function processRoutes(handler, uriContext, routes) { return routes.map(setupRoute); /** * @param {(PreReq|pageAdapter)[]} adapters - Array of adapters and Hapi route prerequisites for processing * an incoming request * @param {pageFilter} pageFilter - Function for performing post-processing on page object before * templating begins * @param {string} method - HTTP method for the route * @param {string} path - Path for the route * @param {module:processRoutes.Context} context * - Data that should be made available to the adapters and route handler * * @returns {object} Hapi route options object */ function setupRoute({adapters, pageFilter, method, path, context}) { const allAdaptersAndPreHandlers = flattenDeep(adapters); const preHandlers = allAdaptersAndPreHandlers.filter(x => isPreHandler(x)); const pageAdapters = allAdaptersAndPreHandlers.filter(x => !isPreHandler(x)); const app = { context, adapters: pageAdapters }; if (pageFilter) { app.pageFilter = pageFilter; } const pre = preHandlers.map(mapToWrappedHandler); return { method, path: uriContext + path, handler, config: { state: { failAction: 'log' }, app, pre } }; } }
javascript
function processRoutes(handler, uriContext, routes) { return routes.map(setupRoute); /** * @param {(PreReq|pageAdapter)[]} adapters - Array of adapters and Hapi route prerequisites for processing * an incoming request * @param {pageFilter} pageFilter - Function for performing post-processing on page object before * templating begins * @param {string} method - HTTP method for the route * @param {string} path - Path for the route * @param {module:processRoutes.Context} context * - Data that should be made available to the adapters and route handler * * @returns {object} Hapi route options object */ function setupRoute({adapters, pageFilter, method, path, context}) { const allAdaptersAndPreHandlers = flattenDeep(adapters); const preHandlers = allAdaptersAndPreHandlers.filter(x => isPreHandler(x)); const pageAdapters = allAdaptersAndPreHandlers.filter(x => !isPreHandler(x)); const app = { context, adapters: pageAdapters }; if (pageFilter) { app.pageFilter = pageFilter; } const pre = preHandlers.map(mapToWrappedHandler); return { method, path: uriContext + path, handler, config: { state: { failAction: 'log' }, app, pre } }; } }
[ "function", "processRoutes", "(", "handler", ",", "uriContext", ",", "routes", ")", "{", "return", "routes", ".", "map", "(", "setupRoute", ")", ";", "function", "setupRoute", "(", "{", "adapters", ",", "pageFilter", ",", "method", ",", "path", ",", "context", "}", ")", "{", "const", "allAdaptersAndPreHandlers", "=", "flattenDeep", "(", "adapters", ")", ";", "const", "preHandlers", "=", "allAdaptersAndPreHandlers", ".", "filter", "(", "x", "=>", "isPreHandler", "(", "x", ")", ")", ";", "const", "pageAdapters", "=", "allAdaptersAndPreHandlers", ".", "filter", "(", "x", "=>", "!", "isPreHandler", "(", "x", ")", ")", ";", "const", "app", "=", "{", "context", ",", "adapters", ":", "pageAdapters", "}", ";", "if", "(", "pageFilter", ")", "{", "app", ".", "pageFilter", "=", "pageFilter", ";", "}", "const", "pre", "=", "preHandlers", ".", "map", "(", "mapToWrappedHandler", ")", ";", "return", "{", "method", ",", "path", ":", "uriContext", "+", "path", ",", "handler", ",", "config", ":", "{", "state", ":", "{", "failAction", ":", "'log'", "}", ",", "app", ",", "pre", "}", "}", ";", "}", "}" ]
Converts an array of Windshield routes into a an array of Hapi routes. Each route will use the same handler method, which accesses a set of Windshield adapters from the route to build a page object, and define a layout template to compile the page object into a web page. @param {handler} handler - Hapi route handler method @param {module:processRoutes.Route[]} routes - Array of Windshield route objects, which are processed into Hapi routes @param {string} uriContext - the URI context to be prepended to the paths of each route. @returns {object[]} - An array of Hapi route options objects
[ "Converts", "an", "array", "of", "Windshield", "routes", "into", "a", "an", "array", "of", "Hapi", "routes", ".", "Each", "route", "will", "use", "the", "same", "handler", "method", "which", "accesses", "a", "set", "of", "Windshield", "adapters", "from", "the", "route", "to", "build", "a", "page", "object", "and", "define", "a", "layout", "template", "to", "compile", "the", "page", "object", "into", "a", "web", "page", "." ]
fddd841c5d9e09251437c9a30cc39700e5e4a1f6
https://github.com/carsdotcom/windshieldjs/blob/fddd841c5d9e09251437c9a30cc39700e5e4a1f6/lib/processRoutes.js#L37-L82
train
atomantic/undermore
dist/undermore.js
function (object) { var sortedObj = {}, keys = _.keys(object); keys = _.sortBy(keys, function(key){ return key; }); _.each(keys, function(key) { if(_.isArray(object[key])) { sortedObj[key] = _.map(object[key], function(val) { return _.isObject(val) ? _.alphabetize(val) : val; }); } else if(_.isObject(object[key])){ sortedObj[key] = _.alphabetize(object[key]); } else { sortedObj[key] = object[key]; } }); return sortedObj; }
javascript
function (object) { var sortedObj = {}, keys = _.keys(object); keys = _.sortBy(keys, function(key){ return key; }); _.each(keys, function(key) { if(_.isArray(object[key])) { sortedObj[key] = _.map(object[key], function(val) { return _.isObject(val) ? _.alphabetize(val) : val; }); } else if(_.isObject(object[key])){ sortedObj[key] = _.alphabetize(object[key]); } else { sortedObj[key] = object[key]; } }); return sortedObj; }
[ "function", "(", "object", ")", "{", "var", "sortedObj", "=", "{", "}", ",", "keys", "=", "_", ".", "keys", "(", "object", ")", ";", "keys", "=", "_", ".", "sortBy", "(", "keys", ",", "function", "(", "key", ")", "{", "return", "key", ";", "}", ")", ";", "_", ".", "each", "(", "keys", ",", "function", "(", "key", ")", "{", "if", "(", "_", ".", "isArray", "(", "object", "[", "key", "]", ")", ")", "{", "sortedObj", "[", "key", "]", "=", "_", ".", "map", "(", "object", "[", "key", "]", ",", "function", "(", "val", ")", "{", "return", "_", ".", "isObject", "(", "val", ")", "?", "_", ".", "alphabetize", "(", "val", ")", ":", "val", ";", "}", ")", ";", "}", "else", "if", "(", "_", ".", "isObject", "(", "object", "[", "key", "]", ")", ")", "{", "sortedObj", "[", "key", "]", "=", "_", ".", "alphabetize", "(", "object", "[", "key", "]", ")", ";", "}", "else", "{", "sortedObj", "[", "key", "]", "=", "object", "[", "key", "]", ";", "}", "}", ")", ";", "return", "sortedObj", ";", "}" ]
sort the keys in an object alphabetically, recursively @function module:undermore.alphabetize @param {object} obj The object to traverse @return {mixed} the object with alphabetized keys @example var obj = { b: 1, a: 2 }; JSON.stringify(_.alphabetize(obj)) === '{"a":2,"b":1}'
[ "sort", "the", "keys", "in", "an", "object", "alphabetically", "recursively" ]
6c6d995460c25c1df087b465fdc4d21035b4c7b2
https://github.com/atomantic/undermore/blob/6c6d995460c25c1df087b465fdc4d21035b4c7b2/dist/undermore.js#L71-L92
train
atomantic/undermore
dist/undermore.js
function(str) { // allow browser implementation if it exists // https://developer.mozilla.org/en-US/docs/Web/API/window.btoa if (typeof atob!=='undefined') { // utf8 decode after the fact to make sure we convert > 0xFF to ascii return _.utf8_decode(atob(str)); } // allow node.js Buffer implementation if it exists if (Buffer) { return new Buffer(str, 'base64').toString('binary'); } // now roll our own // decoder // [https://gist.github.com/1020396] by [https://github.com/atk] str = str.replace(/=+$/, ''); for ( // initialize result and counters var bc = 0, bs, buffer, idx = 0, output = ''; // get next character buffer = str.charAt(idx++); // character found in table? initialize bit storage and add its ascii value; ~ buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, // and if not first of each 4 characters, // convert the first 8 bits to one ascii character bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 ) { // try to find character in table (0-63, not found => -1) buffer = chars.indexOf(buffer); } return output; }
javascript
function(str) { // allow browser implementation if it exists // https://developer.mozilla.org/en-US/docs/Web/API/window.btoa if (typeof atob!=='undefined') { // utf8 decode after the fact to make sure we convert > 0xFF to ascii return _.utf8_decode(atob(str)); } // allow node.js Buffer implementation if it exists if (Buffer) { return new Buffer(str, 'base64').toString('binary'); } // now roll our own // decoder // [https://gist.github.com/1020396] by [https://github.com/atk] str = str.replace(/=+$/, ''); for ( // initialize result and counters var bc = 0, bs, buffer, idx = 0, output = ''; // get next character buffer = str.charAt(idx++); // character found in table? initialize bit storage and add its ascii value; ~ buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, // and if not first of each 4 characters, // convert the first 8 bits to one ascii character bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 ) { // try to find character in table (0-63, not found => -1) buffer = chars.indexOf(buffer); } return output; }
[ "function", "(", "str", ")", "{", "if", "(", "typeof", "atob", "!==", "'undefined'", ")", "{", "return", "_", ".", "utf8_decode", "(", "atob", "(", "str", ")", ")", ";", "}", "if", "(", "Buffer", ")", "{", "return", "new", "Buffer", "(", "str", ",", "'base64'", ")", ".", "toString", "(", "'binary'", ")", ";", "}", "str", "=", "str", ".", "replace", "(", "/", "=+$", "/", ",", "''", ")", ";", "for", "(", "var", "bc", "=", "0", ",", "bs", ",", "buffer", ",", "idx", "=", "0", ",", "output", "=", "''", ";", "buffer", "=", "str", ".", "charAt", "(", "idx", "++", ")", ";", "~", "buffer", "&&", "(", "bs", "=", "bc", "%", "4", "?", "bs", "*", "64", "+", "buffer", ":", "buffer", ",", "bc", "++", "%", "4", ")", "?", "output", "+=", "String", ".", "fromCharCode", "(", "255", "&", "bs", ">>", "(", "-", "2", "*", "bc", "&", "6", ")", ")", ":", "0", ")", "{", "buffer", "=", "chars", ".", "indexOf", "(", "buffer", ")", ";", "}", "return", "output", ";", "}" ]
base64_decode decode a string. This is not a strict polyfill for window.atob because it handles unicode characters @function module:undermore.base64_decode @link https://github.com/davidchambers/Base64.js @param {string} str The string to decode @return {string} @example _.base64_decode('4pyI') => '✈'
[ "base64_decode", "decode", "a", "string", ".", "This", "is", "not", "a", "strict", "polyfill", "for", "window", ".", "atob", "because", "it", "handles", "unicode", "characters" ]
6c6d995460c25c1df087b465fdc4d21035b4c7b2
https://github.com/atomantic/undermore/blob/6c6d995460c25c1df087b465fdc4d21035b4c7b2/dist/undermore.js#L103-L134
train
atomantic/undermore
dist/undermore.js
function(originalFn, moreFn, scope) { return scope ? function() { originalFn.apply(scope, arguments); moreFn.apply(scope, arguments); } : function() { originalFn(); moreFn(); }; }
javascript
function(originalFn, moreFn, scope) { return scope ? function() { originalFn.apply(scope, arguments); moreFn.apply(scope, arguments); } : function() { originalFn(); moreFn(); }; }
[ "function", "(", "originalFn", ",", "moreFn", ",", "scope", ")", "{", "return", "scope", "?", "function", "(", ")", "{", "originalFn", ".", "apply", "(", "scope", ",", "arguments", ")", ";", "moreFn", ".", "apply", "(", "scope", ",", "arguments", ")", ";", "}", ":", "function", "(", ")", "{", "originalFn", "(", ")", ";", "moreFn", "(", ")", ";", "}", ";", "}" ]
get a new function, which runs two functions serially within a given context @function module:undermore.fnMore @param {function} originalFn The original function to run @param {function} moreFn The extra function to run in the same context after the first @param {object} scope The context in which to run the fn @return {function} the new function which will serially call the given functions in the given scope @example var fn = _.fnMore(oldFn,newFn,someObj); fn(); // runs oldFn, then newFn in the context of someObj
[ "get", "a", "new", "function", "which", "runs", "two", "functions", "serially", "within", "a", "given", "context" ]
6c6d995460c25c1df087b465fdc4d21035b4c7b2
https://github.com/atomantic/undermore/blob/6c6d995460c25c1df087b465fdc4d21035b4c7b2/dist/undermore.js#L215-L224
train
yangyxu/zeanium
dist/zn.reactnative.js
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor, _descriptor = {}; if(!_exist){ _descriptor = Object.defineProperty(target, 'on' + name.toLowerCase(), { get: function () { var _listeners = this.__handlers__[name]; if (_listeners) { return _listeners[0].handler; } else { return null; } }, set: function (value) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || []; _listeners[0] = { owner: this, handler: value, context: null }; } }); } _ctor[_key] = { name: name, type: 'event', meta: meta, descriptor: _descriptor }; return _exist; }
javascript
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor, _descriptor = {}; if(!_exist){ _descriptor = Object.defineProperty(target, 'on' + name.toLowerCase(), { get: function () { var _listeners = this.__handlers__[name]; if (_listeners) { return _listeners[0].handler; } else { return null; } }, set: function (value) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || []; _listeners[0] = { owner: this, handler: value, context: null }; } }); } _ctor[_key] = { name: name, type: 'event', meta: meta, descriptor: _descriptor }; return _exist; }
[ "function", "(", "target", ",", "name", ",", "meta", ")", "{", "var", "_ctor", "=", "__define", ".", "fixTargetCtor", "(", "target", ")", ",", "_key", "=", "__define", ".", "fixTargetKey", "(", "name", ")", ",", "_exist", "=", "_key", "in", "_ctor", ",", "_descriptor", "=", "{", "}", ";", "if", "(", "!", "_exist", ")", "{", "_descriptor", "=", "Object", ".", "defineProperty", "(", "target", ",", "'on'", "+", "name", ".", "toLowerCase", "(", ")", ",", "{", "get", ":", "function", "(", ")", "{", "var", "_listeners", "=", "this", ".", "__handlers__", "[", "name", "]", ";", "if", "(", "_listeners", ")", "{", "return", "_listeners", "[", "0", "]", ".", "handler", ";", "}", "else", "{", "return", "null", ";", "}", "}", ",", "set", ":", "function", "(", "value", ")", "{", "var", "_handlers", "=", "this", ".", "__handlers__", ";", "var", "_listeners", "=", "_handlers", "[", "name", "]", "=", "_handlers", "[", "name", "]", "||", "[", "]", ";", "_listeners", "[", "0", "]", "=", "{", "owner", ":", "this", ",", "handler", ":", "value", ",", "context", ":", "null", "}", ";", "}", "}", ")", ";", "}", "_ctor", "[", "_key", "]", "=", "{", "name", ":", "name", ",", "type", ":", "'event'", ",", "meta", ":", "meta", ",", "descriptor", ":", "_descriptor", "}", ";", "return", "_exist", ";", "}" ]
Define an event for target @param target @param name @param meta @returns {boolean}
[ "Define", "an", "event", "for", "target" ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L762-L799
train
yangyxu/zeanium
dist/zn.reactnative.js
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor, _descriptor = {}; var _getter, _setter; if ('value' in meta) { var _value = meta.value, _field = '_' + name, _get = meta.get, _set = meta.set; _getter = _get || function () { if (_field in this) { return this[_field]; } else { return zn.is(_value, 'function') ? _value.call(this) : _value; } }; _setter = meta.readonly ? function (value, options) { if (options && options.force) { this[_field] = value; } else { return false; } } : (_set ||function (value) { this[_field] = value; }); } else { _getter = meta.get || function () { return undefined; }; _setter = meta.set || function () { return false; }; } if (_exist) { _getter.__super__ = _ctor[_key].getter; _setter.__super__ = _ctor[_key].setter; } /* if(!_exist){ _descriptor = Object.defineProperty(target, name, { get: _getter, set: _setter, configurable : true }); }*/ _descriptor = Object.defineProperty(target, name, { get: _getter, set: _setter, configurable : true }); _ctor[_key] = { name: name, type: 'property', meta: meta, getter: _getter, setter: _setter, descriptor: _descriptor }; return _exist; }
javascript
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor, _descriptor = {}; var _getter, _setter; if ('value' in meta) { var _value = meta.value, _field = '_' + name, _get = meta.get, _set = meta.set; _getter = _get || function () { if (_field in this) { return this[_field]; } else { return zn.is(_value, 'function') ? _value.call(this) : _value; } }; _setter = meta.readonly ? function (value, options) { if (options && options.force) { this[_field] = value; } else { return false; } } : (_set ||function (value) { this[_field] = value; }); } else { _getter = meta.get || function () { return undefined; }; _setter = meta.set || function () { return false; }; } if (_exist) { _getter.__super__ = _ctor[_key].getter; _setter.__super__ = _ctor[_key].setter; } /* if(!_exist){ _descriptor = Object.defineProperty(target, name, { get: _getter, set: _setter, configurable : true }); }*/ _descriptor = Object.defineProperty(target, name, { get: _getter, set: _setter, configurable : true }); _ctor[_key] = { name: name, type: 'property', meta: meta, getter: _getter, setter: _setter, descriptor: _descriptor }; return _exist; }
[ "function", "(", "target", ",", "name", ",", "meta", ")", "{", "var", "_ctor", "=", "__define", ".", "fixTargetCtor", "(", "target", ")", ",", "_key", "=", "__define", ".", "fixTargetKey", "(", "name", ")", ",", "_exist", "=", "_key", "in", "_ctor", ",", "_descriptor", "=", "{", "}", ";", "var", "_getter", ",", "_setter", ";", "if", "(", "'value'", "in", "meta", ")", "{", "var", "_value", "=", "meta", ".", "value", ",", "_field", "=", "'_'", "+", "name", ",", "_get", "=", "meta", ".", "get", ",", "_set", "=", "meta", ".", "set", ";", "_getter", "=", "_get", "||", "function", "(", ")", "{", "if", "(", "_field", "in", "this", ")", "{", "return", "this", "[", "_field", "]", ";", "}", "else", "{", "return", "zn", ".", "is", "(", "_value", ",", "'function'", ")", "?", "_value", ".", "call", "(", "this", ")", ":", "_value", ";", "}", "}", ";", "_setter", "=", "meta", ".", "readonly", "?", "function", "(", "value", ",", "options", ")", "{", "if", "(", "options", "&&", "options", ".", "force", ")", "{", "this", "[", "_field", "]", "=", "value", ";", "}", "else", "{", "return", "false", ";", "}", "}", ":", "(", "_set", "||", "function", "(", "value", ")", "{", "this", "[", "_field", "]", "=", "value", ";", "}", ")", ";", "}", "else", "{", "_getter", "=", "meta", ".", "get", "||", "function", "(", ")", "{", "return", "undefined", ";", "}", ";", "_setter", "=", "meta", ".", "set", "||", "function", "(", ")", "{", "return", "false", ";", "}", ";", "}", "if", "(", "_exist", ")", "{", "_getter", ".", "__super__", "=", "_ctor", "[", "_key", "]", ".", "getter", ";", "_setter", ".", "__super__", "=", "_ctor", "[", "_key", "]", ".", "setter", ";", "}", "_descriptor", "=", "Object", ".", "defineProperty", "(", "target", ",", "name", ",", "{", "get", ":", "_getter", ",", "set", ":", "_setter", ",", "configurable", ":", "true", "}", ")", ";", "_ctor", "[", "_key", "]", "=", "{", "name", ":", "name", ",", "type", ":", "'property'", ",", "meta", ":", "meta", ",", "getter", ":", "_getter", ",", "setter", ":", "_setter", ",", "descriptor", ":", "_descriptor", "}", ";", "return", "_exist", ";", "}" ]
Define a property for target @param target @param name @param meta @returns {boolean}
[ "Define", "a", "property", "for", "target" ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L807-L880
train
yangyxu/zeanium
dist/zn.reactnative.js
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor; _ctor[_key] = { name: name, type: 'method', meta: meta }; if (name in target) { if(!meta.value){ meta.value = function (){ }; } meta.value.__super__ = target[name]; } target[name] = meta.value; return _exist; }
javascript
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor; _ctor[_key] = { name: name, type: 'method', meta: meta }; if (name in target) { if(!meta.value){ meta.value = function (){ }; } meta.value.__super__ = target[name]; } target[name] = meta.value; return _exist; }
[ "function", "(", "target", ",", "name", ",", "meta", ")", "{", "var", "_ctor", "=", "__define", ".", "fixTargetCtor", "(", "target", ")", ",", "_key", "=", "__define", ".", "fixTargetKey", "(", "name", ")", ",", "_exist", "=", "_key", "in", "_ctor", ";", "_ctor", "[", "_key", "]", "=", "{", "name", ":", "name", ",", "type", ":", "'method'", ",", "meta", ":", "meta", "}", ";", "if", "(", "name", "in", "target", ")", "{", "if", "(", "!", "meta", ".", "value", ")", "{", "meta", ".", "value", "=", "function", "(", ")", "{", "}", ";", "}", "meta", ".", "value", ".", "__super__", "=", "target", "[", "name", "]", ";", "}", "target", "[", "name", "]", "=", "meta", ".", "value", ";", "return", "_exist", ";", "}" ]
Define a method for target @param target @param name @param meta @returns {boolean}
[ "Define", "a", "method", "for", "target" ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L888-L912
train
yangyxu/zeanium
dist/zn.reactnative.js
function (name, target) { var _ctor = __define.fixTargetCtor(target||this), _member = _ctor[__define.fixTargetKey(name)]; if(!_member&&_ctor!==ZNObject){ return this.member(name, _ctor._super_); } return _member; }
javascript
function (name, target) { var _ctor = __define.fixTargetCtor(target||this), _member = _ctor[__define.fixTargetKey(name)]; if(!_member&&_ctor!==ZNObject){ return this.member(name, _ctor._super_); } return _member; }
[ "function", "(", "name", ",", "target", ")", "{", "var", "_ctor", "=", "__define", ".", "fixTargetCtor", "(", "target", "||", "this", ")", ",", "_member", "=", "_ctor", "[", "__define", ".", "fixTargetKey", "(", "name", ")", "]", ";", "if", "(", "!", "_member", "&&", "_ctor", "!==", "ZNObject", ")", "{", "return", "this", ".", "member", "(", "name", ",", "_ctor", ".", "_super_", ")", ";", "}", "return", "_member", ";", "}" ]
Get specified member. @param name @returns {*}
[ "Get", "specified", "member", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L923-L932
train
yangyxu/zeanium
dist/zn.reactnative.js
function (name, options) { var _member = this.member(name); if(_member && _member.getter){ return _member.getter.call(this, options); } return undefined; }
javascript
function (name, options) { var _member = this.member(name); if(_member && _member.getter){ return _member.getter.call(this, options); } return undefined; }
[ "function", "(", "name", ",", "options", ")", "{", "var", "_member", "=", "this", ".", "member", "(", "name", ")", ";", "if", "(", "_member", "&&", "_member", ".", "getter", ")", "{", "return", "_member", ".", "getter", ".", "call", "(", "this", ",", "options", ")", ";", "}", "return", "undefined", ";", "}" ]
Get specified property value. @method get @param name {String} @param [options] {Any} @returns {*}
[ "Get", "specified", "property", "value", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L970-L977
train
yangyxu/zeanium
dist/zn.reactnative.js
function (name, value, options) { var _member = this.member(name); if (_member && _member.setter) { _member.setter.call(this, value, options); } return this; }
javascript
function (name, value, options) { var _member = this.member(name); if (_member && _member.setter) { _member.setter.call(this, value, options); } return this; }
[ "function", "(", "name", ",", "value", ",", "options", ")", "{", "var", "_member", "=", "this", ".", "member", "(", "name", ")", ";", "if", "(", "_member", "&&", "_member", ".", "setter", ")", "{", "_member", ".", "setter", ".", "call", "(", "this", ",", "value", ",", "options", ")", ";", "}", "return", "this", ";", "}" ]
Set specified property value. @method set @param name {String} @param value {*} @param [options] {Any}
[ "Set", "specified", "property", "value", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L985-L992
train
yangyxu/zeanium
dist/zn.reactnative.js
function (options) { var _values = {}, _properties = __define.fixTargetCtor(this)._properties_; zn.each(_properties, function (name) { _values[name] = this.get(name, options); }, this); return _values; }
javascript
function (options) { var _values = {}, _properties = __define.fixTargetCtor(this)._properties_; zn.each(_properties, function (name) { _values[name] = this.get(name, options); }, this); return _values; }
[ "function", "(", "options", ")", "{", "var", "_values", "=", "{", "}", ",", "_properties", "=", "__define", ".", "fixTargetCtor", "(", "this", ")", ".", "_properties_", ";", "zn", ".", "each", "(", "_properties", ",", "function", "(", "name", ")", "{", "_values", "[", "name", "]", "=", "this", ".", "get", "(", "name", ",", "options", ")", ";", "}", ",", "this", ")", ";", "return", "_values", ";", "}" ]
Get all properties. @method gets @returns {Object} @param [options] {Any}
[ "Get", "all", "properties", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L999-L1007
train
yangyxu/zeanium
dist/zn.reactnative.js
function (values, options, callback) { if (values) { var _value = null; for (var _name in values) { if (values.hasOwnProperty(_name)) { _value = values[_name]; if((callback && callback(_value, _name, options))!==false){ this.set(_name, _value, options); } } } } return this; }
javascript
function (values, options, callback) { if (values) { var _value = null; for (var _name in values) { if (values.hasOwnProperty(_name)) { _value = values[_name]; if((callback && callback(_value, _name, options))!==false){ this.set(_name, _value, options); } } } } return this; }
[ "function", "(", "values", ",", "options", ",", "callback", ")", "{", "if", "(", "values", ")", "{", "var", "_value", "=", "null", ";", "for", "(", "var", "_name", "in", "values", ")", "{", "if", "(", "values", ".", "hasOwnProperty", "(", "_name", ")", ")", "{", "_value", "=", "values", "[", "_name", "]", ";", "if", "(", "(", "callback", "&&", "callback", "(", "_value", ",", "_name", ",", "options", ")", ")", "!==", "false", ")", "{", "this", ".", "set", "(", "_name", ",", "_value", ",", "options", ")", ";", "}", "}", "}", "}", "return", "this", ";", "}" ]
Set a bunch of properties. @method sets @param dict {Object} @param [options] {Any}
[ "Set", "a", "bunch", "of", "properties", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1014-L1028
train
yangyxu/zeanium
dist/zn.reactnative.js
function (name, meta, target) { if (!__define.defineEvent(target || this.prototype, name, meta)) { this._events_.push(name); } return this; }
javascript
function (name, meta, target) { if (!__define.defineEvent(target || this.prototype, name, meta)) { this._events_.push(name); } return this; }
[ "function", "(", "name", ",", "meta", ",", "target", ")", "{", "if", "(", "!", "__define", ".", "defineEvent", "(", "target", "||", "this", ".", "prototype", ",", "name", ",", "meta", ")", ")", "{", "this", ".", "_events_", ".", "push", "(", "name", ")", ";", "}", "return", "this", ";", "}" ]
Define an event. @method defineEvent @static @param name {String} @param [meta] {Object} @param [target] {Object}
[ "Define", "an", "event", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1157-L1163
train
yangyxu/zeanium
dist/zn.reactnative.js
function (name, meta, target) { if (!__define.defineProperty(target || this.prototype, name, meta)) { this._properties_.push(name); } return this; }
javascript
function (name, meta, target) { if (!__define.defineProperty(target || this.prototype, name, meta)) { this._properties_.push(name); } return this; }
[ "function", "(", "name", ",", "meta", ",", "target", ")", "{", "if", "(", "!", "__define", ".", "defineProperty", "(", "target", "||", "this", ".", "prototype", ",", "name", ",", "meta", ")", ")", "{", "this", ".", "_properties_", ".", "push", "(", "name", ")", ";", "}", "return", "this", ";", "}" ]
Define a property. @method defineProperty @static @param name {String} @param [meta] {Object} @param [target] {Object}
[ "Define", "a", "property", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1172-L1178
train
yangyxu/zeanium
dist/zn.reactnative.js
function (name, meta, target) { if (!__define.defineMethod(target || this.prototype, name, meta)) { this._methods_.push(name); } return this; }
javascript
function (name, meta, target) { if (!__define.defineMethod(target || this.prototype, name, meta)) { this._methods_.push(name); } return this; }
[ "function", "(", "name", ",", "meta", ",", "target", ")", "{", "if", "(", "!", "__define", ".", "defineMethod", "(", "target", "||", "this", ".", "prototype", ",", "name", ",", "meta", ")", ")", "{", "this", ".", "_methods_", ".", "push", "(", "name", ")", ";", "}", "return", "this", ";", "}" ]
Define a method. @method defineMethod @static @param name {String} @param meta {Object} @param [target] {Object}
[ "Define", "a", "method", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1187-L1193
train
yangyxu/zeanium
dist/zn.reactnative.js
function (){ var _info = { ClassName: (this.__name__ || 'Anonymous'), InstanceID: this.__id__, Meta: this.constructor._meta_ }; return JSON.stringify(_info); }
javascript
function (){ var _info = { ClassName: (this.__name__ || 'Anonymous'), InstanceID: this.__id__, Meta: this.constructor._meta_ }; return JSON.stringify(_info); }
[ "function", "(", ")", "{", "var", "_info", "=", "{", "ClassName", ":", "(", "this", ".", "__name__", "||", "'Anonymous'", ")", ",", "InstanceID", ":", "this", ".", "__id__", ",", "Meta", ":", "this", ".", "constructor", ".", "_meta_", "}", ";", "return", "JSON", ".", "stringify", "(", "_info", ")", ";", "}" ]
Instance Object to string value. @returns {string}
[ "Instance", "Object", "to", "string", "value", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1201-L1208
train
yangyxu/zeanium
dist/zn.reactnative.js
function (){ var _json = {}; zn.each(this.constructor.getProperties(), function (field, key){ _json[key] = this.get(key); }, this); return _json; }
javascript
function (){ var _json = {}; zn.each(this.constructor.getProperties(), function (field, key){ _json[key] = this.get(key); }, this); return _json; }
[ "function", "(", ")", "{", "var", "_json", "=", "{", "}", ";", "zn", ".", "each", "(", "this", ".", "constructor", ".", "getProperties", "(", ")", ",", "function", "(", "field", ",", "key", ")", "{", "_json", "[", "key", "]", "=", "this", ".", "get", "(", "key", ")", ";", "}", ",", "this", ")", ";", "return", "_json", ";", "}" ]
Instance Object to json value. @returns {json}
[ "Instance", "Object", "to", "json", "value", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1213-L1220
train
yangyxu/zeanium
dist/zn.reactnative.js
function (name, handler, options) { if (handler) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || []; _listeners[0] = zn.extend({ owner: this, handler: handler }, options); } return this; }
javascript
function (name, handler, options) { if (handler) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || []; _listeners[0] = zn.extend({ owner: this, handler: handler }, options); } return this; }
[ "function", "(", "name", ",", "handler", ",", "options", ")", "{", "if", "(", "handler", ")", "{", "var", "_handlers", "=", "this", ".", "__handlers__", ";", "var", "_listeners", "=", "_handlers", "[", "name", "]", "=", "_handlers", "[", "name", "]", "||", "[", "]", ";", "_listeners", "[", "0", "]", "=", "zn", ".", "extend", "(", "{", "owner", ":", "this", ",", "handler", ":", "handler", "}", ",", "options", ")", ";", "}", "return", "this", ";", "}" ]
Add a single event handler. @method upon @param name {String} @param handler {Function} @param [options] {Object}
[ "Add", "a", "single", "event", "handler", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1234-L1246
train
yangyxu/zeanium
dist/zn.reactnative.js
function (name, handler, options) { if (handler) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || [ { owner: null, handler: null, context: null } ]; _listeners.push(zn.extend({ owner: this, handler: handler }, options)); } return this; }
javascript
function (name, handler, options) { if (handler) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || [ { owner: null, handler: null, context: null } ]; _listeners.push(zn.extend({ owner: this, handler: handler }, options)); } return this; }
[ "function", "(", "name", ",", "handler", ",", "options", ")", "{", "if", "(", "handler", ")", "{", "var", "_handlers", "=", "this", ".", "__handlers__", ";", "var", "_listeners", "=", "_handlers", "[", "name", "]", "=", "_handlers", "[", "name", "]", "||", "[", "{", "owner", ":", "null", ",", "handler", ":", "null", ",", "context", ":", "null", "}", "]", ";", "_listeners", ".", "push", "(", "zn", ".", "extend", "(", "{", "owner", ":", "this", ",", "handler", ":", "handler", "}", ",", "options", ")", ")", ";", "}", "return", "this", ";", "}" ]
Add an event handler. @method on @param name {String} @param handler {Function} @param [options] {Object}
[ "Add", "an", "event", "handler", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1254-L1272
train
yangyxu/zeanium
dist/zn.reactnative.js
function (name, handler, options) { var _listeners = this.__handlers__[name]||[], _listener; var _context = options && options.context; if (handler) { for (var i = _listeners.length - 1; i >= 0; i--) { _listener = _listeners[i]; if (_listener.handler === handler && (!_context || _listener.context === _context )) { this.__handlers__[name].splice(i, 1); } } } else { this.__handlers__[name] = [ { owner: null, handler: null, context: null } ]; } return this; }
javascript
function (name, handler, options) { var _listeners = this.__handlers__[name]||[], _listener; var _context = options && options.context; if (handler) { for (var i = _listeners.length - 1; i >= 0; i--) { _listener = _listeners[i]; if (_listener.handler === handler && (!_context || _listener.context === _context )) { this.__handlers__[name].splice(i, 1); } } } else { this.__handlers__[name] = [ { owner: null, handler: null, context: null } ]; } return this; }
[ "function", "(", "name", ",", "handler", ",", "options", ")", "{", "var", "_listeners", "=", "this", ".", "__handlers__", "[", "name", "]", "||", "[", "]", ",", "_listener", ";", "var", "_context", "=", "options", "&&", "options", ".", "context", ";", "if", "(", "handler", ")", "{", "for", "(", "var", "i", "=", "_listeners", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "_listener", "=", "_listeners", "[", "i", "]", ";", "if", "(", "_listener", ".", "handler", "===", "handler", "&&", "(", "!", "_context", "||", "_listener", ".", "context", "===", "_context", ")", ")", "{", "this", ".", "__handlers__", "[", "name", "]", ".", "splice", "(", "i", ",", "1", ")", ";", "}", "}", "}", "else", "{", "this", ".", "__handlers__", "[", "name", "]", "=", "[", "{", "owner", ":", "null", ",", "handler", ":", "null", ",", "context", ":", "null", "}", "]", ";", "}", "return", "this", ";", "}" ]
Remove an event handler. @method off @param name {String} @param [handler] {Function} @param [options] {Object}
[ "Remove", "an", "event", "handler", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1280-L1302
train
yangyxu/zeanium
dist/zn.reactnative.js
function (name, data, options) { var _listeners = this.__handlers__[name], _listener, _result = null; if (_listeners) { for (var i = 0, length = _listeners.length; i < length; i++) { _listener = _listeners[i]; if (_listener && _listener.handler) { if(options && options.method=='apply'){ _result = _listener.handler.apply(_listener.context || _listener.owner, data); } else { _result = _listener.handler.call(_listener.context || _listener.owner, _listener.owner, data, options); } if (false === _result) { return false; } } } } return this; }
javascript
function (name, data, options) { var _listeners = this.__handlers__[name], _listener, _result = null; if (_listeners) { for (var i = 0, length = _listeners.length; i < length; i++) { _listener = _listeners[i]; if (_listener && _listener.handler) { if(options && options.method=='apply'){ _result = _listener.handler.apply(_listener.context || _listener.owner, data); } else { _result = _listener.handler.call(_listener.context || _listener.owner, _listener.owner, data, options); } if (false === _result) { return false; } } } } return this; }
[ "function", "(", "name", ",", "data", ",", "options", ")", "{", "var", "_listeners", "=", "this", ".", "__handlers__", "[", "name", "]", ",", "_listener", ",", "_result", "=", "null", ";", "if", "(", "_listeners", ")", "{", "for", "(", "var", "i", "=", "0", ",", "length", "=", "_listeners", ".", "length", ";", "i", "<", "length", ";", "i", "++", ")", "{", "_listener", "=", "_listeners", "[", "i", "]", ";", "if", "(", "_listener", "&&", "_listener", ".", "handler", ")", "{", "if", "(", "options", "&&", "options", ".", "method", "==", "'apply'", ")", "{", "_result", "=", "_listener", ".", "handler", ".", "apply", "(", "_listener", ".", "context", "||", "_listener", ".", "owner", ",", "data", ")", ";", "}", "else", "{", "_result", "=", "_listener", ".", "handler", ".", "call", "(", "_listener", ".", "context", "||", "_listener", ".", "owner", ",", "_listener", ".", "owner", ",", "data", ",", "options", ")", ";", "}", "if", "(", "false", "===", "_result", ")", "{", "return", "false", ";", "}", "}", "}", "}", "return", "this", ";", "}" ]
Trigger an event. @method fire @param name {String} @param [data] {*} @param [options] {Object}
[ "Trigger", "an", "event", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1330-L1351
train
yangyxu/zeanium
dist/zn.reactnative.js
function (type) { if (typeof type === 'string') { type = zn.path(GLOBAL, type); } if (type) { if (this instanceof type) { return true; } else { var _mixins = this.constructor._mixins_; for (var i = 0, _len = _mixins.length; i < _len; i++) { var _mixin = _mixins[i]; if (type === _mixin) { return true; } } } } return false; }
javascript
function (type) { if (typeof type === 'string') { type = zn.path(GLOBAL, type); } if (type) { if (this instanceof type) { return true; } else { var _mixins = this.constructor._mixins_; for (var i = 0, _len = _mixins.length; i < _len; i++) { var _mixin = _mixins[i]; if (type === _mixin) { return true; } } } } return false; }
[ "function", "(", "type", ")", "{", "if", "(", "typeof", "type", "===", "'string'", ")", "{", "type", "=", "zn", ".", "path", "(", "GLOBAL", ",", "type", ")", ";", "}", "if", "(", "type", ")", "{", "if", "(", "this", "instanceof", "type", ")", "{", "return", "true", ";", "}", "else", "{", "var", "_mixins", "=", "this", ".", "constructor", ".", "_mixins_", ";", "for", "(", "var", "i", "=", "0", ",", "_len", "=", "_mixins", ".", "length", ";", "i", "<", "_len", ";", "i", "++", ")", "{", "var", "_mixin", "=", "_mixins", "[", "i", "]", ";", "if", "(", "type", "===", "_mixin", ")", "{", "return", "true", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
Check whether current object is specified type. @method is @param type {String|Function} @returns {Boolean}
[ "Check", "whether", "current", "object", "is", "specified", "type", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1382-L1402
train
eswdd/aardvark
static-content/ScatterRenderer.js
function(into, data) { var existingDataLen = into.length == 0 ? 0 : into[0].length - 1; var i = 0; var j = 0; for (; i<into.length && j<data.length; ) { if (into[i][0] == data[j][0]) { into[i].push(data[j][1]); i++; j++; } else if (into[i][0] < data[j][0]) { into[i].push(null); i++; } else { var arr = [data[j][0]]; for (var k=1; k<into[i].length; k++) { arr.push(null); } arr.push(data[j][1]); into.splice(i,0,arr); i++; j++; } } while (j<data.length) { var arr = [data[j][0]]; for (var k=0; k<existingDataLen; k++) { arr.push(null); } arr.push(data[j][1]); into.push(arr); j++; } }
javascript
function(into, data) { var existingDataLen = into.length == 0 ? 0 : into[0].length - 1; var i = 0; var j = 0; for (; i<into.length && j<data.length; ) { if (into[i][0] == data[j][0]) { into[i].push(data[j][1]); i++; j++; } else if (into[i][0] < data[j][0]) { into[i].push(null); i++; } else { var arr = [data[j][0]]; for (var k=1; k<into[i].length; k++) { arr.push(null); } arr.push(data[j][1]); into.splice(i,0,arr); i++; j++; } } while (j<data.length) { var arr = [data[j][0]]; for (var k=0; k<existingDataLen; k++) { arr.push(null); } arr.push(data[j][1]); into.push(arr); j++; } }
[ "function", "(", "into", ",", "data", ")", "{", "var", "existingDataLen", "=", "into", ".", "length", "==", "0", "?", "0", ":", "into", "[", "0", "]", ".", "length", "-", "1", ";", "var", "i", "=", "0", ";", "var", "j", "=", "0", ";", "for", "(", ";", "i", "<", "into", ".", "length", "&&", "j", "<", "data", ".", "length", ";", ")", "{", "if", "(", "into", "[", "i", "]", "[", "0", "]", "==", "data", "[", "j", "]", "[", "0", "]", ")", "{", "into", "[", "i", "]", ".", "push", "(", "data", "[", "j", "]", "[", "1", "]", ")", ";", "i", "++", ";", "j", "++", ";", "}", "else", "if", "(", "into", "[", "i", "]", "[", "0", "]", "<", "data", "[", "j", "]", "[", "0", "]", ")", "{", "into", "[", "i", "]", ".", "push", "(", "null", ")", ";", "i", "++", ";", "}", "else", "{", "var", "arr", "=", "[", "data", "[", "j", "]", "[", "0", "]", "]", ";", "for", "(", "var", "k", "=", "1", ";", "k", "<", "into", "[", "i", "]", ".", "length", ";", "k", "++", ")", "{", "arr", ".", "push", "(", "null", ")", ";", "}", "arr", ".", "push", "(", "data", "[", "j", "]", "[", "1", "]", ")", ";", "into", ".", "splice", "(", "i", ",", "0", ",", "arr", ")", ";", "i", "++", ";", "j", "++", ";", "}", "}", "while", "(", "j", "<", "data", ".", "length", ")", "{", "var", "arr", "=", "[", "data", "[", "j", "]", "[", "0", "]", "]", ";", "for", "(", "var", "k", "=", "0", ";", "k", "<", "existingDataLen", ";", "k", "++", ")", "{", "arr", ".", "push", "(", "null", ")", ";", "}", "arr", ".", "push", "(", "data", "[", "j", "]", "[", "1", "]", ")", ";", "into", ".", "push", "(", "arr", ")", ";", "j", "++", ";", "}", "}" ]
should both be sorted already
[ "should", "both", "be", "sorted", "already" ]
7e0797fe5cde53047e610bd866d22e6caf0c6d49
https://github.com/eswdd/aardvark/blob/7e0797fe5cde53047e610bd866d22e6caf0c6d49/static-content/ScatterRenderer.js#L208-L242
train
quentinrossetti/version-sort
index.js
composeVersion
function composeVersion (str, regex) { var r = regex.exec(str) return { number: r[ 1 ], stage: r[ 2 ] || null, stageName: r[ 3 ] || null, stageNumber: r[ 4 ] || null } }
javascript
function composeVersion (str, regex) { var r = regex.exec(str) return { number: r[ 1 ], stage: r[ 2 ] || null, stageName: r[ 3 ] || null, stageNumber: r[ 4 ] || null } }
[ "function", "composeVersion", "(", "str", ",", "regex", ")", "{", "var", "r", "=", "regex", ".", "exec", "(", "str", ")", "return", "{", "number", ":", "r", "[", "1", "]", ",", "stage", ":", "r", "[", "2", "]", "||", "null", ",", "stageName", ":", "r", "[", "3", "]", "||", "null", ",", "stageNumber", ":", "r", "[", "4", "]", "||", "null", "}", "}" ]
Transform a string into an exploitable version object. @param str The original string @returns {{number: *, stage: (*|null), stageName: (*|null), stageNumber: (*|null)}}
[ "Transform", "a", "string", "into", "an", "exploitable", "version", "object", "." ]
3e8855216f14f12e99497bd487355c06076ceedc
https://github.com/quentinrossetti/version-sort/blob/3e8855216f14f12e99497bd487355c06076ceedc/index.js#L167-L175
train
cevadtokatli/cordelia
dist/js/cordelia.esm.js
createEvent
function createEvent(name) { var event = void 0; if (typeof document !== 'undefined') { event = document.createEvent('HTMLEvents') || document.createEvent('event'); event.initEvent(name, false, true); } return event; }
javascript
function createEvent(name) { var event = void 0; if (typeof document !== 'undefined') { event = document.createEvent('HTMLEvents') || document.createEvent('event'); event.initEvent(name, false, true); } return event; }
[ "function", "createEvent", "(", "name", ")", "{", "var", "event", "=", "void", "0", ";", "if", "(", "typeof", "document", "!==", "'undefined'", ")", "{", "event", "=", "document", ".", "createEvent", "(", "'HTMLEvents'", ")", "||", "document", ".", "createEvent", "(", "'event'", ")", ";", "event", ".", "initEvent", "(", "name", ",", "false", ",", "true", ")", ";", "}", "return", "event", ";", "}" ]
Creates a new event and initalizes it. @param {String} name @returns {Event}
[ "Creates", "a", "new", "event", "and", "initalizes", "it", "." ]
ac2c66c6844b28d3bf9ceb2c4c22b20bda0fc5ca
https://github.com/cevadtokatli/cordelia/blob/ac2c66c6844b28d3bf9ceb2c4c22b20bda0fc5ca/dist/js/cordelia.esm.js#L1229-L1236
train
eswdd/aardvark
static-content/DeepUtils.js
function(target, skeleton) { // console.log("Applying change: "+JSON.stringify(skeleton)); if (skeleton == null) { return false; } if (typeof skeleton != typeof target) { return false; } switch (typeof skeleton) { case 'string': case 'number': case 'boolean': // gone too far return false; case 'object': if (skeleton instanceof Array) { // for now only support direct replacement/mutation of elements, skeleton is insufficient to describe splicing if (target.length != skeleton.length) { return false; } var changed = false; for (var i=0; i<skeleton.length; i++) { if (skeleton[i] == null) { continue; } switch (typeof skeleton[i]) { case 'string': case 'number': case 'boolean': changed = (target[i] != skeleton[i]) || changed; target[i] = skeleton[i]; break; case 'object': changed = deepApply(target[i], skeleton[i]) || changed; break; default: throw 'Unrecognized type: '+(typeof skeleton[i]); } } return changed; } else { var changed = false; for (var k in skeleton) { if (skeleton.hasOwnProperty(k)) { if (target.hasOwnProperty(k)) { if (skeleton[k] == null) { continue; } switch (typeof skeleton[k]) { case 'string': case 'number': case 'boolean': changed = target[k] != skeleton[k] || changed; target[k] = skeleton[k]; break; case 'object': changed = deepApply(target[k], skeleton[k]) || changed; break; default: throw 'Unrecognized type: '+(typeof skeleton[k]); } } else { target[k] = skeleton[k]; } } } return changed; } break; default: throw 'Unrecognized type: '+(typeof incoming); } }
javascript
function(target, skeleton) { // console.log("Applying change: "+JSON.stringify(skeleton)); if (skeleton == null) { return false; } if (typeof skeleton != typeof target) { return false; } switch (typeof skeleton) { case 'string': case 'number': case 'boolean': // gone too far return false; case 'object': if (skeleton instanceof Array) { // for now only support direct replacement/mutation of elements, skeleton is insufficient to describe splicing if (target.length != skeleton.length) { return false; } var changed = false; for (var i=0; i<skeleton.length; i++) { if (skeleton[i] == null) { continue; } switch (typeof skeleton[i]) { case 'string': case 'number': case 'boolean': changed = (target[i] != skeleton[i]) || changed; target[i] = skeleton[i]; break; case 'object': changed = deepApply(target[i], skeleton[i]) || changed; break; default: throw 'Unrecognized type: '+(typeof skeleton[i]); } } return changed; } else { var changed = false; for (var k in skeleton) { if (skeleton.hasOwnProperty(k)) { if (target.hasOwnProperty(k)) { if (skeleton[k] == null) { continue; } switch (typeof skeleton[k]) { case 'string': case 'number': case 'boolean': changed = target[k] != skeleton[k] || changed; target[k] = skeleton[k]; break; case 'object': changed = deepApply(target[k], skeleton[k]) || changed; break; default: throw 'Unrecognized type: '+(typeof skeleton[k]); } } else { target[k] = skeleton[k]; } } } return changed; } break; default: throw 'Unrecognized type: '+(typeof incoming); } }
[ "function", "(", "target", ",", "skeleton", ")", "{", "if", "(", "skeleton", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "typeof", "skeleton", "!=", "typeof", "target", ")", "{", "return", "false", ";", "}", "switch", "(", "typeof", "skeleton", ")", "{", "case", "'string'", ":", "case", "'number'", ":", "case", "'boolean'", ":", "return", "false", ";", "case", "'object'", ":", "if", "(", "skeleton", "instanceof", "Array", ")", "{", "if", "(", "target", ".", "length", "!=", "skeleton", ".", "length", ")", "{", "return", "false", ";", "}", "var", "changed", "=", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "skeleton", ".", "length", ";", "i", "++", ")", "{", "if", "(", "skeleton", "[", "i", "]", "==", "null", ")", "{", "continue", ";", "}", "switch", "(", "typeof", "skeleton", "[", "i", "]", ")", "{", "case", "'string'", ":", "case", "'number'", ":", "case", "'boolean'", ":", "changed", "=", "(", "target", "[", "i", "]", "!=", "skeleton", "[", "i", "]", ")", "||", "changed", ";", "target", "[", "i", "]", "=", "skeleton", "[", "i", "]", ";", "break", ";", "case", "'object'", ":", "changed", "=", "deepApply", "(", "target", "[", "i", "]", ",", "skeleton", "[", "i", "]", ")", "||", "changed", ";", "break", ";", "default", ":", "throw", "'Unrecognized type: '", "+", "(", "typeof", "skeleton", "[", "i", "]", ")", ";", "}", "}", "return", "changed", ";", "}", "else", "{", "var", "changed", "=", "false", ";", "for", "(", "var", "k", "in", "skeleton", ")", "{", "if", "(", "skeleton", ".", "hasOwnProperty", "(", "k", ")", ")", "{", "if", "(", "target", ".", "hasOwnProperty", "(", "k", ")", ")", "{", "if", "(", "skeleton", "[", "k", "]", "==", "null", ")", "{", "continue", ";", "}", "switch", "(", "typeof", "skeleton", "[", "k", "]", ")", "{", "case", "'string'", ":", "case", "'number'", ":", "case", "'boolean'", ":", "changed", "=", "target", "[", "k", "]", "!=", "skeleton", "[", "k", "]", "||", "changed", ";", "target", "[", "k", "]", "=", "skeleton", "[", "k", "]", ";", "break", ";", "case", "'object'", ":", "changed", "=", "deepApply", "(", "target", "[", "k", "]", ",", "skeleton", "[", "k", "]", ")", "||", "changed", ";", "break", ";", "default", ":", "throw", "'Unrecognized type: '", "+", "(", "typeof", "skeleton", "[", "k", "]", ")", ";", "}", "}", "else", "{", "target", "[", "k", "]", "=", "skeleton", "[", "k", "]", ";", "}", "}", "}", "return", "changed", ";", "}", "break", ";", "default", ":", "throw", "'Unrecognized type: '", "+", "(", "typeof", "incoming", ")", ";", "}", "}" ]
Deep applies a skeleton change to the target object
[ "Deep", "applies", "a", "skeleton", "change", "to", "the", "target", "object" ]
7e0797fe5cde53047e610bd866d22e6caf0c6d49
https://github.com/eswdd/aardvark/blob/7e0797fe5cde53047e610bd866d22e6caf0c6d49/static-content/DeepUtils.js#L50-L126
train
solid/source-pane
sourcePane.js
function (newPaneOptions) { var newInstance = newPaneOptions.newInstance if (!newInstance) { let uri = newPaneOptions.newBase if (uri.endsWith('/')) { uri = uri.slice(0, -1) newPaneOptions.newBase = uri } newInstance = kb.sym(uri) newPaneOptions.newInstance = newInstance } var contentType = mime.lookup(newInstance.uri) if (!contentType || !(contentType.startsWith('text') || contentType.includes('xml'))) { let msg = 'A new text file has to have an file extension like .txt .ttl etc.' alert(msg) throw new Error(msg) } return new Promise(function (resolve, reject) { kb.fetcher.webOperation('PUT', newInstance.uri, {data: '\n', contentType: contentType}) .then(function (response) { console.log('New text file created: ' + newInstance.uri) newPaneOptions.newInstance = newInstance resolve(newPaneOptions) }, err => { alert('Cant make new file: ' + err) reject(err) }) }) }
javascript
function (newPaneOptions) { var newInstance = newPaneOptions.newInstance if (!newInstance) { let uri = newPaneOptions.newBase if (uri.endsWith('/')) { uri = uri.slice(0, -1) newPaneOptions.newBase = uri } newInstance = kb.sym(uri) newPaneOptions.newInstance = newInstance } var contentType = mime.lookup(newInstance.uri) if (!contentType || !(contentType.startsWith('text') || contentType.includes('xml'))) { let msg = 'A new text file has to have an file extension like .txt .ttl etc.' alert(msg) throw new Error(msg) } return new Promise(function (resolve, reject) { kb.fetcher.webOperation('PUT', newInstance.uri, {data: '\n', contentType: contentType}) .then(function (response) { console.log('New text file created: ' + newInstance.uri) newPaneOptions.newInstance = newInstance resolve(newPaneOptions) }, err => { alert('Cant make new file: ' + err) reject(err) }) }) }
[ "function", "(", "newPaneOptions", ")", "{", "var", "newInstance", "=", "newPaneOptions", ".", "newInstance", "if", "(", "!", "newInstance", ")", "{", "let", "uri", "=", "newPaneOptions", ".", "newBase", "if", "(", "uri", ".", "endsWith", "(", "'/'", ")", ")", "{", "uri", "=", "uri", ".", "slice", "(", "0", ",", "-", "1", ")", "newPaneOptions", ".", "newBase", "=", "uri", "}", "newInstance", "=", "kb", ".", "sym", "(", "uri", ")", "newPaneOptions", ".", "newInstance", "=", "newInstance", "}", "var", "contentType", "=", "mime", ".", "lookup", "(", "newInstance", ".", "uri", ")", "if", "(", "!", "contentType", "||", "!", "(", "contentType", ".", "startsWith", "(", "'text'", ")", "||", "contentType", ".", "includes", "(", "'xml'", ")", ")", ")", "{", "let", "msg", "=", "'A new text file has to have an file extension like .txt .ttl etc.'", "alert", "(", "msg", ")", "throw", "new", "Error", "(", "msg", ")", "}", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "kb", ".", "fetcher", ".", "webOperation", "(", "'PUT'", ",", "newInstance", ".", "uri", ",", "{", "data", ":", "'\\n'", ",", "\\n", "}", ")", ".", "contentType", ":", "contentType", "then", "}", ")", "}" ]
Create a new text file in a Solid system,
[ "Create", "a", "new", "text", "file", "in", "a", "Solid", "system" ]
cd7803323fd79016c78eac08000faf0d40d285cf
https://github.com/solid/source-pane/blob/cd7803323fd79016c78eac08000faf0d40d285cf/sourcePane.js#L28-L58
train
jamiebuilds/graph-sequencer
index.js
visit
function visit(item, cycle) { let visitedDeps = visited.get(item); // Create an object for the item to mark visited deps. if (!visitedDeps) { visitedDeps = []; visited.set(item, visitedDeps); } // Get the current deps for the item. let deps = currDepsMap.get(item); if (typeof deps === 'undefined') return; // For each dep, for (let dep of deps) { // Check if this dep creates a cycle. We know it's a cycle if the first // item is the same as our dep. if (cycle[0] === dep) { cycles.push(cycle); } // If an item hasn't been visited, visit it (and pass an updated // potential cycle) if (!arrayIncludes(visitedDeps, dep)) { visitedDeps.push(dep); visit(dep, cycle.concat(dep)); } } }
javascript
function visit(item, cycle) { let visitedDeps = visited.get(item); // Create an object for the item to mark visited deps. if (!visitedDeps) { visitedDeps = []; visited.set(item, visitedDeps); } // Get the current deps for the item. let deps = currDepsMap.get(item); if (typeof deps === 'undefined') return; // For each dep, for (let dep of deps) { // Check if this dep creates a cycle. We know it's a cycle if the first // item is the same as our dep. if (cycle[0] === dep) { cycles.push(cycle); } // If an item hasn't been visited, visit it (and pass an updated // potential cycle) if (!arrayIncludes(visitedDeps, dep)) { visitedDeps.push(dep); visit(dep, cycle.concat(dep)); } } }
[ "function", "visit", "(", "item", ",", "cycle", ")", "{", "let", "visitedDeps", "=", "visited", ".", "get", "(", "item", ")", ";", "if", "(", "!", "visitedDeps", ")", "{", "visitedDeps", "=", "[", "]", ";", "visited", ".", "set", "(", "item", ",", "visitedDeps", ")", ";", "}", "let", "deps", "=", "currDepsMap", ".", "get", "(", "item", ")", ";", "if", "(", "typeof", "deps", "===", "'undefined'", ")", "return", ";", "for", "(", "let", "dep", "of", "deps", ")", "{", "if", "(", "cycle", "[", "0", "]", "===", "dep", ")", "{", "cycles", ".", "push", "(", "cycle", ")", ";", "}", "if", "(", "!", "arrayIncludes", "(", "visitedDeps", ",", "dep", ")", ")", "{", "visitedDeps", ".", "push", "(", "dep", ")", ";", "visit", "(", "dep", ",", "cycle", ".", "concat", "(", "dep", ")", ")", ";", "}", "}", "}" ]
Create a function to call recursively in a depth-first search.
[ "Create", "a", "function", "to", "call", "recursively", "in", "a", "depth", "-", "first", "search", "." ]
565c024a02a1e3b83758149a2fd4eeb24753a898
https://github.com/jamiebuilds/graph-sequencer/blob/565c024a02a1e3b83758149a2fd4eeb24753a898/index.js#L32-L60
train
botmasterai/node-red-contrib-botmaster
dist/botmaster.js
setupBotStatus
function setupBotStatus(bot, node) { var updates = 0; var replies = 0; var updateText = function updateText() { return updates !== 1 ? updates + ' updates' : updates + ' update'; }; var replyText= function replyText() { return replies !== 1 ? replies + ' replies': replies + ' reply'; }; var updateStatus = function updateStatus() { node.status({fill: 'green', shape: 'dot', text: updateText() + '; ' + replyText() }); }; node.status({fill: 'grey', shape: 'ring', text: 'inactive'}); bot.on('update', function updateCallback() { updates += 1; updateStatus(); }); bot.on('error', function errorCallback(error) { node.error(error); node.status({fill: 'red', shape: 'dot', text: 'error'}); }); bot.use('outgoing', function outgoingCallback(bot, update, message, next) { replies += 1; updateStatus(); next(); }); }
javascript
function setupBotStatus(bot, node) { var updates = 0; var replies = 0; var updateText = function updateText() { return updates !== 1 ? updates + ' updates' : updates + ' update'; }; var replyText= function replyText() { return replies !== 1 ? replies + ' replies': replies + ' reply'; }; var updateStatus = function updateStatus() { node.status({fill: 'green', shape: 'dot', text: updateText() + '; ' + replyText() }); }; node.status({fill: 'grey', shape: 'ring', text: 'inactive'}); bot.on('update', function updateCallback() { updates += 1; updateStatus(); }); bot.on('error', function errorCallback(error) { node.error(error); node.status({fill: 'red', shape: 'dot', text: 'error'}); }); bot.use('outgoing', function outgoingCallback(bot, update, message, next) { replies += 1; updateStatus(); next(); }); }
[ "function", "setupBotStatus", "(", "bot", ",", "node", ")", "{", "var", "updates", "=", "0", ";", "var", "replies", "=", "0", ";", "var", "updateText", "=", "function", "updateText", "(", ")", "{", "return", "updates", "!==", "1", "?", "updates", "+", "' updates'", ":", "updates", "+", "' update'", ";", "}", ";", "var", "replyText", "=", "function", "replyText", "(", ")", "{", "return", "replies", "!==", "1", "?", "replies", "+", "' replies'", ":", "replies", "+", "' reply'", ";", "}", ";", "var", "updateStatus", "=", "function", "updateStatus", "(", ")", "{", "node", ".", "status", "(", "{", "fill", ":", "'green'", ",", "shape", ":", "'dot'", ",", "text", ":", "updateText", "(", ")", "+", "'; '", "+", "replyText", "(", ")", "}", ")", ";", "}", ";", "node", ".", "status", "(", "{", "fill", ":", "'grey'", ",", "shape", ":", "'ring'", ",", "text", ":", "'inactive'", "}", ")", ";", "bot", ".", "on", "(", "'update'", ",", "function", "updateCallback", "(", ")", "{", "updates", "+=", "1", ";", "updateStatus", "(", ")", ";", "}", ")", ";", "bot", ".", "on", "(", "'error'", ",", "function", "errorCallback", "(", "error", ")", "{", "node", ".", "error", "(", "error", ")", ";", "node", ".", "status", "(", "{", "fill", ":", "'red'", ",", "shape", ":", "'dot'", ",", "text", ":", "'error'", "}", ")", ";", "}", ")", ";", "bot", ".", "use", "(", "'outgoing'", ",", "function", "outgoingCallback", "(", "bot", ",", "update", ",", "message", ",", "next", ")", "{", "replies", "+=", "1", ";", "updateStatus", "(", ")", ";", "next", "(", ")", ";", "}", ")", ";", "}" ]
Show a little status next to each configured bot
[ "Show", "a", "little", "status", "next", "to", "each", "configured", "bot" ]
8a42897b15f7f99c1e7989ea9eacc3eceefa0905
https://github.com/botmasterai/node-red-contrib-botmaster/blob/8a42897b15f7f99c1e7989ea9eacc3eceefa0905/dist/botmaster.js#L57-L87
train
scienceai/jsonld-rdfa-parser
src/index.js
processGraph
function processGraph(data) { let dataset = { '@default': [] }; let subjects = data.subjects, htmlMapper = n => { let div = n.ownerDocument.createElement('div'); div.appendChild(n.cloneNode(true)); return div.innerHTML; }; Object.keys(subjects).forEach(subject => { let predicates = subjects[subject].predicates; Object.keys(predicates).forEach(predicate => { // iterate over objects let objects = predicates[predicate].objects; for (let oi = 0; oi < objects.length; ++oi) { let object = objects[oi]; // create RDF triple let triple = {}; // add subject & predicate triple.subject = { type: subject.indexOf('_:') === 0 ? 'blank node' : 'IRI', value: subject }; triple.predicate = { type: predicate.indexOf('_:') === 0 ? 'blank node' : 'IRI', value: predicate }; triple.object = {}; // serialize XML literal let value = object.value; // !!! TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // The below actually most likely does NOT work. // In most usage contexts this will be an HTML DOM, passing it to xmldom's XMLSerializer // will cause it to call .toString() on all the nodes it finds — this only works inside // xmldom. if (object.type === RDF_XML_LITERAL) { // initialize XMLSerializer let serializer = new XMLSerializer(); value = Array.from(object.value) .map(n => serializer.serializeToString(n)) .join(''); triple.object.datatype = RDF_XML_LITERAL; } // serialise HTML literal else if (object.type === RDF_HTML_LITERAL) { value = Array.from(object.value) .map(htmlMapper) .join(''); triple.object.datatype = RDF_HTML_LITERAL; } // object is an IRI else if (object.type === RDF_OBJECT) { if (object.value.indexOf('_:') === 0) triple.object.type = 'blank node'; else triple.object.type = 'IRI'; } else { // object is a literal triple.object.type = 'literal'; if (object.type === RDF_PLAIN_LITERAL) { if (object.language) { triple.object.datatype = RDF_LANGSTRING; triple.object.language = object.language; } else { triple.object.datatype = XSD_STRING; } } else { triple.object.datatype = object.type; } } triple.object.value = value; // add triple to dataset in default graph dataset['@default'].push(triple); } }); }); return dataset; }
javascript
function processGraph(data) { let dataset = { '@default': [] }; let subjects = data.subjects, htmlMapper = n => { let div = n.ownerDocument.createElement('div'); div.appendChild(n.cloneNode(true)); return div.innerHTML; }; Object.keys(subjects).forEach(subject => { let predicates = subjects[subject].predicates; Object.keys(predicates).forEach(predicate => { // iterate over objects let objects = predicates[predicate].objects; for (let oi = 0; oi < objects.length; ++oi) { let object = objects[oi]; // create RDF triple let triple = {}; // add subject & predicate triple.subject = { type: subject.indexOf('_:') === 0 ? 'blank node' : 'IRI', value: subject }; triple.predicate = { type: predicate.indexOf('_:') === 0 ? 'blank node' : 'IRI', value: predicate }; triple.object = {}; // serialize XML literal let value = object.value; // !!! TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // The below actually most likely does NOT work. // In most usage contexts this will be an HTML DOM, passing it to xmldom's XMLSerializer // will cause it to call .toString() on all the nodes it finds — this only works inside // xmldom. if (object.type === RDF_XML_LITERAL) { // initialize XMLSerializer let serializer = new XMLSerializer(); value = Array.from(object.value) .map(n => serializer.serializeToString(n)) .join(''); triple.object.datatype = RDF_XML_LITERAL; } // serialise HTML literal else if (object.type === RDF_HTML_LITERAL) { value = Array.from(object.value) .map(htmlMapper) .join(''); triple.object.datatype = RDF_HTML_LITERAL; } // object is an IRI else if (object.type === RDF_OBJECT) { if (object.value.indexOf('_:') === 0) triple.object.type = 'blank node'; else triple.object.type = 'IRI'; } else { // object is a literal triple.object.type = 'literal'; if (object.type === RDF_PLAIN_LITERAL) { if (object.language) { triple.object.datatype = RDF_LANGSTRING; triple.object.language = object.language; } else { triple.object.datatype = XSD_STRING; } } else { triple.object.datatype = object.type; } } triple.object.value = value; // add triple to dataset in default graph dataset['@default'].push(triple); } }); }); return dataset; }
[ "function", "processGraph", "(", "data", ")", "{", "let", "dataset", "=", "{", "'@default'", ":", "[", "]", "}", ";", "let", "subjects", "=", "data", ".", "subjects", ",", "htmlMapper", "=", "n", "=>", "{", "let", "div", "=", "n", ".", "ownerDocument", ".", "createElement", "(", "'div'", ")", ";", "div", ".", "appendChild", "(", "n", ".", "cloneNode", "(", "true", ")", ")", ";", "return", "div", ".", "innerHTML", ";", "}", ";", "Object", ".", "keys", "(", "subjects", ")", ".", "forEach", "(", "subject", "=>", "{", "let", "predicates", "=", "subjects", "[", "subject", "]", ".", "predicates", ";", "Object", ".", "keys", "(", "predicates", ")", ".", "forEach", "(", "predicate", "=>", "{", "let", "objects", "=", "predicates", "[", "predicate", "]", ".", "objects", ";", "for", "(", "let", "oi", "=", "0", ";", "oi", "<", "objects", ".", "length", ";", "++", "oi", ")", "{", "let", "object", "=", "objects", "[", "oi", "]", ";", "let", "triple", "=", "{", "}", ";", "triple", ".", "subject", "=", "{", "type", ":", "subject", ".", "indexOf", "(", "'_:'", ")", "===", "0", "?", "'blank node'", ":", "'IRI'", ",", "value", ":", "subject", "}", ";", "triple", ".", "predicate", "=", "{", "type", ":", "predicate", ".", "indexOf", "(", "'_:'", ")", "===", "0", "?", "'blank node'", ":", "'IRI'", ",", "value", ":", "predicate", "}", ";", "triple", ".", "object", "=", "{", "}", ";", "let", "value", "=", "object", ".", "value", ";", "if", "(", "object", ".", "type", "===", "RDF_XML_LITERAL", ")", "{", "let", "serializer", "=", "new", "XMLSerializer", "(", ")", ";", "value", "=", "Array", ".", "from", "(", "object", ".", "value", ")", ".", "map", "(", "n", "=>", "serializer", ".", "serializeToString", "(", "n", ")", ")", ".", "join", "(", "''", ")", ";", "triple", ".", "object", ".", "datatype", "=", "RDF_XML_LITERAL", ";", "}", "else", "if", "(", "object", ".", "type", "===", "RDF_HTML_LITERAL", ")", "{", "value", "=", "Array", ".", "from", "(", "object", ".", "value", ")", ".", "map", "(", "htmlMapper", ")", ".", "join", "(", "''", ")", ";", "triple", ".", "object", ".", "datatype", "=", "RDF_HTML_LITERAL", ";", "}", "else", "if", "(", "object", ".", "type", "===", "RDF_OBJECT", ")", "{", "if", "(", "object", ".", "value", ".", "indexOf", "(", "'_:'", ")", "===", "0", ")", "triple", ".", "object", ".", "type", "=", "'blank node'", ";", "else", "triple", ".", "object", ".", "type", "=", "'IRI'", ";", "}", "else", "{", "triple", ".", "object", ".", "type", "=", "'literal'", ";", "if", "(", "object", ".", "type", "===", "RDF_PLAIN_LITERAL", ")", "{", "if", "(", "object", ".", "language", ")", "{", "triple", ".", "object", ".", "datatype", "=", "RDF_LANGSTRING", ";", "triple", ".", "object", ".", "language", "=", "object", ".", "language", ";", "}", "else", "{", "triple", ".", "object", ".", "datatype", "=", "XSD_STRING", ";", "}", "}", "else", "{", "triple", ".", "object", ".", "datatype", "=", "object", ".", "type", ";", "}", "}", "triple", ".", "object", ".", "value", "=", "value", ";", "dataset", "[", "'@default'", "]", ".", "push", "(", "triple", ")", ";", "}", "}", ")", ";", "}", ")", ";", "return", "dataset", ";", "}" ]
This function is mostly taken from the jsonld.js lib but updated to the latest green-turtle API, and for support for HTML
[ "This", "function", "is", "mostly", "taken", "from", "the", "jsonld", ".", "js", "lib", "but", "updated", "to", "the", "latest", "green", "-", "turtle", "API", "and", "for", "support", "for", "HTML" ]
694459fa3cce03832f9a67f522a5143c89a47b84
https://github.com/scienceai/jsonld-rdfa-parser/blob/694459fa3cce03832f9a67f522a5143c89a47b84/src/index.js#L64-L148
train
chriszarate/supergenpass-lib
src/lib/hash.js
customBase64Hash
function customBase64Hash(str, hashFunction) { const result = hashFunction(str).toString(encBase64); return customBase64(result); }
javascript
function customBase64Hash(str, hashFunction) { const result = hashFunction(str).toString(encBase64); return customBase64(result); }
[ "function", "customBase64Hash", "(", "str", ",", "hashFunction", ")", "{", "const", "result", "=", "hashFunction", "(", "str", ")", ".", "toString", "(", "encBase64", ")", ";", "return", "customBase64", "(", "result", ")", ";", "}" ]
Compute hexadecimal hash and convert it to Base-64.
[ "Compute", "hexadecimal", "hash", "and", "convert", "it", "to", "Base", "-", "64", "." ]
eb9ee92050813d498229bfe0e6ccbcb87124cf90
https://github.com/chriszarate/supergenpass-lib/blob/eb9ee92050813d498229bfe0e6ccbcb87124cf90/src/lib/hash.js#L19-L22
train
chriszarate/supergenpass-lib
src/lib/hash.js
hash
function hash(method) { // Is user supplies a function, use it and assume they will take of any // encoding (Base-64 or otherwise). if (typeof method === 'function') { return method; } if (hashFunctions.hasOwnProperty(method)) { return hashFunctions[method]; } throw new Error(`Could not resolve hash function, received ${typeof method}.`); }
javascript
function hash(method) { // Is user supplies a function, use it and assume they will take of any // encoding (Base-64 or otherwise). if (typeof method === 'function') { return method; } if (hashFunctions.hasOwnProperty(method)) { return hashFunctions[method]; } throw new Error(`Could not resolve hash function, received ${typeof method}.`); }
[ "function", "hash", "(", "method", ")", "{", "if", "(", "typeof", "method", "===", "'function'", ")", "{", "return", "method", ";", "}", "if", "(", "hashFunctions", ".", "hasOwnProperty", "(", "method", ")", ")", "{", "return", "hashFunctions", "[", "method", "]", ";", "}", "throw", "new", "Error", "(", "`", "${", "typeof", "method", "}", "`", ")", ";", "}" ]
Return a hash function for SGP to use.
[ "Return", "a", "hash", "function", "for", "SGP", "to", "use", "." ]
eb9ee92050813d498229bfe0e6ccbcb87124cf90
https://github.com/chriszarate/supergenpass-lib/blob/eb9ee92050813d498229bfe0e6ccbcb87124cf90/src/lib/hash.js#L30-L42
train
cowboy/node-toc
lib/toc.js
normalize
function normalize(options, templates) { // Options override defaults and toc methods. var result = _.defaults({}, options, toc, toc.defaults); // Remove "core" methods from result object. ['defaults', 'process', 'anchorize', 'toc'].forEach(function(prop) { delete result[prop]; }); // Compile Lodash string templates into functions. (templates || []).forEach(function(tmpl) { if (typeof result[tmpl] === 'string') { result[tmpl] = _.template(result[tmpl]); } }); return result; }
javascript
function normalize(options, templates) { // Options override defaults and toc methods. var result = _.defaults({}, options, toc, toc.defaults); // Remove "core" methods from result object. ['defaults', 'process', 'anchorize', 'toc'].forEach(function(prop) { delete result[prop]; }); // Compile Lodash string templates into functions. (templates || []).forEach(function(tmpl) { if (typeof result[tmpl] === 'string') { result[tmpl] = _.template(result[tmpl]); } }); return result; }
[ "function", "normalize", "(", "options", ",", "templates", ")", "{", "var", "result", "=", "_", ".", "defaults", "(", "{", "}", ",", "options", ",", "toc", ",", "toc", ".", "defaults", ")", ";", "[", "'defaults'", ",", "'process'", ",", "'anchorize'", ",", "'toc'", "]", ".", "forEach", "(", "function", "(", "prop", ")", "{", "delete", "result", "[", "prop", "]", ";", "}", ")", ";", "(", "templates", "||", "[", "]", ")", ".", "forEach", "(", "function", "(", "tmpl", ")", "{", "if", "(", "typeof", "result", "[", "tmpl", "]", "===", "'string'", ")", "{", "result", "[", "tmpl", "]", "=", "_", ".", "template", "(", "result", "[", "tmpl", "]", ")", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Compile specified lodash string template properties into functions.
[ "Compile", "specified", "lodash", "string", "template", "properties", "into", "functions", "." ]
a6907a18cafb6741d9770a93f27f0fda98a8cff3
https://github.com/cowboy/node-toc/blob/a6907a18cafb6741d9770a93f27f0fda98a8cff3/lib/toc.js#L82-L96
train
BohemiaInteractive/bi-service
lib/cli/runCmd.js
_parseShellConfigOptions
function _parseShellConfigOptions(argv) { var out = {}; //`parse-pos-args` value is `true` by default, it must be //explicitly set to falsy value thus undefined & null values does not count if (argv['parse-pos-args'] === false || argv['parse-pos-args'] === 0) { setConfigPathOption(out); return out; } var options = argv.options.reduce(function(out, option, index) { if (index % 2 === 0) { out.names.push(option); } else { out.values.push(option); } return out; }, { names: [], values: [] }); if (argv.options.length % 2 !== 0) { throw new Error( `Invalid number of shell positional arguments received. Possitional arguments are expected to be in "[key] [value]" pairs` ); } options.names.forEach(function(propPath, index) { _.set( out, propPath, json5.parse(options.values[index]) ); }); setConfigPathOption(out); return out; function setConfigPathOption(obj) { //for overwriting expected config filepath we can use --config option only if (argv.config) { obj.fileConfigPath = argv.config; obj.fileConfigPath = path.normalize(obj.fileConfigPath); } else { delete obj.fileConfigPath; } } }
javascript
function _parseShellConfigOptions(argv) { var out = {}; //`parse-pos-args` value is `true` by default, it must be //explicitly set to falsy value thus undefined & null values does not count if (argv['parse-pos-args'] === false || argv['parse-pos-args'] === 0) { setConfigPathOption(out); return out; } var options = argv.options.reduce(function(out, option, index) { if (index % 2 === 0) { out.names.push(option); } else { out.values.push(option); } return out; }, { names: [], values: [] }); if (argv.options.length % 2 !== 0) { throw new Error( `Invalid number of shell positional arguments received. Possitional arguments are expected to be in "[key] [value]" pairs` ); } options.names.forEach(function(propPath, index) { _.set( out, propPath, json5.parse(options.values[index]) ); }); setConfigPathOption(out); return out; function setConfigPathOption(obj) { //for overwriting expected config filepath we can use --config option only if (argv.config) { obj.fileConfigPath = argv.config; obj.fileConfigPath = path.normalize(obj.fileConfigPath); } else { delete obj.fileConfigPath; } } }
[ "function", "_parseShellConfigOptions", "(", "argv", ")", "{", "var", "out", "=", "{", "}", ";", "if", "(", "argv", "[", "'parse-pos-args'", "]", "===", "false", "||", "argv", "[", "'parse-pos-args'", "]", "===", "0", ")", "{", "setConfigPathOption", "(", "out", ")", ";", "return", "out", ";", "}", "var", "options", "=", "argv", ".", "options", ".", "reduce", "(", "function", "(", "out", ",", "option", ",", "index", ")", "{", "if", "(", "index", "%", "2", "===", "0", ")", "{", "out", ".", "names", ".", "push", "(", "option", ")", ";", "}", "else", "{", "out", ".", "values", ".", "push", "(", "option", ")", ";", "}", "return", "out", ";", "}", ",", "{", "names", ":", "[", "]", ",", "values", ":", "[", "]", "}", ")", ";", "if", "(", "argv", ".", "options", ".", "length", "%", "2", "!==", "0", ")", "{", "throw", "new", "Error", "(", "`", "`", ")", ";", "}", "options", ".", "names", ".", "forEach", "(", "function", "(", "propPath", ",", "index", ")", "{", "_", ".", "set", "(", "out", ",", "propPath", ",", "json5", ".", "parse", "(", "options", ".", "values", "[", "index", "]", ")", ")", ";", "}", ")", ";", "setConfigPathOption", "(", "out", ")", ";", "return", "out", ";", "function", "setConfigPathOption", "(", "obj", ")", "{", "if", "(", "argv", ".", "config", ")", "{", "obj", ".", "fileConfigPath", "=", "argv", ".", "config", ";", "obj", ".", "fileConfigPath", "=", "path", ".", "normalize", "(", "obj", ".", "fileConfigPath", ")", ";", "}", "else", "{", "delete", "obj", ".", "fileConfigPath", ";", "}", "}", "}" ]
returns parsed object with positional shell arguments. These options will then overwrite option values set in configuration file @private @param {Object} argv - shell arguments @return {Object}
[ "returns", "parsed", "object", "with", "positional", "shell", "arguments", ".", "These", "options", "will", "then", "overwrite", "option", "values", "set", "in", "configuration", "file" ]
89e76f2e93714a3150ce7f59f16f646e4bdbbce1
https://github.com/BohemiaInteractive/bi-service/blob/89e76f2e93714a3150ce7f59f16f646e4bdbbce1/lib/cli/runCmd.js#L132-L182
train
joshfire/woodman
lib/logevent.js
function (loggerName, level, message) { this.time = new Date(); this.loggerName = loggerName; this.level = level; this.message = message; }
javascript
function (loggerName, level, message) { this.time = new Date(); this.loggerName = loggerName; this.level = level; this.message = message; }
[ "function", "(", "loggerName", ",", "level", ",", "message", ")", "{", "this", ".", "time", "=", "new", "Date", "(", ")", ";", "this", ".", "loggerName", "=", "loggerName", ";", "this", ".", "level", "=", "level", ";", "this", ".", "message", "=", "message", ";", "}" ]
Definition of the LogEvent class. @constructor @param {string} loggerName Name of the logger that creates this event @param {string} level The trace level ('info', 'warning', 'error'...) @param {Message} message The message to log.
[ "Definition", "of", "the", "LogEvent", "class", "." ]
fdc05de2124388780924980e6f27bf4483056d18
https://github.com/joshfire/woodman/blob/fdc05de2124388780924980e6f27bf4483056d18/lib/logevent.js#L29-L34
train
jimivdw/grunt-mutation-testing
lib/reporting/html/FileHtmlBuilder.js
writeReport
function writeReport(fileResult, formatter, formattedSourceLines, baseDir) { var fileName = fileResult.fileName, stats = StatUtils.decorateStatPercentages(fileResult.stats), parentDir = path.normalize(baseDir + '/..'), mutations = formatter.formatMutations(fileResult.mutationResults), breadcrumb = new IndexHtmlBuilder(baseDir).linkPathItems({ currentDir: parentDir, fileName: baseDir + '/' + fileName + '.html', separator: ' >> ', relativePath: getRelativeDistance(baseDir + '/' + fileName, baseDir ), linkDirectoryOnly: true }); var file = Templates.fileTemplate({ sourceLines: formattedSourceLines, mutations: mutations }); fs.writeFileSync( path.join(baseDir, fileName + ".html"), Templates.baseTemplate({ style: Templates.baseStyleTemplate({ additionalStyle: Templates.fileStyleCode }), script: Templates.baseScriptTemplate({ additionalScript: Templates.fileScriptCode }), fileName: path.basename(fileName), stats: stats, status: stats.successRate > this._config.successThreshold ? 'killed' : stats.all > 0 ? 'survived' : 'neutral', breadcrumb: breadcrumb, generatedAt: new Date().toLocaleString(), content: file }) ); }
javascript
function writeReport(fileResult, formatter, formattedSourceLines, baseDir) { var fileName = fileResult.fileName, stats = StatUtils.decorateStatPercentages(fileResult.stats), parentDir = path.normalize(baseDir + '/..'), mutations = formatter.formatMutations(fileResult.mutationResults), breadcrumb = new IndexHtmlBuilder(baseDir).linkPathItems({ currentDir: parentDir, fileName: baseDir + '/' + fileName + '.html', separator: ' >> ', relativePath: getRelativeDistance(baseDir + '/' + fileName, baseDir ), linkDirectoryOnly: true }); var file = Templates.fileTemplate({ sourceLines: formattedSourceLines, mutations: mutations }); fs.writeFileSync( path.join(baseDir, fileName + ".html"), Templates.baseTemplate({ style: Templates.baseStyleTemplate({ additionalStyle: Templates.fileStyleCode }), script: Templates.baseScriptTemplate({ additionalScript: Templates.fileScriptCode }), fileName: path.basename(fileName), stats: stats, status: stats.successRate > this._config.successThreshold ? 'killed' : stats.all > 0 ? 'survived' : 'neutral', breadcrumb: breadcrumb, generatedAt: new Date().toLocaleString(), content: file }) ); }
[ "function", "writeReport", "(", "fileResult", ",", "formatter", ",", "formattedSourceLines", ",", "baseDir", ")", "{", "var", "fileName", "=", "fileResult", ".", "fileName", ",", "stats", "=", "StatUtils", ".", "decorateStatPercentages", "(", "fileResult", ".", "stats", ")", ",", "parentDir", "=", "path", ".", "normalize", "(", "baseDir", "+", "'/..'", ")", ",", "mutations", "=", "formatter", ".", "formatMutations", "(", "fileResult", ".", "mutationResults", ")", ",", "breadcrumb", "=", "new", "IndexHtmlBuilder", "(", "baseDir", ")", ".", "linkPathItems", "(", "{", "currentDir", ":", "parentDir", ",", "fileName", ":", "baseDir", "+", "'/'", "+", "fileName", "+", "'.html'", ",", "separator", ":", "' >> '", ",", "relativePath", ":", "getRelativeDistance", "(", "baseDir", "+", "'/'", "+", "fileName", ",", "baseDir", ")", ",", "linkDirectoryOnly", ":", "true", "}", ")", ";", "var", "file", "=", "Templates", ".", "fileTemplate", "(", "{", "sourceLines", ":", "formattedSourceLines", ",", "mutations", ":", "mutations", "}", ")", ";", "fs", ".", "writeFileSync", "(", "path", ".", "join", "(", "baseDir", ",", "fileName", "+", "\".html\"", ")", ",", "Templates", ".", "baseTemplate", "(", "{", "style", ":", "Templates", ".", "baseStyleTemplate", "(", "{", "additionalStyle", ":", "Templates", ".", "fileStyleCode", "}", ")", ",", "script", ":", "Templates", ".", "baseScriptTemplate", "(", "{", "additionalScript", ":", "Templates", ".", "fileScriptCode", "}", ")", ",", "fileName", ":", "path", ".", "basename", "(", "fileName", ")", ",", "stats", ":", "stats", ",", "status", ":", "stats", ".", "successRate", ">", "this", ".", "_config", ".", "successThreshold", "?", "'killed'", ":", "stats", ".", "all", ">", "0", "?", "'survived'", ":", "'neutral'", ",", "breadcrumb", ":", "breadcrumb", ",", "generatedAt", ":", "new", "Date", "(", ")", ".", "toLocaleString", "(", ")", ",", "content", ":", "file", "}", ")", ")", ";", "}" ]
write the report to file
[ "write", "the", "report", "to", "file" ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/lib/reporting/html/FileHtmlBuilder.js#L52-L83
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(obj, keys, caseSensitive /* default: false */) { var key, keyLower, newObj = {}; if (!$.isArray(keys) || !keys.length) { return newObj; } for (var i = 0; i < keys.length; i++) { key = keys[i]; if (obj.hasOwnProperty(key)) { newObj[key] = obj[key]; } if(caseSensitive === true) { continue; } //when getting data-* attributes via $.data() it's converted to lowercase. //details: http://stackoverflow.com/questions/7602565/using-data-attributes-with-jquery //workaround is code below. keyLower = key.toLowerCase(); if (obj.hasOwnProperty(keyLower)) { newObj[key] = obj[keyLower]; } } return newObj; }
javascript
function(obj, keys, caseSensitive /* default: false */) { var key, keyLower, newObj = {}; if (!$.isArray(keys) || !keys.length) { return newObj; } for (var i = 0; i < keys.length; i++) { key = keys[i]; if (obj.hasOwnProperty(key)) { newObj[key] = obj[key]; } if(caseSensitive === true) { continue; } //when getting data-* attributes via $.data() it's converted to lowercase. //details: http://stackoverflow.com/questions/7602565/using-data-attributes-with-jquery //workaround is code below. keyLower = key.toLowerCase(); if (obj.hasOwnProperty(keyLower)) { newObj[key] = obj[keyLower]; } } return newObj; }
[ "function", "(", "obj", ",", "keys", ",", "caseSensitive", ")", "{", "var", "key", ",", "keyLower", ",", "newObj", "=", "{", "}", ";", "if", "(", "!", "$", ".", "isArray", "(", "keys", ")", "||", "!", "keys", ".", "length", ")", "{", "return", "newObj", ";", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "i", "++", ")", "{", "key", "=", "keys", "[", "i", "]", ";", "if", "(", "obj", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "newObj", "[", "key", "]", "=", "obj", "[", "key", "]", ";", "}", "if", "(", "caseSensitive", "===", "true", ")", "{", "continue", ";", "}", "keyLower", "=", "key", ".", "toLowerCase", "(", ")", ";", "if", "(", "obj", ".", "hasOwnProperty", "(", "keyLower", ")", ")", "{", "newObj", "[", "key", "]", "=", "obj", "[", "keyLower", "]", ";", "}", "}", "return", "newObj", ";", "}" ]
slice object by specified keys
[ "slice", "object", "by", "specified", "keys" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L688-L715
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(element, options) { this.$element = $(element); //since 1.4.1 container do not use data-* directly as they already merged into options. this.options = $.extend({}, $.fn.editableContainer.defaults, options); this.splitOptions(); //set scope of form callbacks to element this.formOptions.scope = this.$element[0]; this.initContainer(); //flag to hide container, when saving value will finish this.delayedHide = false; //bind 'destroyed' listener to destroy container when element is removed from dom this.$element.on('destroyed', $.proxy(function(){ this.destroy(); }, this)); //attach document handler to close containers on click / escape if(!$(document).data('editable-handlers-attached')) { //close all on escape $(document).on('keyup.editable', function (e) { if (e.which === 27) { $('.editable-open').editableContainer('hide'); //todo: return focus on element } }); //close containers when click outside //(mousedown could be better than click, it closes everything also on drag drop) $(document).on('click.editable', function(e) { var $target = $(e.target), i, exclude_classes = ['.editable-container', '.ui-datepicker-header', '.datepicker', //in inline mode datepicker is rendered into body '.modal-backdrop', '.bootstrap-wysihtml5-insert-image-modal', '.bootstrap-wysihtml5-insert-link-modal' ]; //check if element is detached. It occurs when clicking in bootstrap datepicker if (!$.contains(document.documentElement, e.target)) { return; } //for some reason FF 20 generates extra event (click) in select2 widget with e.target = document //we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199 //Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec if($target.is(document)) { return; } //if click inside one of exclude classes --> no nothing for(i=0; i<exclude_classes.length; i++) { if($target.is(exclude_classes[i]) || $target.parents(exclude_classes[i]).length) { return; } } //close all open containers (except one - target) Popup.prototype.closeOthers(e.target); }); $(document).data('editable-handlers-attached', true); } }
javascript
function(element, options) { this.$element = $(element); //since 1.4.1 container do not use data-* directly as they already merged into options. this.options = $.extend({}, $.fn.editableContainer.defaults, options); this.splitOptions(); //set scope of form callbacks to element this.formOptions.scope = this.$element[0]; this.initContainer(); //flag to hide container, when saving value will finish this.delayedHide = false; //bind 'destroyed' listener to destroy container when element is removed from dom this.$element.on('destroyed', $.proxy(function(){ this.destroy(); }, this)); //attach document handler to close containers on click / escape if(!$(document).data('editable-handlers-attached')) { //close all on escape $(document).on('keyup.editable', function (e) { if (e.which === 27) { $('.editable-open').editableContainer('hide'); //todo: return focus on element } }); //close containers when click outside //(mousedown could be better than click, it closes everything also on drag drop) $(document).on('click.editable', function(e) { var $target = $(e.target), i, exclude_classes = ['.editable-container', '.ui-datepicker-header', '.datepicker', //in inline mode datepicker is rendered into body '.modal-backdrop', '.bootstrap-wysihtml5-insert-image-modal', '.bootstrap-wysihtml5-insert-link-modal' ]; //check if element is detached. It occurs when clicking in bootstrap datepicker if (!$.contains(document.documentElement, e.target)) { return; } //for some reason FF 20 generates extra event (click) in select2 widget with e.target = document //we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199 //Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec if($target.is(document)) { return; } //if click inside one of exclude classes --> no nothing for(i=0; i<exclude_classes.length; i++) { if($target.is(exclude_classes[i]) || $target.parents(exclude_classes[i]).length) { return; } } //close all open containers (except one - target) Popup.prototype.closeOthers(e.target); }); $(document).data('editable-handlers-attached', true); } }
[ "function", "(", "element", ",", "options", ")", "{", "this", ".", "$element", "=", "$", "(", "element", ")", ";", "this", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "$", ".", "fn", ".", "editableContainer", ".", "defaults", ",", "options", ")", ";", "this", ".", "splitOptions", "(", ")", ";", "this", ".", "formOptions", ".", "scope", "=", "this", ".", "$element", "[", "0", "]", ";", "this", ".", "initContainer", "(", ")", ";", "this", ".", "delayedHide", "=", "false", ";", "this", ".", "$element", ".", "on", "(", "'destroyed'", ",", "$", ".", "proxy", "(", "function", "(", ")", "{", "this", ".", "destroy", "(", ")", ";", "}", ",", "this", ")", ")", ";", "if", "(", "!", "$", "(", "document", ")", ".", "data", "(", "'editable-handlers-attached'", ")", ")", "{", "$", "(", "document", ")", ".", "on", "(", "'keyup.editable'", ",", "function", "(", "e", ")", "{", "if", "(", "e", ".", "which", "===", "27", ")", "{", "$", "(", "'.editable-open'", ")", ".", "editableContainer", "(", "'hide'", ")", ";", "}", "}", ")", ";", "$", "(", "document", ")", ".", "on", "(", "'click.editable'", ",", "function", "(", "e", ")", "{", "var", "$target", "=", "$", "(", "e", ".", "target", ")", ",", "i", ",", "exclude_classes", "=", "[", "'.editable-container'", ",", "'.ui-datepicker-header'", ",", "'.datepicker'", ",", "'.modal-backdrop'", ",", "'.bootstrap-wysihtml5-insert-image-modal'", ",", "'.bootstrap-wysihtml5-insert-link-modal'", "]", ";", "if", "(", "!", "$", ".", "contains", "(", "document", ".", "documentElement", ",", "e", ".", "target", ")", ")", "{", "return", ";", "}", "if", "(", "$target", ".", "is", "(", "document", ")", ")", "{", "return", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "exclude_classes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "$target", ".", "is", "(", "exclude_classes", "[", "i", "]", ")", "||", "$target", ".", "parents", "(", "exclude_classes", "[", "i", "]", ")", ".", "length", ")", "{", "return", ";", "}", "}", "Popup", ".", "prototype", ".", "closeOthers", "(", "e", ".", "target", ")", ";", "}", ")", ";", "$", "(", "document", ")", ".", "data", "(", "'editable-handlers-attached'", ",", "true", ")", ";", "}", "}" ]
css class applied to container element
[ "css", "class", "applied", "to", "container", "element" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L901-L967
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function() { this.containerOptions = {}; this.formOptions = {}; if(!$.fn[this.containerName]) { throw new Error(this.containerName + ' not found. Have you included corresponding js file?'); } var cDef = $.fn[this.containerName].defaults; //keys defined in container defaults go to container, others go to form for(var k in this.options) { if(k in cDef) { this.containerOptions[k] = this.options[k]; } else { this.formOptions[k] = this.options[k]; } } }
javascript
function() { this.containerOptions = {}; this.formOptions = {}; if(!$.fn[this.containerName]) { throw new Error(this.containerName + ' not found. Have you included corresponding js file?'); } var cDef = $.fn[this.containerName].defaults; //keys defined in container defaults go to container, others go to form for(var k in this.options) { if(k in cDef) { this.containerOptions[k] = this.options[k]; } else { this.formOptions[k] = this.options[k]; } } }
[ "function", "(", ")", "{", "this", ".", "containerOptions", "=", "{", "}", ";", "this", ".", "formOptions", "=", "{", "}", ";", "if", "(", "!", "$", ".", "fn", "[", "this", ".", "containerName", "]", ")", "{", "throw", "new", "Error", "(", "this", ".", "containerName", "+", "' not found. Have you included corresponding js file?'", ")", ";", "}", "var", "cDef", "=", "$", ".", "fn", "[", "this", ".", "containerName", "]", ".", "defaults", ";", "for", "(", "var", "k", "in", "this", ".", "options", ")", "{", "if", "(", "k", "in", "cDef", ")", "{", "this", ".", "containerOptions", "[", "k", "]", "=", "this", ".", "options", "[", "k", "]", ";", "}", "else", "{", "this", ".", "formOptions", "[", "k", "]", "=", "this", ".", "options", "[", "k", "]", ";", "}", "}", "}" ]
split options on containerOptions and formOptions
[ "split", "options", "on", "containerOptions", "and", "formOptions" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L970-L987
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(reason) { if(!this.tip() || !this.tip().is(':visible') || !this.$element.hasClass('editable-open')) { return; } //if form is saving value, schedule hide if(this.$form.data('editableform').isSaving) { this.delayedHide = {reason: reason}; return; } else { this.delayedHide = false; } this.$element.removeClass('editable-open'); this.innerHide(); /** Fired when container was hidden. It occurs on both save or cancel. **Note:** Bootstrap popover has own `hidden` event that now cannot be separated from x-editable's one. The workaround is to check `arguments.length` that is always `2` for x-editable. @event hidden @param {object} event event object @param {string} reason Reason caused hiding. Can be <code>save|cancel|onblur|nochange|manual</code> @example $('#username').on('hidden', function(e, reason) { if(reason === 'save' || reason === 'cancel') { //auto-open next editable $(this).closest('tr').next().find('.editable').editable('show'); } }); **/ this.$element.triggerHandler('hidden', reason || 'manual'); }
javascript
function(reason) { if(!this.tip() || !this.tip().is(':visible') || !this.$element.hasClass('editable-open')) { return; } //if form is saving value, schedule hide if(this.$form.data('editableform').isSaving) { this.delayedHide = {reason: reason}; return; } else { this.delayedHide = false; } this.$element.removeClass('editable-open'); this.innerHide(); /** Fired when container was hidden. It occurs on both save or cancel. **Note:** Bootstrap popover has own `hidden` event that now cannot be separated from x-editable's one. The workaround is to check `arguments.length` that is always `2` for x-editable. @event hidden @param {object} event event object @param {string} reason Reason caused hiding. Can be <code>save|cancel|onblur|nochange|manual</code> @example $('#username').on('hidden', function(e, reason) { if(reason === 'save' || reason === 'cancel') { //auto-open next editable $(this).closest('tr').next().find('.editable').editable('show'); } }); **/ this.$element.triggerHandler('hidden', reason || 'manual'); }
[ "function", "(", "reason", ")", "{", "if", "(", "!", "this", ".", "tip", "(", ")", "||", "!", "this", ".", "tip", "(", ")", ".", "is", "(", "':visible'", ")", "||", "!", "this", ".", "$element", ".", "hasClass", "(", "'editable-open'", ")", ")", "{", "return", ";", "}", "if", "(", "this", ".", "$form", ".", "data", "(", "'editableform'", ")", ".", "isSaving", ")", "{", "this", ".", "delayedHide", "=", "{", "reason", ":", "reason", "}", ";", "return", ";", "}", "else", "{", "this", ".", "delayedHide", "=", "false", ";", "}", "this", ".", "$element", ".", "removeClass", "(", "'editable-open'", ")", ";", "this", ".", "innerHide", "(", ")", ";", "this", ".", "$element", ".", "triggerHandler", "(", "'hidden'", ",", "reason", "||", "'manual'", ")", ";", "}" ]
Hides container with form @method hide() @param {string} reason Reason caused hiding. Can be <code>save|cancel|onblur|nochange|undefined (=manual)</code>
[ "Hides", "container", "with", "form" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L1110-L1143
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(value, convertStr, response) { if(convertStr) { this.value = this.input.str2value(value); } else { this.value = value; } if(this.container) { this.container.option('value', this.value); } $.when(this.render(response)) .then($.proxy(function() { this.handleEmpty(); }, this)); }
javascript
function(value, convertStr, response) { if(convertStr) { this.value = this.input.str2value(value); } else { this.value = value; } if(this.container) { this.container.option('value', this.value); } $.when(this.render(response)) .then($.proxy(function() { this.handleEmpty(); }, this)); }
[ "function", "(", "value", ",", "convertStr", ",", "response", ")", "{", "if", "(", "convertStr", ")", "{", "this", ".", "value", "=", "this", ".", "input", ".", "str2value", "(", "value", ")", ";", "}", "else", "{", "this", ".", "value", "=", "value", ";", "}", "if", "(", "this", ".", "container", ")", "{", "this", ".", "container", ".", "option", "(", "'value'", ",", "this", ".", "value", ")", ";", "}", "$", ".", "when", "(", "this", ".", "render", "(", "response", ")", ")", ".", "then", "(", "$", ".", "proxy", "(", "function", "(", ")", "{", "this", ".", "handleEmpty", "(", ")", ";", "}", ",", "this", ")", ")", ";", "}" ]
Sets new value of editable @method setValue(value, convertStr) @param {mixed} value new value @param {boolean} convertStr whether to convert value from string to internal format
[ "Sets", "new", "value", "of", "editable" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L1887-L1900
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function() { if (this.options.clear) { this.$clear = $('<span class="editable-clear-x"></span>'); this.$input.after(this.$clear) .css('padding-right', 24) .keyup($.proxy(function(e) { //arrows, enter, tab, etc if(~$.inArray(e.keyCode, [40,38,9,13,27])) { return; } clearTimeout(this.t); var that = this; this.t = setTimeout(function() { that.toggleClear(e); }, 100); }, this)) .parent().css('position', 'relative'); this.$clear.click($.proxy(this.clear, this)); } }
javascript
function() { if (this.options.clear) { this.$clear = $('<span class="editable-clear-x"></span>'); this.$input.after(this.$clear) .css('padding-right', 24) .keyup($.proxy(function(e) { //arrows, enter, tab, etc if(~$.inArray(e.keyCode, [40,38,9,13,27])) { return; } clearTimeout(this.t); var that = this; this.t = setTimeout(function() { that.toggleClear(e); }, 100); }, this)) .parent().css('position', 'relative'); this.$clear.click($.proxy(this.clear, this)); } }
[ "function", "(", ")", "{", "if", "(", "this", ".", "options", ".", "clear", ")", "{", "this", ".", "$clear", "=", "$", "(", "'<span class=\"editable-clear-x\"></span>'", ")", ";", "this", ".", "$input", ".", "after", "(", "this", ".", "$clear", ")", ".", "css", "(", "'padding-right'", ",", "24", ")", ".", "keyup", "(", "$", ".", "proxy", "(", "function", "(", "e", ")", "{", "if", "(", "~", "$", ".", "inArray", "(", "e", ".", "keyCode", ",", "[", "40", ",", "38", ",", "9", ",", "13", ",", "27", "]", ")", ")", "{", "return", ";", "}", "clearTimeout", "(", "this", ".", "t", ")", ";", "var", "that", "=", "this", ";", "this", ".", "t", "=", "setTimeout", "(", "function", "(", ")", "{", "that", ".", "toggleClear", "(", "e", ")", ";", "}", ",", "100", ")", ";", "}", ",", "this", ")", ")", ".", "parent", "(", ")", ".", "css", "(", "'position'", ",", "'relative'", ")", ";", "this", ".", "$clear", ".", "click", "(", "$", ".", "proxy", "(", "this", ".", "clear", ",", "this", ")", ")", ";", "}", "}" ]
render clear button
[ "render", "clear", "button" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L2831-L2853
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(str) { var reg, value = null; if(typeof str === 'string' && str.length) { reg = new RegExp('\\s*'+$.trim(this.options.separator)+'\\s*'); value = str.split(reg); } else if($.isArray(str)) { value = str; } else { value = [str]; } return value; }
javascript
function(str) { var reg, value = null; if(typeof str === 'string' && str.length) { reg = new RegExp('\\s*'+$.trim(this.options.separator)+'\\s*'); value = str.split(reg); } else if($.isArray(str)) { value = str; } else { value = [str]; } return value; }
[ "function", "(", "str", ")", "{", "var", "reg", ",", "value", "=", "null", ";", "if", "(", "typeof", "str", "===", "'string'", "&&", "str", ".", "length", ")", "{", "reg", "=", "new", "RegExp", "(", "'\\\\s*'", "+", "\\\\", "+", "$", ".", "trim", "(", "this", ".", "options", ".", "separator", ")", ")", ";", "'\\\\s*'", "}", "else", "\\\\", "value", "=", "str", ".", "split", "(", "reg", ")", ";", "}" ]
parse separated string
[ "parse", "separated", "string" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L3190-L3201
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(value) { this.$input.prop('checked', false); if($.isArray(value) && value.length) { this.$input.each(function(i, el) { var $el = $(el); // cannot use $.inArray as it performs strict comparison $.each(value, function(j, val){ /*jslint eqeq: true*/ if($el.val() == val) { /*jslint eqeq: false*/ $el.prop('checked', true); } }); }); } }
javascript
function(value) { this.$input.prop('checked', false); if($.isArray(value) && value.length) { this.$input.each(function(i, el) { var $el = $(el); // cannot use $.inArray as it performs strict comparison $.each(value, function(j, val){ /*jslint eqeq: true*/ if($el.val() == val) { /*jslint eqeq: false*/ $el.prop('checked', true); } }); }); } }
[ "function", "(", "value", ")", "{", "this", ".", "$input", ".", "prop", "(", "'checked'", ",", "false", ")", ";", "if", "(", "$", ".", "isArray", "(", "value", ")", "&&", "value", ".", "length", ")", "{", "this", ".", "$input", ".", "each", "(", "function", "(", "i", ",", "el", ")", "{", "var", "$el", "=", "$", "(", "el", ")", ";", "$", ".", "each", "(", "value", ",", "function", "(", "j", ",", "val", ")", "{", "if", "(", "$el", ".", "val", "(", ")", "==", "val", ")", "{", "$el", ".", "prop", "(", "'checked'", ",", "true", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}", "}" ]
set checked on required checkboxes
[ "set", "checked", "on", "required", "checkboxes" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L3204-L3219
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(value, element) { var html = [], checked = $.fn.editableutils.itemsByValue(value, this.sourceData); if(checked.length) { $.each(checked, function(i, v) { html.push($.fn.editableutils.escape(v.text)); }); $(element).html(html.join('<br>')); } else { $(element).empty(); } }
javascript
function(value, element) { var html = [], checked = $.fn.editableutils.itemsByValue(value, this.sourceData); if(checked.length) { $.each(checked, function(i, v) { html.push($.fn.editableutils.escape(v.text)); }); $(element).html(html.join('<br>')); } else { $(element).empty(); } }
[ "function", "(", "value", ",", "element", ")", "{", "var", "html", "=", "[", "]", ",", "checked", "=", "$", ".", "fn", ".", "editableutils", ".", "itemsByValue", "(", "value", ",", "this", ".", "sourceData", ")", ";", "if", "(", "checked", ".", "length", ")", "{", "$", ".", "each", "(", "checked", ",", "function", "(", "i", ",", "v", ")", "{", "html", ".", "push", "(", "$", ".", "fn", ".", "editableutils", ".", "escape", "(", "v", ".", "text", ")", ")", ";", "}", ")", ";", "$", "(", "element", ")", ".", "html", "(", "html", ".", "join", "(", "'<br>'", ")", ")", ";", "}", "else", "{", "$", "(", "element", ")", ".", "empty", "(", ")", ";", "}", "}" ]
collect text of checked boxes
[ "collect", "text", "of", "checked", "boxes" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L3230-L3240
train
infrabel/themes-gnap
raw/ace/mustache/app/views/assets/scripts/calendar.js
function(date, allDay) { // this function is called when something is dropped // retrieve the dropped element's stored Event Object var originalEventObject = $(this).data('eventObject'); var $extraEventClass = $(this).attr('data-class'); // we need to copy it, so that multiple events don't have a reference to the same object var copiedEventObject = $.extend({}, originalEventObject); // assign it the date that was reported copiedEventObject.start = date; copiedEventObject.allDay = allDay; if($extraEventClass) copiedEventObject['className'] = [$extraEventClass]; // render the event on the calendar // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/) $('#calendar').fullCalendar('renderEvent', copiedEventObject, true); // is the "remove after drop" checkbox checked? if ($('#drop-remove').is(':checked')) { // if so, remove the element from the "Draggable Events" list $(this).remove(); } }
javascript
function(date, allDay) { // this function is called when something is dropped // retrieve the dropped element's stored Event Object var originalEventObject = $(this).data('eventObject'); var $extraEventClass = $(this).attr('data-class'); // we need to copy it, so that multiple events don't have a reference to the same object var copiedEventObject = $.extend({}, originalEventObject); // assign it the date that was reported copiedEventObject.start = date; copiedEventObject.allDay = allDay; if($extraEventClass) copiedEventObject['className'] = [$extraEventClass]; // render the event on the calendar // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/) $('#calendar').fullCalendar('renderEvent', copiedEventObject, true); // is the "remove after drop" checkbox checked? if ($('#drop-remove').is(':checked')) { // if so, remove the element from the "Draggable Events" list $(this).remove(); } }
[ "function", "(", "date", ",", "allDay", ")", "{", "var", "originalEventObject", "=", "$", "(", "this", ")", ".", "data", "(", "'eventObject'", ")", ";", "var", "$extraEventClass", "=", "$", "(", "this", ")", ".", "attr", "(", "'data-class'", ")", ";", "var", "copiedEventObject", "=", "$", ".", "extend", "(", "{", "}", ",", "originalEventObject", ")", ";", "copiedEventObject", ".", "start", "=", "date", ";", "copiedEventObject", ".", "allDay", "=", "allDay", ";", "if", "(", "$extraEventClass", ")", "copiedEventObject", "[", "'className'", "]", "=", "[", "$extraEventClass", "]", ";", "$", "(", "'#calendar'", ")", ".", "fullCalendar", "(", "'renderEvent'", ",", "copiedEventObject", ",", "true", ")", ";", "if", "(", "$", "(", "'#drop-remove'", ")", ".", "is", "(", "':checked'", ")", ")", "{", "$", "(", "this", ")", ".", "remove", "(", ")", ";", "}", "}" ]
this allows things to be dropped onto the calendar !!!
[ "this", "allows", "things", "to", "be", "dropped", "onto", "the", "calendar", "!!!" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/mustache/app/views/assets/scripts/calendar.js#L69-L94
train
BohemiaInteractive/bi-service
lib/common/route.js
applyCatchList
function applyCatchList(promise, req, res, catchList, index) { index = index || 0; if ( !Array.isArray(catchList) || index > catchList.length - 1 || !Array.isArray(catchList[index]) || !(catchList[index][1] instanceof Function) ) { return promise; } var args = _.clone(catchList[index]); var cb = args[1]; args[1] = function(err) { return cb(err, req, res); }; promise = promise.catch.apply(promise, args); return applyCatchList(promise, req, res, catchList, ++index); }
javascript
function applyCatchList(promise, req, res, catchList, index) { index = index || 0; if ( !Array.isArray(catchList) || index > catchList.length - 1 || !Array.isArray(catchList[index]) || !(catchList[index][1] instanceof Function) ) { return promise; } var args = _.clone(catchList[index]); var cb = args[1]; args[1] = function(err) { return cb(err, req, res); }; promise = promise.catch.apply(promise, args); return applyCatchList(promise, req, res, catchList, ++index); }
[ "function", "applyCatchList", "(", "promise", ",", "req", ",", "res", ",", "catchList", ",", "index", ")", "{", "index", "=", "index", "||", "0", ";", "if", "(", "!", "Array", ".", "isArray", "(", "catchList", ")", "||", "index", ">", "catchList", ".", "length", "-", "1", "||", "!", "Array", ".", "isArray", "(", "catchList", "[", "index", "]", ")", "||", "!", "(", "catchList", "[", "index", "]", "[", "1", "]", "instanceof", "Function", ")", ")", "{", "return", "promise", ";", "}", "var", "args", "=", "_", ".", "clone", "(", "catchList", "[", "index", "]", ")", ";", "var", "cb", "=", "args", "[", "1", "]", ";", "args", "[", "1", "]", "=", "function", "(", "err", ")", "{", "return", "cb", "(", "err", ",", "req", ",", "res", ")", ";", "}", ";", "promise", "=", "promise", ".", "catch", ".", "apply", "(", "promise", ",", "args", ")", ";", "return", "applyCatchList", "(", "promise", ",", "req", ",", "res", ",", "catchList", ",", "++", "index", ")", ";", "}" ]
applies collection of catch handler functions to provided Promise object @private @param {Promise} promise - the promise catch functions are going to be applied to @param {Object} req @param {Object} res @param {Array} catchList - array of arrays - each item of array is a pair of [ErrorFilterConstructor,FunctionErrHandler] @return {Promise}
[ "applies", "collection", "of", "catch", "handler", "functions", "to", "provided", "Promise", "object" ]
89e76f2e93714a3150ce7f59f16f646e4bdbbce1
https://github.com/BohemiaInteractive/bi-service/blob/89e76f2e93714a3150ce7f59f16f646e4bdbbce1/lib/common/route.js#L604-L624
train
adaptive-learning/flocs-visual-components
src/selectors/gameState.js
performMove
function performMove(fields, direction) { const oldSpaceshipPosition = findSpaceshipPosition(fields); const dx = { left: -1, ahead: 0, right: 1 }[direction]; const newSpaceshipPosition = [oldSpaceshipPosition[0] - 1, oldSpaceshipPosition[1] + dx]; const newFields = fields.map((row, i) => row.map((field, j) => { const [background, oldObjects] = field; let newObjects = oldObjects; if (i === oldSpaceshipPosition[0] && j === oldSpaceshipPosition[1]) { if (outsideWorld(fields, newSpaceshipPosition)) { let border = null; if (i === 0) { border = 'top'; } else if (j === 0) { border = 'left'; } else { border = 'right'; } newObjects = [`spaceship-out-${border}`]; } else { newObjects = removeSpaceship(oldObjects); } } if (i === newSpaceshipPosition[0] && j === newSpaceshipPosition[1]) { if (onRock(fields, newSpaceshipPosition)) { newObjects = [...newObjects, 'spaceship-broken']; } else { newObjects = [...newObjects, 'S']; } } return [background, newObjects]; })); return newFields; }
javascript
function performMove(fields, direction) { const oldSpaceshipPosition = findSpaceshipPosition(fields); const dx = { left: -1, ahead: 0, right: 1 }[direction]; const newSpaceshipPosition = [oldSpaceshipPosition[0] - 1, oldSpaceshipPosition[1] + dx]; const newFields = fields.map((row, i) => row.map((field, j) => { const [background, oldObjects] = field; let newObjects = oldObjects; if (i === oldSpaceshipPosition[0] && j === oldSpaceshipPosition[1]) { if (outsideWorld(fields, newSpaceshipPosition)) { let border = null; if (i === 0) { border = 'top'; } else if (j === 0) { border = 'left'; } else { border = 'right'; } newObjects = [`spaceship-out-${border}`]; } else { newObjects = removeSpaceship(oldObjects); } } if (i === newSpaceshipPosition[0] && j === newSpaceshipPosition[1]) { if (onRock(fields, newSpaceshipPosition)) { newObjects = [...newObjects, 'spaceship-broken']; } else { newObjects = [...newObjects, 'S']; } } return [background, newObjects]; })); return newFields; }
[ "function", "performMove", "(", "fields", ",", "direction", ")", "{", "const", "oldSpaceshipPosition", "=", "findSpaceshipPosition", "(", "fields", ")", ";", "const", "dx", "=", "{", "left", ":", "-", "1", ",", "ahead", ":", "0", ",", "right", ":", "1", "}", "[", "direction", "]", ";", "const", "newSpaceshipPosition", "=", "[", "oldSpaceshipPosition", "[", "0", "]", "-", "1", ",", "oldSpaceshipPosition", "[", "1", "]", "+", "dx", "]", ";", "const", "newFields", "=", "fields", ".", "map", "(", "(", "row", ",", "i", ")", "=>", "row", ".", "map", "(", "(", "field", ",", "j", ")", "=>", "{", "const", "[", "background", ",", "oldObjects", "]", "=", "field", ";", "let", "newObjects", "=", "oldObjects", ";", "if", "(", "i", "===", "oldSpaceshipPosition", "[", "0", "]", "&&", "j", "===", "oldSpaceshipPosition", "[", "1", "]", ")", "{", "if", "(", "outsideWorld", "(", "fields", ",", "newSpaceshipPosition", ")", ")", "{", "let", "border", "=", "null", ";", "if", "(", "i", "===", "0", ")", "{", "border", "=", "'top'", ";", "}", "else", "if", "(", "j", "===", "0", ")", "{", "border", "=", "'left'", ";", "}", "else", "{", "border", "=", "'right'", ";", "}", "newObjects", "=", "[", "`", "${", "border", "}", "`", "]", ";", "}", "else", "{", "newObjects", "=", "removeSpaceship", "(", "oldObjects", ")", ";", "}", "}", "if", "(", "i", "===", "newSpaceshipPosition", "[", "0", "]", "&&", "j", "===", "newSpaceshipPosition", "[", "1", "]", ")", "{", "if", "(", "onRock", "(", "fields", ",", "newSpaceshipPosition", ")", ")", "{", "newObjects", "=", "[", "...", "newObjects", ",", "'spaceship-broken'", "]", ";", "}", "else", "{", "newObjects", "=", "[", "...", "newObjects", ",", "'S'", "]", ";", "}", "}", "return", "[", "background", ",", "newObjects", "]", ";", "}", ")", ")", ";", "return", "newFields", ";", "}" ]
Return new 2D fields after move of the spaceship represented as object 'S'. Dicection is one of 'left', 'ahead', 'right'.
[ "Return", "new", "2D", "fields", "after", "move", "of", "the", "spaceship", "represented", "as", "object", "S", ".", "Dicection", "is", "one", "of", "left", "ahead", "right", "." ]
c62e80a1fd5ad65ae2cbe37a1d9450a96c3a9306
https://github.com/adaptive-learning/flocs-visual-components/blob/c62e80a1fd5ad65ae2cbe37a1d9450a96c3a9306/src/selectors/gameState.js#L280-L312
train
jimivdw/grunt-mutation-testing
lib/karma/KarmaServerPool.js
KarmaServerPool
function KarmaServerPool(config) { this._config = _.merge({ port: 12111, maxActiveServers: 5, startInterval: 100 }, config); this._instances = []; }
javascript
function KarmaServerPool(config) { this._config = _.merge({ port: 12111, maxActiveServers: 5, startInterval: 100 }, config); this._instances = []; }
[ "function", "KarmaServerPool", "(", "config", ")", "{", "this", ".", "_config", "=", "_", ".", "merge", "(", "{", "port", ":", "12111", ",", "maxActiveServers", ":", "5", ",", "startInterval", ":", "100", "}", ",", "config", ")", ";", "this", ".", "_instances", "=", "[", "]", ";", "}" ]
Constructor for a Karma server manager @param config {object} Configuration object for the server. @constructor
[ "Constructor", "for", "a", "Karma", "server", "manager" ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/lib/karma/KarmaServerPool.js#L25-L28
train
joshfire/woodman
lib/loggercontext.js
LoggerContext
function LoggerContext() { LifeCycle.call(this); /** * Context start time */ this.startTime = new Date(); /** * The list of trace levels that the logger context knows about */ this.logLevel = new LogLevel(); /** * Root logger, final ancestor of all loggers */ this.rootLogger = new Logger('[root]', this); /** * List of loggers that have been created, indexed by name. */ this.loggers = {}; /** * List of appenders that have been registered through a call to * "registerAppender", indexed by name. */ this.appenders = {}; /** * List of filters that have been registered through a call to * "registerFilter", indexed by name. */ this.filters = {}; /** * List of layouts that have been registered through a call to * "registerLayout", indexed by name. */ this.layouts = {}; /** * List of appenders that have been instantiated. * * The list is constructed when the configuration is applied. It is used * to start/stop appenders when corresponding functions are called on this * context. */ this.createdAppenders = []; /** * The context-wide filter. * * The filter is constructed when the configuration is applied. If the * configuration specifies more than one context-wide filter, a * CompositeFilter filter is created. */ this.filter = null; /** * Flag set when the context is up and running */ this.started = false; /** * Log events received by the context before it got a chance to start and * that need to be processed as soon as the context is operational * * The context keeps a maximum of 1000 events in memory. If more events are * received before the context becomes operational, the context starts to * drop events, replacing the first event with a warning that events had to * be droppes. That warning is sent to the root logger. */ this.pendingEvents = []; /** * Maximum number of log events that can be stored in the pending list. * * TODO: adjust this setting based on configuration settings. */ this.maxPendingEvents = 1000; /** * Number of log events that had to be discarded so far */ this.discardedPendingEvents = 0; }
javascript
function LoggerContext() { LifeCycle.call(this); /** * Context start time */ this.startTime = new Date(); /** * The list of trace levels that the logger context knows about */ this.logLevel = new LogLevel(); /** * Root logger, final ancestor of all loggers */ this.rootLogger = new Logger('[root]', this); /** * List of loggers that have been created, indexed by name. */ this.loggers = {}; /** * List of appenders that have been registered through a call to * "registerAppender", indexed by name. */ this.appenders = {}; /** * List of filters that have been registered through a call to * "registerFilter", indexed by name. */ this.filters = {}; /** * List of layouts that have been registered through a call to * "registerLayout", indexed by name. */ this.layouts = {}; /** * List of appenders that have been instantiated. * * The list is constructed when the configuration is applied. It is used * to start/stop appenders when corresponding functions are called on this * context. */ this.createdAppenders = []; /** * The context-wide filter. * * The filter is constructed when the configuration is applied. If the * configuration specifies more than one context-wide filter, a * CompositeFilter filter is created. */ this.filter = null; /** * Flag set when the context is up and running */ this.started = false; /** * Log events received by the context before it got a chance to start and * that need to be processed as soon as the context is operational * * The context keeps a maximum of 1000 events in memory. If more events are * received before the context becomes operational, the context starts to * drop events, replacing the first event with a warning that events had to * be droppes. That warning is sent to the root logger. */ this.pendingEvents = []; /** * Maximum number of log events that can be stored in the pending list. * * TODO: adjust this setting based on configuration settings. */ this.maxPendingEvents = 1000; /** * Number of log events that had to be discarded so far */ this.discardedPendingEvents = 0; }
[ "function", "LoggerContext", "(", ")", "{", "LifeCycle", ".", "call", "(", "this", ")", ";", "this", ".", "startTime", "=", "new", "Date", "(", ")", ";", "this", ".", "logLevel", "=", "new", "LogLevel", "(", ")", ";", "this", ".", "rootLogger", "=", "new", "Logger", "(", "'[root]'", ",", "this", ")", ";", "this", ".", "loggers", "=", "{", "}", ";", "this", ".", "appenders", "=", "{", "}", ";", "this", ".", "filters", "=", "{", "}", ";", "this", ".", "layouts", "=", "{", "}", ";", "this", ".", "createdAppenders", "=", "[", "]", ";", "this", ".", "filter", "=", "null", ";", "this", ".", "started", "=", "false", ";", "this", ".", "pendingEvents", "=", "[", "]", ";", "this", ".", "maxPendingEvents", "=", "1000", ";", "this", ".", "discardedPendingEvents", "=", "0", ";", "}" ]
Internal anchor point for the logging system, used by LogManager. @constructor
[ "Internal", "anchor", "point", "for", "the", "logging", "system", "used", "by", "LogManager", "." ]
fdc05de2124388780924980e6f27bf4483056d18
https://github.com/joshfire/woodman/blob/fdc05de2124388780924980e6f27bf4483056d18/lib/loggercontext.js#L45-L131
train
jldec/marked-forms
marked-forms.js
link
function link(href, title, text) { var reLabelFirst = /^(.*?)\s*\?([^?\s]*)\?(\*?)(X?)(H?)$/; var reLabelAfter = /^\?([^?\s]*)\?(\*?)(X?)(H?)\s*(.*)$/; var m = text.match(reLabelFirst); if (m) return renderInput(m[1], m[2], m[3], m[4], m[5], href, title, true); m = text.match(reLabelAfter); if (m) return renderInput(m[5], m[1], m[2], m[3], m[4], href, title, false); return fallback.link.call(this, href, title, text); }
javascript
function link(href, title, text) { var reLabelFirst = /^(.*?)\s*\?([^?\s]*)\?(\*?)(X?)(H?)$/; var reLabelAfter = /^\?([^?\s]*)\?(\*?)(X?)(H?)\s*(.*)$/; var m = text.match(reLabelFirst); if (m) return renderInput(m[1], m[2], m[3], m[4], m[5], href, title, true); m = text.match(reLabelAfter); if (m) return renderInput(m[5], m[1], m[2], m[3], m[4], href, title, false); return fallback.link.call(this, href, title, text); }
[ "function", "link", "(", "href", ",", "title", ",", "text", ")", "{", "var", "reLabelFirst", "=", "/", "^(.*?)\\s*\\?([^?\\s]*)\\?(\\*?)(X?)(H?)$", "/", ";", "var", "reLabelAfter", "=", "/", "^\\?([^?\\s]*)\\?(\\*?)(X?)(H?)\\s*(.*)$", "/", ";", "var", "m", "=", "text", ".", "match", "(", "reLabelFirst", ")", ";", "if", "(", "m", ")", "return", "renderInput", "(", "m", "[", "1", "]", ",", "m", "[", "2", "]", ",", "m", "[", "3", "]", ",", "m", "[", "4", "]", ",", "m", "[", "5", "]", ",", "href", ",", "title", ",", "true", ")", ";", "m", "=", "text", ".", "match", "(", "reLabelAfter", ")", ";", "if", "(", "m", ")", "return", "renderInput", "(", "m", "[", "5", "]", ",", "m", "[", "1", "]", ",", "m", "[", "2", "]", ",", "m", "[", "3", "]", ",", "m", "[", "4", "]", ",", "href", ",", "title", ",", "false", ")", ";", "return", "fallback", ".", "link", ".", "call", "(", "this", ",", "href", ",", "title", ",", "text", ")", ";", "}" ]
markdown link syntax extension for forms
[ "markdown", "link", "syntax", "extension", "for", "forms" ]
096f0ed19319c83df1a5479782c635fd5ce6281c
https://github.com/jldec/marked-forms/blob/096f0ed19319c83df1a5479782c635fd5ce6281c/marked-forms.js#L40-L52
train
jldec/marked-forms
marked-forms.js
listitem
function listitem(text) { if (inList()) { // capture value in trailing "text" - unescape makes regexp work var m = unescapeQuotes(text).match(/^(.*)\s+"([^"]*)"\s*$/); var txt = m ? escapeQuotes(m[1]) : text; var val = m ? escapeQuotes(m[2]) : text; return renderOption(txt, val); } return fallback.listitem.call(this, text); }
javascript
function listitem(text) { if (inList()) { // capture value in trailing "text" - unescape makes regexp work var m = unescapeQuotes(text).match(/^(.*)\s+"([^"]*)"\s*$/); var txt = m ? escapeQuotes(m[1]) : text; var val = m ? escapeQuotes(m[2]) : text; return renderOption(txt, val); } return fallback.listitem.call(this, text); }
[ "function", "listitem", "(", "text", ")", "{", "if", "(", "inList", "(", ")", ")", "{", "var", "m", "=", "unescapeQuotes", "(", "text", ")", ".", "match", "(", "/", "^(.*)\\s+\"([^\"]*)\"\\s*$", "/", ")", ";", "var", "txt", "=", "m", "?", "escapeQuotes", "(", "m", "[", "1", "]", ")", ":", "text", ";", "var", "val", "=", "m", "?", "escapeQuotes", "(", "m", "[", "2", "]", ")", ":", "text", ";", "return", "renderOption", "(", "txt", ",", "val", ")", ";", "}", "return", "fallback", ".", "listitem", ".", "call", "(", "this", ",", "text", ")", ";", "}" ]
capture listitems for select, checklist, radiolist
[ "capture", "listitems", "for", "select", "checklist", "radiolist" ]
096f0ed19319c83df1a5479782c635fd5ce6281c
https://github.com/jldec/marked-forms/blob/096f0ed19319c83df1a5479782c635fd5ce6281c/marked-forms.js#L55-L67
train
jldec/marked-forms
marked-forms.js
list
function list(body, ordered) { if (inList()) return body + endList(); return fallback.list.call(this, body, ordered); }
javascript
function list(body, ordered) { if (inList()) return body + endList(); return fallback.list.call(this, body, ordered); }
[ "function", "list", "(", "body", ",", "ordered", ")", "{", "if", "(", "inList", "(", ")", ")", "return", "body", "+", "endList", "(", ")", ";", "return", "fallback", ".", "list", ".", "call", "(", "this", ",", "body", ",", "ordered", ")", ";", "}" ]
rendering the list terminates listitem collector
[ "rendering", "the", "list", "terminates", "listitem", "collector" ]
096f0ed19319c83df1a5479782c635fd5ce6281c
https://github.com/jldec/marked-forms/blob/096f0ed19319c83df1a5479782c635fd5ce6281c/marked-forms.js#L76-L79
train
RoganMurley/hitagi.js
examples/example6/example6.js
function () { this.update = { velocity: function (entity, dt) { entity.c.position.x += hitagi.utils.delta(entity.c.velocity.xspeed, dt); } }; }
javascript
function () { this.update = { velocity: function (entity, dt) { entity.c.position.x += hitagi.utils.delta(entity.c.velocity.xspeed, dt); } }; }
[ "function", "(", ")", "{", "this", ".", "update", "=", "{", "velocity", ":", "function", "(", "entity", ",", "dt", ")", "{", "entity", ".", "c", ".", "position", ".", "x", "+=", "hitagi", ".", "utils", ".", "delta", "(", "entity", ".", "c", ".", "velocity", ".", "xspeed", ",", "dt", ")", ";", "}", "}", ";", "}" ]
We need to update horizontal and vertical velocity seperately for our collision resolution technique. The default hitagi VelocitySystem doesn't support this, but it's easy to make our own.
[ "We", "need", "to", "update", "horizontal", "and", "vertical", "velocity", "seperately", "for", "our", "collision", "resolution", "technique", ".", "The", "default", "hitagi", "VelocitySystem", "doesn", "t", "support", "this", "but", "it", "s", "easy", "to", "make", "our", "own", "." ]
6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053
https://github.com/RoganMurley/hitagi.js/blob/6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053/examples/example6/example6.js#L15-L21
train
RoganMurley/hitagi.js
examples/example6/example6.js
function (params) { this.$id = 'dragBoxUI'; this.width = 0; this.height = 0; this.origin = { x: params.x, y: params.y }; }
javascript
function (params) { this.$id = 'dragBoxUI'; this.width = 0; this.height = 0; this.origin = { x: params.x, y: params.y }; }
[ "function", "(", "params", ")", "{", "this", ".", "$id", "=", "'dragBoxUI'", ";", "this", ".", "width", "=", "0", ";", "this", ".", "height", "=", "0", ";", "this", ".", "origin", "=", "{", "x", ":", "params", ".", "x", ",", "y", ":", "params", ".", "y", "}", ";", "}" ]
Define components.
[ "Define", "components", "." ]
6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053
https://github.com/RoganMurley/hitagi.js/blob/6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053/examples/example6/example6.js#L263-L271
train
RoganMurley/hitagi.js
src/components/collision.js
function (params) { params = _.extend({ anchor: { x: 0.5, y: 0.5 } }, params); this.$id = 'collision'; this.$deps = ['position']; this.width = params.width; this.height = params.height; this.anchor = params.anchor; }
javascript
function (params) { params = _.extend({ anchor: { x: 0.5, y: 0.5 } }, params); this.$id = 'collision'; this.$deps = ['position']; this.width = params.width; this.height = params.height; this.anchor = params.anchor; }
[ "function", "(", "params", ")", "{", "params", "=", "_", ".", "extend", "(", "{", "anchor", ":", "{", "x", ":", "0.5", ",", "y", ":", "0.5", "}", "}", ",", "params", ")", ";", "this", ".", "$id", "=", "'collision'", ";", "this", ".", "$deps", "=", "[", "'position'", "]", ";", "this", ".", "width", "=", "params", ".", "width", ";", "this", ".", "height", "=", "params", ".", "height", ";", "this", ".", "anchor", "=", "params", ".", "anchor", ";", "}" ]
Represents the collision boundaries of an entity.
[ "Represents", "the", "collision", "boundaries", "of", "an", "entity", "." ]
6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053
https://github.com/RoganMurley/hitagi.js/blob/6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053/src/components/collision.js#L7-L21
train
njoubert/node-groupme
lib/Stateless.js
getRequest
function getRequest(at, api_url, config, callback) { if (!config.responseCode) config.responseCode = 200; request( { uri: getURL(at, api_url, config.opts), method: 'GET', headers: {'Content-Type': 'application/json'} }, function(err,res,body) { if (!err && res.statusCode == config.responseCode) { if (config.doParse) { callback(null,JSON.parse(body).response); } else { callback(null,res.statusCode); } } else { callback(res) } }); }
javascript
function getRequest(at, api_url, config, callback) { if (!config.responseCode) config.responseCode = 200; request( { uri: getURL(at, api_url, config.opts), method: 'GET', headers: {'Content-Type': 'application/json'} }, function(err,res,body) { if (!err && res.statusCode == config.responseCode) { if (config.doParse) { callback(null,JSON.parse(body).response); } else { callback(null,res.statusCode); } } else { callback(res) } }); }
[ "function", "getRequest", "(", "at", ",", "api_url", ",", "config", ",", "callback", ")", "{", "if", "(", "!", "config", ".", "responseCode", ")", "config", ".", "responseCode", "=", "200", ";", "request", "(", "{", "uri", ":", "getURL", "(", "at", ",", "api_url", ",", "config", ".", "opts", ")", ",", "method", ":", "'GET'", ",", "headers", ":", "{", "'Content-Type'", ":", "'application/json'", "}", "}", ",", "function", "(", "err", ",", "res", ",", "body", ")", "{", "if", "(", "!", "err", "&&", "res", ".", "statusCode", "==", "config", ".", "responseCode", ")", "{", "if", "(", "config", ".", "doParse", ")", "{", "callback", "(", "null", ",", "JSON", ".", "parse", "(", "body", ")", ".", "response", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "res", ".", "statusCode", ")", ";", "}", "}", "else", "{", "callback", "(", "res", ")", "}", "}", ")", ";", "}" ]
This makes one of many different types of post requests. config.opts - this adds additional parameters to the url config.doParse - if true, parses the return value as json config.responseCode - if set, checks for this response code
[ "This", "makes", "one", "of", "many", "different", "types", "of", "post", "requests", ".", "config", ".", "opts", "-", "this", "adds", "additional", "parameters", "to", "the", "url", "config", ".", "doParse", "-", "if", "true", "parses", "the", "return", "value", "as", "json", "config", ".", "responseCode", "-", "if", "set", "checks", "for", "this", "response", "code" ]
0d242fb41db4efa3edd9cd332626640623f8493b
https://github.com/njoubert/node-groupme/blob/0d242fb41db4efa3edd9cd332626640623f8493b/lib/Stateless.js#L36-L58
train
njoubert/node-groupme
lib/Stateless.js
postRequest
function postRequest(at, api_url, config, callback) { var r_opts = { uri: getURL(at, api_url), method: 'POST', headers: {'Content-Type': 'application/json'} }; if (config.body && !config.form) { r_opts.body = JSON.stringify(config.body); } else { r_opts.form = config.form; } if (!config.responseCode) config.responseCode = 200; request( r_opts, function(err,res,body) { if (!err && res.statusCode == config.responseCode) { if (config.doParse) { callback(null,JSON.parse(body).response); } else { callback(null,res.statusCode); } } else { callback(res) } }); }
javascript
function postRequest(at, api_url, config, callback) { var r_opts = { uri: getURL(at, api_url), method: 'POST', headers: {'Content-Type': 'application/json'} }; if (config.body && !config.form) { r_opts.body = JSON.stringify(config.body); } else { r_opts.form = config.form; } if (!config.responseCode) config.responseCode = 200; request( r_opts, function(err,res,body) { if (!err && res.statusCode == config.responseCode) { if (config.doParse) { callback(null,JSON.parse(body).response); } else { callback(null,res.statusCode); } } else { callback(res) } }); }
[ "function", "postRequest", "(", "at", ",", "api_url", ",", "config", ",", "callback", ")", "{", "var", "r_opts", "=", "{", "uri", ":", "getURL", "(", "at", ",", "api_url", ")", ",", "method", ":", "'POST'", ",", "headers", ":", "{", "'Content-Type'", ":", "'application/json'", "}", "}", ";", "if", "(", "config", ".", "body", "&&", "!", "config", ".", "form", ")", "{", "r_opts", ".", "body", "=", "JSON", ".", "stringify", "(", "config", ".", "body", ")", ";", "}", "else", "{", "r_opts", ".", "form", "=", "config", ".", "form", ";", "}", "if", "(", "!", "config", ".", "responseCode", ")", "config", ".", "responseCode", "=", "200", ";", "request", "(", "r_opts", ",", "function", "(", "err", ",", "res", ",", "body", ")", "{", "if", "(", "!", "err", "&&", "res", ".", "statusCode", "==", "config", ".", "responseCode", ")", "{", "if", "(", "config", ".", "doParse", ")", "{", "callback", "(", "null", ",", "JSON", ".", "parse", "(", "body", ")", ".", "response", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "res", ".", "statusCode", ")", ";", "}", "}", "else", "{", "callback", "(", "res", ")", "}", "}", ")", ";", "}" ]
This makes one of many different types of post requests. config.body - this stingifies the object as the POST body config.form - this sets the POST body as form parameters config.doParse - if true, parses the return value as json config.responseCode - if set, checks for this response code
[ "This", "makes", "one", "of", "many", "different", "types", "of", "post", "requests", ".", "config", ".", "body", "-", "this", "stingifies", "the", "object", "as", "the", "POST", "body", "config", ".", "form", "-", "this", "sets", "the", "POST", "body", "as", "form", "parameters", "config", ".", "doParse", "-", "if", "true", "parses", "the", "return", "value", "as", "json", "config", ".", "responseCode", "-", "if", "set", "checks", "for", "this", "response", "code" ]
0d242fb41db4efa3edd9cd332626640623f8493b
https://github.com/njoubert/node-groupme/blob/0d242fb41db4efa3edd9cd332626640623f8493b/lib/Stateless.js#L65-L96
train
commenthol/clones
src/index.js
clones
function clones (source, bind, target) { let opts = { bind: bind, visited: [], cloned: [] } return _clone(opts, source, target) }
javascript
function clones (source, bind, target) { let opts = { bind: bind, visited: [], cloned: [] } return _clone(opts, source, target) }
[ "function", "clones", "(", "source", ",", "bind", ",", "target", ")", "{", "let", "opts", "=", "{", "bind", ":", "bind", ",", "visited", ":", "[", "]", ",", "cloned", ":", "[", "]", "}", "return", "_clone", "(", "opts", ",", "source", ",", "target", ")", "}" ]
A Deep-Clone of object `source` @static @param {Object} source - clone source @param {Object} [bind] - bind functions to this context @return {Any} deep clone of `source` @example const clones = require('clones') const source = [ {a: {b: 1}}, {c: {d: 2}}, '3', function () { return 4 } ] // adding circularities source[0].a.e = source[0].a const dest = clones(source) // => [{ a: { b: 1, e: [Circular] } }, // { c: { d: 2 } }, // '3', // [Function] ]
[ "A", "Deep", "-", "Clone", "of", "object", "source" ]
dd9d357948c949bd10a818d1f36e64b4d89c35b4
https://github.com/commenthol/clones/blob/dd9d357948c949bd10a818d1f36e64b4d89c35b4/src/index.js#L33-L40
train
commenthol/clones
src/index.js
_clone
function _clone (opts, source, target) { let type = toType(source) switch (type) { case 'String': case 'Number': case 'Boolean': case 'Null': case 'Undefined': case 'Symbol': case 'DOMPrototype': // (browser) case 'process': // (node) cloning this is not a good idea target = source break case 'Function': if (!target) { let _bind = (opts.bind === null ? null : opts.bind || source) if (opts.wrapFn) { target = function () { return source.apply(_bind, arguments) } } else { target = source.bind(_bind) } } target = _props(opts, source, target) break case 'Int8Array': case 'Uint8Array': case 'Uint8ClampedArray': case 'Int16Array': case 'Uint16Array': case 'Int32Array': case 'Uint32Array': case 'Float32Array': case 'Float64Array': target = new source.constructor(source) break case 'Array': target = source.map(function (item) { return _clone(opts, item) }) target = _props(opts, source, target) break case 'Date': target = new Date(source) break case 'Error': case 'EvalError': case 'InternalError': case 'RangeError': case 'ReferenceError': case 'SyntaxError': case 'TypeError': case 'URIError': target = new source.constructor(source.message) target = _props(opts, source, target) target.stack = source.stack break case 'RegExp': let flags = source.flags || (source.global ? 'g' : '') + (source.ignoreCase ? 'i' : '') + (source.multiline ? 'm' : '') target = new RegExp(source.source, flags) break case 'Buffer': target = new source.constructor(source) break case 'Window': // clone of global object case 'global': opts.wrapFn = true target = _props(opts, source, target || {}) break case 'Math': case 'JSON': case 'Console': case 'Navigator': case 'Screen': case 'Object': target = _props(opts, source, target || {}) break default: if (/^HTML/.test(type)) { // handle HTMLElements if (source.cloneNode) { target = source.cloneNode(true) } else { target = source } } else if (typeof source === 'object') { // handle other object based types target = _props(opts, source, target || {}) } else { // anything else should be a primitive target = source } } return target }
javascript
function _clone (opts, source, target) { let type = toType(source) switch (type) { case 'String': case 'Number': case 'Boolean': case 'Null': case 'Undefined': case 'Symbol': case 'DOMPrototype': // (browser) case 'process': // (node) cloning this is not a good idea target = source break case 'Function': if (!target) { let _bind = (opts.bind === null ? null : opts.bind || source) if (opts.wrapFn) { target = function () { return source.apply(_bind, arguments) } } else { target = source.bind(_bind) } } target = _props(opts, source, target) break case 'Int8Array': case 'Uint8Array': case 'Uint8ClampedArray': case 'Int16Array': case 'Uint16Array': case 'Int32Array': case 'Uint32Array': case 'Float32Array': case 'Float64Array': target = new source.constructor(source) break case 'Array': target = source.map(function (item) { return _clone(opts, item) }) target = _props(opts, source, target) break case 'Date': target = new Date(source) break case 'Error': case 'EvalError': case 'InternalError': case 'RangeError': case 'ReferenceError': case 'SyntaxError': case 'TypeError': case 'URIError': target = new source.constructor(source.message) target = _props(opts, source, target) target.stack = source.stack break case 'RegExp': let flags = source.flags || (source.global ? 'g' : '') + (source.ignoreCase ? 'i' : '') + (source.multiline ? 'm' : '') target = new RegExp(source.source, flags) break case 'Buffer': target = new source.constructor(source) break case 'Window': // clone of global object case 'global': opts.wrapFn = true target = _props(opts, source, target || {}) break case 'Math': case 'JSON': case 'Console': case 'Navigator': case 'Screen': case 'Object': target = _props(opts, source, target || {}) break default: if (/^HTML/.test(type)) { // handle HTMLElements if (source.cloneNode) { target = source.cloneNode(true) } else { target = source } } else if (typeof source === 'object') { // handle other object based types target = _props(opts, source, target || {}) } else { // anything else should be a primitive target = source } } return target }
[ "function", "_clone", "(", "opts", ",", "source", ",", "target", ")", "{", "let", "type", "=", "toType", "(", "source", ")", "switch", "(", "type", ")", "{", "case", "'String'", ":", "case", "'Number'", ":", "case", "'Boolean'", ":", "case", "'Null'", ":", "case", "'Undefined'", ":", "case", "'Symbol'", ":", "case", "'DOMPrototype'", ":", "case", "'process'", ":", "target", "=", "source", "break", "case", "'Function'", ":", "if", "(", "!", "target", ")", "{", "let", "_bind", "=", "(", "opts", ".", "bind", "===", "null", "?", "null", ":", "opts", ".", "bind", "||", "source", ")", "if", "(", "opts", ".", "wrapFn", ")", "{", "target", "=", "function", "(", ")", "{", "return", "source", ".", "apply", "(", "_bind", ",", "arguments", ")", "}", "}", "else", "{", "target", "=", "source", ".", "bind", "(", "_bind", ")", "}", "}", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", ")", "break", "case", "'Int8Array'", ":", "case", "'Uint8Array'", ":", "case", "'Uint8ClampedArray'", ":", "case", "'Int16Array'", ":", "case", "'Uint16Array'", ":", "case", "'Int32Array'", ":", "case", "'Uint32Array'", ":", "case", "'Float32Array'", ":", "case", "'Float64Array'", ":", "target", "=", "new", "source", ".", "constructor", "(", "source", ")", "break", "case", "'Array'", ":", "target", "=", "source", ".", "map", "(", "function", "(", "item", ")", "{", "return", "_clone", "(", "opts", ",", "item", ")", "}", ")", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", ")", "break", "case", "'Date'", ":", "target", "=", "new", "Date", "(", "source", ")", "break", "case", "'Error'", ":", "case", "'EvalError'", ":", "case", "'InternalError'", ":", "case", "'RangeError'", ":", "case", "'ReferenceError'", ":", "case", "'SyntaxError'", ":", "case", "'TypeError'", ":", "case", "'URIError'", ":", "target", "=", "new", "source", ".", "constructor", "(", "source", ".", "message", ")", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", ")", "target", ".", "stack", "=", "source", ".", "stack", "break", "case", "'RegExp'", ":", "let", "flags", "=", "source", ".", "flags", "||", "(", "source", ".", "global", "?", "'g'", ":", "''", ")", "+", "(", "source", ".", "ignoreCase", "?", "'i'", ":", "''", ")", "+", "(", "source", ".", "multiline", "?", "'m'", ":", "''", ")", "target", "=", "new", "RegExp", "(", "source", ".", "source", ",", "flags", ")", "break", "case", "'Buffer'", ":", "target", "=", "new", "source", ".", "constructor", "(", "source", ")", "break", "case", "'Window'", ":", "case", "'global'", ":", "opts", ".", "wrapFn", "=", "true", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", "||", "{", "}", ")", "break", "case", "'Math'", ":", "case", "'JSON'", ":", "case", "'Console'", ":", "case", "'Navigator'", ":", "case", "'Screen'", ":", "case", "'Object'", ":", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", "||", "{", "}", ")", "break", "default", ":", "if", "(", "/", "^HTML", "/", ".", "test", "(", "type", ")", ")", "{", "if", "(", "source", ".", "cloneNode", ")", "{", "target", "=", "source", ".", "cloneNode", "(", "true", ")", "}", "else", "{", "target", "=", "source", "}", "}", "else", "if", "(", "typeof", "source", "===", "'object'", ")", "{", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", "||", "{", "}", ")", "}", "else", "{", "target", "=", "source", "}", "}", "return", "target", "}" ]
Recursively clone source @static @private @param {Object} opts - options @param {Object} [opts.bind] - optional bind for function clones @param {Array} opts.visited - visited references to detect circularities @param {Array} opts.cloned - visited references of clones to assign circularities @param {Any} source - The object to clone @return {Any} deep clone of `source`
[ "Recursively", "clone", "source" ]
dd9d357948c949bd10a818d1f36e64b4d89c35b4
https://github.com/commenthol/clones/blob/dd9d357948c949bd10a818d1f36e64b4d89c35b4/src/index.js#L81-L176
train
commenthol/clones
src/index.js
_props
function _props (opts, source, target) { let idx = opts.visited.indexOf(source) // check for circularities if (idx === -1) { opts.visited.push(source) opts.cloned.push(target) Object.getOwnPropertyNames(source).forEach(function (key) { if (key === 'prototype') { target[key] = Object.create(source[key]) Object.getOwnPropertyNames(source[key]).forEach(function (p) { if (p !== 'constructor') { _descriptor(opts, source[key], target[key], p) // } else { // target[key][p] = target // Safari may throw here with TypeError: Attempted to assign to readonly property. } }) } else { _descriptor(opts, source, target, key) } }) opts.visited.pop() opts.cloned.pop() } else { target = opts.cloned[idx] // add reference of circularity } return target }
javascript
function _props (opts, source, target) { let idx = opts.visited.indexOf(source) // check for circularities if (idx === -1) { opts.visited.push(source) opts.cloned.push(target) Object.getOwnPropertyNames(source).forEach(function (key) { if (key === 'prototype') { target[key] = Object.create(source[key]) Object.getOwnPropertyNames(source[key]).forEach(function (p) { if (p !== 'constructor') { _descriptor(opts, source[key], target[key], p) // } else { // target[key][p] = target // Safari may throw here with TypeError: Attempted to assign to readonly property. } }) } else { _descriptor(opts, source, target, key) } }) opts.visited.pop() opts.cloned.pop() } else { target = opts.cloned[idx] // add reference of circularity } return target }
[ "function", "_props", "(", "opts", ",", "source", ",", "target", ")", "{", "let", "idx", "=", "opts", ".", "visited", ".", "indexOf", "(", "source", ")", "if", "(", "idx", "===", "-", "1", ")", "{", "opts", ".", "visited", ".", "push", "(", "source", ")", "opts", ".", "cloned", ".", "push", "(", "target", ")", "Object", ".", "getOwnPropertyNames", "(", "source", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "key", "===", "'prototype'", ")", "{", "target", "[", "key", "]", "=", "Object", ".", "create", "(", "source", "[", "key", "]", ")", "Object", ".", "getOwnPropertyNames", "(", "source", "[", "key", "]", ")", ".", "forEach", "(", "function", "(", "p", ")", "{", "if", "(", "p", "!==", "'constructor'", ")", "{", "_descriptor", "(", "opts", ",", "source", "[", "key", "]", ",", "target", "[", "key", "]", ",", "p", ")", "}", "}", ")", "}", "else", "{", "_descriptor", "(", "opts", ",", "source", ",", "target", ",", "key", ")", "}", "}", ")", "opts", ".", "visited", ".", "pop", "(", ")", "opts", ".", "cloned", ".", "pop", "(", ")", "}", "else", "{", "target", "=", "opts", ".", "cloned", "[", "idx", "]", "}", "return", "target", "}" ]
Clone property while cloning circularities @static @private @param {Object} opts - options @param {Any} source - source object @param {Any} [target] - target object @returns {Any} target
[ "Clone", "property", "while", "cloning", "circularities" ]
dd9d357948c949bd10a818d1f36e64b4d89c35b4
https://github.com/commenthol/clones/blob/dd9d357948c949bd10a818d1f36e64b4d89c35b4/src/index.js#L188-L214
train
commenthol/clones
src/index.js
_descriptor
function _descriptor (opts, source, target, key) { let desc = Object.getOwnPropertyDescriptor(source, key) if (desc) { if (desc.writable) { desc.value = _clone(opts, desc.value) } try { Object.defineProperty(target, key, desc) } catch (e) { // Safari throws with TypeError: // Attempting to change access mechanism for an unconfigurable property. // Attempting to change value of a readonly property. if (!'Attempting to change'.indexOf(e.message)) { throw e } } } }
javascript
function _descriptor (opts, source, target, key) { let desc = Object.getOwnPropertyDescriptor(source, key) if (desc) { if (desc.writable) { desc.value = _clone(opts, desc.value) } try { Object.defineProperty(target, key, desc) } catch (e) { // Safari throws with TypeError: // Attempting to change access mechanism for an unconfigurable property. // Attempting to change value of a readonly property. if (!'Attempting to change'.indexOf(e.message)) { throw e } } } }
[ "function", "_descriptor", "(", "opts", ",", "source", ",", "target", ",", "key", ")", "{", "let", "desc", "=", "Object", ".", "getOwnPropertyDescriptor", "(", "source", ",", "key", ")", "if", "(", "desc", ")", "{", "if", "(", "desc", ".", "writable", ")", "{", "desc", ".", "value", "=", "_clone", "(", "opts", ",", "desc", ".", "value", ")", "}", "try", "{", "Object", ".", "defineProperty", "(", "target", ",", "key", ",", "desc", ")", "}", "catch", "(", "e", ")", "{", "if", "(", "!", "'Attempting to change'", ".", "indexOf", "(", "e", ".", "message", ")", ")", "{", "throw", "e", "}", "}", "}", "}" ]
assign descriptor with property `key` from source to target @private
[ "assign", "descriptor", "with", "property", "key", "from", "source", "to", "target" ]
dd9d357948c949bd10a818d1f36e64b4d89c35b4
https://github.com/commenthol/clones/blob/dd9d357948c949bd10a818d1f36e64b4d89c35b4/src/index.js#L220-L237
train
atomantic/undermore
gulp/tasks/undermore.js
cleanContent
function cleanContent() { function transform(file, cb) { file.contents = new Buffer((function (src) { var lines = src.replace('_.mixin({\n','').split('\n'), last = lines.pop(); // handle empty lines at the end of the file while(last===''){ last = lines.pop(); } return lines.join('\n'); })(String(file.contents))); cb(null, file); } return require('event-stream').map(transform); }
javascript
function cleanContent() { function transform(file, cb) { file.contents = new Buffer((function (src) { var lines = src.replace('_.mixin({\n','').split('\n'), last = lines.pop(); // handle empty lines at the end of the file while(last===''){ last = lines.pop(); } return lines.join('\n'); })(String(file.contents))); cb(null, file); } return require('event-stream').map(transform); }
[ "function", "cleanContent", "(", ")", "{", "function", "transform", "(", "file", ",", "cb", ")", "{", "file", ".", "contents", "=", "new", "Buffer", "(", "(", "function", "(", "src", ")", "{", "var", "lines", "=", "src", ".", "replace", "(", "'_.mixin({\\n'", ",", "\\n", ")", ".", "''", "split", ",", "(", "'\\n'", ")", ";", "\\n", "last", "=", "lines", ".", "pop", "(", ")", "}", ")", "while", "(", "last", "===", "''", ")", "{", "last", "=", "lines", ".", "pop", "(", ")", ";", "}", ")", ";", "return", "lines", ".", "join", "(", "'\\n'", ")", ";", "}", "\\n", "}" ]
This method is used as a modifier for minification to clean up the stream a bit.
[ "This", "method", "is", "used", "as", "a", "modifier", "for", "minification", "to", "clean", "up", "the", "stream", "a", "bit", "." ]
6c6d995460c25c1df087b465fdc4d21035b4c7b2
https://github.com/atomantic/undermore/blob/6c6d995460c25c1df087b465fdc4d21035b4c7b2/gulp/tasks/undermore.js#L16-L31
train
ToMMApps/express-waf
express-waf.js
recursiveCall
function recursiveCall(i, callback) { if(i >= _modules.length) { callback(); } else { _modules[i].check(req, res, function () { recursiveCall(++i, callback); }) } }
javascript
function recursiveCall(i, callback) { if(i >= _modules.length) { callback(); } else { _modules[i].check(req, res, function () { recursiveCall(++i, callback); }) } }
[ "function", "recursiveCall", "(", "i", ",", "callback", ")", "{", "if", "(", "i", ">=", "_modules", ".", "length", ")", "{", "callback", "(", ")", ";", "}", "else", "{", "_modules", "[", "i", "]", ".", "check", "(", "req", ",", "res", ",", "function", "(", ")", "{", "recursiveCall", "(", "++", "i", ",", "callback", ")", ";", "}", ")", "}", "}" ]
This iterates over all modules and run on them function check @param i {int} iterator @param callback {function} Callback after iteration ended
[ "This", "iterates", "over", "all", "modules", "and", "run", "on", "them", "function", "check" ]
5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a
https://github.com/ToMMApps/express-waf/blob/5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a/express-waf.js#L43-L51
train
joshfire/woodman
lib/message.js
function (params) { this.formatString = ''; this.params = []; if (!params) { return; } params = utils.isArray(params) ? params : [params]; if ((params.length > 0) && utils.isString(params[0]) && (params[0].indexOf('{}') !== -1)) { this.formatString = params[0]; this.params = params.slice(1); } else { this.params = params; } }
javascript
function (params) { this.formatString = ''; this.params = []; if (!params) { return; } params = utils.isArray(params) ? params : [params]; if ((params.length > 0) && utils.isString(params[0]) && (params[0].indexOf('{}') !== -1)) { this.formatString = params[0]; this.params = params.slice(1); } else { this.params = params; } }
[ "function", "(", "params", ")", "{", "this", ".", "formatString", "=", "''", ";", "this", ".", "params", "=", "[", "]", ";", "if", "(", "!", "params", ")", "{", "return", ";", "}", "params", "=", "utils", ".", "isArray", "(", "params", ")", "?", "params", ":", "[", "params", "]", ";", "if", "(", "(", "params", ".", "length", ">", "0", ")", "&&", "utils", ".", "isString", "(", "params", "[", "0", "]", ")", "&&", "(", "params", "[", "0", "]", ".", "indexOf", "(", "'{}'", ")", "!==", "-", "1", ")", ")", "{", "this", ".", "formatString", "=", "params", "[", "0", "]", ";", "this", ".", "params", "=", "params", ".", "slice", "(", "1", ")", ";", "}", "else", "{", "this", ".", "params", "=", "params", ";", "}", "}" ]
Definition of the Message class. If the first parameter in the message is a string that contains "{}", it is taken to be a format string, and the getFormattedMessage function will substitute the occurrences of "{}" with the serialization of the other parameters in order. @constructor @param {(string|Object|Array.<(string|Object)>)} params The parameters that compose the message.
[ "Definition", "of", "the", "Message", "class", "." ]
fdc05de2124388780924980e6f27bf4483056d18
https://github.com/joshfire/woodman/blob/fdc05de2124388780924980e6f27bf4483056d18/lib/message.js#L47-L65
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/jquery.colorbox.js
setSize
function setSize(size, dimension) { return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10)); }
javascript
function setSize(size, dimension) { return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10)); }
[ "function", "setSize", "(", "size", ",", "dimension", ")", "{", "return", "Math", ".", "round", "(", "(", "/", "%", "/", ".", "test", "(", "size", ")", "?", "(", "(", "dimension", "===", "'x'", "?", "$window", ".", "width", "(", ")", ":", "winheight", "(", ")", ")", "/", "100", ")", ":", "1", ")", "*", "parseInt", "(", "size", ",", "10", ")", ")", ";", "}" ]
Convert '%' and 'px' values to integers
[ "Convert", "%", "and", "px", "values", "to", "integers" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/jquery.colorbox.js#L171-L173
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/jquery.colorbox.js
appendHTML
function appendHTML() { if (!$box && document.body) { init = false; $window = $(window); $box = $tag(div).attr({ id: colorbox, 'class': $.support.opacity === false ? prefix + 'IE' : '', // class for optional IE8 & lower targeted CSS. role: 'dialog', tabindex: '-1' }).hide(); $overlay = $tag(div, "Overlay").hide(); $loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]); $wrap = $tag(div, "Wrapper"); $content = $tag(div, "Content").append( $title = $tag(div, "Title"), $current = $tag(div, "Current"), $prev = $('<button type="button"/>').attr({id:prefix+'Previous'}), $next = $('<button type="button"/>').attr({id:prefix+'Next'}), $slideshow = $tag('button', "Slideshow"), $loadingOverlay ); $close = $('<button type="button"/>').attr({id:prefix+'Close'}); $wrap.append( // The 3x3 Grid that makes up Colorbox $tag(div).append( $tag(div, "TopLeft"), $topBorder = $tag(div, "TopCenter"), $tag(div, "TopRight") ), $tag(div, false, 'clear:left').append( $leftBorder = $tag(div, "MiddleLeft"), $content, $rightBorder = $tag(div, "MiddleRight") ), $tag(div, false, 'clear:left').append( $tag(div, "BottomLeft"), $bottomBorder = $tag(div, "BottomCenter"), $tag(div, "BottomRight") ) ).find('div div').css({'float': 'left'}); $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none'); $groupControls = $next.add($prev).add($current).add($slideshow); $(document.body).append($overlay, $box.append($wrap, $loadingBay)); } }
javascript
function appendHTML() { if (!$box && document.body) { init = false; $window = $(window); $box = $tag(div).attr({ id: colorbox, 'class': $.support.opacity === false ? prefix + 'IE' : '', // class for optional IE8 & lower targeted CSS. role: 'dialog', tabindex: '-1' }).hide(); $overlay = $tag(div, "Overlay").hide(); $loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]); $wrap = $tag(div, "Wrapper"); $content = $tag(div, "Content").append( $title = $tag(div, "Title"), $current = $tag(div, "Current"), $prev = $('<button type="button"/>').attr({id:prefix+'Previous'}), $next = $('<button type="button"/>').attr({id:prefix+'Next'}), $slideshow = $tag('button', "Slideshow"), $loadingOverlay ); $close = $('<button type="button"/>').attr({id:prefix+'Close'}); $wrap.append( // The 3x3 Grid that makes up Colorbox $tag(div).append( $tag(div, "TopLeft"), $topBorder = $tag(div, "TopCenter"), $tag(div, "TopRight") ), $tag(div, false, 'clear:left').append( $leftBorder = $tag(div, "MiddleLeft"), $content, $rightBorder = $tag(div, "MiddleRight") ), $tag(div, false, 'clear:left').append( $tag(div, "BottomLeft"), $bottomBorder = $tag(div, "BottomCenter"), $tag(div, "BottomRight") ) ).find('div div').css({'float': 'left'}); $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none'); $groupControls = $next.add($prev).add($current).add($slideshow); $(document.body).append($overlay, $box.append($wrap, $loadingBay)); } }
[ "function", "appendHTML", "(", ")", "{", "if", "(", "!", "$box", "&&", "document", ".", "body", ")", "{", "init", "=", "false", ";", "$window", "=", "$", "(", "window", ")", ";", "$box", "=", "$tag", "(", "div", ")", ".", "attr", "(", "{", "id", ":", "colorbox", ",", "'class'", ":", "$", ".", "support", ".", "opacity", "===", "false", "?", "prefix", "+", "'IE'", ":", "''", ",", "role", ":", "'dialog'", ",", "tabindex", ":", "'-1'", "}", ")", ".", "hide", "(", ")", ";", "$overlay", "=", "$tag", "(", "div", ",", "\"Overlay\"", ")", ".", "hide", "(", ")", ";", "$loadingOverlay", "=", "$", "(", "[", "$tag", "(", "div", ",", "\"LoadingOverlay\"", ")", "[", "0", "]", ",", "$tag", "(", "div", ",", "\"LoadingGraphic\"", ")", "[", "0", "]", "]", ")", ";", "$wrap", "=", "$tag", "(", "div", ",", "\"Wrapper\"", ")", ";", "$content", "=", "$tag", "(", "div", ",", "\"Content\"", ")", ".", "append", "(", "$title", "=", "$tag", "(", "div", ",", "\"Title\"", ")", ",", "$current", "=", "$tag", "(", "div", ",", "\"Current\"", ")", ",", "$prev", "=", "$", "(", "'<button type=\"button\"/>'", ")", ".", "attr", "(", "{", "id", ":", "prefix", "+", "'Previous'", "}", ")", ",", "$next", "=", "$", "(", "'<button type=\"button\"/>'", ")", ".", "attr", "(", "{", "id", ":", "prefix", "+", "'Next'", "}", ")", ",", "$slideshow", "=", "$tag", "(", "'button'", ",", "\"Slideshow\"", ")", ",", "$loadingOverlay", ")", ";", "$close", "=", "$", "(", "'<button type=\"button\"/>'", ")", ".", "attr", "(", "{", "id", ":", "prefix", "+", "'Close'", "}", ")", ";", "$wrap", ".", "append", "(", "$tag", "(", "div", ")", ".", "append", "(", "$tag", "(", "div", ",", "\"TopLeft\"", ")", ",", "$topBorder", "=", "$tag", "(", "div", ",", "\"TopCenter\"", ")", ",", "$tag", "(", "div", ",", "\"TopRight\"", ")", ")", ",", "$tag", "(", "div", ",", "false", ",", "'clear:left'", ")", ".", "append", "(", "$leftBorder", "=", "$tag", "(", "div", ",", "\"MiddleLeft\"", ")", ",", "$content", ",", "$rightBorder", "=", "$tag", "(", "div", ",", "\"MiddleRight\"", ")", ")", ",", "$tag", "(", "div", ",", "false", ",", "'clear:left'", ")", ".", "append", "(", "$tag", "(", "div", ",", "\"BottomLeft\"", ")", ",", "$bottomBorder", "=", "$tag", "(", "div", ",", "\"BottomCenter\"", ")", ",", "$tag", "(", "div", ",", "\"BottomRight\"", ")", ")", ")", ".", "find", "(", "'div div'", ")", ".", "css", "(", "{", "'float'", ":", "'left'", "}", ")", ";", "$loadingBay", "=", "$tag", "(", "div", ",", "false", ",", "'position:absolute; width:9999px; visibility:hidden; display:none'", ")", ";", "$groupControls", "=", "$next", ".", "add", "(", "$prev", ")", ".", "add", "(", "$current", ")", ".", "add", "(", "$slideshow", ")", ";", "$", "(", "document", ".", "body", ")", ".", "append", "(", "$overlay", ",", "$box", ".", "append", "(", "$wrap", ",", "$loadingBay", ")", ")", ";", "}", "}" ]
Colorbox's markup needs to be added to the DOM prior to being called so that the browser will go ahead and load the CSS background images.
[ "Colorbox", "s", "markup", "needs", "to", "be", "added", "to", "the", "DOM", "prior", "to", "being", "called", "so", "that", "the", "browser", "will", "go", "ahead", "and", "load", "the", "CSS", "background", "images", "." ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/jquery.colorbox.js#L406-L454
train
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/jquery.colorbox.js
addBindings
function addBindings() { function clickHandler(e) { // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt. // See: http://jacklmoore.com/notes/click-events/ if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) { e.preventDefault(); launch(this); } } if ($box) { if (!init) { init = true; // Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly. $next.click(function () { publicMethod.next(); }); $prev.click(function () { publicMethod.prev(); }); $close.click(function () { publicMethod.close(); }); $overlay.click(function () { if (settings.overlayClose) { publicMethod.close(); } }); // Key Bindings $(document).bind('keydown.' + prefix, function (e) { var key = e.keyCode; if (open && settings.escKey && key === 27) { e.preventDefault(); publicMethod.close(); } if (open && settings.arrowKey && $related[1] && !e.altKey) { if (key === 37) { e.preventDefault(); $prev.click(); } else if (key === 39) { e.preventDefault(); $next.click(); } } }); if ($.isFunction($.fn.on)) { // For jQuery 1.7+ $(document).on('click.'+prefix, '.'+boxElement, clickHandler); } else { // For jQuery 1.3.x -> 1.6.x // This code is never reached in jQuery 1.9, so do not contact me about 'live' being removed. // This is not here for jQuery 1.9, it's here for legacy users. $('.'+boxElement).live('click.'+prefix, clickHandler); } } return true; } return false; }
javascript
function addBindings() { function clickHandler(e) { // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt. // See: http://jacklmoore.com/notes/click-events/ if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) { e.preventDefault(); launch(this); } } if ($box) { if (!init) { init = true; // Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly. $next.click(function () { publicMethod.next(); }); $prev.click(function () { publicMethod.prev(); }); $close.click(function () { publicMethod.close(); }); $overlay.click(function () { if (settings.overlayClose) { publicMethod.close(); } }); // Key Bindings $(document).bind('keydown.' + prefix, function (e) { var key = e.keyCode; if (open && settings.escKey && key === 27) { e.preventDefault(); publicMethod.close(); } if (open && settings.arrowKey && $related[1] && !e.altKey) { if (key === 37) { e.preventDefault(); $prev.click(); } else if (key === 39) { e.preventDefault(); $next.click(); } } }); if ($.isFunction($.fn.on)) { // For jQuery 1.7+ $(document).on('click.'+prefix, '.'+boxElement, clickHandler); } else { // For jQuery 1.3.x -> 1.6.x // This code is never reached in jQuery 1.9, so do not contact me about 'live' being removed. // This is not here for jQuery 1.9, it's here for legacy users. $('.'+boxElement).live('click.'+prefix, clickHandler); } } return true; } return false; }
[ "function", "addBindings", "(", ")", "{", "function", "clickHandler", "(", "e", ")", "{", "if", "(", "!", "(", "e", ".", "which", ">", "1", "||", "e", ".", "shiftKey", "||", "e", ".", "altKey", "||", "e", ".", "metaKey", "||", "e", ".", "ctrlKey", ")", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "launch", "(", "this", ")", ";", "}", "}", "if", "(", "$box", ")", "{", "if", "(", "!", "init", ")", "{", "init", "=", "true", ";", "$next", ".", "click", "(", "function", "(", ")", "{", "publicMethod", ".", "next", "(", ")", ";", "}", ")", ";", "$prev", ".", "click", "(", "function", "(", ")", "{", "publicMethod", ".", "prev", "(", ")", ";", "}", ")", ";", "$close", ".", "click", "(", "function", "(", ")", "{", "publicMethod", ".", "close", "(", ")", ";", "}", ")", ";", "$overlay", ".", "click", "(", "function", "(", ")", "{", "if", "(", "settings", ".", "overlayClose", ")", "{", "publicMethod", ".", "close", "(", ")", ";", "}", "}", ")", ";", "$", "(", "document", ")", ".", "bind", "(", "'keydown.'", "+", "prefix", ",", "function", "(", "e", ")", "{", "var", "key", "=", "e", ".", "keyCode", ";", "if", "(", "open", "&&", "settings", ".", "escKey", "&&", "key", "===", "27", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "publicMethod", ".", "close", "(", ")", ";", "}", "if", "(", "open", "&&", "settings", ".", "arrowKey", "&&", "$related", "[", "1", "]", "&&", "!", "e", ".", "altKey", ")", "{", "if", "(", "key", "===", "37", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "$prev", ".", "click", "(", ")", ";", "}", "else", "if", "(", "key", "===", "39", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "$next", ".", "click", "(", ")", ";", "}", "}", "}", ")", ";", "if", "(", "$", ".", "isFunction", "(", "$", ".", "fn", ".", "on", ")", ")", "{", "$", "(", "document", ")", ".", "on", "(", "'click.'", "+", "prefix", ",", "'.'", "+", "boxElement", ",", "clickHandler", ")", ";", "}", "else", "{", "$", "(", "'.'", "+", "boxElement", ")", ".", "live", "(", "'click.'", "+", "prefix", ",", "clickHandler", ")", ";", "}", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Add Colorbox's event bindings
[ "Add", "Colorbox", "s", "event", "bindings" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/jquery.colorbox.js#L457-L518
train
ToMMApps/express-waf
blocker.js
Blocker
function Blocker(config, logger) { //DB must define an add, remove and contains function! if(!(config.db && config.db.add && config.db.remove && config.db.contains)){ throw "db must define an add, remove and contains function"; }; _config = config; _logger = logger; }
javascript
function Blocker(config, logger) { //DB must define an add, remove and contains function! if(!(config.db && config.db.add && config.db.remove && config.db.contains)){ throw "db must define an add, remove and contains function"; }; _config = config; _logger = logger; }
[ "function", "Blocker", "(", "config", ",", "logger", ")", "{", "if", "(", "!", "(", "config", ".", "db", "&&", "config", ".", "db", ".", "add", "&&", "config", ".", "db", ".", "remove", "&&", "config", ".", "db", ".", "contains", ")", ")", "{", "throw", "\"db must define an add, remove and contains function\"", ";", "}", ";", "_config", "=", "config", ";", "_logger", "=", "logger", ";", "}" ]
The Blocker class realizes an IP blocklist that allows other modules to block attackers. @param config must contain at least an object named db that must have an add, remove and contains function. Furthermore it allow the user to specifiy a blockTime. If blockTime is not set, entries will never be removed from Blocklist. @constructor
[ "The", "Blocker", "class", "realizes", "an", "IP", "blocklist", "that", "allows", "other", "modules", "to", "block", "attackers", "." ]
5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a
https://github.com/ToMMApps/express-waf/blob/5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a/blocker.js#L13-L22
train
zhengxiaoyao0716/markplus
lib/Render.js
replaceHtml
function replaceHtml(ele, html) { var _this = this; if (ele.classList.contains('raw-text')) { return; } ele.innerHTML = withEscape( // eslint-disable-line no-undef function (html) { return function (reg, rep) { return _this.htmlSugars.reduce(function (html, _ref) { var _ref2 = _slicedToArray(_ref, 2), regExp = _ref2[0], replace = _ref2[1]; return html.replace(regExp, replace); }, html).replace(reg, rep); }; })(html); }
javascript
function replaceHtml(ele, html) { var _this = this; if (ele.classList.contains('raw-text')) { return; } ele.innerHTML = withEscape( // eslint-disable-line no-undef function (html) { return function (reg, rep) { return _this.htmlSugars.reduce(function (html, _ref) { var _ref2 = _slicedToArray(_ref, 2), regExp = _ref2[0], replace = _ref2[1]; return html.replace(regExp, replace); }, html).replace(reg, rep); }; })(html); }
[ "function", "replaceHtml", "(", "ele", ",", "html", ")", "{", "var", "_this", "=", "this", ";", "if", "(", "ele", ".", "classList", ".", "contains", "(", "'raw-text'", ")", ")", "{", "return", ";", "}", "ele", ".", "innerHTML", "=", "withEscape", "(", "function", "(", "html", ")", "{", "return", "function", "(", "reg", ",", "rep", ")", "{", "return", "_this", ".", "htmlSugars", ".", "reduce", "(", "function", "(", "html", ",", "_ref", ")", "{", "var", "_ref2", "=", "_slicedToArray", "(", "_ref", ",", "2", ")", ",", "regExp", "=", "_ref2", "[", "0", "]", ",", "replace", "=", "_ref2", "[", "1", "]", ";", "return", "html", ".", "replace", "(", "regExp", ",", "replace", ")", ";", "}", ",", "html", ")", ".", "replace", "(", "reg", ",", "rep", ")", ";", "}", ";", "}", ")", "(", "html", ")", ";", "}" ]
replace the sugars in the html content. @param {HTMLElement} ele Element witch the resolved html will be set on. @param {*} html Html content to be replaced the sugars.
[ "replace", "the", "sugars", "in", "the", "html", "content", "." ]
fd55e04beb2025b483e78ae5fb711dcbf3083035
https://github.com/zhengxiaoyao0716/markplus/blob/fd55e04beb2025b483e78ae5fb711dcbf3083035/lib/Render.js#L73-L91
train
infrabel/themes-gnap
raw/angular-local-storage/angular-local-storage.js
function() { try { return navigator.cookieEnabled || ("cookie" in $document && ($document.cookie.length > 0 || ($document.cookie = "test").indexOf.call($document.cookie, "test") > -1)); } catch (e) { $rootScope.$broadcast('LocalStorageModule.notification.error', e.message); return false; } }
javascript
function() { try { return navigator.cookieEnabled || ("cookie" in $document && ($document.cookie.length > 0 || ($document.cookie = "test").indexOf.call($document.cookie, "test") > -1)); } catch (e) { $rootScope.$broadcast('LocalStorageModule.notification.error', e.message); return false; } }
[ "function", "(", ")", "{", "try", "{", "return", "navigator", ".", "cookieEnabled", "||", "(", "\"cookie\"", "in", "$document", "&&", "(", "$document", ".", "cookie", ".", "length", ">", "0", "||", "(", "$document", ".", "cookie", "=", "\"test\"", ")", ".", "indexOf", ".", "call", "(", "$document", ".", "cookie", ",", "\"test\"", ")", ">", "-", "1", ")", ")", ";", "}", "catch", "(", "e", ")", "{", "$rootScope", ".", "$broadcast", "(", "'LocalStorageModule.notification.error'", ",", "e", ".", "message", ")", ";", "return", "false", ";", "}", "}" ]
Checks the browser to see if cookies are supported
[ "Checks", "the", "browser", "to", "see", "if", "cookies", "are", "supported" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/angular-local-storage/angular-local-storage.js#L264-L273
train
infrabel/themes-gnap
raw/ace/mustache/app/views/assets/scripts/jqgrid.js
updatePagerIcons
function updatePagerIcons(table) { var replacement = { 'ui-icon-seek-first' : 'icon-double-angle-left bigger-140', 'ui-icon-seek-prev' : 'icon-angle-left bigger-140', 'ui-icon-seek-next' : 'icon-angle-right bigger-140', 'ui-icon-seek-end' : 'icon-double-angle-right bigger-140' }; $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){ var icon = $(this); var $class = $.trim(icon.attr('class').replace('ui-icon', '')); if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]); }) }
javascript
function updatePagerIcons(table) { var replacement = { 'ui-icon-seek-first' : 'icon-double-angle-left bigger-140', 'ui-icon-seek-prev' : 'icon-angle-left bigger-140', 'ui-icon-seek-next' : 'icon-angle-right bigger-140', 'ui-icon-seek-end' : 'icon-double-angle-right bigger-140' }; $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){ var icon = $(this); var $class = $.trim(icon.attr('class').replace('ui-icon', '')); if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]); }) }
[ "function", "updatePagerIcons", "(", "table", ")", "{", "var", "replacement", "=", "{", "'ui-icon-seek-first'", ":", "'icon-double-angle-left bigger-140'", ",", "'ui-icon-seek-prev'", ":", "'icon-angle-left bigger-140'", ",", "'ui-icon-seek-next'", ":", "'icon-angle-right bigger-140'", ",", "'ui-icon-seek-end'", ":", "'icon-double-angle-right bigger-140'", "}", ";", "$", "(", "'.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon'", ")", ".", "each", "(", "function", "(", ")", "{", "var", "icon", "=", "$", "(", "this", ")", ";", "var", "$class", "=", "$", ".", "trim", "(", "icon", ".", "attr", "(", "'class'", ")", ".", "replace", "(", "'ui-icon'", ",", "''", ")", ")", ";", "if", "(", "$class", "in", "replacement", ")", "icon", ".", "attr", "(", "'class'", ",", "'ui-icon '", "+", "replacement", "[", "$class", "]", ")", ";", "}", ")", "}" ]
replace icons with FontAwesome icons like above
[ "replace", "icons", "with", "FontAwesome", "icons", "like", "above" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/mustache/app/views/assets/scripts/jqgrid.js#L285-L299
train
jimivdw/grunt-mutation-testing
lib/karma/KarmaServerManager.js
KarmaServerManager
function KarmaServerManager(config, port, runnerTimeUnlimited) { this._status = null; this._serverProcess = null; this._runnerTimeUnlimited = runnerTimeUnlimited; this._config = _.merge({ waitForServerTime: 10, waitForRunnerTime: 2 }, config, { port: port }); var notIncluded = this._config.notIncluded || []; this._config.files = _.map(this._config.files, function(filename) { return { pattern: filename, included: _.indexOf(notIncluded, filename) < 0 }; }); }
javascript
function KarmaServerManager(config, port, runnerTimeUnlimited) { this._status = null; this._serverProcess = null; this._runnerTimeUnlimited = runnerTimeUnlimited; this._config = _.merge({ waitForServerTime: 10, waitForRunnerTime: 2 }, config, { port: port }); var notIncluded = this._config.notIncluded || []; this._config.files = _.map(this._config.files, function(filename) { return { pattern: filename, included: _.indexOf(notIncluded, filename) < 0 }; }); }
[ "function", "KarmaServerManager", "(", "config", ",", "port", ",", "runnerTimeUnlimited", ")", "{", "this", ".", "_status", "=", "null", ";", "this", ".", "_serverProcess", "=", "null", ";", "this", ".", "_runnerTimeUnlimited", "=", "runnerTimeUnlimited", ";", "this", ".", "_config", "=", "_", ".", "merge", "(", "{", "waitForServerTime", ":", "10", ",", "waitForRunnerTime", ":", "2", "}", ",", "config", ",", "{", "port", ":", "port", "}", ")", ";", "var", "notIncluded", "=", "this", ".", "_config", ".", "notIncluded", "||", "[", "]", ";", "this", ".", "_config", ".", "files", "=", "_", ".", "map", "(", "this", ".", "_config", ".", "files", ",", "function", "(", "filename", ")", "{", "return", "{", "pattern", ":", "filename", ",", "included", ":", "_", ".", "indexOf", "(", "notIncluded", ",", "filename", ")", "<", "0", "}", ";", "}", ")", ";", "}" ]
Constructor for a Karma server instance @param config {object} Karma configuration object that should be used @param port {number} The port on which the Karma server should run @param runnerTimeUnlimited {boolean} if set the KarmaServerManager will not limit the running time of the runner @constructor
[ "Constructor", "for", "a", "Karma", "server", "instance" ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/lib/karma/KarmaServerManager.js#L30-L40
train
jimivdw/grunt-mutation-testing
lib/karma/KarmaServerManager.js
startServer
function startServer(serverPromise) { var self = this, startTime = Date.now(), browsersStarting, serverTimeout, serverProcess = fork(__dirname + '/KarmaWorker.js', { silent: true }); // Limit the time it can take for a server to start to config.waitForServerTime seconds serverTimeout = setTimeout(function() { self._setStatus(KarmaServerStatus.DEFUNCT); serverPromise.reject( 'Could not connect to a Karma server on port ' + self._config.port + ' within ' + self._config.waitForServerTime + ' seconds' ); }, self._config.waitForServerTime * 1000); serverProcess.send({ command: 'start', config: self._config }); serverProcess.stdout.on('data', function(data) { var message = data.toString('utf-8'), messageParts = message.split(/\s/g); logger.debug(message); //this is a hack: because Karma exposes no method of determining when the server is started up we'll dissect the log messages if(message.indexOf('Starting browser') > -1) { browsersStarting = browsersStarting ? browsersStarting.concat([messageParts[4]]) : [messageParts[4]]; } if(message.indexOf('Connected on socket') > -1) { browsersStarting.pop(); if(browsersStarting && browsersStarting.length === 0) { clearTimeout(serverTimeout); self._setStatus(KarmaServerStatus.READY); logger.info( 'Karma server started after %dms and is listening on port %d', (Date.now() - startTime), self._config.port ); serverPromise.resolve(self); } } }); return serverProcess; }
javascript
function startServer(serverPromise) { var self = this, startTime = Date.now(), browsersStarting, serverTimeout, serverProcess = fork(__dirname + '/KarmaWorker.js', { silent: true }); // Limit the time it can take for a server to start to config.waitForServerTime seconds serverTimeout = setTimeout(function() { self._setStatus(KarmaServerStatus.DEFUNCT); serverPromise.reject( 'Could not connect to a Karma server on port ' + self._config.port + ' within ' + self._config.waitForServerTime + ' seconds' ); }, self._config.waitForServerTime * 1000); serverProcess.send({ command: 'start', config: self._config }); serverProcess.stdout.on('data', function(data) { var message = data.toString('utf-8'), messageParts = message.split(/\s/g); logger.debug(message); //this is a hack: because Karma exposes no method of determining when the server is started up we'll dissect the log messages if(message.indexOf('Starting browser') > -1) { browsersStarting = browsersStarting ? browsersStarting.concat([messageParts[4]]) : [messageParts[4]]; } if(message.indexOf('Connected on socket') > -1) { browsersStarting.pop(); if(browsersStarting && browsersStarting.length === 0) { clearTimeout(serverTimeout); self._setStatus(KarmaServerStatus.READY); logger.info( 'Karma server started after %dms and is listening on port %d', (Date.now() - startTime), self._config.port ); serverPromise.resolve(self); } } }); return serverProcess; }
[ "function", "startServer", "(", "serverPromise", ")", "{", "var", "self", "=", "this", ",", "startTime", "=", "Date", ".", "now", "(", ")", ",", "browsersStarting", ",", "serverTimeout", ",", "serverProcess", "=", "fork", "(", "__dirname", "+", "'/KarmaWorker.js'", ",", "{", "silent", ":", "true", "}", ")", ";", "serverTimeout", "=", "setTimeout", "(", "function", "(", ")", "{", "self", ".", "_setStatus", "(", "KarmaServerStatus", ".", "DEFUNCT", ")", ";", "serverPromise", ".", "reject", "(", "'Could not connect to a Karma server on port '", "+", "self", ".", "_config", ".", "port", "+", "' within '", "+", "self", ".", "_config", ".", "waitForServerTime", "+", "' seconds'", ")", ";", "}", ",", "self", ".", "_config", ".", "waitForServerTime", "*", "1000", ")", ";", "serverProcess", ".", "send", "(", "{", "command", ":", "'start'", ",", "config", ":", "self", ".", "_config", "}", ")", ";", "serverProcess", ".", "stdout", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "var", "message", "=", "data", ".", "toString", "(", "'utf-8'", ")", ",", "messageParts", "=", "message", ".", "split", "(", "/", "\\s", "/", "g", ")", ";", "logger", ".", "debug", "(", "message", ")", ";", "if", "(", "message", ".", "indexOf", "(", "'Starting browser'", ")", ">", "-", "1", ")", "{", "browsersStarting", "=", "browsersStarting", "?", "browsersStarting", ".", "concat", "(", "[", "messageParts", "[", "4", "]", "]", ")", ":", "[", "messageParts", "[", "4", "]", "]", ";", "}", "if", "(", "message", ".", "indexOf", "(", "'Connected on socket'", ")", ">", "-", "1", ")", "{", "browsersStarting", ".", "pop", "(", ")", ";", "if", "(", "browsersStarting", "&&", "browsersStarting", ".", "length", "===", "0", ")", "{", "clearTimeout", "(", "serverTimeout", ")", ";", "self", ".", "_setStatus", "(", "KarmaServerStatus", ".", "READY", ")", ";", "logger", ".", "info", "(", "'Karma server started after %dms and is listening on port %d'", ",", "(", "Date", ".", "now", "(", ")", "-", "startTime", ")", ",", "self", ".", "_config", ".", "port", ")", ";", "serverPromise", ".", "resolve", "(", "self", ")", ";", "}", "}", "}", ")", ";", "return", "serverProcess", ";", "}" ]
start a karma server by calling node's "fork" method. The stdio will be piped to the current process so that it can be read and interpreted
[ "start", "a", "karma", "server", "by", "calling", "node", "s", "fork", "method", ".", "The", "stdio", "will", "be", "piped", "to", "the", "current", "process", "so", "that", "it", "can", "be", "read", "and", "interpreted" ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/lib/karma/KarmaServerManager.js#L165-L210
train
jimivdw/grunt-mutation-testing
utils/ExclusionUtils.js
parseASTComments
function parseASTComments(astNode) { var comments = []; if(astNode && astNode.leadingComments) { _.forEach(astNode.leadingComments, function(comment) { if(comment.type === 'Block') { comments = comments.concat(comment.value.split('\n').map(function(commentLine) { // Remove asterisks at the start of the line return commentLine.replace(/^\s*\*\s*/g, '').trim(); })); } else { comments.push(comment.value); } }); } return comments; }
javascript
function parseASTComments(astNode) { var comments = []; if(astNode && astNode.leadingComments) { _.forEach(astNode.leadingComments, function(comment) { if(comment.type === 'Block') { comments = comments.concat(comment.value.split('\n').map(function(commentLine) { // Remove asterisks at the start of the line return commentLine.replace(/^\s*\*\s*/g, '').trim(); })); } else { comments.push(comment.value); } }); } return comments; }
[ "function", "parseASTComments", "(", "astNode", ")", "{", "var", "comments", "=", "[", "]", ";", "if", "(", "astNode", "&&", "astNode", ".", "leadingComments", ")", "{", "_", ".", "forEach", "(", "astNode", ".", "leadingComments", ",", "function", "(", "comment", ")", "{", "if", "(", "comment", ".", "type", "===", "'Block'", ")", "{", "comments", "=", "comments", ".", "concat", "(", "comment", ".", "value", ".", "split", "(", "'\\n'", ")", ".", "\\n", "map", ")", ";", "}", "else", "(", "function", "(", "commentLine", ")", "{", "return", "commentLine", ".", "replace", "(", "/", "^\\s*\\*\\s*", "/", "g", ",", "''", ")", ".", "trim", "(", ")", ";", "}", ")", "}", ")", ";", "}", "{", "comments", ".", "push", "(", "comment", ".", "value", ")", ";", "}", "}" ]
Parse the comments from a given astNode. It removes all leading asterisks from multiline comments, as well as all leading and trailing whitespace. @param {object} astNode the AST node from which comments should be retrieved @returns {[string]} the comments for the AST node, or an empty array if none could be found
[ "Parse", "the", "comments", "from", "a", "given", "astNode", ".", "It", "removes", "all", "leading", "asterisks", "from", "multiline", "comments", "as", "well", "as", "all", "leading", "and", "trailing", "whitespace", "." ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/utils/ExclusionUtils.js#L22-L38
train
joshfire/woodman
precompile/precompile.js
function (node, nodeType) { var parentNode = node; var levelNode = 0; // Security in while loop while ((parentNode.type !== nodeType) && (parentNode.parent !== undefined) && (levelNode <= 20)) { levelNode++; parentNode = parentNode.parent; } parentNode.levelNode = levelNode; return parentNode; }
javascript
function (node, nodeType) { var parentNode = node; var levelNode = 0; // Security in while loop while ((parentNode.type !== nodeType) && (parentNode.parent !== undefined) && (levelNode <= 20)) { levelNode++; parentNode = parentNode.parent; } parentNode.levelNode = levelNode; return parentNode; }
[ "function", "(", "node", ",", "nodeType", ")", "{", "var", "parentNode", "=", "node", ";", "var", "levelNode", "=", "0", ";", "while", "(", "(", "parentNode", ".", "type", "!==", "nodeType", ")", "&&", "(", "parentNode", ".", "parent", "!==", "undefined", ")", "&&", "(", "levelNode", "<=", "20", ")", ")", "{", "levelNode", "++", ";", "parentNode", "=", "parentNode", ".", "parent", ";", "}", "parentNode", ".", "levelNode", "=", "levelNode", ";", "return", "parentNode", ";", "}" ]
Returns the first ancestor of the given node in the AST tree that has the specified node type. @function @param {Object} node The node to start from in the AST tree @param {string} nodeType The type of node you are searching for, e.g. "VariableDeclaration", "ExpressionStatement"... @return {Object} The first node in the ancestors of the given node that matches the given type, null if not found
[ "Returns", "the", "first", "ancestor", "of", "the", "given", "node", "in", "the", "AST", "tree", "that", "has", "the", "specified", "node", "type", "." ]
fdc05de2124388780924980e6f27bf4483056d18
https://github.com/joshfire/woodman/blob/fdc05de2124388780924980e6f27bf4483056d18/precompile/precompile.js#L124-L135
train
peerigon/alamid-schema
plugins/validation/index.js
runValidation
function runValidation(validators, field, context, callback) { var fieldErrors = []; var pending = 0; function saveResult(result) { if (result !== true) { fieldErrors.push(result); } } function doCallback() { callback(fieldErrors); } function asyncValidationDone(result) { saveResult(result); pending--; pending === 0 && doCallback(); } validators.forEach(function (validator) { if (validator.length === 2) { pending++; validator.call(context, field, asyncValidationDone); } else { saveResult(validator.call(context, field)); } }); if (pending === 0) { // synchronous callback doCallback(); } return fieldErrors; }
javascript
function runValidation(validators, field, context, callback) { var fieldErrors = []; var pending = 0; function saveResult(result) { if (result !== true) { fieldErrors.push(result); } } function doCallback() { callback(fieldErrors); } function asyncValidationDone(result) { saveResult(result); pending--; pending === 0 && doCallback(); } validators.forEach(function (validator) { if (validator.length === 2) { pending++; validator.call(context, field, asyncValidationDone); } else { saveResult(validator.call(context, field)); } }); if (pending === 0) { // synchronous callback doCallback(); } return fieldErrors; }
[ "function", "runValidation", "(", "validators", ",", "field", ",", "context", ",", "callback", ")", "{", "var", "fieldErrors", "=", "[", "]", ";", "var", "pending", "=", "0", ";", "function", "saveResult", "(", "result", ")", "{", "if", "(", "result", "!==", "true", ")", "{", "fieldErrors", ".", "push", "(", "result", ")", ";", "}", "}", "function", "doCallback", "(", ")", "{", "callback", "(", "fieldErrors", ")", ";", "}", "function", "asyncValidationDone", "(", "result", ")", "{", "saveResult", "(", "result", ")", ";", "pending", "--", ";", "pending", "===", "0", "&&", "doCallback", "(", ")", ";", "}", "validators", ".", "forEach", "(", "function", "(", "validator", ")", "{", "if", "(", "validator", ".", "length", "===", "2", ")", "{", "pending", "++", ";", "validator", ".", "call", "(", "context", ",", "field", ",", "asyncValidationDone", ")", ";", "}", "else", "{", "saveResult", "(", "validator", ".", "call", "(", "context", ",", "field", ")", ")", ";", "}", "}", ")", ";", "if", "(", "pending", "===", "0", ")", "{", "doCallback", "(", ")", ";", "}", "return", "fieldErrors", ";", "}" ]
Runs the given validators on a single field. Caution: callback will be called in synchronously in some situations. This behavior should usually be avoided in public APIs, but since runValidation() is internal, we know how to deal with it. It allows us to speed up validation and to return all synchronous validation results as soon as possible. The final callback, however, is guaranteed to be asynchronous. @param {Array} validators @param {*} field @param {Object} context @param {Function} callback @returns {Array}
[ "Runs", "the", "given", "validators", "on", "a", "single", "field", "." ]
7faa6e826f485b33ccc2e41b86b5861c61184a3c
https://github.com/peerigon/alamid-schema/blob/7faa6e826f485b33ccc2e41b86b5861c61184a3c/plugins/validation/index.js#L21-L56
train
peerigon/alamid-schema
plugins/validation/validators.js
matchesValidator
function matchesValidator(match) { return function matchValue(value) { var result; if (typeof match.test === "function") { match.lastIndex = 0; // reset the lastIndex just in case the regexp is accidentally global result = match.test(value); } else { result = match === value; } return result || "matches"; }; }
javascript
function matchesValidator(match) { return function matchValue(value) { var result; if (typeof match.test === "function") { match.lastIndex = 0; // reset the lastIndex just in case the regexp is accidentally global result = match.test(value); } else { result = match === value; } return result || "matches"; }; }
[ "function", "matchesValidator", "(", "match", ")", "{", "return", "function", "matchValue", "(", "value", ")", "{", "var", "result", ";", "if", "(", "typeof", "match", ".", "test", "===", "\"function\"", ")", "{", "match", ".", "lastIndex", "=", "0", ";", "result", "=", "match", ".", "test", "(", "value", ")", ";", "}", "else", "{", "result", "=", "match", "===", "value", ";", "}", "return", "result", "||", "\"matches\"", ";", "}", ";", "}" ]
Returns true if the given value matches the pattern. The pattern may be a value or a regular expression. If it's a value, a strict comparison will be performed. In case it's a regex, the test method will be invoked. @param {*|RegExp} match @returns {Function}
[ "Returns", "true", "if", "the", "given", "value", "matches", "the", "pattern", ".", "The", "pattern", "may", "be", "a", "value", "or", "a", "regular", "expression", ".", "If", "it", "s", "a", "value", "a", "strict", "comparison", "will", "be", "performed", ".", "In", "case", "it", "s", "a", "regex", "the", "test", "method", "will", "be", "invoked", "." ]
7faa6e826f485b33ccc2e41b86b5861c61184a3c
https://github.com/peerigon/alamid-schema/blob/7faa6e826f485b33ccc2e41b86b5861c61184a3c/plugins/validation/validators.js#L94-L107
train
BohemiaInteractive/bi-service
bin/bi-service.js
_setImmediate
function _setImmediate(fn) { let args = Array.prototype.slice.call(arguments, 1); return new Promise(function(resolve, reject) { setImmediate(function() { try { fn.apply(this, args); } catch(e) { return reject(e); } resolve(); }); }); }
javascript
function _setImmediate(fn) { let args = Array.prototype.slice.call(arguments, 1); return new Promise(function(resolve, reject) { setImmediate(function() { try { fn.apply(this, args); } catch(e) { return reject(e); } resolve(); }); }); }
[ "function", "_setImmediate", "(", "fn", ")", "{", "let", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ";", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "setImmediate", "(", "function", "(", ")", "{", "try", "{", "fn", ".", "apply", "(", "this", ",", "args", ")", ";", "}", "catch", "(", "e", ")", "{", "return", "reject", "(", "e", ")", ";", "}", "resolve", "(", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
setImmediate which returns a Promise @return <Promise>
[ "setImmediate", "which", "returns", "a", "Promise" ]
89e76f2e93714a3150ce7f59f16f646e4bdbbce1
https://github.com/BohemiaInteractive/bi-service/blob/89e76f2e93714a3150ce7f59f16f646e4bdbbce1/bin/bi-service.js#L223-L235
train
BohemiaInteractive/bi-service
bin/bi-service.js
_onBuildApp
function _onBuildApp(app) { let proto = Object.getPrototypeOf(app); if (proto.constructor && proto.constructor.name === 'ShellApp') { app.once('post-init', function() { this.build(); this.listen(); }); } }
javascript
function _onBuildApp(app) { let proto = Object.getPrototypeOf(app); if (proto.constructor && proto.constructor.name === 'ShellApp') { app.once('post-init', function() { this.build(); this.listen(); }); } }
[ "function", "_onBuildApp", "(", "app", ")", "{", "let", "proto", "=", "Object", ".", "getPrototypeOf", "(", "app", ")", ";", "if", "(", "proto", ".", "constructor", "&&", "proto", ".", "constructor", ".", "name", "===", "'ShellApp'", ")", "{", "app", ".", "once", "(", "'post-init'", ",", "function", "(", ")", "{", "this", ".", "build", "(", ")", ";", "this", ".", "listen", "(", ")", ";", "}", ")", ";", "}", "}" ]
`build-app` AppManager listener @private
[ "build", "-", "app", "AppManager", "listener" ]
89e76f2e93714a3150ce7f59f16f646e4bdbbce1
https://github.com/BohemiaInteractive/bi-service/blob/89e76f2e93714a3150ce7f59f16f646e4bdbbce1/bin/bi-service.js#L241-L249
train
koopero/node-unique-file-name
src/random.js
random
function random( width, set ) { width = parseInt( width ) || 4 set = set || RANDOM_SET ass.isString( set, "Random character set must be string" ) var i = 0, r = '' for ( ; i < width; i ++ ) r += RANDOM_SET[ Math.floor( Math.random() * RANDOM_SET.length ) ] return r }
javascript
function random( width, set ) { width = parseInt( width ) || 4 set = set || RANDOM_SET ass.isString( set, "Random character set must be string" ) var i = 0, r = '' for ( ; i < width; i ++ ) r += RANDOM_SET[ Math.floor( Math.random() * RANDOM_SET.length ) ] return r }
[ "function", "random", "(", "width", ",", "set", ")", "{", "width", "=", "parseInt", "(", "width", ")", "||", "4", "set", "=", "set", "||", "RANDOM_SET", "ass", ".", "isString", "(", "set", ",", "\"Random character set must be string\"", ")", "var", "i", "=", "0", ",", "r", "=", "''", "for", "(", ";", "i", "<", "width", ";", "i", "++", ")", "r", "+=", "RANDOM_SET", "[", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "RANDOM_SET", ".", "length", ")", "]", "return", "r", "}" ]
Produces a string of random character of a certain width. Uses the character set RANDOM_SET.
[ "Produces", "a", "string", "of", "random", "character", "of", "a", "certain", "width", ".", "Uses", "the", "character", "set", "RANDOM_SET", "." ]
e503c0f743711bbfcf5444165902206192567c06
https://github.com/koopero/node-unique-file-name/blob/e503c0f743711bbfcf5444165902206192567c06/src/random.js#L13-L27
train
jimivdw/grunt-mutation-testing
utils/OptionUtils.js
expandFiles
function expandFiles(files, basePath) { var expandedFiles = []; files = files ? _.isArray(files) ? files : [files] : []; _.forEach(files, function(fileName) { expandedFiles = _.union( expandedFiles, glob.sync(path.join(basePath, fileName), { dot: true, nodir: true }) ); }); return expandedFiles; }
javascript
function expandFiles(files, basePath) { var expandedFiles = []; files = files ? _.isArray(files) ? files : [files] : []; _.forEach(files, function(fileName) { expandedFiles = _.union( expandedFiles, glob.sync(path.join(basePath, fileName), { dot: true, nodir: true }) ); }); return expandedFiles; }
[ "function", "expandFiles", "(", "files", ",", "basePath", ")", "{", "var", "expandedFiles", "=", "[", "]", ";", "files", "=", "files", "?", "_", ".", "isArray", "(", "files", ")", "?", "files", ":", "[", "files", "]", ":", "[", "]", ";", "_", ".", "forEach", "(", "files", ",", "function", "(", "fileName", ")", "{", "expandedFiles", "=", "_", ".", "union", "(", "expandedFiles", ",", "glob", ".", "sync", "(", "path", ".", "join", "(", "basePath", ",", "fileName", ")", ",", "{", "dot", ":", "true", ",", "nodir", ":", "true", "}", ")", ")", ";", "}", ")", ";", "return", "expandedFiles", ";", "}" ]
Prepend all given files with the provided basepath and expand all wildcards @param files the files to expand @param basePath the basepath from which the files should be expanded @returns {Array} list of expanded files
[ "Prepend", "all", "given", "files", "with", "the", "provided", "basepath", "and", "expand", "all", "wildcards" ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/utils/OptionUtils.js#L89-L101
train
jimivdw/grunt-mutation-testing
utils/OptionUtils.js
getOptions
function getOptions(grunt, task) { var globalOpts = grunt.config(task.name).options; var localOpts = grunt.config([task.name, task.target]).options; var opts = _.merge({}, DEFAULT_OPTIONS, globalOpts, localOpts); // Set logging options log4js.setGlobalLogLevel(log4js.levels[opts.logLevel]); log4js.configure(LOG_OPTIONS); opts.code = expandFiles(opts.code, opts.basePath); opts.specs = expandFiles(opts.specs, opts.basePath); opts.mutate = expandFiles(opts.mutate, opts.basePath); if (opts.karma) { opts.karma.notIncluded = expandFiles(opts.karma.notIncluded, opts.basePath); } var requiredOptionsSetErr = areRequiredOptionsSet(opts); if(requiredOptionsSetErr !== null) { grunt.warn('Not all required options have been set properly. ' + requiredOptionsSetErr); return null; } ensureReportersConfig(opts); ensureIgnoreConfig(opts); return opts; }
javascript
function getOptions(grunt, task) { var globalOpts = grunt.config(task.name).options; var localOpts = grunt.config([task.name, task.target]).options; var opts = _.merge({}, DEFAULT_OPTIONS, globalOpts, localOpts); // Set logging options log4js.setGlobalLogLevel(log4js.levels[opts.logLevel]); log4js.configure(LOG_OPTIONS); opts.code = expandFiles(opts.code, opts.basePath); opts.specs = expandFiles(opts.specs, opts.basePath); opts.mutate = expandFiles(opts.mutate, opts.basePath); if (opts.karma) { opts.karma.notIncluded = expandFiles(opts.karma.notIncluded, opts.basePath); } var requiredOptionsSetErr = areRequiredOptionsSet(opts); if(requiredOptionsSetErr !== null) { grunt.warn('Not all required options have been set properly. ' + requiredOptionsSetErr); return null; } ensureReportersConfig(opts); ensureIgnoreConfig(opts); return opts; }
[ "function", "getOptions", "(", "grunt", ",", "task", ")", "{", "var", "globalOpts", "=", "grunt", ".", "config", "(", "task", ".", "name", ")", ".", "options", ";", "var", "localOpts", "=", "grunt", ".", "config", "(", "[", "task", ".", "name", ",", "task", ".", "target", "]", ")", ".", "options", ";", "var", "opts", "=", "_", ".", "merge", "(", "{", "}", ",", "DEFAULT_OPTIONS", ",", "globalOpts", ",", "localOpts", ")", ";", "log4js", ".", "setGlobalLogLevel", "(", "log4js", ".", "levels", "[", "opts", ".", "logLevel", "]", ")", ";", "log4js", ".", "configure", "(", "LOG_OPTIONS", ")", ";", "opts", ".", "code", "=", "expandFiles", "(", "opts", ".", "code", ",", "opts", ".", "basePath", ")", ";", "opts", ".", "specs", "=", "expandFiles", "(", "opts", ".", "specs", ",", "opts", ".", "basePath", ")", ";", "opts", ".", "mutate", "=", "expandFiles", "(", "opts", ".", "mutate", ",", "opts", ".", "basePath", ")", ";", "if", "(", "opts", ".", "karma", ")", "{", "opts", ".", "karma", ".", "notIncluded", "=", "expandFiles", "(", "opts", ".", "karma", ".", "notIncluded", ",", "opts", ".", "basePath", ")", ";", "}", "var", "requiredOptionsSetErr", "=", "areRequiredOptionsSet", "(", "opts", ")", ";", "if", "(", "requiredOptionsSetErr", "!==", "null", ")", "{", "grunt", ".", "warn", "(", "'Not all required options have been set properly. '", "+", "requiredOptionsSetErr", ")", ";", "return", "null", ";", "}", "ensureReportersConfig", "(", "opts", ")", ";", "ensureIgnoreConfig", "(", "opts", ")", ";", "return", "opts", ";", "}" ]
Get the options for a given mutationTest grunt task @param grunt @param task the grunt task @returns {*} the found options, or [null] when not all required options have been set
[ "Get", "the", "options", "for", "a", "given", "mutationTest", "grunt", "task" ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/utils/OptionUtils.js#L109-L136
train
peecky/node-buffering
lib/buffering.js
Buffering
function Buffering(options) { events.EventEmitter.call(this); options = options || {}; if (options.useUnique) { var newOptions = {}; Object.keys(options).forEach(function(key) { if (key != 'useUnique') newOptions[key] = options[key]; }); return new UniqueBuffering(newOptions); } this._timeThreshold = (typeof options.timeThreshold === 'undefined') ? -1 : options.timeThreshold; this._sizeThreshold = (typeof options.sizeThreshold === 'undefined') ? -1 : options.sizeThreshold; this._data = []; this._flushTimer = null; this._paused = false; this._resumeTimer = null; this._flushingBySize = false; }
javascript
function Buffering(options) { events.EventEmitter.call(this); options = options || {}; if (options.useUnique) { var newOptions = {}; Object.keys(options).forEach(function(key) { if (key != 'useUnique') newOptions[key] = options[key]; }); return new UniqueBuffering(newOptions); } this._timeThreshold = (typeof options.timeThreshold === 'undefined') ? -1 : options.timeThreshold; this._sizeThreshold = (typeof options.sizeThreshold === 'undefined') ? -1 : options.sizeThreshold; this._data = []; this._flushTimer = null; this._paused = false; this._resumeTimer = null; this._flushingBySize = false; }
[ "function", "Buffering", "(", "options", ")", "{", "events", ".", "EventEmitter", ".", "call", "(", "this", ")", ";", "options", "=", "options", "||", "{", "}", ";", "if", "(", "options", ".", "useUnique", ")", "{", "var", "newOptions", "=", "{", "}", ";", "Object", ".", "keys", "(", "options", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "key", "!=", "'useUnique'", ")", "newOptions", "[", "key", "]", "=", "options", "[", "key", "]", ";", "}", ")", ";", "return", "new", "UniqueBuffering", "(", "newOptions", ")", ";", "}", "this", ".", "_timeThreshold", "=", "(", "typeof", "options", ".", "timeThreshold", "===", "'undefined'", ")", "?", "-", "1", ":", "options", ".", "timeThreshold", ";", "this", ".", "_sizeThreshold", "=", "(", "typeof", "options", ".", "sizeThreshold", "===", "'undefined'", ")", "?", "-", "1", ":", "options", ".", "sizeThreshold", ";", "this", ".", "_data", "=", "[", "]", ";", "this", ".", "_flushTimer", "=", "null", ";", "this", ".", "_paused", "=", "false", ";", "this", ".", "_resumeTimer", "=", "null", ";", "this", ".", "_flushingBySize", "=", "false", ";", "}" ]
ES 5+ will handle null and undefined
[ "ES", "5", "+", "will", "handle", "null", "and", "undefined" ]
c3ce84d796aeb319ecbeafce6833587dff9cb048
https://github.com/peecky/node-buffering/blob/c3ce84d796aeb319ecbeafce6833587dff9cb048/lib/buffering.js#L6-L26
train
eswdd/aardvark
static-content/HorizonRenderer.js
reducer
function reducer(individualSeries, initialFunction, reductionFunction) { if (individualSeries.length == 0) { return NaN; } var initial = initialFunction(individualSeries[0][1]); var i=1; for (; initial==null && i<individualSeries.length; i++) { initial = initialFunction(individualSeries[i][1]); } for (; i<individualSeries.length; i++) { if (individualSeries[i][1] != null) { initial = reductionFunction(initial, individualSeries[i][1]); } } return initial; }
javascript
function reducer(individualSeries, initialFunction, reductionFunction) { if (individualSeries.length == 0) { return NaN; } var initial = initialFunction(individualSeries[0][1]); var i=1; for (; initial==null && i<individualSeries.length; i++) { initial = initialFunction(individualSeries[i][1]); } for (; i<individualSeries.length; i++) { if (individualSeries[i][1] != null) { initial = reductionFunction(initial, individualSeries[i][1]); } } return initial; }
[ "function", "reducer", "(", "individualSeries", ",", "initialFunction", ",", "reductionFunction", ")", "{", "if", "(", "individualSeries", ".", "length", "==", "0", ")", "{", "return", "NaN", ";", "}", "var", "initial", "=", "initialFunction", "(", "individualSeries", "[", "0", "]", "[", "1", "]", ")", ";", "var", "i", "=", "1", ";", "for", "(", ";", "initial", "==", "null", "&&", "i", "<", "individualSeries", ".", "length", ";", "i", "++", ")", "{", "initial", "=", "initialFunction", "(", "individualSeries", "[", "i", "]", "[", "1", "]", ")", ";", "}", "for", "(", ";", "i", "<", "individualSeries", ".", "length", ";", "i", "++", ")", "{", "if", "(", "individualSeries", "[", "i", "]", "[", "1", "]", "!=", "null", ")", "{", "initial", "=", "reductionFunction", "(", "initial", ",", "individualSeries", "[", "i", "]", "[", "1", "]", ")", ";", "}", "}", "return", "initial", ";", "}" ]
do sorting before we parse
[ "do", "sorting", "before", "we", "parse" ]
7e0797fe5cde53047e610bd866d22e6caf0c6d49
https://github.com/eswdd/aardvark/blob/7e0797fe5cde53047e610bd866d22e6caf0c6d49/static-content/HorizonRenderer.js#L326-L341
train
jimivdw/grunt-mutation-testing
lib/reporting/html/IndexHtmlBuilder.js
function(baseDir, config) { this._baseDir = baseDir; this._config = _.merge({}, DEFAULT_CONFIG, config); this._folderPercentages = {}; }
javascript
function(baseDir, config) { this._baseDir = baseDir; this._config = _.merge({}, DEFAULT_CONFIG, config); this._folderPercentages = {}; }
[ "function", "(", "baseDir", ",", "config", ")", "{", "this", ".", "_baseDir", "=", "baseDir", ";", "this", ".", "_config", "=", "_", ".", "merge", "(", "{", "}", ",", "DEFAULT_CONFIG", ",", "config", ")", ";", "this", ".", "_folderPercentages", "=", "{", "}", ";", "}" ]
IndexHtmlBuilder constructor. @param {string} baseDir @param {object=} config @constructor
[ "IndexHtmlBuilder", "constructor", "." ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/lib/reporting/html/IndexHtmlBuilder.js#L28-L32
train
userapp-io/passport-userapp
examples/signup-login/app.js
createUser
function createUser(req, res, next){ // the HTML form names are conveniently named the same as // the UserApp fields... var user = req.body; // Create the user in UserApp UserApp.User.save(user, function(err, user){ // We can just pass through messages like "Password must be at least 5 characters." etc. if (err) return res.render('signup', {user: false, message: err.message}); // UserApp passport needs a username parameter req.body.username = req.body.login; //on to authentication next(); }); // authenticate the user using passport }
javascript
function createUser(req, res, next){ // the HTML form names are conveniently named the same as // the UserApp fields... var user = req.body; // Create the user in UserApp UserApp.User.save(user, function(err, user){ // We can just pass through messages like "Password must be at least 5 characters." etc. if (err) return res.render('signup', {user: false, message: err.message}); // UserApp passport needs a username parameter req.body.username = req.body.login; //on to authentication next(); }); // authenticate the user using passport }
[ "function", "createUser", "(", "req", ",", "res", ",", "next", ")", "{", "var", "user", "=", "req", ".", "body", ";", "UserApp", ".", "User", ".", "save", "(", "user", ",", "function", "(", "err", ",", "user", ")", "{", "if", "(", "err", ")", "return", "res", ".", "render", "(", "'signup'", ",", "{", "user", ":", "false", ",", "message", ":", "err", ".", "message", "}", ")", ";", "req", ".", "body", ".", "username", "=", "req", ".", "body", ".", "login", ";", "next", "(", ")", ";", "}", ")", ";", "}" ]
first we need to create the user in UserApp
[ "first", "we", "need", "to", "create", "the", "user", "in", "UserApp" ]
3f4b7a09ff19abf7f7620c04b37023b06b2f85d0
https://github.com/userapp-io/passport-userapp/blob/3f4b7a09ff19abf7f7620c04b37023b06b2f85d0/examples/signup-login/app.js#L92-L112
train
jhermsmeier/node-udif
lib/block.js
Block
function Block() { if( !(this instanceof Block) ) return new Block() /** @type {Number} Entry / compression type */ this.type = 0x00000000 /** @type {String} Entry type name */ this.description = 'UNKNOWN' /** @type {String} Comment ('+beg'|'+end' if type == COMMENT) */ this.comment = '' /** @type {Number} Start sector of this chunk */ this.sectorNumber = 0x0000000000000000 /** @type {Number} Number of sectors in this chunk */ this.sectorCount = 0x0000000000000000 /** @type {Number} Start of chunk in data fork */ this.compressedOffset = 0x0000000000000000 /** @type {Number} Chunk's bytelength in data fork */ this.compressedLength = 0x0000000000000000 }
javascript
function Block() { if( !(this instanceof Block) ) return new Block() /** @type {Number} Entry / compression type */ this.type = 0x00000000 /** @type {String} Entry type name */ this.description = 'UNKNOWN' /** @type {String} Comment ('+beg'|'+end' if type == COMMENT) */ this.comment = '' /** @type {Number} Start sector of this chunk */ this.sectorNumber = 0x0000000000000000 /** @type {Number} Number of sectors in this chunk */ this.sectorCount = 0x0000000000000000 /** @type {Number} Start of chunk in data fork */ this.compressedOffset = 0x0000000000000000 /** @type {Number} Chunk's bytelength in data fork */ this.compressedLength = 0x0000000000000000 }
[ "function", "Block", "(", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Block", ")", ")", "return", "new", "Block", "(", ")", "this", ".", "type", "=", "0x00000000", "this", ".", "description", "=", "'UNKNOWN'", "this", ".", "comment", "=", "''", "this", ".", "sectorNumber", "=", "0x0000000000000000", "this", ".", "sectorCount", "=", "0x0000000000000000", "this", ".", "compressedOffset", "=", "0x0000000000000000", "this", ".", "compressedLength", "=", "0x0000000000000000", "}" ]
Mish Blkx Block Descriptor @constructor @memberOf DMG.Mish @return {Block}
[ "Mish", "Blkx", "Block", "Descriptor" ]
1f5ee84d617e8ebafc8740aec0a734602a1e8b13
https://github.com/jhermsmeier/node-udif/blob/1f5ee84d617e8ebafc8740aec0a734602a1e8b13/lib/block.js#L10-L30
train
jhermsmeier/node-udif
lib/block.js
function( buffer, offset ) { offset = offset || 0 this.type = buffer.readUInt32BE( offset + 0 ) this.description = Block.getDescription( this.type ) this.comment = buffer.toString( 'ascii', offset + 4, offset + 8 ).replace( /\u0000/g, '' ) this.sectorNumber = uint64.readBE( buffer, offset + 8, 8 ) this.sectorCount = uint64.readBE( buffer, offset + 16, 8 ) this.compressedOffset = uint64.readBE( buffer, offset + 24, 8 ) this.compressedLength = uint64.readBE( buffer, offset + 32, 8 ) return this }
javascript
function( buffer, offset ) { offset = offset || 0 this.type = buffer.readUInt32BE( offset + 0 ) this.description = Block.getDescription( this.type ) this.comment = buffer.toString( 'ascii', offset + 4, offset + 8 ).replace( /\u0000/g, '' ) this.sectorNumber = uint64.readBE( buffer, offset + 8, 8 ) this.sectorCount = uint64.readBE( buffer, offset + 16, 8 ) this.compressedOffset = uint64.readBE( buffer, offset + 24, 8 ) this.compressedLength = uint64.readBE( buffer, offset + 32, 8 ) return this }
[ "function", "(", "buffer", ",", "offset", ")", "{", "offset", "=", "offset", "||", "0", "this", ".", "type", "=", "buffer", ".", "readUInt32BE", "(", "offset", "+", "0", ")", "this", ".", "description", "=", "Block", ".", "getDescription", "(", "this", ".", "type", ")", "this", ".", "comment", "=", "buffer", ".", "toString", "(", "'ascii'", ",", "offset", "+", "4", ",", "offset", "+", "8", ")", ".", "replace", "(", "/", "\\u0000", "/", "g", ",", "''", ")", "this", ".", "sectorNumber", "=", "uint64", ".", "readBE", "(", "buffer", ",", "offset", "+", "8", ",", "8", ")", "this", ".", "sectorCount", "=", "uint64", ".", "readBE", "(", "buffer", ",", "offset", "+", "16", ",", "8", ")", "this", ".", "compressedOffset", "=", "uint64", ".", "readBE", "(", "buffer", ",", "offset", "+", "24", ",", "8", ")", "this", ".", "compressedLength", "=", "uint64", ".", "readBE", "(", "buffer", ",", "offset", "+", "32", ",", "8", ")", "return", "this", "}" ]
Parse Mish Block data from a buffer @param {Buffer} buffer @param {Number} [offset=0] @returns {Block}
[ "Parse", "Mish", "Block", "data", "from", "a", "buffer" ]
1f5ee84d617e8ebafc8740aec0a734602a1e8b13
https://github.com/jhermsmeier/node-udif/blob/1f5ee84d617e8ebafc8740aec0a734602a1e8b13/lib/block.js#L76-L90
train
tumblr/tumblr-repl
index.js
print
function print(object) { console.log(util.inspect(object, null, null, true)); }
javascript
function print(object) { console.log(util.inspect(object, null, null, true)); }
[ "function", "print", "(", "object", ")", "{", "console", ".", "log", "(", "util", ".", "inspect", "(", "object", ",", "null", ",", "null", ",", "true", ")", ")", ";", "}" ]
Style output with ANSI color codes
[ "Style", "output", "with", "ANSI", "color", "codes" ]
9af1d83ff76aa318be921947ecdefe7d0ae90346
https://github.com/tumblr/tumblr-repl/blob/9af1d83ff76aa318be921947ecdefe7d0ae90346/index.js#L19-L21
train
chanon/re-require-module
index.js
callsites
function callsites() { var _ = Error.prepareStackTrace; Error.prepareStackTrace = function (_, stack) { return stack; }; var stack = new Error().stack.slice(1); Error.prepareStackTrace = _; return stack; }
javascript
function callsites() { var _ = Error.prepareStackTrace; Error.prepareStackTrace = function (_, stack) { return stack; }; var stack = new Error().stack.slice(1); Error.prepareStackTrace = _; return stack; }
[ "function", "callsites", "(", ")", "{", "var", "_", "=", "Error", ".", "prepareStackTrace", ";", "Error", ".", "prepareStackTrace", "=", "function", "(", "_", ",", "stack", ")", "{", "return", "stack", ";", "}", ";", "var", "stack", "=", "new", "Error", "(", ")", ".", "stack", ".", "slice", "(", "1", ")", ";", "Error", ".", "prepareStackTrace", "=", "_", ";", "return", "stack", ";", "}" ]
taken from callsites module
[ "taken", "from", "callsites", "module" ]
bd0d05df8bdd0efd3d49e26b91f71e09ec24b340
https://github.com/chanon/re-require-module/blob/bd0d05df8bdd0efd3d49e26b91f71e09ec24b340/index.js#L5-L13
train
chanon/re-require-module
index.js
existsCached
function existsCached(testPath) { if (existsCache[testPath] == 1) { return true; } if (existsCache[testPath] == 0) { return false; } if (exists(testPath)) { existsCache[testPath] = 1; return true; } else { existsCache[testPath] = 0; return false; } }
javascript
function existsCached(testPath) { if (existsCache[testPath] == 1) { return true; } if (existsCache[testPath] == 0) { return false; } if (exists(testPath)) { existsCache[testPath] = 1; return true; } else { existsCache[testPath] = 0; return false; } }
[ "function", "existsCached", "(", "testPath", ")", "{", "if", "(", "existsCache", "[", "testPath", "]", "==", "1", ")", "{", "return", "true", ";", "}", "if", "(", "existsCache", "[", "testPath", "]", "==", "0", ")", "{", "return", "false", ";", "}", "if", "(", "exists", "(", "testPath", ")", ")", "{", "existsCache", "[", "testPath", "]", "=", "1", ";", "return", "true", ";", "}", "else", "{", "existsCache", "[", "testPath", "]", "=", "0", ";", "return", "false", ";", "}", "}" ]
caches the 'exists' results so we don't hit the file system everytime in production
[ "caches", "the", "exists", "results", "so", "we", "don", "t", "hit", "the", "file", "system", "everytime", "in", "production" ]
bd0d05df8bdd0efd3d49e26b91f71e09ec24b340
https://github.com/chanon/re-require-module/blob/bd0d05df8bdd0efd3d49e26b91f71e09ec24b340/index.js#L28-L43
train
mikewesthad/pirate-speak
lib/pirate-speak.js
applyCase
function applyCase(wordA, wordB) { // Exception to avoid words like "I" being converted to "ME" if (wordA.length === 1 && wordB.length !== 1) return wordB; // Uppercase if (wordA === wordA.toUpperCase()) return wordB.toUpperCase(); // Lowercase if (wordA === wordA.toLowerCase()) return wordB.toLowerCase(); // Capitialized var firstChar = wordA.slice(0, 1); var otherChars = wordA.slice(1); if (firstChar === firstChar.toUpperCase() && otherChars === otherChars.toLowerCase()) { return wordB.slice(0, 1).toUpperCase() + wordB.slice(1).toLowerCase(); } // Other cases return wordB; }
javascript
function applyCase(wordA, wordB) { // Exception to avoid words like "I" being converted to "ME" if (wordA.length === 1 && wordB.length !== 1) return wordB; // Uppercase if (wordA === wordA.toUpperCase()) return wordB.toUpperCase(); // Lowercase if (wordA === wordA.toLowerCase()) return wordB.toLowerCase(); // Capitialized var firstChar = wordA.slice(0, 1); var otherChars = wordA.slice(1); if (firstChar === firstChar.toUpperCase() && otherChars === otherChars.toLowerCase()) { return wordB.slice(0, 1).toUpperCase() + wordB.slice(1).toLowerCase(); } // Other cases return wordB; }
[ "function", "applyCase", "(", "wordA", ",", "wordB", ")", "{", "if", "(", "wordA", ".", "length", "===", "1", "&&", "wordB", ".", "length", "!==", "1", ")", "return", "wordB", ";", "if", "(", "wordA", "===", "wordA", ".", "toUpperCase", "(", ")", ")", "return", "wordB", ".", "toUpperCase", "(", ")", ";", "if", "(", "wordA", "===", "wordA", ".", "toLowerCase", "(", ")", ")", "return", "wordB", ".", "toLowerCase", "(", ")", ";", "var", "firstChar", "=", "wordA", ".", "slice", "(", "0", ",", "1", ")", ";", "var", "otherChars", "=", "wordA", ".", "slice", "(", "1", ")", ";", "if", "(", "firstChar", "===", "firstChar", ".", "toUpperCase", "(", ")", "&&", "otherChars", "===", "otherChars", ".", "toLowerCase", "(", ")", ")", "{", "return", "wordB", ".", "slice", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "wordB", ".", "slice", "(", "1", ")", ".", "toLowerCase", "(", ")", ";", "}", "return", "wordB", ";", "}" ]
Take the case from wordA and apply it to wordB
[ "Take", "the", "case", "from", "wordA", "and", "apply", "it", "to", "wordB" ]
2b7c9ef4fb82877ed88d0ed2644ccb60b06415d6
https://github.com/mikewesthad/pirate-speak/blob/2b7c9ef4fb82877ed88d0ed2644ccb60b06415d6/lib/pirate-speak.js#L164-L179
train
gosaya-com/needjs
index.js
function(options){ EventEmitter.call(this); // Data Structures // Persistence this.data = {}; this.triggers = {}; this.queue = []; this.nextTick = false; // Dynamic this.needs = {}; this.events = {}; this.options = options || {}; }
javascript
function(options){ EventEmitter.call(this); // Data Structures // Persistence this.data = {}; this.triggers = {}; this.queue = []; this.nextTick = false; // Dynamic this.needs = {}; this.events = {}; this.options = options || {}; }
[ "function", "(", "options", ")", "{", "EventEmitter", ".", "call", "(", "this", ")", ";", "this", ".", "data", "=", "{", "}", ";", "this", ".", "triggers", "=", "{", "}", ";", "this", ".", "queue", "=", "[", "]", ";", "this", ".", "nextTick", "=", "false", ";", "this", ".", "needs", "=", "{", "}", ";", "this", ".", "events", "=", "{", "}", ";", "this", ".", "options", "=", "options", "||", "{", "}", ";", "}" ]
The core NeedJS system. This class handles all calls and manages the needs and requests. @module NeedJS @alias module:NeedJS
[ "The", "core", "NeedJS", "system", ".", "This", "class", "handles", "all", "calls", "and", "manages", "the", "needs", "and", "requests", "." ]
d45f1f91127710becac512f4309de8fca5a0bef9
https://github.com/gosaya-com/needjs/blob/d45f1f91127710becac512f4309de8fca5a0bef9/index.js#L12-L26
train