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
arendjr/laces.js
demo-hogan-local-js/hogan.js
function(symbol, ctx, partials, indent) { var partial = this.ep(symbol, partials); if (!partial) { return ''; } return partial.ri(ctx, partials, indent); }
javascript
function(symbol, ctx, partials, indent) { var partial = this.ep(symbol, partials); if (!partial) { return ''; } return partial.ri(ctx, partials, indent); }
[ "function", "(", "symbol", ",", "ctx", ",", "partials", ",", "indent", ")", "{", "var", "partial", "=", "this", ".", "ep", "(", "symbol", ",", "partials", ")", ";", "if", "(", "!", "partial", ")", "{", "return", "''", ";", "}", "return", "partial",...
tries to find a partial in the current scope and render it
[ "tries", "to", "find", "a", "partial", "in", "the", "current", "scope", "and", "render", "it" ]
e04fd060a4668abe58064267b1405e6a40f8a6f2
https://github.com/arendjr/laces.js/blob/e04fd060a4668abe58064267b1405e6a40f8a6f2/demo-hogan-local-js/hogan.js#L88-L95
train
arendjr/laces.js
demo-hogan-local-js/hogan.js
function(func, ctx, partials) { var cx = ctx[ctx.length - 1]; return func.call(cx); }
javascript
function(func, ctx, partials) { var cx = ctx[ctx.length - 1]; return func.call(cx); }
[ "function", "(", "func", ",", "ctx", ",", "partials", ")", "{", "var", "cx", "=", "ctx", "[", "ctx", ".", "length", "-", "1", "]", ";", "return", "func", ".", "call", "(", "cx", ")", ";", "}" ]
method replace section
[ "method", "replace", "section" ]
e04fd060a4668abe58064267b1405e6a40f8a6f2
https://github.com/arendjr/laces.js/blob/e04fd060a4668abe58064267b1405e6a40f8a6f2/demo-hogan-local-js/hogan.js#L226-L229
train
arendjr/laces.js
demo-hogan-local-js/hogan.js
findInScope
function findInScope(key, scope, doModelGet) { var val, checkVal; if (scope && typeof scope == 'object') { if (scope[key] != null) { val = scope[key]; // try lookup with get for backbone or similar model data } else if (doModelGet && scope.get && typeof scope.get == 'function') { ...
javascript
function findInScope(key, scope, doModelGet) { var val, checkVal; if (scope && typeof scope == 'object') { if (scope[key] != null) { val = scope[key]; // try lookup with get for backbone or similar model data } else if (doModelGet && scope.get && typeof scope.get == 'function') { ...
[ "function", "findInScope", "(", "key", ",", "scope", ",", "doModelGet", ")", "{", "var", "val", ",", "checkVal", ";", "if", "(", "scope", "&&", "typeof", "scope", "==", "'object'", ")", "{", "if", "(", "scope", "[", "key", "]", "!=", "null", ")", "...
Find a key in an object
[ "Find", "a", "key", "in", "an", "object" ]
e04fd060a4668abe58064267b1405e6a40f8a6f2
https://github.com/arendjr/laces.js/blob/e04fd060a4668abe58064267b1405e6a40f8a6f2/demo-hogan-local-js/hogan.js#L249-L264
train
KTH/kth-node-mongo
index.js
_mergeOptions
function _mergeOptions () { var options = {} for (var i = 0; i < arguments.length; ++i) { let obj = arguments[i] for (var attr in obj) { options[attr] = obj[attr] } } return options }
javascript
function _mergeOptions () { var options = {} for (var i = 0; i < arguments.length; ++i) { let obj = arguments[i] for (var attr in obj) { options[attr] = obj[attr] } } return options }
[ "function", "_mergeOptions", "(", ")", "{", "var", "options", "=", "{", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "arguments", ".", "length", ";", "++", "i", ")", "{", "let", "obj", "=", "arguments", "[", "i", "]", "for", "(", "var"...
merge all options objects front to back, i.e. later overriding earlier objects
[ "merge", "all", "options", "objects", "front", "to", "back", "i", ".", "e", ".", "later", "overriding", "earlier", "objects" ]
03810f92dc504cfe0740c3083ce01dac00ba5aa1
https://github.com/KTH/kth-node-mongo/blob/03810f92dc504cfe0740c3083ce01dac00ba5aa1/index.js#L88-L95
train
AriaMinaei/mocha-pretty-spec-reporter
lib/base.js
Base
function Base(runner) { var self = this , stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 } , failures = this.failures = []; if (!runner) return; this.runner = runner; runner.stats = stats; runner.on('start', function(){ stats.start = new Date; }); runner.on(...
javascript
function Base(runner) { var self = this , stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 } , failures = this.failures = []; if (!runner) return; this.runner = runner; runner.stats = stats; runner.on('start', function(){ stats.start = new Date; }); runner.on(...
[ "function", "Base", "(", "runner", ")", "{", "var", "self", "=", "this", ",", "stats", "=", "this", ".", "stats", "=", "{", "suites", ":", "0", ",", "tests", ":", "0", ",", "passes", ":", "0", ",", "pending", ":", "0", ",", "failures", ":", "0"...
Initialize a new `Base` reporter. All other reporters generally inherit from this reporter, providing stats such as test duration, number of tests passed / failed etc. @param {Runner} runner @api public
[ "Initialize", "a", "new", "Base", "reporter", "." ]
3799a77d6bac1852f4c79912b552e23e3ffb3699
https://github.com/AriaMinaei/mocha-pretty-spec-reporter/blob/3799a77d6bac1852f4c79912b552e23e3ffb3699/lib/base.js#L242-L294
train
AriaMinaei/mocha-pretty-spec-reporter
lib/base.js
inlineDiff
function inlineDiff(err, escape) { var msg = errorDiff(err, 'WordsWithSpace', escape); // linenos var lines = msg.split('\n'); if (lines.length > 4) { var width = String(lines.length).length; msg = lines.map(function(str, i){ return pad(++i, width) + ' |' + ' ' + str; }).join('\n'); } //...
javascript
function inlineDiff(err, escape) { var msg = errorDiff(err, 'WordsWithSpace', escape); // linenos var lines = msg.split('\n'); if (lines.length > 4) { var width = String(lines.length).length; msg = lines.map(function(str, i){ return pad(++i, width) + ' |' + ' ' + str; }).join('\n'); } //...
[ "function", "inlineDiff", "(", "err", ",", "escape", ")", "{", "var", "msg", "=", "errorDiff", "(", "err", ",", "'WordsWithSpace'", ",", "escape", ")", ";", "// linenos", "var", "lines", "=", "msg", ".", "split", "(", "'\\n'", ")", ";", "if", "(", "l...
Returns an inline diff between 2 strings with coloured ANSI output @param {Error} Error with actual/expected @return {String} Diff @api private
[ "Returns", "an", "inline", "diff", "between", "2", "strings", "with", "coloured", "ANSI", "output" ]
3799a77d6bac1852f4c79912b552e23e3ffb3699
https://github.com/AriaMinaei/mocha-pretty-spec-reporter/blob/3799a77d6bac1852f4c79912b552e23e3ffb3699/lib/base.js#L364-L388
train
AriaMinaei/mocha-pretty-spec-reporter
lib/base.js
unifiedDiff
function unifiedDiff(err, escape) { var indent = ' '; function cleanUp(line) { if (escape) { line = escapeInvisibles(line); } if (line[0] === '+') return indent + colorLines('diff added', line); if (line[0] === '-') return indent + colorLines('diff removed', line); if (line.match(/\@\...
javascript
function unifiedDiff(err, escape) { var indent = ' '; function cleanUp(line) { if (escape) { line = escapeInvisibles(line); } if (line[0] === '+') return indent + colorLines('diff added', line); if (line[0] === '-') return indent + colorLines('diff removed', line); if (line.match(/\@\...
[ "function", "unifiedDiff", "(", "err", ",", "escape", ")", "{", "var", "indent", "=", "' '", ";", "function", "cleanUp", "(", "line", ")", "{", "if", "(", "escape", ")", "{", "line", "=", "escapeInvisibles", "(", "line", ")", ";", "}", "if", "("...
Returns a unified diff between 2 strings @param {Error} Error with actual/expected @return {String} Diff @api private
[ "Returns", "a", "unified", "diff", "between", "2", "strings" ]
3799a77d6bac1852f4c79912b552e23e3ffb3699
https://github.com/AriaMinaei/mocha-pretty-spec-reporter/blob/3799a77d6bac1852f4c79912b552e23e3ffb3699/lib/base.js#L398-L420
train
AriaMinaei/mocha-pretty-spec-reporter
lib/base.js
stringify
function stringify(obj) { if (obj instanceof RegExp) return obj.toString(); return JSON.stringify(obj, null, 2); }
javascript
function stringify(obj) { if (obj instanceof RegExp) return obj.toString(); return JSON.stringify(obj, null, 2); }
[ "function", "stringify", "(", "obj", ")", "{", "if", "(", "obj", "instanceof", "RegExp", ")", "return", "obj", ".", "toString", "(", ")", ";", "return", "JSON", ".", "stringify", "(", "obj", ",", "null", ",", "2", ")", ";", "}" ]
Stringify `obj`. @param {Object} obj @return {String} @api private
[ "Stringify", "obj", "." ]
3799a77d6bac1852f4c79912b552e23e3ffb3699
https://github.com/AriaMinaei/mocha-pretty-spec-reporter/blob/3799a77d6bac1852f4c79912b552e23e3ffb3699/lib/base.js#L476-L479
train
AriaMinaei/mocha-pretty-spec-reporter
lib/base.js
canonicalize
function canonicalize(obj, stack) { stack = stack || []; if (utils.indexOf(stack, obj) !== -1) return obj; var canonicalizedObj; if ('[object Array]' == {}.toString.call(obj)) { stack.push(obj); canonicalizedObj = utils.map(obj, function(item) { return canonicalize(item, stack); });...
javascript
function canonicalize(obj, stack) { stack = stack || []; if (utils.indexOf(stack, obj) !== -1) return obj; var canonicalizedObj; if ('[object Array]' == {}.toString.call(obj)) { stack.push(obj); canonicalizedObj = utils.map(obj, function(item) { return canonicalize(item, stack); });...
[ "function", "canonicalize", "(", "obj", ",", "stack", ")", "{", "stack", "=", "stack", "||", "[", "]", ";", "if", "(", "utils", ".", "indexOf", "(", "stack", ",", "obj", ")", "!==", "-", "1", ")", "return", "obj", ";", "var", "canonicalizedObj", ";...
Return a new object that has the keys in sorted order. @param {Object} obj @return {Object} @api private
[ "Return", "a", "new", "object", "that", "has", "the", "keys", "in", "sorted", "order", "." ]
3799a77d6bac1852f4c79912b552e23e3ffb3699
https://github.com/AriaMinaei/mocha-pretty-spec-reporter/blob/3799a77d6bac1852f4c79912b552e23e3ffb3699/lib/base.js#L488-L513
train
jridgewell/PJs
promise.js
RejectedPromise
function RejectedPromise(reason, unused, onRejected, deferred) { if (!onRejected) { deferredAdopt(deferred, RejectedPromise, reason); return this; } if (!deferred) { deferred = new Deferred(this.constructor); } defer(tryCatchDeferred(deferred, onRejected, reason)); return deferred.promise; }
javascript
function RejectedPromise(reason, unused, onRejected, deferred) { if (!onRejected) { deferredAdopt(deferred, RejectedPromise, reason); return this; } if (!deferred) { deferred = new Deferred(this.constructor); } defer(tryCatchDeferred(deferred, onRejected, reason)); return deferred.promise; }
[ "function", "RejectedPromise", "(", "reason", ",", "unused", ",", "onRejected", ",", "deferred", ")", "{", "if", "(", "!", "onRejected", ")", "{", "deferredAdopt", "(", "deferred", ",", "RejectedPromise", ",", "reason", ")", ";", "return", "this", ";", "}"...
The Rejected Promise state. Calls onRejected with the resolved value of this promise, creating a new promise. If there is no onRejected, returns the current promise to avoid an promise instance. @this {!Promise} The current promise @param {*=} reason The current promise's rejection reason. @param {function(*=)=} unus...
[ "The", "Rejected", "Promise", "state", ".", "Calls", "onRejected", "with", "the", "resolved", "value", "of", "this", "promise", "creating", "a", "new", "promise", "." ]
2dc2185f174e3b79daa1d66638056d9f5e1f7792
https://github.com/jridgewell/PJs/blob/2dc2185f174e3b79daa1d66638056d9f5e1f7792/promise.js#L236-L246
train
jridgewell/PJs
promise.js
PendingPromise
function PendingPromise(queue, onFulfilled, onRejected, deferred) { if (!deferred) { if (!onFulfilled && !onRejected) { return this; } deferred = new Deferred(this.constructor); } queue.push({ deferred: deferred, onFulfilled: onFulfilled || deferred.resolve, onRejected: onRejected || deferred....
javascript
function PendingPromise(queue, onFulfilled, onRejected, deferred) { if (!deferred) { if (!onFulfilled && !onRejected) { return this; } deferred = new Deferred(this.constructor); } queue.push({ deferred: deferred, onFulfilled: onFulfilled || deferred.resolve, onRejected: onRejected || deferred....
[ "function", "PendingPromise", "(", "queue", ",", "onFulfilled", ",", "onRejected", ",", "deferred", ")", "{", "if", "(", "!", "deferred", ")", "{", "if", "(", "!", "onFulfilled", "&&", "!", "onRejected", ")", "{", "return", "this", ";", "}", "deferred", ...
The Pending Promise state. Eventually calls onFulfilled once the promise has resolved, or onRejected once the promise rejects. If there is no onFulfilled and no onRejected, returns the current promise to avoid an promise instance. @this {!Promise} The current promise @param {*=} queue The current promise's pending pr...
[ "The", "Pending", "Promise", "state", ".", "Eventually", "calls", "onFulfilled", "once", "the", "promise", "has", "resolved", "or", "onRejected", "once", "the", "promise", "rejects", "." ]
2dc2185f174e3b79daa1d66638056d9f5e1f7792
https://github.com/jridgewell/PJs/blob/2dc2185f174e3b79daa1d66638056d9f5e1f7792/promise.js#L266-L277
train
jridgewell/PJs
promise.js
adopt
function adopt(promise, state, value, adoptee) { var queue = promise._value; promise._state = state; promise._value = value; if (adoptee && state === PendingPromise) { adoptee._state(value, void 0, void 0, { promise: promise, resolve: void 0, reject: void 0 }); } for (var i = 0; ...
javascript
function adopt(promise, state, value, adoptee) { var queue = promise._value; promise._state = state; promise._value = value; if (adoptee && state === PendingPromise) { adoptee._state(value, void 0, void 0, { promise: promise, resolve: void 0, reject: void 0 }); } for (var i = 0; ...
[ "function", "adopt", "(", "promise", ",", "state", ",", "value", ",", "adoptee", ")", "{", "var", "queue", "=", "promise", ".", "_value", ";", "promise", ".", "_state", "=", "state", ";", "promise", ".", "_value", "=", "value", ";", "if", "(", "adopt...
Transitions the state of promise to another state. This is only ever called on with a promise that is currently in the Pending state. @param {!Promise} promise @param {function(this:Promise,*=,function(*=),function(*=),Deferred):!Promise} state @param {*=} value
[ "Transitions", "the", "state", "of", "promise", "to", "another", "state", ".", "This", "is", "only", "ever", "called", "on", "with", "a", "promise", "that", "is", "currently", "in", "the", "Pending", "state", "." ]
2dc2185f174e3b79daa1d66638056d9f5e1f7792
https://github.com/jridgewell/PJs/blob/2dc2185f174e3b79daa1d66638056d9f5e1f7792/promise.js#L306-L338
train
jridgewell/PJs
promise.js
deferredAdopt
function deferredAdopt(deferred, state, value) { if (deferred) { var promise = deferred.promise; promise._state = state; promise._value = value; } }
javascript
function deferredAdopt(deferred, state, value) { if (deferred) { var promise = deferred.promise; promise._state = state; promise._value = value; } }
[ "function", "deferredAdopt", "(", "deferred", ",", "state", ",", "value", ")", "{", "if", "(", "deferred", ")", "{", "var", "promise", "=", "deferred", ".", "promise", ";", "promise", ".", "_state", "=", "state", ";", "promise", ".", "_value", "=", "va...
Updates a deferred promises state. Necessary for updating an adopting promise's state when the adoptee resolves. @param {?Deferred} deferred @param {function(this:Promise,*=,function(*=),function(*=),Deferred):!Promise} state @param {*=} value
[ "Updates", "a", "deferred", "promises", "state", ".", "Necessary", "for", "updating", "an", "adopting", "promise", "s", "state", "when", "the", "adoptee", "resolves", "." ]
2dc2185f174e3b79daa1d66638056d9f5e1f7792
https://github.com/jridgewell/PJs/blob/2dc2185f174e3b79daa1d66638056d9f5e1f7792/promise.js#L361-L367
train
jridgewell/PJs
promise.js
each
function each(collection, iterator) { for (var i = 0; i < collection.length; i++) { iterator(collection[i], i); } }
javascript
function each(collection, iterator) { for (var i = 0; i < collection.length; i++) { iterator(collection[i], i); } }
[ "function", "each", "(", "collection", ",", "iterator", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "collection", ".", "length", ";", "i", "++", ")", "{", "iterator", "(", "collection", "[", "i", "]", ",", "i", ")", ";", "}", "}"...
Iterates over each element of an array, calling the iterator with the element and its index. @param {!Array} collection @param {function(*=,number)} iterator
[ "Iterates", "over", "each", "element", "of", "an", "array", "calling", "the", "iterator", "with", "the", "element", "and", "its", "index", "." ]
2dc2185f174e3b79daa1d66638056d9f5e1f7792
https://github.com/jridgewell/PJs/blob/2dc2185f174e3b79daa1d66638056d9f5e1f7792/promise.js#L401-L405
train
jridgewell/PJs
promise.js
tryCatchDeferred
function tryCatchDeferred(deferred, fn, arg) { var promise = deferred.promise; var resolve = deferred.resolve; var reject = deferred.reject; return function() { try { var result = fn(arg); doResolve(promise, resolve, reject, result, result); } catch (e) { reject(e); } }; }
javascript
function tryCatchDeferred(deferred, fn, arg) { var promise = deferred.promise; var resolve = deferred.resolve; var reject = deferred.reject; return function() { try { var result = fn(arg); doResolve(promise, resolve, reject, result, result); } catch (e) { reject(e); } }; }
[ "function", "tryCatchDeferred", "(", "deferred", ",", "fn", ",", "arg", ")", "{", "var", "promise", "=", "deferred", ".", "promise", ";", "var", "resolve", "=", "deferred", ".", "resolve", ";", "var", "reject", "=", "deferred", ".", "reject", ";", "retur...
Creates a function that will attempt to resolve the deferred with the return of fn. If any error is raised, rejects instead. @param {!Deferred} deferred @param {function(*=)} fn @param {*} arg @returns {function()}
[ "Creates", "a", "function", "that", "will", "attempt", "to", "resolve", "the", "deferred", "with", "the", "return", "of", "fn", ".", "If", "any", "error", "is", "raised", "rejects", "instead", "." ]
2dc2185f174e3b79daa1d66638056d9f5e1f7792
https://github.com/jridgewell/PJs/blob/2dc2185f174e3b79daa1d66638056d9f5e1f7792/promise.js#L416-L428
train
avoidwork/mpass
src/password.js
password
function password (n, special) { n = n || 3; special = special === true; var result = "", i = -1, used = {}, hasSub = false, hasExtra = false, flip, lth, pos, rnd, word; function sub (x, idx) { if (!hasSub && word.indexOf(x) > -1) { word = word.replace(x, subs[idx]); hasSub = true; flip = fals...
javascript
function password (n, special) { n = n || 3; special = special === true; var result = "", i = -1, used = {}, hasSub = false, hasExtra = false, flip, lth, pos, rnd, word; function sub (x, idx) { if (!hasSub && word.indexOf(x) > -1) { word = word.replace(x, subs[idx]); hasSub = true; flip = fals...
[ "function", "password", "(", "n", ",", "special", ")", "{", "n", "=", "n", "||", "3", ";", "special", "=", "special", "===", "true", ";", "var", "result", "=", "\"\"", ",", "i", "=", "-", "1", ",", "used", "=", "{", "}", ",", "hasSub", "=", "...
Mnemonic password generator @method password @param {Number} n Number of words to use (3) @param {Boolean} special Use special characters (false) @return {String} Password
[ "Mnemonic", "password", "generator" ]
3881af71808c1eba55a9f0525c919f0491e949cb
https://github.com/avoidwork/mpass/blob/3881af71808c1eba55a9f0525c919f0491e949cb/src/password.js#L9-L80
train
yoshuawuyts/size-stream
index.js
CountStream
function CountStream (opts) { if (!(this instanceof CountStream)) return new CountStream(opts) stream.PassThrough.call(this, opts) this.destroyed = false this.size = 0 }
javascript
function CountStream (opts) { if (!(this instanceof CountStream)) return new CountStream(opts) stream.PassThrough.call(this, opts) this.destroyed = false this.size = 0 }
[ "function", "CountStream", "(", "opts", ")", "{", "if", "(", "!", "(", "this", "instanceof", "CountStream", ")", ")", "return", "new", "CountStream", "(", "opts", ")", "stream", ".", "PassThrough", ".", "call", "(", "this", ",", "opts", ")", "this", "....
create a new count stream obj? -> tstream
[ "create", "a", "new", "count", "stream", "obj?", "-", ">", "tstream" ]
ecd21e639e73e404c789201bd6dde4250fc7938a
https://github.com/yoshuawuyts/size-stream/blob/ecd21e639e73e404c789201bd6dde4250fc7938a/index.js#L8-L14
train
defunctzombie/node-superstack
index.js
function(stack) { if (exports.async_trace_limit <= 0) { return; } var count = exports.async_trace_limit - 1; var previous = stack; while (previous && count > 1) { previous = previous.__previous__; --count; } if (previous) { delete previous.__previous__; ...
javascript
function(stack) { if (exports.async_trace_limit <= 0) { return; } var count = exports.async_trace_limit - 1; var previous = stack; while (previous && count > 1) { previous = previous.__previous__; --count; } if (previous) { delete previous.__previous__; ...
[ "function", "(", "stack", ")", "{", "if", "(", "exports", ".", "async_trace_limit", "<=", "0", ")", "{", "return", ";", "}", "var", "count", "=", "exports", ".", "async_trace_limit", "-", "1", ";", "var", "previous", "=", "stack", ";", "while", "(", ...
truncate frames to async_trace_limit
[ "truncate", "frames", "to", "async_trace_limit" ]
9ae6996a10b2e97ac2327a3e1e484839689c11ec
https://github.com/defunctzombie/node-superstack/blob/9ae6996a10b2e97ac2327a3e1e484839689c11ec/index.js#L70-L86
train
defunctzombie/node-superstack
index.js
function(callback) { // capture current error location var trace_error = new Error(); trace_error.id = ERROR_ID++; trace_error.__previous__ = current_trace_error; trace_error.__trace_count__ = current_trace_error ? current_trace_error.__trace_count__ + 1 : 1; limit_frames(trace_error); var n...
javascript
function(callback) { // capture current error location var trace_error = new Error(); trace_error.id = ERROR_ID++; trace_error.__previous__ = current_trace_error; trace_error.__trace_count__ = current_trace_error ? current_trace_error.__trace_count__ + 1 : 1; limit_frames(trace_error); var n...
[ "function", "(", "callback", ")", "{", "// capture current error location", "var", "trace_error", "=", "new", "Error", "(", ")", ";", "trace_error", ".", "id", "=", "ERROR_ID", "++", ";", "trace_error", ".", "__previous__", "=", "current_trace_error", ";", "trac...
wrap a callback to capture any error or throw and thus the stacktrace
[ "wrap", "a", "callback", "to", "capture", "any", "error", "or", "throw", "and", "thus", "the", "stacktrace" ]
9ae6996a10b2e97ac2327a3e1e484839689c11ec
https://github.com/defunctzombie/node-superstack/blob/9ae6996a10b2e97ac2327a3e1e484839689c11ec/index.js#L89-L105
train
francois2metz/node-intervals
bin/cli.js
addTime
function addTime(options, client) { return function(next, project) { var dates = options.dates; delete options.dates; var join = futures.join(); join.add(dates.map(function(date) { var promise = futures.future(); // we must clone to prevent options.date overri...
javascript
function addTime(options, client) { return function(next, project) { var dates = options.dates; delete options.dates; var join = futures.join(); join.add(dates.map(function(date) { var promise = futures.future(); // we must clone to prevent options.date overri...
[ "function", "addTime", "(", "options", ",", "client", ")", "{", "return", "function", "(", "next", ",", "project", ")", "{", "var", "dates", "=", "options", ".", "dates", ";", "delete", "options", ".", "dates", ";", "var", "join", "=", "futures", ".", ...
Add time for each dates specified
[ "Add", "time", "for", "each", "dates", "specified" ]
0633747156f02938ce4d8063e1fed8a33beab365
https://github.com/francois2metz/node-intervals/blob/0633747156f02938ce4d8063e1fed8a33beab365/bin/cli.js#L16-L42
train
francois2metz/node-intervals
bin/cli.js
askForSave
function askForSave(conf) { return function(next, project) { process.stdout.write('Do you yant to save this project combinaison: (y/N)'); utils.readInput(function(input) { if (input == 'y') { process.stdout.write('Name of this combinaison: '); utils.readIn...
javascript
function askForSave(conf) { return function(next, project) { process.stdout.write('Do you yant to save this project combinaison: (y/N)'); utils.readInput(function(input) { if (input == 'y') { process.stdout.write('Name of this combinaison: '); utils.readIn...
[ "function", "askForSave", "(", "conf", ")", "{", "return", "function", "(", "next", ",", "project", ")", "{", "process", ".", "stdout", ".", "write", "(", "'Do you yant to save this project combinaison: (y/N)'", ")", ";", "utils", ".", "readInput", "(", "functio...
Ask user to save the project
[ "Ask", "user", "to", "save", "the", "project" ]
0633747156f02938ce4d8063e1fed8a33beab365
https://github.com/francois2metz/node-intervals/blob/0633747156f02938ce4d8063e1fed8a33beab365/bin/cli.js#L68-L89
train
francois2metz/node-intervals
bin/cli.js
optionsFrom
function optionsFrom(argv) { var date = argv.date, dates = utils.parseDate(date), options = { time: argv.hours, dates: dates, billable: argv.billable || argv.b, description: argv.description }; return options; }
javascript
function optionsFrom(argv) { var date = argv.date, dates = utils.parseDate(date), options = { time: argv.hours, dates: dates, billable: argv.billable || argv.b, description: argv.description }; return options; }
[ "function", "optionsFrom", "(", "argv", ")", "{", "var", "date", "=", "argv", ".", "date", ",", "dates", "=", "utils", ".", "parseDate", "(", "date", ")", ",", "options", "=", "{", "time", ":", "argv", ".", "hours", ",", "dates", ":", "dates", ",",...
Extract options from argv
[ "Extract", "options", "from", "argv" ]
0633747156f02938ce4d8063e1fed8a33beab365
https://github.com/francois2metz/node-intervals/blob/0633747156f02938ce4d8063e1fed8a33beab365/bin/cli.js#L94-L102
train
singulargarden/firebase-scheduler
functions/index.js
reqURL
function reqURL(req, newPath) { return url.format({ protocol: 'https', //req.protocol, // by default this returns http which gets redirected host: req.get('host'), pathname: newPath }) }
javascript
function reqURL(req, newPath) { return url.format({ protocol: 'https', //req.protocol, // by default this returns http which gets redirected host: req.get('host'), pathname: newPath }) }
[ "function", "reqURL", "(", "req", ",", "newPath", ")", "{", "return", "url", ".", "format", "(", "{", "protocol", ":", "'https'", ",", "//req.protocol, // by default this returns http which gets redirected", "host", ":", "req", ".", "get", "(", "'host'", ")", ",...
Retrieve the URL for another endpoint running on the same server, on https. @param req The express/firebase function request object @param newPath The endpoint @returns {string} The URL
[ "Retrieve", "the", "URL", "for", "another", "endpoint", "running", "on", "the", "same", "server", "on", "https", "." ]
0b6e46b5987cac16289a747c4bca5bd748397ee8
https://github.com/singulargarden/firebase-scheduler/blob/0b6e46b5987cac16289a747c4bca5bd748397ee8/functions/index.js#L27-L33
train
rmdort/react-kitt
src/components/Tooltip/index.js
ToolTip
function ToolTip({ className, children, label, position, type }) { const classes = cx( tooltipClassName, `${tooltipClassName}--${position}`, `${tooltipClassName}--${type}`, className ) return ( <button role="tooltip" type="button" className={classes} aria-label={label}> {children} </...
javascript
function ToolTip({ className, children, label, position, type }) { const classes = cx( tooltipClassName, `${tooltipClassName}--${position}`, `${tooltipClassName}--${type}`, className ) return ( <button role="tooltip" type="button" className={classes} aria-label={label}> {children} </...
[ "function", "ToolTip", "(", "{", "className", ",", "children", ",", "label", ",", "position", ",", "type", "}", ")", "{", "const", "classes", "=", "cx", "(", "tooltipClassName", ",", "`", "${", "tooltipClassName", "}", "${", "position", "}", "`", ",", ...
Render tooltips using `hint.css` https://github.com/chinchang/hint.css/
[ "Render", "tooltips", "using", "hint", ".", "css" ]
a3dc0ef1451a84b8f7bed1f86dd0f3db26e8ff31
https://github.com/rmdort/react-kitt/blob/a3dc0ef1451a84b8f7bed1f86dd0f3db26e8ff31/src/components/Tooltip/index.js#L12-L24
train
aaronabramov/esfmt
package/block.js
format
function format(node, context, recur) { var blockComments = context.blockComments(node); for (var i = 0; i < node.body.length; i++) { var previous = node.body[i - 1]; var current = node.body[i]; var next = node.body[i + 1]; if (current.type === 'EmptyStatement') { c...
javascript
function format(node, context, recur) { var blockComments = context.blockComments(node); for (var i = 0; i < node.body.length; i++) { var previous = node.body[i - 1]; var current = node.body[i]; var next = node.body[i + 1]; if (current.type === 'EmptyStatement') { c...
[ "function", "format", "(", "node", ",", "context", ",", "recur", ")", "{", "var", "blockComments", "=", "context", ".", "blockComments", "(", "node", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "node", ".", "body", ".", "length", ";"...
Shared block formatting function @param {Object} node Program or BlockStatement @param {Object} context @param {Function} recur
[ "Shared", "block", "formatting", "function" ]
8e05fa01d777d504f965ba484c287139a00b5b00
https://github.com/aaronabramov/esfmt/blob/8e05fa01d777d504f965ba484c287139a00b5b00/package/block.js#L11-L34
train
kuno/neco
deps/npm/lib/view.js
showFields
function showFields (data, version, fields) { var o = {} ;[data,version].forEach(function (s) { Object.keys(s).forEach(function (k) { o[k] = s[k] }) }) return search(o, fields.split("."), version._id, fields) }
javascript
function showFields (data, version, fields) { var o = {} ;[data,version].forEach(function (s) { Object.keys(s).forEach(function (k) { o[k] = s[k] }) }) return search(o, fields.split("."), version._id, fields) }
[ "function", "showFields", "(", "data", ",", "version", ",", "fields", ")", "{", "var", "o", "=", "{", "}", ";", "[", "data", ",", "version", "]", ".", "forEach", "(", "function", "(", "s", ")", "{", "Object", ".", "keys", "(", "s", ")", ".", "f...
return whatever was printed
[ "return", "whatever", "was", "printed" ]
cf6361c1fcb9466c6b2ab3b127b5d0160ca50735
https://github.com/kuno/neco/blob/cf6361c1fcb9466c6b2ab3b127b5d0160ca50735/deps/npm/lib/view.js#L85-L93
train
MartinKolarik/ractive-render
lib/utils.js
findPartials
function findPartials(fragment) { var found = []; walkRecursive(fragment.t, function(item) { if (item.t === 8) { found.push(item.r); } }); return _.uniq(found); }
javascript
function findPartials(fragment) { var found = []; walkRecursive(fragment.t, function(item) { if (item.t === 8) { found.push(item.r); } }); return _.uniq(found); }
[ "function", "findPartials", "(", "fragment", ")", "{", "var", "found", "=", "[", "]", ";", "walkRecursive", "(", "fragment", ".", "t", ",", "function", "(", "item", ")", "{", "if", "(", "item", ".", "t", "===", "8", ")", "{", "found", ".", "push", ...
Return a list of all partials used in the given template @param {Array|Object} fragment @returns {Array|Object} @private
[ "Return", "a", "list", "of", "all", "partials", "used", "in", "the", "given", "template" ]
417a97c42de4b1ea6c1ab13803f5470b3cc6f75a
https://github.com/MartinKolarik/ractive-render/blob/417a97c42de4b1ea6c1ab13803f5470b3cc6f75a/lib/utils.js#L163-L173
train
Raynos/serve-browserify
index.js
function (location, opts, callback) { resolve(location, function (err, fileUri) { if (err) { return callback(err) } bundle(fileUri, opts, callback) }) }
javascript
function (location, opts, callback) { resolve(location, function (err, fileUri) { if (err) { return callback(err) } bundle(fileUri, opts, callback) }) }
[ "function", "(", "location", ",", "opts", ",", "callback", ")", "{", "resolve", "(", "location", ",", "function", "(", "err", ",", "fileUri", ")", "{", "if", "(", "err", ")", "{", "return", "callback", "(", "err", ")", "}", "bundle", "(", "fileUri", ...
this is the function to compile the resource. the location is the value returned by findResource you should pass a String to the callback
[ "this", "is", "the", "function", "to", "compile", "the", "resource", ".", "the", "location", "is", "the", "value", "returned", "by", "findResource", "you", "should", "pass", "a", "String", "to", "the", "callback" ]
a57baf3524b8b366dd9f1e8cffcb4467c914fe3a
https://github.com/Raynos/serve-browserify/blob/a57baf3524b8b366dd9f1e8cffcb4467c914fe3a/index.js#L13-L21
train
Raynos/serve-browserify
index.js
sendError
function sendError(req, res, err) { return res.end("(" + function (err) { throw new Error(err) } + "(" + JSON.stringify(err.message) + "))") }
javascript
function sendError(req, res, err) { return res.end("(" + function (err) { throw new Error(err) } + "(" + JSON.stringify(err.message) + "))") }
[ "function", "sendError", "(", "req", ",", "res", ",", "err", ")", "{", "return", "res", ".", "end", "(", "\"(\"", "+", "function", "(", "err", ")", "{", "throw", "new", "Error", "(", "err", ")", "}", "+", "\"(\"", "+", "JSON", ".", "stringify", "...
This is the logic of how to display errors to the user
[ "This", "is", "the", "logic", "of", "how", "to", "display", "errors", "to", "the", "user" ]
a57baf3524b8b366dd9f1e8cffcb4467c914fe3a
https://github.com/Raynos/serve-browserify/blob/a57baf3524b8b366dd9f1e8cffcb4467c914fe3a/index.js#L23-L27
train
ragingwind/eddystone-beacon-config
eddystone-characteristics.js
ByteCharateristic
function ByteCharateristic(opts) { ByteCharateristic.super_.call(this, opts); this.on('beforeWrite', function(data, res) { res(data.length == opts.sizeof ? Results.Success : Results.InvalidAttributeLength); }); this.toBuffer = byte2buf(opts.sizeof); this.fromBuffer = buf2byte(opts.sizeof); }
javascript
function ByteCharateristic(opts) { ByteCharateristic.super_.call(this, opts); this.on('beforeWrite', function(data, res) { res(data.length == opts.sizeof ? Results.Success : Results.InvalidAttributeLength); }); this.toBuffer = byte2buf(opts.sizeof); this.fromBuffer = buf2byte(opts.sizeof); }
[ "function", "ByteCharateristic", "(", "opts", ")", "{", "ByteCharateristic", ".", "super_", ".", "call", "(", "this", ",", "opts", ")", ";", "this", ".", "on", "(", "'beforeWrite'", ",", "function", "(", "data", ",", "res", ")", "{", "res", "(", "data"...
characteristics for byte data
[ "characteristics", "for", "byte", "data" ]
0ccc4ade7732f1cbe1740a591d50fb91c2cb6e2b
https://github.com/ragingwind/eddystone-beacon-config/blob/0ccc4ade7732f1cbe1740a591d50fb91c2cb6e2b/eddystone-characteristics.js#L114-L123
train
ragingwind/eddystone-beacon-config
eddystone-characteristics.js
LockStateCharateristic
function LockStateCharateristic(opts) { LockStateCharateristic.super_.call(this, objectAssign({ uuid: 'ee0c2081-8786-40ba-ab96-99b91ac981d8', properties: ['read'], sizeof: 1 }, opts)); }
javascript
function LockStateCharateristic(opts) { LockStateCharateristic.super_.call(this, objectAssign({ uuid: 'ee0c2081-8786-40ba-ab96-99b91ac981d8', properties: ['read'], sizeof: 1 }, opts)); }
[ "function", "LockStateCharateristic", "(", "opts", ")", "{", "LockStateCharateristic", ".", "super_", ".", "call", "(", "this", ",", "objectAssign", "(", "{", "uuid", ":", "'ee0c2081-8786-40ba-ab96-99b91ac981d8'", ",", "properties", ":", "[", "'read'", "]", ",", ...
lock state characteristic
[ "lock", "state", "characteristic" ]
0ccc4ade7732f1cbe1740a591d50fb91c2cb6e2b
https://github.com/ragingwind/eddystone-beacon-config/blob/0ccc4ade7732f1cbe1740a591d50fb91c2cb6e2b/eddystone-characteristics.js#L128-L134
train
ragingwind/eddystone-beacon-config
eddystone-characteristics.js
TxPowerLevelCharateristic
function TxPowerLevelCharateristic(opts) { TxPowerLevelCharateristic.super_.call(this, objectAssign({ uuid: 'ee0c2084-8786-40ba-ab96-99b91ac981d8', properties: ['read', 'write'], }, opts)); this.on('beforeWrite', function(data, res) { res(data.length == 4 ? Results.Success : Results.InvalidAttributeLength); ...
javascript
function TxPowerLevelCharateristic(opts) { TxPowerLevelCharateristic.super_.call(this, objectAssign({ uuid: 'ee0c2084-8786-40ba-ab96-99b91ac981d8', properties: ['read', 'write'], }, opts)); this.on('beforeWrite', function(data, res) { res(data.length == 4 ? Results.Success : Results.InvalidAttributeLength); ...
[ "function", "TxPowerLevelCharateristic", "(", "opts", ")", "{", "TxPowerLevelCharateristic", ".", "super_", ".", "call", "(", "this", ",", "objectAssign", "(", "{", "uuid", ":", "'ee0c2084-8786-40ba-ab96-99b91ac981d8'", ",", "properties", ":", "[", "'read'", ",", ...
tx power characteristic
[ "tx", "power", "characteristic" ]
0ccc4ade7732f1cbe1740a591d50fb91c2cb6e2b
https://github.com/ragingwind/eddystone-beacon-config/blob/0ccc4ade7732f1cbe1740a591d50fb91c2cb6e2b/eddystone-characteristics.js#L187-L199
train
ragingwind/eddystone-beacon-config
eddystone-characteristics.js
TxPowerModeCharateristic
function TxPowerModeCharateristic(opts) { TxPowerModeCharateristic.super_.call(this, objectAssign({ uuid: 'ee0c2087-8786-40ba-ab96-99b91ac981d8', properties: ['read', 'write'], sizeof: 1 }, opts)); this.removeAllListeners('beforeWrite'); this.on('beforeWrite', function(data, res) { var err = Results.Succe...
javascript
function TxPowerModeCharateristic(opts) { TxPowerModeCharateristic.super_.call(this, objectAssign({ uuid: 'ee0c2087-8786-40ba-ab96-99b91ac981d8', properties: ['read', 'write'], sizeof: 1 }, opts)); this.removeAllListeners('beforeWrite'); this.on('beforeWrite', function(data, res) { var err = Results.Succe...
[ "function", "TxPowerModeCharateristic", "(", "opts", ")", "{", "TxPowerModeCharateristic", ".", "super_", ".", "call", "(", "this", ",", "objectAssign", "(", "{", "uuid", ":", "'ee0c2087-8786-40ba-ab96-99b91ac981d8'", ",", "properties", ":", "[", "'read'", ",", "'...
tx power mode characteristic
[ "tx", "power", "mode", "characteristic" ]
0ccc4ade7732f1cbe1740a591d50fb91c2cb6e2b
https://github.com/ragingwind/eddystone-beacon-config/blob/0ccc4ade7732f1cbe1740a591d50fb91c2cb6e2b/eddystone-characteristics.js#L204-L224
train
ragingwind/eddystone-beacon-config
eddystone-characteristics.js
BeaconPeriodCharateristic
function BeaconPeriodCharateristic(opts) { BeaconPeriodCharateristic.super_.call(this, objectAssign({ uuid: 'ee0c2088-8786-40ba-ab96-99b91ac981d8', properties: ['read', 'write'], sizeof: 2 }, opts)); }
javascript
function BeaconPeriodCharateristic(opts) { BeaconPeriodCharateristic.super_.call(this, objectAssign({ uuid: 'ee0c2088-8786-40ba-ab96-99b91ac981d8', properties: ['read', 'write'], sizeof: 2 }, opts)); }
[ "function", "BeaconPeriodCharateristic", "(", "opts", ")", "{", "BeaconPeriodCharateristic", ".", "super_", ".", "call", "(", "this", ",", "objectAssign", "(", "{", "uuid", ":", "'ee0c2088-8786-40ba-ab96-99b91ac981d8'", ",", "properties", ":", "[", "'read'", ",", ...
beacon period characteristic
[ "beacon", "period", "characteristic" ]
0ccc4ade7732f1cbe1740a591d50fb91c2cb6e2b
https://github.com/ragingwind/eddystone-beacon-config/blob/0ccc4ade7732f1cbe1740a591d50fb91c2cb6e2b/eddystone-characteristics.js#L229-L235
train
gummesson/get-browser-language
index.js
getBrowserLanguage
function getBrowserLanguage() { var first = window.navigator.languages ? window.navigator.languages[0] : null var lang = first || window.navigator.language || window.navigator.browserLanguage || window.navigator.userLanguage return lang }
javascript
function getBrowserLanguage() { var first = window.navigator.languages ? window.navigator.languages[0] : null var lang = first || window.navigator.language || window.navigator.browserLanguage || window.navigator.userLanguage return lang }
[ "function", "getBrowserLanguage", "(", ")", "{", "var", "first", "=", "window", ".", "navigator", ".", "languages", "?", "window", ".", "navigator", ".", "languages", "[", "0", "]", ":", "null", "var", "lang", "=", "first", "||", "window", ".", "navigato...
Get browser language. @return {String}
[ "Get", "browser", "language", "." ]
4669bc5fa2c5abd00a701a01ed7ef0e9fc1464c5
https://github.com/gummesson/get-browser-language/blob/4669bc5fa2c5abd00a701a01ed7ef0e9fc1464c5/index.js#L13-L24
train
bikramjeet/sanitation
sanitation.js
isPositiveIntegerArray
function isPositiveIntegerArray(value) { var success = true; for(var i = 0; i < value.length; i++) { if(!config.checkIntegerValue.test(value[i]) || parseInt(value[i]) <= 0) { success = false; break; } } return success; }
javascript
function isPositiveIntegerArray(value) { var success = true; for(var i = 0; i < value.length; i++) { if(!config.checkIntegerValue.test(value[i]) || parseInt(value[i]) <= 0) { success = false; break; } } return success; }
[ "function", "isPositiveIntegerArray", "(", "value", ")", "{", "var", "success", "=", "true", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "value", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "config", ".", "checkIntegerValue", ...
Validates the non-zero positive integer value from the array of strings and returns true for success. @method isPositiveInteger @param {Array} value The values to be tested.
[ "Validates", "the", "non", "-", "zero", "positive", "integer", "value", "from", "the", "array", "of", "strings", "and", "returns", "true", "for", "success", "." ]
af362d99c689ad1eb15cbd4639b346f3eac6cfb5
https://github.com/bikramjeet/sanitation/blob/af362d99c689ad1eb15cbd4639b346f3eac6cfb5/sanitation.js#L120-L129
train
bikramjeet/sanitation
sanitation.js
isValidDate
function isValidDate(dateString, dateFormat, returnDateFormat) { if(moment(dateString, dateFormat).format(dateFormat) !== dateString) { return false; } if(!moment(dateString, dateFormat).isValid()) { return false; } if(returnDateFormat) { return moment(dateString, dateFormat)...
javascript
function isValidDate(dateString, dateFormat, returnDateFormat) { if(moment(dateString, dateFormat).format(dateFormat) !== dateString) { return false; } if(!moment(dateString, dateFormat).isValid()) { return false; } if(returnDateFormat) { return moment(dateString, dateFormat)...
[ "function", "isValidDate", "(", "dateString", ",", "dateFormat", ",", "returnDateFormat", ")", "{", "if", "(", "moment", "(", "dateString", ",", "dateFormat", ")", ".", "format", "(", "dateFormat", ")", "!==", "dateString", ")", "{", "return", "false", ";", ...
Checks the date format along with valid date and convert to the expected format. @method isValidDate @param {String} dateString The date value to validate. @param {String} dateFormat The expected format of the date value. @param {String} [returnDateFormat] The expected date format after conversion as the return value.
[ "Checks", "the", "date", "format", "along", "with", "valid", "date", "and", "convert", "to", "the", "expected", "format", "." ]
af362d99c689ad1eb15cbd4639b346f3eac6cfb5
https://github.com/bikramjeet/sanitation/blob/af362d99c689ad1eb15cbd4639b346f3eac6cfb5/sanitation.js#L156-L167
train
bikramjeet/sanitation
sanitation.js
objValByStr
function objValByStr(name, separator, context) { var func, i, n, ns, _i, _len; if (!name || !separator || !context) { return null; } ns = name.split(separator); func = context; try { for (i = _i = 0, _len = ns.length; _i < _len; i = ++_i) { n = ns[i]; func...
javascript
function objValByStr(name, separator, context) { var func, i, n, ns, _i, _len; if (!name || !separator || !context) { return null; } ns = name.split(separator); func = context; try { for (i = _i = 0, _len = ns.length; _i < _len; i = ++_i) { n = ns[i]; func...
[ "function", "objValByStr", "(", "name", ",", "separator", ",", "context", ")", "{", "var", "func", ",", "i", ",", "n", ",", "ns", ",", "_i", ",", "_len", ";", "if", "(", "!", "name", "||", "!", "separator", "||", "!", "context", ")", "{", "return...
Returns the value of the nested object based on string path and the separator provided. @param {String} name The path of the nested object structure to fetch the value. @param {String} separator The identifier to split the string to iterate over the JSON object keys. @param {Object} context The original nested JSON obj...
[ "Returns", "the", "value", "of", "the", "nested", "object", "based", "on", "string", "path", "and", "the", "separator", "provided", "." ]
af362d99c689ad1eb15cbd4639b346f3eac6cfb5
https://github.com/bikramjeet/sanitation/blob/af362d99c689ad1eb15cbd4639b346f3eac6cfb5/sanitation.js#L175-L191
train
QuietWind/find-imports
lib/index.js
function (arrArg) { return arrArg.filter(function (elem, pos, arr) { return arr.indexOf(elem) === pos; }); }
javascript
function (arrArg) { return arrArg.filter(function (elem, pos, arr) { return arr.indexOf(elem) === pos; }); }
[ "function", "(", "arrArg", ")", "{", "return", "arrArg", ".", "filter", "(", "function", "(", "elem", ",", "pos", ",", "arr", ")", "{", "return", "arr", ".", "indexOf", "(", "elem", ")", "===", "pos", ";", "}", ")", ";", "}" ]
clear memory data
[ "clear", "memory", "data" ]
f0ecef2ff8025abfe59fcb19539965717ecd08ab
https://github.com/QuietWind/find-imports/blob/f0ecef2ff8025abfe59fcb19539965717ecd08ab/lib/index.js#L16-L20
train
pwstegman/pw-csp
index.js
CSP
function CSP(class1, class2) { var cov1 = stat.cov(class1); var cov2 = stat.cov(class2); this.V = numeric.eig(math.multiply(math.inv(math.add(cov1, cov2)), cov1)).E.x; }
javascript
function CSP(class1, class2) { var cov1 = stat.cov(class1); var cov2 = stat.cov(class2); this.V = numeric.eig(math.multiply(math.inv(math.add(cov1, cov2)), cov1)).E.x; }
[ "function", "CSP", "(", "class1", ",", "class2", ")", "{", "var", "cov1", "=", "stat", ".", "cov", "(", "class1", ")", ";", "var", "cov2", "=", "stat", ".", "cov", "(", "class2", ")", ";", "this", ".", "V", "=", "numeric", ".", "eig", "(", "mat...
Creates a new CSP object @constructor @param {number[][]} class1 - Data samples for class 1. Rows should be samples, columns should be signals. @param {number[][]} class2 - Data samples for class 2. Rows should be samples, columns should be signals.
[ "Creates", "a", "new", "CSP", "object" ]
58b7a8bf7055c333fe02bb8e23443a55ddb084ca
https://github.com/pwstegman/pw-csp/blob/58b7a8bf7055c333fe02bb8e23443a55ddb084ca/index.js#L15-L19
train
redarrowlabs/strongback
bin/form/field-wrapper.js
FieldLabel
function FieldLabel(props) { var label = props.label, indicator = props.indicator, tooltipProps = props.tooltipProps, infoIconProps = props.infoIconProps; var indicatorEl = null; if (indicator === 'optional') { indicatorEl = React.createElement("span", { className: 'indicator' }, "(optional)"); ...
javascript
function FieldLabel(props) { var label = props.label, indicator = props.indicator, tooltipProps = props.tooltipProps, infoIconProps = props.infoIconProps; var indicatorEl = null; if (indicator === 'optional') { indicatorEl = React.createElement("span", { className: 'indicator' }, "(optional)"); ...
[ "function", "FieldLabel", "(", "props", ")", "{", "var", "label", "=", "props", ".", "label", ",", "indicator", "=", "props", ".", "indicator", ",", "tooltipProps", "=", "props", ".", "tooltipProps", ",", "infoIconProps", "=", "props", ".", "infoIconProps", ...
The label of the field, including indicators.
[ "The", "label", "of", "the", "field", "including", "indicators", "." ]
cdc8e0431a7fdf4faeb4016ba498b9146fc166aa
https://github.com/redarrowlabs/strongback/blob/cdc8e0431a7fdf4faeb4016ba498b9146fc166aa/bin/form/field-wrapper.js#L52-L82
train
redarrowlabs/strongback
bin/form/field-wrapper.js
FieldError
function FieldError(props) { var touched = props.touched, error = props.error; if (touched && error) { return React.createElement("div", { className: 'c-form-field--error-message' }, error); } return null; }
javascript
function FieldError(props) { var touched = props.touched, error = props.error; if (touched && error) { return React.createElement("div", { className: 'c-form-field--error-message' }, error); } return null; }
[ "function", "FieldError", "(", "props", ")", "{", "var", "touched", "=", "props", ".", "touched", ",", "error", "=", "props", ".", "error", ";", "if", "(", "touched", "&&", "error", ")", "{", "return", "React", ".", "createElement", "(", "\"div\"", ","...
The error message section of a field.
[ "The", "error", "message", "section", "of", "a", "field", "." ]
cdc8e0431a7fdf4faeb4016ba498b9146fc166aa
https://github.com/redarrowlabs/strongback/blob/cdc8e0431a7fdf4faeb4016ba498b9146fc166aa/bin/form/field-wrapper.js#L84-L90
train
dizmo/functions-buffered
dist/lib/buffered.js
buffered
function buffered(fn) { var ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200; var id = void 0; var bn = function bn() { var _this = this; for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_k...
javascript
function buffered(fn) { var ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200; var id = void 0; var bn = function bn() { var _this = this; for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_k...
[ "function", "buffered", "(", "fn", ")", "{", "var", "ms", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "200", ";", "var", "id", "=", "void", "0", ";", "var"...
Returns a buffered and cancelable version for the provided function. The buffered function does *not* get invoked, before the specified delay in milliseconds passes, no matter how much it gets invoked in between. Also upon the invocation of the *actual* function a promise is returned. Further, it is also possible...
[ "Returns", "a", "buffered", "and", "cancelable", "version", "for", "the", "provided", "function", "." ]
63139ca7d68767890076ccd11368804e87816f07
https://github.com/dizmo/functions-buffered/blob/63139ca7d68767890076ccd11368804e87816f07/dist/lib/buffered.js#L20-L42
train
Maximilianos/imgGlitch
dist/imgGlitch.js
imgGlitch
function imgGlitch(img, options) { var imgElement = 'string' === typeof img ? document.querySelector(img) : img; if (!(imgElement instanceof HTMLImageElement && imgElement.constructor === HTMLImageElement)) { throw new TypeError('renderImgCorruption expects input img to be a valid image element'); } var co...
javascript
function imgGlitch(img, options) { var imgElement = 'string' === typeof img ? document.querySelector(img) : img; if (!(imgElement instanceof HTMLImageElement && imgElement.constructor === HTMLImageElement)) { throw new TypeError('renderImgCorruption expects input img to be a valid image element'); } var co...
[ "function", "imgGlitch", "(", "img", ",", "options", ")", "{", "var", "imgElement", "=", "'string'", "===", "typeof", "img", "?", "document", ".", "querySelector", "(", "img", ")", ":", "img", ";", "if", "(", "!", "(", "imgElement", "instanceof", "HTMLIm...
Render the base64 corruption based image glitch effect @param img @param options @returns {{start, stop, clear}}
[ "Render", "the", "base64", "corruption", "based", "image", "glitch", "effect" ]
806ec31c5f6368ec91e2cc94cea44a35813c80c5
https://github.com/Maximilianos/imgGlitch/blob/806ec31c5f6368ec91e2cc94cea44a35813c80c5/dist/imgGlitch.js#L72-L127
train
halfbakedsneed/chowdown
src/document/index.js
add
function add(name, methods) { // Create a container class that extends Document for our methods. class ConcreteDocument extends Document { constructor(document, root) { super(name, document, root); } } // Assign the methods to the new classes prototype. assignIn(ConcreteDocument.prototype, met...
javascript
function add(name, methods) { // Create a container class that extends Document for our methods. class ConcreteDocument extends Document { constructor(document, root) { super(name, document, root); } } // Assign the methods to the new classes prototype. assignIn(ConcreteDocument.prototype, met...
[ "function", "add", "(", "name", ",", "methods", ")", "{", "// Create a container class that extends Document for our methods.", "class", "ConcreteDocument", "extends", "Document", "{", "constructor", "(", "document", ",", "root", ")", "{", "super", "(", "name", ",", ...
Creates and adds a a factory method for a new subtype of document. @param {string} name The name of the subtype. @param {object} methods The methods the class will have.
[ "Creates", "and", "adds", "a", "a", "factory", "method", "for", "a", "new", "subtype", "of", "document", "." ]
b0e322c6070f82d557886afec9217b41f5214543
https://github.com/halfbakedsneed/chowdown/blob/b0e322c6070f82d557886afec9217b41f5214543/src/document/index.js#L136-L150
train
fex-team/fis-packager-map
index.js
function(subpath, regs){ for(var i = 0, len = regs.length; i < len; i++){ var reg = regs[i]; if(reg && fis.util.filter(subpath, reg)){ return i; } } return false; }
javascript
function(subpath, regs){ for(var i = 0, len = regs.length; i < len; i++){ var reg = regs[i]; if(reg && fis.util.filter(subpath, reg)){ return i; } } return false; }
[ "function", "(", "subpath", ",", "regs", ")", "{", "for", "(", "var", "i", "=", "0", ",", "len", "=", "regs", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "reg", "=", "regs", "[", "i", "]", ";", "if", "(", "reg", ...
determine if subpath hit a pack config
[ "determine", "if", "subpath", "hit", "a", "pack", "config" ]
277a78adb101ef69ce9a19823ffce79d98f3f389
https://github.com/fex-team/fis-packager-map/blob/277a78adb101ef69ce9a19823ffce79d98f3f389/index.js#L37-L45
train
meetings/gearsloth
lib/config/validate.js
confBool
function confBool(obj, field) { if (field in obj) obj[field] = bool(obj[field]); }
javascript
function confBool(obj, field) { if (field in obj) obj[field] = bool(obj[field]); }
[ "function", "confBool", "(", "obj", ",", "field", ")", "{", "if", "(", "field", "in", "obj", ")", "obj", "[", "field", "]", "=", "bool", "(", "obj", "[", "field", "]", ")", ";", "}" ]
Validate and clean a boolean field.
[ "Validate", "and", "clean", "a", "boolean", "field", "." ]
21d07729d6197bdbea515f32922896e3ae485d46
https://github.com/meetings/gearsloth/blob/21d07729d6197bdbea515f32922896e3ae485d46/lib/config/validate.js#L78-L81
train
djordjelacmanovic/yql-node
index.js
function (consumer_key, consumer_secret) { this.oauth = new OAuth.OAuth( 'https://query.yahooapis.com/v1/yql/', 'https://query.yahooapis.com/v1/yql/', consumer_key, //consumer key consumer_secret, //consumer secret '1.0', null, 'HMAC-SHA1' ...
javascript
function (consumer_key, consumer_secret) { this.oauth = new OAuth.OAuth( 'https://query.yahooapis.com/v1/yql/', 'https://query.yahooapis.com/v1/yql/', consumer_key, //consumer key consumer_secret, //consumer secret '1.0', null, 'HMAC-SHA1' ...
[ "function", "(", "consumer_key", ",", "consumer_secret", ")", "{", "this", ".", "oauth", "=", "new", "OAuth", ".", "OAuth", "(", "'https://query.yahooapis.com/v1/yql/'", ",", "'https://query.yahooapis.com/v1/yql/'", ",", "consumer_key", ",", "//consumer key", "consumer_...
yql-node used to output only xml, now the formatAsJSON chainloader should help.
[ "yql", "-", "node", "used", "to", "output", "only", "xml", "now", "the", "formatAsJSON", "chainloader", "should", "help", "." ]
855f264e39b9a77475b54741b47bfcf5016cee7f
https://github.com/djordjelacmanovic/yql-node/blob/855f264e39b9a77475b54741b47bfcf5016cee7f/index.js#L8-L21
train
dominictarr/libnested
index.js
clone
function clone (obj) { if(!isObject(obj, true)) return obj var _obj _obj = Array.isArray(obj) ? [] : {} for(var k in obj) _obj[k] = clone(obj[k]) return _obj }
javascript
function clone (obj) { if(!isObject(obj, true)) return obj var _obj _obj = Array.isArray(obj) ? [] : {} for(var k in obj) _obj[k] = clone(obj[k]) return _obj }
[ "function", "clone", "(", "obj", ")", "{", "if", "(", "!", "isObject", "(", "obj", ",", "true", ")", ")", "return", "obj", "var", "_obj", "_obj", "=", "Array", ".", "isArray", "(", "obj", ")", "?", "[", "]", ":", "{", "}", "for", "(", "var", ...
note, cyclic objects are not supported. will cause an stack overflow.
[ "note", "cyclic", "objects", "are", "not", "supported", ".", "will", "cause", "an", "stack", "overflow", "." ]
06b06a22d968323ae619166e2078f955dc57ecbe
https://github.com/dominictarr/libnested/blob/06b06a22d968323ae619166e2078f955dc57ecbe/index.js#L86-L92
train
jeanamarante/catena
tasks/util/stream.js
iteratePipeFile
function iteratePipeFile () { if (!isIterating()) { return undefined; } let data = iterateData; let file = data.collection[data.i]; data.i++; if (data.i >= data.collection.length) { resetIterateData(); pipeLastFile(file); } else { pipeFile(file, iteratePipeFile); }...
javascript
function iteratePipeFile () { if (!isIterating()) { return undefined; } let data = iterateData; let file = data.collection[data.i]; data.i++; if (data.i >= data.collection.length) { resetIterateData(); pipeLastFile(file); } else { pipeFile(file, iteratePipeFile); }...
[ "function", "iteratePipeFile", "(", ")", "{", "if", "(", "!", "isIterating", "(", ")", ")", "{", "return", "undefined", ";", "}", "let", "data", "=", "iterateData", ";", "let", "file", "=", "data", ".", "collection", "[", "data", ".", "i", "]", ";", ...
Recursively pipe all files. @function iteratePipeFile @api private
[ "Recursively", "pipe", "all", "files", "." ]
c7762332f71c0fd7cfafba8d1e3cd66053529954
https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/util/stream.js#L113-L127
train
jeanamarante/catena
tasks/util/stream.js
iterateWriteArray
function iterateWriteArray () { if (!isIterating()) { return undefined; } let data = iterateData; let content = data.collection[data.i]; data.i++; if (data.i >= data.collection.length) { resetIterateData(); writable.write(content, 'utf8', onWriteFinish); } else { writ...
javascript
function iterateWriteArray () { if (!isIterating()) { return undefined; } let data = iterateData; let content = data.collection[data.i]; data.i++; if (data.i >= data.collection.length) { resetIterateData(); writable.write(content, 'utf8', onWriteFinish); } else { writ...
[ "function", "iterateWriteArray", "(", ")", "{", "if", "(", "!", "isIterating", "(", ")", ")", "{", "return", "undefined", ";", "}", "let", "data", "=", "iterateData", ";", "let", "content", "=", "data", ".", "collection", "[", "data", ".", "i", "]", ...
Recursively write content in array. @function iterateWriteArray @api private
[ "Recursively", "write", "content", "in", "array", "." ]
c7762332f71c0fd7cfafba8d1e3cd66053529954
https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/util/stream.js#L136-L151
train
jeanamarante/catena
tasks/util/stream.js
iterateWriteLinkedList
function iterateWriteLinkedList () { if (!isIterating()) { return undefined; } let data = iterateData; let content = iterateData.item.content; data.item = data.item.next; if (data.item === null) { resetIterateData(); writable.write(content, 'utf8', onWriteFinish); } else { ...
javascript
function iterateWriteLinkedList () { if (!isIterating()) { return undefined; } let data = iterateData; let content = iterateData.item.content; data.item = data.item.next; if (data.item === null) { resetIterateData(); writable.write(content, 'utf8', onWriteFinish); } else { ...
[ "function", "iterateWriteLinkedList", "(", ")", "{", "if", "(", "!", "isIterating", "(", ")", ")", "{", "return", "undefined", ";", "}", "let", "data", "=", "iterateData", ";", "let", "content", "=", "iterateData", ".", "item", ".", "content", ";", "data...
Recursively write content in linked list. @function iterateWriteLinkedList @api private
[ "Recursively", "write", "content", "in", "linked", "list", "." ]
c7762332f71c0fd7cfafba8d1e3cd66053529954
https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/util/stream.js#L160-L175
train
jeanamarante/catena
tasks/util/stream.js
pipeFile
function pipeFile (file, endCallback) { testPipeFile(); testFunction(endCallback, 'endCallback'); let readable = fs.createReadStream(file); readableEndCallback = endCallback; readable.once('error', throwAsyncError); readable.once('close', onReadableClose); readable.pipe(writable, { end: ...
javascript
function pipeFile (file, endCallback) { testPipeFile(); testFunction(endCallback, 'endCallback'); let readable = fs.createReadStream(file); readableEndCallback = endCallback; readable.once('error', throwAsyncError); readable.once('close', onReadableClose); readable.pipe(writable, { end: ...
[ "function", "pipeFile", "(", "file", ",", "endCallback", ")", "{", "testPipeFile", "(", ")", ";", "testFunction", "(", "endCallback", ",", "'endCallback'", ")", ";", "let", "readable", "=", "fs", ".", "createReadStream", "(", "file", ")", ";", "readableEndCa...
Pipe file contents without ending WriteStream. @function pipeFile @param {String} file @param {Function} endCallback @api public
[ "Pipe", "file", "contents", "without", "ending", "WriteStream", "." ]
c7762332f71c0fd7cfafba8d1e3cd66053529954
https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/util/stream.js#L186-L198
train
jeanamarante/catena
tasks/util/stream.js
pipeFileArray
function pipeFileArray (arr) { testPipeFile(); // Just end WriteStream if no files need to be read to keep default pipe behavior. if (arr.length === 0) { writable.end(); } else { iterateData.collection = arr; iteratePipeFile(); } }
javascript
function pipeFileArray (arr) { testPipeFile(); // Just end WriteStream if no files need to be read to keep default pipe behavior. if (arr.length === 0) { writable.end(); } else { iterateData.collection = arr; iteratePipeFile(); } }
[ "function", "pipeFileArray", "(", "arr", ")", "{", "testPipeFile", "(", ")", ";", "// Just end WriteStream if no files need to be read to keep default pipe behavior.", "if", "(", "arr", ".", "length", "===", "0", ")", "{", "writable", ".", "end", "(", ")", ";", "}...
Pipe files recursively and then end WriteStream. @function pipeFileArray @param {Array} arr @api public
[ "Pipe", "files", "recursively", "and", "then", "end", "WriteStream", "." ]
c7762332f71c0fd7cfafba8d1e3cd66053529954
https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/util/stream.js#L208-L219
train
jeanamarante/catena
tasks/util/stream.js
pipeLastFile
function pipeLastFile (file) { testPipeFile(); let readable = fs.createReadStream(file); readable.once('error', throwAsyncError); readable.pipe(writable); }
javascript
function pipeLastFile (file) { testPipeFile(); let readable = fs.createReadStream(file); readable.once('error', throwAsyncError); readable.pipe(writable); }
[ "function", "pipeLastFile", "(", "file", ")", "{", "testPipeFile", "(", ")", ";", "let", "readable", "=", "fs", ".", "createReadStream", "(", "file", ")", ";", "readable", ".", "once", "(", "'error'", ",", "throwAsyncError", ")", ";", "readable", ".", "p...
Pipe file contents and then end WriteStream. @function pipeLastFile @param {String} file @api public
[ "Pipe", "file", "contents", "and", "then", "end", "WriteStream", "." ]
c7762332f71c0fd7cfafba8d1e3cd66053529954
https://github.com/jeanamarante/catena/blob/c7762332f71c0fd7cfafba8d1e3cd66053529954/tasks/util/stream.js#L229-L237
train
observing/leverage
index.js
Leverage
function Leverage(client, sub, options) { if (!this) return new Leverage(client, sub, options); // // Flakey detection if we got a options argument or an actual Redis client. We // could do an instanceOf RedisClient check but I don't want to have Redis as // a dependency of this module. // if ('object' =...
javascript
function Leverage(client, sub, options) { if (!this) return new Leverage(client, sub, options); // // Flakey detection if we got a options argument or an actual Redis client. We // could do an instanceOf RedisClient check but I don't want to have Redis as // a dependency of this module. // if ('object' =...
[ "function", "Leverage", "(", "client", ",", "sub", ",", "options", ")", "{", "if", "(", "!", "this", ")", "return", "new", "Leverage", "(", "client", ",", "sub", ",", "options", ")", ";", "//", "// Flakey detection if we got a options argument or an actual Redis...
Leverage the awesome power of Lua scripting. @constructor @param {Redis} client Redis client to publish the messages over. @param {Redis} sub Redis client to subscribe with. @param {Object} options Options.
[ "Leverage", "the", "awesome", "power", "of", "Lua", "scripting", "." ]
8a5896d9bdee81542a32e68053490224e488db3e
https://github.com/observing/leverage/blob/8a5896d9bdee81542a32e68053490224e488db3e/index.js#L27-L126
train
observing/leverage
index.js
failed
function failed(err) { leverage.emit(channel +'::error', err); if (!bailout) return debug('received an error without bailout mode, gnoring it', err.message); leverage.emit(channel +'::bailout', err); leverage.unsubscribe(channel); }
javascript
function failed(err) { leverage.emit(channel +'::error', err); if (!bailout) return debug('received an error without bailout mode, gnoring it', err.message); leverage.emit(channel +'::bailout', err); leverage.unsubscribe(channel); }
[ "function", "failed", "(", "err", ")", "{", "leverage", ".", "emit", "(", "channel", "+", "'::error'", ",", "err", ")", ";", "if", "(", "!", "bailout", ")", "return", "debug", "(", "'received an error without bailout mode, gnoring it'", ",", "err", ".", "mes...
Bailout and cancel all the things @param {Error} Err The error that occurred @api private
[ "Bailout", "and", "cancel", "all", "the", "things" ]
8a5896d9bdee81542a32e68053490224e488db3e
https://github.com/observing/leverage/blob/8a5896d9bdee81542a32e68053490224e488db3e/index.js#L215-L222
train
observing/leverage
index.js
parse
function parse(packet) { if ('object' === typeof packet) return packet; try { return JSON.parse(packet); } catch (e) { return failed(e); } }
javascript
function parse(packet) { if ('object' === typeof packet) return packet; try { return JSON.parse(packet); } catch (e) { return failed(e); } }
[ "function", "parse", "(", "packet", ")", "{", "if", "(", "'object'", "===", "typeof", "packet", ")", "return", "packet", ";", "try", "{", "return", "JSON", ".", "parse", "(", "packet", ")", ";", "}", "catch", "(", "e", ")", "{", "return", "failed", ...
Parse the packet. @param {String} packet The encoded message. @returns {Object} @api private
[ "Parse", "the", "packet", "." ]
8a5896d9bdee81542a32e68053490224e488db3e
https://github.com/observing/leverage/blob/8a5896d9bdee81542a32e68053490224e488db3e/index.js#L241-L246
train
observing/leverage
index.js
flush
function flush() { if (queue.length) { // // We might want to indicate that these are already queued, so we don't // fetch data again. // queue.splice(0).sort(function sort(a, b) { return a.id - b.id; }).forEach(onmessage); } }
javascript
function flush() { if (queue.length) { // // We might want to indicate that these are already queued, so we don't // fetch data again. // queue.splice(0).sort(function sort(a, b) { return a.id - b.id; }).forEach(onmessage); } }
[ "function", "flush", "(", ")", "{", "if", "(", "queue", ".", "length", ")", "{", "//", "// We might want to indicate that these are already queued, so we don't", "// fetch data again.", "//", "queue", ".", "splice", "(", "0", ")", ".", "sort", "(", "function", "so...
We have messages queued, now that we've successfully send the message we probably want to try and resend all of these messages and hope that we we've restored the reliability again. @api private
[ "We", "have", "messages", "queued", "now", "that", "we", "ve", "successfully", "send", "the", "message", "we", "probably", "want", "to", "try", "and", "resend", "all", "of", "these", "messages", "and", "hope", "that", "we", "we", "ve", "restored", "the", ...
8a5896d9bdee81542a32e68053490224e488db3e
https://github.com/observing/leverage/blob/8a5896d9bdee81542a32e68053490224e488db3e/index.js#L265-L275
train
observing/leverage
index.js
allowed
function allowed(packet) { if (!packet) return false; if (uv.position === 'inactive' || (!uv.received(packet.id) && ordered)) { queue.push(packet); return false; } return true; }
javascript
function allowed(packet) { if (!packet) return false; if (uv.position === 'inactive' || (!uv.received(packet.id) && ordered)) { queue.push(packet); return false; } return true; }
[ "function", "allowed", "(", "packet", ")", "{", "if", "(", "!", "packet", ")", "return", "false", ";", "if", "(", "uv", ".", "position", "===", "'inactive'", "||", "(", "!", "uv", ".", "received", "(", "packet", ".", "id", ")", "&&", "ordered", ")"...
Checks if we are allowed to emit the message. @param {Object} packet The message packet. @api private
[ "Checks", "if", "we", "are", "allowed", "to", "emit", "the", "message", "." ]
8a5896d9bdee81542a32e68053490224e488db3e
https://github.com/observing/leverage/blob/8a5896d9bdee81542a32e68053490224e488db3e/index.js#L283-L292
train
observing/leverage
index.js
onmessage
function onmessage(packet) { if (arguments.length === 2) packet = arguments[1]; packet = parse(packet); if (allowed(packet)) emit(packet); }
javascript
function onmessage(packet) { if (arguments.length === 2) packet = arguments[1]; packet = parse(packet); if (allowed(packet)) emit(packet); }
[ "function", "onmessage", "(", "packet", ")", "{", "if", "(", "arguments", ".", "length", "===", "2", ")", "packet", "=", "arguments", "[", "1", "]", ";", "packet", "=", "parse", "(", "packet", ")", ";", "if", "(", "allowed", "(", "packet", ")", ")"...
Handle incomming messages. @param {String} packet The message @api private
[ "Handle", "incomming", "messages", "." ]
8a5896d9bdee81542a32e68053490224e488db3e
https://github.com/observing/leverage/blob/8a5896d9bdee81542a32e68053490224e488db3e/index.js#L300-L305
train
meetings/gearsloth
lib/adapters/composite.js
initialize
function initialize(config, callback, config_helper) { config_helper = config_helper || require('../config/index'); if(!checkConfSanity(config)) { callback(new Error('conf.dbopt is not sane, can\'t initialize composite adapter')); return; } populateDatabasesArray(config, config_helper, function(err, d...
javascript
function initialize(config, callback, config_helper) { config_helper = config_helper || require('../config/index'); if(!checkConfSanity(config)) { callback(new Error('conf.dbopt is not sane, can\'t initialize composite adapter')); return; } populateDatabasesArray(config, config_helper, function(err, d...
[ "function", "initialize", "(", "config", ",", "callback", ",", "config_helper", ")", "{", "config_helper", "=", "config_helper", "||", "require", "(", "'../config/index'", ")", ";", "if", "(", "!", "checkConfSanity", "(", "config", ")", ")", "{", "callback", ...
A composite adapter that consists of multiple adapters. The adapters may be of a different type. `config.dbopt` should be an array containing JSON-objects that will be used to initialize the individual adapters. This function uses config/index.js's initializeDb-function to initialize the adapters. @param {Object} con...
[ "A", "composite", "adapter", "that", "consists", "of", "multiple", "adapters", ".", "The", "adapters", "may", "be", "of", "a", "different", "type", "." ]
21d07729d6197bdbea515f32922896e3ae485d46
https://github.com/meetings/gearsloth/blob/21d07729d6197bdbea515f32922896e3ae485d46/lib/adapters/composite.js#L25-L39
train
veyo-care/deep-sync
src/index.js
deepSync
function deepSync(target, source, overwrite) { if (!(((target) && (typeof target === 'object')) && ((source) && (typeof source === 'object'))) || (source instanceof Array) || (target instanceof Array)) { throw new TypeError('Source and Target must be objects.'); } let sourceKeys =...
javascript
function deepSync(target, source, overwrite) { if (!(((target) && (typeof target === 'object')) && ((source) && (typeof source === 'object'))) || (source instanceof Array) || (target instanceof Array)) { throw new TypeError('Source and Target must be objects.'); } let sourceKeys =...
[ "function", "deepSync", "(", "target", ",", "source", ",", "overwrite", ")", "{", "if", "(", "!", "(", "(", "(", "target", ")", "&&", "(", "typeof", "target", "===", "'object'", ")", ")", "&&", "(", "(", "source", ")", "&&", "(", "typeof", "source"...
Recursively synchronizes two JS objects where the target becomes the source, without changing the targets values for the keys that is has in common with the source. Does not work with arrays for obvious reasons. @param target - the object to be synchronized @param source - the object to sync data from @param overwrit...
[ "Recursively", "synchronizes", "two", "JS", "objects", "where", "the", "target", "becomes", "the", "source", "without", "changing", "the", "targets", "values", "for", "the", "keys", "that", "is", "has", "in", "common", "with", "the", "source", "." ]
cd385f22cfa08613ee0f673904dcc17b94b2c6fd
https://github.com/veyo-care/deep-sync/blob/cd385f22cfa08613ee0f673904dcc17b94b2c6fd/src/index.js#L16-L78
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
equalSimpleArrays
function equalSimpleArrays(arr1, arr2) { if (arr1 && (arr1.length > 0)) return ( arr2 && (arr2.length === arr1.length) && arr2.every((v, i) => (v === arr1[i])) ); return (!arr2 || (arr2.length === 0)); }
javascript
function equalSimpleArrays(arr1, arr2) { if (arr1 && (arr1.length > 0)) return ( arr2 && (arr2.length === arr1.length) && arr2.every((v, i) => (v === arr1[i])) ); return (!arr2 || (arr2.length === 0)); }
[ "function", "equalSimpleArrays", "(", "arr1", ",", "arr2", ")", "{", "if", "(", "arr1", "&&", "(", "arr1", ".", "length", ">", "0", ")", ")", "return", "(", "arr2", "&&", "(", "arr2", ".", "length", "===", "arr1", ".", "length", ")", "&&", "arr2", ...
Test if two simple value arrays are equal. @private @param {?Array} arr1 Array 1. @param {?Array} arr2 Array 2. @returns {boolean} <code>true</code> if considered equal.
[ "Test", "if", "two", "simple", "value", "arrays", "are", "equal", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L49-L59
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
equalSimpleMaps
function equalSimpleMaps(map1, map2) { const keys1 = (map1 && Object.keys(map1)); if (map1 && (keys1.length > 0)) { const keys2 = (map2 && Object.keys(map2)); return ( keys2 && (keys2.length === keys1.length) && keys2.every(k => (map2[k] === map1[k])) ); } return (!map2 || (Object.keys(map2).leng...
javascript
function equalSimpleMaps(map1, map2) { const keys1 = (map1 && Object.keys(map1)); if (map1 && (keys1.length > 0)) { const keys2 = (map2 && Object.keys(map2)); return ( keys2 && (keys2.length === keys1.length) && keys2.every(k => (map2[k] === map1[k])) ); } return (!map2 || (Object.keys(map2).leng...
[ "function", "equalSimpleMaps", "(", "map1", ",", "map2", ")", "{", "const", "keys1", "=", "(", "map1", "&&", "Object", ".", "keys", "(", "map1", ")", ")", ";", "if", "(", "map1", "&&", "(", "keys1", ".", "length", ">", "0", ")", ")", "{", "const"...
Test if two simple value maps are equal. @private @param {?Object} map1 Map 1. @param {?Object} map2 Map 2. @returns {boolean} <code>true</code> if considered equal.
[ "Test", "if", "two", "simple", "value", "maps", "are", "equal", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L69-L82
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
needsAdd
function needsAdd(ptr, record, value) { const propDesc = ptr.propDesc; if (propDesc.isArray()) { if (ptr.collectionElement) return true; if (propDesc.scalarValueType === 'object') return !equalObjectArrays(/*ptr.getValue(record), value*/); return !equalSimpleArrays(ptr.getValue(record), value); } if ...
javascript
function needsAdd(ptr, record, value) { const propDesc = ptr.propDesc; if (propDesc.isArray()) { if (ptr.collectionElement) return true; if (propDesc.scalarValueType === 'object') return !equalObjectArrays(/*ptr.getValue(record), value*/); return !equalSimpleArrays(ptr.getValue(record), value); } if ...
[ "function", "needsAdd", "(", "ptr", ",", "record", ",", "value", ")", "{", "const", "propDesc", "=", "ptr", ".", "propDesc", ";", "if", "(", "propDesc", ".", "isArray", "(", ")", ")", "{", "if", "(", "ptr", ".", "collectionElement", ")", "return", "t...
Tell if anything needs to be done to "add" the specified value at the specified by the pointer location in the specified record. @private @param {module:x2node-pointers~RecordElementPointer} ptr The pointer. @param {Object} record The record. @param {*} value The value. @returns {boolean} <code>true</code> if "add" pa...
[ "Tell", "if", "anything", "needs", "to", "be", "done", "to", "add", "the", "specified", "value", "at", "the", "specified", "by", "the", "pointer", "location", "in", "the", "specified", "record", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L137-L159
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
build
function build(recordTypes, recordTypeName, patch) { // get the record type descriptor if (!recordTypes.hasRecordType(recordTypeName)) throw new common.X2UsageError( `Unknown record type ${recordTypeName}.`); const recordTypeDesc = recordTypes.getRecordTypeDesc(recordTypeName); // make sure the patch spec is...
javascript
function build(recordTypes, recordTypeName, patch) { // get the record type descriptor if (!recordTypes.hasRecordType(recordTypeName)) throw new common.X2UsageError( `Unknown record type ${recordTypeName}.`); const recordTypeDesc = recordTypes.getRecordTypeDesc(recordTypeName); // make sure the patch spec is...
[ "function", "build", "(", "recordTypes", ",", "recordTypeName", ",", "patch", ")", "{", "// get the record type descriptor", "if", "(", "!", "recordTypes", ".", "hasRecordType", "(", "recordTypeName", ")", ")", "throw", "new", "common", ".", "X2UsageError", "(", ...
Build record patch object from JSON Patch specification. @function module:x2node-patches.build @param {module:x2node-records~RecordTypesLibrary} recordTypes Record types library. @param {string} recordTypeName Name of the record type, against records of which the patch will be applied. @param {Array.<Object>} patch RF...
[ "Build", "record", "patch", "object", "from", "JSON", "Patch", "specification", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L605-L626
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
buildMerge
function buildMerge(recordTypes, recordTypeName, mergePatch) { // only object merge patches are supported if (((typeof mergePatch) !== 'object') || (mergePatch === null)) throw new common.X2SyntaxError('Merge patch must be an object.'); // build JSON patch const jsonPatch = new Array(); buildMergeLevel('', mer...
javascript
function buildMerge(recordTypes, recordTypeName, mergePatch) { // only object merge patches are supported if (((typeof mergePatch) !== 'object') || (mergePatch === null)) throw new common.X2SyntaxError('Merge patch must be an object.'); // build JSON patch const jsonPatch = new Array(); buildMergeLevel('', mer...
[ "function", "buildMerge", "(", "recordTypes", ",", "recordTypeName", ",", "mergePatch", ")", "{", "// only object merge patches are supported", "if", "(", "(", "(", "typeof", "mergePatch", ")", "!==", "'object'", ")", "||", "(", "mergePatch", "===", "null", ")", ...
Build record patch object from Merge Patch specification. @function module:x2node-patches.buildMerge @param {module:x2node-records~RecordTypesLibrary} recordTypes Record types library. @param {string} recordTypeName Name of the record type, against records of which the patch will be applied. @param {Object} mergePatch...
[ "Build", "record", "patch", "object", "from", "Merge", "Patch", "specification", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L644-L656
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
buildMergeLevel
function buildMergeLevel(basePtr, levelMergePatch, jsonPatch) { for (let propName in levelMergePatch) { const mergeVal = levelMergePatch[propName]; const path = basePtr + '/' + propName; if (mergeVal === null) { jsonPatch.push({ op: 'remove', path: path }); } else if (Array.isArray(mergeVal)) { ...
javascript
function buildMergeLevel(basePtr, levelMergePatch, jsonPatch) { for (let propName in levelMergePatch) { const mergeVal = levelMergePatch[propName]; const path = basePtr + '/' + propName; if (mergeVal === null) { jsonPatch.push({ op: 'remove', path: path }); } else if (Array.isArray(mergeVal)) { ...
[ "function", "buildMergeLevel", "(", "basePtr", ",", "levelMergePatch", ",", "jsonPatch", ")", "{", "for", "(", "let", "propName", "in", "levelMergePatch", ")", "{", "const", "mergeVal", "=", "levelMergePatch", "[", "propName", "]", ";", "const", "path", "=", ...
Recusrively build JSON patch from Merge patch's nesting level. @private @param {string} basePtr Base JSON pointer for the nesting level. @param {Object} levelMergePatch Nested Merge patch for the level. @param {Array.<Object>} jsonPatch Resulting JSON patch specification array.
[ "Recusrively", "build", "JSON", "patch", "from", "Merge", "patch", "s", "nesting", "level", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L666-L699
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
resolvePropPointer
function resolvePropPointer(recordTypeDesc, propPointer, noDash, ptrUse) { // parse the pointer const ptr = pointers.parse(recordTypeDesc, propPointer, noDash); // check if top pointer if (ptr.isRoot()) throw new common.X2SyntaxError( 'Patch operations involving top records as a whole are not' + ' allowe...
javascript
function resolvePropPointer(recordTypeDesc, propPointer, noDash, ptrUse) { // parse the pointer const ptr = pointers.parse(recordTypeDesc, propPointer, noDash); // check if top pointer if (ptr.isRoot()) throw new common.X2SyntaxError( 'Patch operations involving top records as a whole are not' + ' allowe...
[ "function", "resolvePropPointer", "(", "recordTypeDesc", ",", "propPointer", ",", "noDash", ",", "ptrUse", ")", "{", "// parse the pointer", "const", "ptr", "=", "pointers", ".", "parse", "(", "recordTypeDesc", ",", "propPointer", ",", "noDash", ")", ";", "// ch...
Resolve property pointer. @private @param {module:x2node-records~RecordTypeDescriptor} recordTypeDesc Record type descriptor. @param {string} propPointer Property pointer. @param {boolean} noDash <code>true</code> if dash at the end of the array property pointer is disallowed (in the context of the patch operation). @...
[ "Resolve", "property", "pointer", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L838-L863
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
validatePatchOperationValue
function validatePatchOperationValue( recordTypes, opType, opInd, pathPtr, val, forUpdate) { // error function const validate = errMsg => { if (errMsg) throw new common.X2SyntaxError( `Invalid value in patch operation #${opInd + 1} (${opType}):` + ` ${errMsg}`); }; // check if we have the value if...
javascript
function validatePatchOperationValue( recordTypes, opType, opInd, pathPtr, val, forUpdate) { // error function const validate = errMsg => { if (errMsg) throw new common.X2SyntaxError( `Invalid value in patch operation #${opInd + 1} (${opType}):` + ` ${errMsg}`); }; // check if we have the value if...
[ "function", "validatePatchOperationValue", "(", "recordTypes", ",", "opType", ",", "opInd", ",", "pathPtr", ",", "val", ",", "forUpdate", ")", "{", "// error function", "const", "validate", "=", "errMsg", "=>", "{", "if", "(", "errMsg", ")", "throw", "new", ...
Validate value provided with a patch operation. @private @param {module:x2node-records~RecordTypesLibrary} recordTypes Record types library. @param {string} opType Patch operation type. @param {number} opInd Index of the patch operation in the list of operations. @param {module:x2node-pointers~RecordElementPointer} pa...
[ "Validate", "value", "provided", "with", "a", "patch", "operation", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L883-L955
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
isValidRefValue
function isValidRefValue(recordTypes, val, propDesc) { if ((typeof val) !== 'string') return false; const hashInd = val.indexOf('#'); if ((hashInd <= 0) || (hashInd === val.length - 1)) return false; const refTarget = val.substring(0, hashInd); if (refTarget !== propDesc.refTarget) return false; const r...
javascript
function isValidRefValue(recordTypes, val, propDesc) { if ((typeof val) !== 'string') return false; const hashInd = val.indexOf('#'); if ((hashInd <= 0) || (hashInd === val.length - 1)) return false; const refTarget = val.substring(0, hashInd); if (refTarget !== propDesc.refTarget) return false; const r...
[ "function", "isValidRefValue", "(", "recordTypes", ",", "val", ",", "propDesc", ")", "{", "if", "(", "(", "typeof", "val", ")", "!==", "'string'", ")", "return", "false", ";", "const", "hashInd", "=", "val", ".", "indexOf", "(", "'#'", ")", ";", "if", ...
Tell if the specified value is suitable to be the specified reference property's value. @private @param {module:x2node-records~RecordTypesLibrary} recordTypes Record types library. @param {*} val The value to test. @param {module:x2node-records~PropertyDescriptor} propDef Reference property descriptor. @returns {boole...
[ "Tell", "if", "the", "specified", "value", "is", "suitable", "to", "be", "the", "specified", "reference", "property", "s", "value", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L1025-L1047
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
isValidObjectValue
function isValidObjectValue(recordTypes, val, objectPropDesc, forUpdate) { const container = objectPropDesc.nestedProperties; for (let propName of container.allPropertyNames) { const propDesc = container.getPropertyDesc(propName); if (propDesc.isView() || propDesc.isCalculated()) continue; const propVal = v...
javascript
function isValidObjectValue(recordTypes, val, objectPropDesc, forUpdate) { const container = objectPropDesc.nestedProperties; for (let propName of container.allPropertyNames) { const propDesc = container.getPropertyDesc(propName); if (propDesc.isView() || propDesc.isCalculated()) continue; const propVal = v...
[ "function", "isValidObjectValue", "(", "recordTypes", ",", "val", ",", "objectPropDesc", ",", "forUpdate", ")", "{", "const", "container", "=", "objectPropDesc", ".", "nestedProperties", ";", "for", "(", "let", "propName", "of", "container", ".", "allPropertyNames...
Tell if the specified object is suitable to be a value for the specified nested object property. @private @param {module:x2node-records~RecordTypesLibrary} recordTypes Record types library. @param {Object} val The object to test. May not be <code>null</code> nor <code>undefined</code>. @param {module:x2node-records~Pr...
[ "Tell", "if", "the", "specified", "object", "is", "suitable", "to", "be", "a", "value", "for", "the", "specified", "nested", "object", "property", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L1065-L1103
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
validatePatchOperationFrom
function validatePatchOperationFrom(opType, opInd, pathPtr, fromPtr, forMove) { const invalidFrom = msg => new common.X2SyntaxError( `Invalid "from" pointer in patch operation #${opInd + 1} (${opType}):` + ` ${msg}`); if (forMove && pathPtr.isChildOf(fromPtr)) throw invalidFrom('may not move location into on...
javascript
function validatePatchOperationFrom(opType, opInd, pathPtr, fromPtr, forMove) { const invalidFrom = msg => new common.X2SyntaxError( `Invalid "from" pointer in patch operation #${opInd + 1} (${opType}):` + ` ${msg}`); if (forMove && pathPtr.isChildOf(fromPtr)) throw invalidFrom('may not move location into on...
[ "function", "validatePatchOperationFrom", "(", "opType", ",", "opInd", ",", "pathPtr", ",", "fromPtr", ",", "forMove", ")", "{", "const", "invalidFrom", "=", "msg", "=>", "new", "common", ".", "X2SyntaxError", "(", "`", "${", "opInd", "+", "1", "}", "${", ...
Validate "from" property provided with a patch operation. @private @param {string} opType Patch operation type. @param {number} opInd Index of the patch operation in the list of operations. @param {module:x2node-pointers~RecordElementPointer} pathPtr Information object for the property path where the "from" property i...
[ "Validate", "from", "property", "provided", "with", "a", "patch", "operation", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L1122-L1154
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
isCompatibleObjects
function isCompatibleObjects(objectPropDesc1, objectPropDesc2) { const propNames2 = new Set(objectPropDesc2.allPropertyNames); const container1 = objectPropDesc1.nestedProperties; const container2 = objectPropDesc2.nestedProperties; for (let propName of objectPropDesc1.allPropertyNames) { const propDesc1 = conta...
javascript
function isCompatibleObjects(objectPropDesc1, objectPropDesc2) { const propNames2 = new Set(objectPropDesc2.allPropertyNames); const container1 = objectPropDesc1.nestedProperties; const container2 = objectPropDesc2.nestedProperties; for (let propName of objectPropDesc1.allPropertyNames) { const propDesc1 = conta...
[ "function", "isCompatibleObjects", "(", "objectPropDesc1", ",", "objectPropDesc2", ")", "{", "const", "propNames2", "=", "new", "Set", "(", "objectPropDesc2", ".", "allPropertyNames", ")", ";", "const", "container1", "=", "objectPropDesc1", ".", "nestedProperties", ...
Tell if a value of the nested object property 2 can be used as a value of the nested object property 1. @private @param {module:x2node-records~PropertyDescriptor} objectPropDesc1 Nested object property 1. @param {module:x2node-records~PropertyDescriptor} objectPropDesc2 Nested object property 2. @returns {boolean} <co...
[ "Tell", "if", "a", "value", "of", "the", "nested", "object", "property", "2", "can", "be", "used", "as", "a", "value", "of", "the", "nested", "object", "property", "1", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L1167-L1205
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
addInvolvedProperty
function addInvolvedProperty(pathPtr, involvedPropPaths, updatedPropPaths) { if (updatedPropPaths) { const propPathParts = pathPtr.propPath.split('.'); let propPath = ''; for (let i = 0, len = propPathParts.length - 1; i < len; i++) { if (propPath.length > 0) propPath += '.'; propPath += propPathParts...
javascript
function addInvolvedProperty(pathPtr, involvedPropPaths, updatedPropPaths) { if (updatedPropPaths) { const propPathParts = pathPtr.propPath.split('.'); let propPath = ''; for (let i = 0, len = propPathParts.length - 1; i < len; i++) { if (propPath.length > 0) propPath += '.'; propPath += propPathParts...
[ "function", "addInvolvedProperty", "(", "pathPtr", ",", "involvedPropPaths", ",", "updatedPropPaths", ")", "{", "if", "(", "updatedPropPaths", ")", "{", "const", "propPathParts", "=", "pathPtr", ".", "propPath", ".", "split", "(", "'.'", ")", ";", "let", "prop...
Add property to the involved property paths collection. @private @param {module:x2node-pointers~RecordElementPointer} pathPtr Resolved property pointer. @param {Set.<string>} involvedPropPaths Involved property paths collection. @param {Set.<string>} [updatedPropPaths] Updated property paths collection if the involved...
[ "Add", "property", "to", "the", "involved", "property", "paths", "collection", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L1219-L1242
train
boylesoftware/x2node-patches
lib/record-patch-builder.js
addInvolvedObjectProperty
function addInvolvedObjectProperty( objectPropDesc, involvedPropPaths, updatedPropPaths) { if (updatedPropPaths) updatedPropPaths.add( objectPropDesc.container.nestedPath + objectPropDesc.name); const container = objectPropDesc.nestedProperties; for (let propName of container.allPropertyNames) { const prop...
javascript
function addInvolvedObjectProperty( objectPropDesc, involvedPropPaths, updatedPropPaths) { if (updatedPropPaths) updatedPropPaths.add( objectPropDesc.container.nestedPath + objectPropDesc.name); const container = objectPropDesc.nestedProperties; for (let propName of container.allPropertyNames) { const prop...
[ "function", "addInvolvedObjectProperty", "(", "objectPropDesc", ",", "involvedPropPaths", ",", "updatedPropPaths", ")", "{", "if", "(", "updatedPropPaths", ")", "updatedPropPaths", ".", "add", "(", "objectPropDesc", ".", "container", ".", "nestedPath", "+", "objectPro...
Recursively add nested object property to the involved property paths collection. @private @param {module:x2node-records~PropertyDescriptor} objectPropDesc Nested object property descriptor. @param {Set.<string>} involvedPropPaths Involved property paths collection. @param {Set.<string>} [updatedPropPaths] Updated pro...
[ "Recursively", "add", "nested", "object", "property", "to", "the", "involved", "property", "paths", "collection", "." ]
59debdb270c899bcca3f330217b68e2f746d9646
https://github.com/boylesoftware/x2node-patches/blob/59debdb270c899bcca3f330217b68e2f746d9646/lib/record-patch-builder.js#L1255-L1277
train
soimy/arabic-persian-reshaper
index.js
convertArabicBack
function convertArabicBack(apfb) { var toReturn = "", selectedChar; theLoop: for( var i = 0 ; i < apfb.length ; ++i ) { selectedChar = apfb.charCodeAt(i); for( var j = 0 ; j < charsMap.length ; ++j ) { if( charsMap[j][4] == selectedChar || charsMap[j][2] == selectedChar || charsMap[j][1] == selected...
javascript
function convertArabicBack(apfb) { var toReturn = "", selectedChar; theLoop: for( var i = 0 ; i < apfb.length ; ++i ) { selectedChar = apfb.charCodeAt(i); for( var j = 0 ; j < charsMap.length ; ++j ) { if( charsMap[j][4] == selectedChar || charsMap[j][2] == selectedChar || charsMap[j][1] == selected...
[ "function", "convertArabicBack", "(", "apfb", ")", "{", "var", "toReturn", "=", "\"\"", ",", "selectedChar", ";", "theLoop", ":", "for", "(", "var", "i", "=", "0", ";", "i", "<", "apfb", ".", "length", ";", "++", "i", ")", "{", "selectedChar", "=", ...
convert from Arabic Presentation Forms B
[ "convert", "from", "Arabic", "Presentation", "Forms", "B" ]
ce8bc48d61f9290f07f720bcf474db425f0de1de
https://github.com/soimy/arabic-persian-reshaper/blob/ce8bc48d61f9290f07f720bcf474db425f0de1de/index.js#L211-L238
train
thlorenz/files-provider
files-provider.js
createFilesProvider
function createFilesProvider({ regex = null , single = HANDLE , multi = PROMPT_AND_HANDLE , choiceAll = true , handler = null , promptHeader = defaultPromptHeader , promptFooter = defaultPromptFooter } = {}) { return new FilesProvider({ regex , single , multi , choice...
javascript
function createFilesProvider({ regex = null , single = HANDLE , multi = PROMPT_AND_HANDLE , choiceAll = true , handler = null , promptHeader = defaultPromptHeader , promptFooter = defaultPromptFooter } = {}) { return new FilesProvider({ regex , single , multi , choice...
[ "function", "createFilesProvider", "(", "{", "regex", "=", "null", ",", "single", "=", "HANDLE", ",", "multi", "=", "PROMPT_AND_HANDLE", ",", "choiceAll", "=", "true", ",", "handler", "=", "null", ",", "promptHeader", "=", "defaultPromptHeader", ",", "promptFo...
Creates a FilesProvider @param {Object} $0 options @param {RegExp} $0.regex the regex to match the files with @param {Number} [$0.single = PROMPT] strategy for handling a single file `HANDLE|RETURN` @param {Number} [$0.multi = PROMPT_AND_HANDLE] strategy for handling multiple files `HANDLE|PROMPT|RETURN|PROMPT_AND_HAN...
[ "Creates", "a", "FilesProvider" ]
ad6ca193ff612a00b480e8d2d05dc46880708c83
https://github.com/thlorenz/files-provider/blob/ad6ca193ff612a00b480e8d2d05dc46880708c83/files-provider.js#L171-L189
train
szanata/full_stack
lib/full_stack.js
prepareStackTrace
function prepareStackTrace( error, structuredStackTrace ) { // If error already have a cached trace inside, just return that // happens on true errors most if ( error.__cachedTrace ) { return error.__cachedTrace; } const stackTrace = utils.createStackTrace( error, structuredStackTrace ); error.__cachedTrace ...
javascript
function prepareStackTrace( error, structuredStackTrace ) { // If error already have a cached trace inside, just return that // happens on true errors most if ( error.__cachedTrace ) { return error.__cachedTrace; } const stackTrace = utils.createStackTrace( error, structuredStackTrace ); error.__cachedTrace ...
[ "function", "prepareStackTrace", "(", "error", ",", "structuredStackTrace", ")", "{", "// If error already have a cached trace inside, just return that", "// happens on true errors most", "if", "(", "error", ".", "__cachedTrace", ")", "{", "return", "error", ".", "__cachedTra...
Custom prepareStackTrace preparation, to be used on place o of the native @param {Error} error Error being used as start point for the stack @param {Callsite[]} structuredStackTrace Array of Callsites, which are previous stests from a stack trace, in a native object format
[ "Custom", "prepareStackTrace", "preparation", "to", "be", "used", "on", "place", "o", "of", "the", "native" ]
e9f3150219f4194def31e5a5175010536c0d9288
https://github.com/szanata/full_stack/blob/e9f3150219f4194def31e5a5175010536c0d9288/lib/full_stack.js#L28-L48
train
szanata/full_stack
lib/full_stack.js
wrapCallback
function wrapCallback( fn, frameLocation ) { const traceError = new Error(); traceError.__location = frameLocation; traceError.__previous = currentTraceError; return function $wrappedCallback( ...args ) { currentTraceError = traceError; try { return fn.call( this, ...args ); } catch ( e ) { ...
javascript
function wrapCallback( fn, frameLocation ) { const traceError = new Error(); traceError.__location = frameLocation; traceError.__previous = currentTraceError; return function $wrappedCallback( ...args ) { currentTraceError = traceError; try { return fn.call( this, ...args ); } catch ( e ) { ...
[ "function", "wrapCallback", "(", "fn", ",", "frameLocation", ")", "{", "const", "traceError", "=", "new", "Error", "(", ")", ";", "traceError", ".", "__location", "=", "frameLocation", ";", "traceError", ".", "__previous", "=", "currentTraceError", ";", "retur...
Wrap given callback access its original trace @param {function} fn Callback function @param {String} frameLocation Code point where this callback was called. Eg. "MyClass.method"
[ "Wrap", "given", "callback", "access", "its", "original", "trace" ]
e9f3150219f4194def31e5a5175010536c0d9288
https://github.com/szanata/full_stack/blob/e9f3150219f4194def31e5a5175010536c0d9288/lib/full_stack.js#L56-L71
train
szanata/full_stack
lib/full_stack.js
$wrapped
function $wrapped( ...args ) { const wrappedArgs = args.slice(); args.forEach( ( arg, i ) => { if ( typeof arg === 'function' ) { wrappedArgs[i] = wrapCallback( args[i], origin ); } } ); return method.call( this, ...wrappedArgs ); }
javascript
function $wrapped( ...args ) { const wrappedArgs = args.slice(); args.forEach( ( arg, i ) => { if ( typeof arg === 'function' ) { wrappedArgs[i] = wrapCallback( args[i], origin ); } } ); return method.call( this, ...wrappedArgs ); }
[ "function", "$wrapped", "(", "...", "args", ")", "{", "const", "wrappedArgs", "=", "args", ".", "slice", "(", ")", ";", "args", ".", "forEach", "(", "(", "arg", ",", "i", ")", "=>", "{", "if", "(", "typeof", "arg", "===", "'function'", ")", "{", ...
return a wrapped version of given object method
[ "return", "a", "wrapped", "version", "of", "given", "object", "method" ]
e9f3150219f4194def31e5a5175010536c0d9288
https://github.com/szanata/full_stack/blob/e9f3150219f4194def31e5a5175010536c0d9288/lib/full_stack.js#L100-L110
train
kuno/neco
deps/npm/lib/cache.js
ls_
function ls_ (req, depth, cb) { if (typeof cb !== "function") cb = depth, depth = 1 mkdir(npm.cache, function (er) { if (er) return log.er(cb, "no cache dir")(er) function dirFilter (f, type) { return type !== "dir" || ( f && f !== npm.cache + "/" + req && f !== npm.cache + "/" + req ...
javascript
function ls_ (req, depth, cb) { if (typeof cb !== "function") cb = depth, depth = 1 mkdir(npm.cache, function (er) { if (er) return log.er(cb, "no cache dir")(er) function dirFilter (f, type) { return type !== "dir" || ( f && f !== npm.cache + "/" + req && f !== npm.cache + "/" + req ...
[ "function", "ls_", "(", "req", ",", "depth", ",", "cb", ")", "{", "if", "(", "typeof", "cb", "!==", "\"function\"", ")", "cb", "=", "depth", ",", "depth", "=", "1", "mkdir", "(", "npm", ".", "cache", ",", "function", "(", "er", ")", "{", "if", ...
Calls cb with list of cached pkgs matching show.
[ "Calls", "cb", "with", "list", "of", "cached", "pkgs", "matching", "show", "." ]
cf6361c1fcb9466c6b2ab3b127b5d0160ca50735
https://github.com/kuno/neco/blob/cf6361c1fcb9466c6b2ab3b127b5d0160ca50735/deps/npm/lib/cache.js#L139-L158
train
alexindigo/executioner
lib/parse.js
parse
function parse(cmd, params) { return Object.keys(params).reduce(iterator.bind(this, params), cmd); }
javascript
function parse(cmd, params) { return Object.keys(params).reduce(iterator.bind(this, params), cmd); }
[ "function", "parse", "(", "cmd", ",", "params", ")", "{", "return", "Object", ".", "keys", "(", "params", ")", ".", "reduce", "(", "iterator", ".", "bind", "(", "this", ",", "params", ")", ",", "cmd", ")", ";", "}" ]
Parses command and updated with provided parameters @param {string} cmd - command template @param {object} params - list of parameters @returns {string} - updated command
[ "Parses", "command", "and", "updated", "with", "provided", "parameters" ]
582f92897f47c13f4531e0b692aebb4a9f134eec
https://github.com/alexindigo/executioner/blob/582f92897f47c13f4531e0b692aebb4a9f134eec/lib/parse.js#L11-L14
train
alexindigo/executioner
lib/parse.js
iterator
function iterator(params, cmd, p) { var value = params[p]; // shortcut if (!cmd) return cmd; // fold booleans into strings accepted by shell if (typeof value == 'boolean') { value = value ? '1' : ''; } if (value !== null && ['undefined', 'string', 'number'].indexOf(typeof value) == -1) { //...
javascript
function iterator(params, cmd, p) { var value = params[p]; // shortcut if (!cmd) return cmd; // fold booleans into strings accepted by shell if (typeof value == 'boolean') { value = value ? '1' : ''; } if (value !== null && ['undefined', 'string', 'number'].indexOf(typeof value) == -1) { //...
[ "function", "iterator", "(", "params", ",", "cmd", ",", "p", ")", "{", "var", "value", "=", "params", "[", "p", "]", ";", "// shortcut", "if", "(", "!", "cmd", ")", "return", "cmd", ";", "// fold booleans into strings accepted by shell", "if", "(", "typeof...
Iterator over params elements @param {object} params - list of parameters @param {string} cmd - command template @param {string} p - parameter key @returns {string} - updated command or empty string if one of the params didn't pass the filter
[ "Iterator", "over", "params", "elements" ]
582f92897f47c13f4531e0b692aebb4a9f134eec
https://github.com/alexindigo/executioner/blob/582f92897f47c13f4531e0b692aebb4a9f134eec/lib/parse.js#L25-L46
train
boylesoftware/x2node-dbos
lib/props-tree-builder.js
buildPropsTreeBranches
function buildPropsTreeBranches( recordTypes, topPropDesc, clause, baseValueExprCtx, scopePropPath, propPatterns, options) { // create the branching tree top node const topNode = PropertyTreeNode.createTopNode( recordTypes, topPropDesc, baseValueExprCtx, clause); // add direct patterns const valuePropsTrees =...
javascript
function buildPropsTreeBranches( recordTypes, topPropDesc, clause, baseValueExprCtx, scopePropPath, propPatterns, options) { // create the branching tree top node const topNode = PropertyTreeNode.createTopNode( recordTypes, topPropDesc, baseValueExprCtx, clause); // add direct patterns const valuePropsTrees =...
[ "function", "buildPropsTreeBranches", "(", "recordTypes", ",", "topPropDesc", ",", "clause", ",", "baseValueExprCtx", ",", "scopePropPath", ",", "propPatterns", ",", "options", ")", "{", "// create the branching tree top node", "const", "topNode", "=", "PropertyTreeNode",...
Build properties tree from a list of property path patterns and debranch it. @protected @param {module:x2node-records~RecordTypesLibrary} recordTypes Record types library. @param {module:x2node-records~PropertyDescriptor} topPropDesc Descriptor of the top property in the resulting tree. For example, when the tree is b...
[ "Build", "properties", "tree", "from", "a", "list", "of", "property", "path", "patterns", "and", "debranch", "it", "." ]
d7b847d859b79dce0c46e04788201e05d5a70886
https://github.com/boylesoftware/x2node-dbos/blob/d7b847d859b79dce0c46e04788201e05d5a70886/lib/props-tree-builder.js#L720-L779
train
boylesoftware/x2node-dbos
lib/props-tree-builder.js
buildSuperPropsTreeBranches
function buildSuperPropsTreeBranches( recordTypes, recordTypeDesc, superPropNames) { // create the branching tree top node const topNode = PropertyTreeNode.createTopNode( recordTypes, { isScalar() { return true; }, isCalculated() { return false; }, refTarget: recordTypeDesc.superRecordTypeName }, new...
javascript
function buildSuperPropsTreeBranches( recordTypes, recordTypeDesc, superPropNames) { // create the branching tree top node const topNode = PropertyTreeNode.createTopNode( recordTypes, { isScalar() { return true; }, isCalculated() { return false; }, refTarget: recordTypeDesc.superRecordTypeName }, new...
[ "function", "buildSuperPropsTreeBranches", "(", "recordTypes", ",", "recordTypeDesc", ",", "superPropNames", ")", "{", "// create the branching tree top node", "const", "topNode", "=", "PropertyTreeNode", ".", "createTopNode", "(", "recordTypes", ",", "{", "isScalar", "("...
Build properties tree for a super-properties query and debranch it. @protected @param {module:x2node-records~RecordTypesLibrary} recordTypes Record types library. @param {module:x2node-records~RecordTypeDescriptor} recordTypeDesc Record type descriptor. @param {Iterable.<string>} superPropName Selected super-property ...
[ "Build", "properties", "tree", "for", "a", "super", "-", "properties", "query", "and", "debranch", "it", "." ]
d7b847d859b79dce0c46e04788201e05d5a70886
https://github.com/boylesoftware/x2node-dbos/blob/d7b847d859b79dce0c46e04788201e05d5a70886/lib/props-tree-builder.js#L795-L827
train
boylesoftware/x2node-dbos
lib/props-tree-builder.js
buildSimplePropsTree
function buildSimplePropsTree( recordTypes, topPropDesc, clause, baseValueExprCtx, propPaths) { // create the branching tree top node const topNode = PropertyTreeNode.createTopNode( recordTypes, topPropDesc, baseValueExprCtx, clause); // add properties const valuePropsTrees = new Map(); const options = { ig...
javascript
function buildSimplePropsTree( recordTypes, topPropDesc, clause, baseValueExprCtx, propPaths) { // create the branching tree top node const topNode = PropertyTreeNode.createTopNode( recordTypes, topPropDesc, baseValueExprCtx, clause); // add properties const valuePropsTrees = new Map(); const options = { ig...
[ "function", "buildSimplePropsTree", "(", "recordTypes", ",", "topPropDesc", ",", "clause", ",", "baseValueExprCtx", ",", "propPaths", ")", "{", "// create the branching tree top node", "const", "topNode", "=", "PropertyTreeNode", ".", "createTopNode", "(", "recordTypes", ...
Build possibly branching properties tree assuming no side-value trees are involved. @protected @param {module:x2node-records~RecordTypesLibrary} recordTypes Record types library. @param {module:x2node-records~PropertyDescriptor} topPropDesc Descriptor of the top property in the resulting tree. For example, when the tr...
[ "Build", "possibly", "branching", "properties", "tree", "assuming", "no", "side", "-", "value", "trees", "are", "involved", "." ]
d7b847d859b79dce0c46e04788201e05d5a70886
https://github.com/boylesoftware/x2node-dbos/blob/d7b847d859b79dce0c46e04788201e05d5a70886/lib/props-tree-builder.js#L852-L876
train
boylesoftware/x2node-dbos
lib/props-tree-builder.js
addProperty
function addProperty( topNode, scopePropPath, propPattern, clause, options, valuePropsTrees, wcPatterns) { // process the pattern parts let expandChildren = false; const propPatternParts = propPattern.split('.'); const numParts = propPatternParts.length; let parentNode = topNode; let patternPrefix = topNode.pa...
javascript
function addProperty( topNode, scopePropPath, propPattern, clause, options, valuePropsTrees, wcPatterns) { // process the pattern parts let expandChildren = false; const propPatternParts = propPattern.split('.'); const numParts = propPatternParts.length; let parentNode = topNode; let patternPrefix = topNode.pa...
[ "function", "addProperty", "(", "topNode", ",", "scopePropPath", ",", "propPattern", ",", "clause", ",", "options", ",", "valuePropsTrees", ",", "wcPatterns", ")", "{", "// process the pattern parts", "let", "expandChildren", "=", "false", ";", "const", "propPattern...
Add property to the properties tree. @private @param {module:x2node-dbos~PropertyTreeNode} topNode Top node of the properties tree. @param {?string} scopeColPath Path of the scope collection property. If provided, the pattern may only belong to the scope collection property's axis. @param {string} propPattern Property...
[ "Add", "property", "to", "the", "properties", "tree", "." ]
d7b847d859b79dce0c46e04788201e05d5a70886
https://github.com/boylesoftware/x2node-dbos/blob/d7b847d859b79dce0c46e04788201e05d5a70886/lib/props-tree-builder.js#L897-L988
train
hash-bang/Node-Mongoose-Scenario
index.js
function(model, options, finish) { var asyncCreator = async() // Task runner that actually creates all the Mongo records // Deal with timeout errors (usually unsolvable circular references) {{{ .timeout(settings.timeout || 2000, function() { var taskIDs = {}; var remaining = this._struct // Prepare a loo...
javascript
function(model, options, finish) { var asyncCreator = async() // Task runner that actually creates all the Mongo records // Deal with timeout errors (usually unsolvable circular references) {{{ .timeout(settings.timeout || 2000, function() { var taskIDs = {}; var remaining = this._struct // Prepare a loo...
[ "function", "(", "model", ",", "options", ",", "finish", ")", "{", "var", "asyncCreator", "=", "async", "(", ")", "// Task runner that actually creates all the Mongo records", "// Deal with timeout errors (usually unsolvable circular references) {{{", ".", "timeout", "(", "se...
Import a scenario file into a Mongo database A scenario must be complete - i.e. have no dangling references for it to suceed @param {Object} model The scenario to create - expected format is a hash of collection names each containing a collection of records (e.g. `{users: [{name: 'user1'}, {name: 'user2'}] }`) @param {...
[ "Import", "a", "scenario", "file", "into", "a", "Mongo", "database", "A", "scenario", "must", "be", "complete", "-", "i", ".", "e", ".", "have", "no", "dangling", "references", "for", "it", "to", "suceed" ]
e50ed7f2f420fb0df317c1ef1b5262fd354c4b78
https://github.com/hash-bang/Node-Mongoose-Scenario/blob/e50ed7f2f420fb0df317c1ef1b5262fd354c4b78/index.js#L63-L206
train
hash-bang/Node-Mongoose-Scenario
index.js
extractFKs
function extractFKs(schema) { var FKs = {}; _.forEach(schema.paths, function(path, id) { if (id == 'id' || id == '_id') { // Pass } else if (path.instance && path.instance == 'ObjectID') { FKs[id] = {type: FK_OBJECTID}; } else if (path.caster && path.caster.instance == 'ObjectID') { // Array of ObjectIDs...
javascript
function extractFKs(schema) { var FKs = {}; _.forEach(schema.paths, function(path, id) { if (id == 'id' || id == '_id') { // Pass } else if (path.instance && path.instance == 'ObjectID') { FKs[id] = {type: FK_OBJECTID}; } else if (path.caster && path.caster.instance == 'ObjectID') { // Array of ObjectIDs...
[ "function", "extractFKs", "(", "schema", ")", "{", "var", "FKs", "=", "{", "}", ";", "_", ".", "forEach", "(", "schema", ".", "paths", ",", "function", "(", "path", ",", "id", ")", "{", "if", "(", "id", "==", "'id'", "||", "id", "==", "'_id'", ...
Extract the FK relationship from a Mongo document @param {Object} schema The schema object to examine (usually connection.base.models[model].schema) @return {Object} A dictionary of foreign keys for the schema
[ "Extract", "the", "FK", "relationship", "from", "a", "Mongo", "document" ]
e50ed7f2f420fb0df317c1ef1b5262fd354c4b78
https://github.com/hash-bang/Node-Mongoose-Scenario/blob/e50ed7f2f420fb0df317c1ef1b5262fd354c4b78/index.js#L214-L233
train
hash-bang/Node-Mongoose-Scenario
index.js
injectFKs
function injectFKs(row, fks) { _.forEach(fks, function(fk, id) { if (!_.has(row, id)) return; // Skip omitted FK refs var lookupKey = _.get(row, id); switch (fk.type) { case FK_OBJECTID: // 1:1 relationship if (!settings.refs[lookupKey]) throw new Error('Attempting to inject non-existant reference "...
javascript
function injectFKs(row, fks) { _.forEach(fks, function(fk, id) { if (!_.has(row, id)) return; // Skip omitted FK refs var lookupKey = _.get(row, id); switch (fk.type) { case FK_OBJECTID: // 1:1 relationship if (!settings.refs[lookupKey]) throw new Error('Attempting to inject non-existant reference "...
[ "function", "injectFKs", "(", "row", ",", "fks", ")", "{", "_", ".", "forEach", "(", "fks", ",", "function", "(", "fk", ",", "id", ")", "{", "if", "(", "!", "_", ".", "has", "(", "row", ",", "id", ")", ")", "return", ";", "// Skip omitted FK refs...
Inject foreign keys into a row before it gets passed to Mongo for insert @param {Object} row The row that will be inserted - values will be replaced inline @param {Object} fks The foreign keys for the given row (extacted via extractFKs) @see extractFKs()
[ "Inject", "foreign", "keys", "into", "a", "row", "before", "it", "gets", "passed", "to", "Mongo", "for", "insert" ]
e50ed7f2f420fb0df317c1ef1b5262fd354c4b78
https://github.com/hash-bang/Node-Mongoose-Scenario/blob/e50ed7f2f420fb0df317c1ef1b5262fd354c4b78/index.js#L241-L266
train
hash-bang/Node-Mongoose-Scenario
index.js
determineFKs
function determineFKs(row, fks) { var refs = []; _.forEach(fks, function(fk, id) { if (row[id] === undefined) return; // Skip omitted FK refs switch (fk.type) { case FK_OBJECTID: // 1:1 relationship refs.push(row[id]); break; case FK_OBJECTID_ARRAY: // 1:M array based relationship _.forEach(ro...
javascript
function determineFKs(row, fks) { var refs = []; _.forEach(fks, function(fk, id) { if (row[id] === undefined) return; // Skip omitted FK refs switch (fk.type) { case FK_OBJECTID: // 1:1 relationship refs.push(row[id]); break; case FK_OBJECTID_ARRAY: // 1:M array based relationship _.forEach(ro...
[ "function", "determineFKs", "(", "row", ",", "fks", ")", "{", "var", "refs", "=", "[", "]", ";", "_", ".", "forEach", "(", "fks", ",", "function", "(", "fk", ",", "id", ")", "{", "if", "(", "row", "[", "id", "]", "===", "undefined", ")", "retur...
Get an array of required foreign keys values so we can calculate the dependency tree @param {Object} row The row that will be inserted @param {Object} fks The foreign keys for the given row (extacted via extractFKs) @see extractFKs() @return {array} An array of required references
[ "Get", "an", "array", "of", "required", "foreign", "keys", "values", "so", "we", "can", "calculate", "the", "dependency", "tree" ]
e50ed7f2f420fb0df317c1ef1b5262fd354c4b78
https://github.com/hash-bang/Node-Mongoose-Scenario/blob/e50ed7f2f420fb0df317c1ef1b5262fd354c4b78/index.js#L275-L301
train
hash-bang/Node-Mongoose-Scenario
index.js
unflatten
function unflatten(obj) { var out = {}; _.forEach(obj, function(v, k) { _.set(out, k, v); }); return out; }
javascript
function unflatten(obj) { var out = {}; _.forEach(obj, function(v, k) { _.set(out, k, v); }); return out; }
[ "function", "unflatten", "(", "obj", ")", "{", "var", "out", "=", "{", "}", ";", "_", ".", "forEach", "(", "obj", ",", "function", "(", "v", ",", "k", ")", "{", "_", ".", "set", "(", "out", ",", "k", ",", "v", ")", ";", "}", ")", ";", "re...
Take a flattened object and return a nested object @param {Object} obj The flattened object @return {Object} The unflattened object
[ "Take", "a", "flattened", "object", "and", "return", "a", "nested", "object" ]
e50ed7f2f420fb0df317c1ef1b5262fd354c4b78
https://github.com/hash-bang/Node-Mongoose-Scenario/blob/e50ed7f2f420fb0df317c1ef1b5262fd354c4b78/index.js#L332-L338
train
hash-bang/Node-Mongoose-Scenario
index.js
createRow
function createRow(collection, id, row, callback) { injectFKs(row, settings.knownFK[collection]); // build up list of all sub-document _ref's that we need to find in the newly saved document // this is to ensure we capture _id from inside nested array documents that do not exist at root level var refsMeta = []; t...
javascript
function createRow(collection, id, row, callback) { injectFKs(row, settings.knownFK[collection]); // build up list of all sub-document _ref's that we need to find in the newly saved document // this is to ensure we capture _id from inside nested array documents that do not exist at root level var refsMeta = []; t...
[ "function", "createRow", "(", "collection", ",", "id", ",", "row", ",", "callback", ")", "{", "injectFKs", "(", "row", ",", "settings", ".", "knownFK", "[", "collection", "]", ")", ";", "// build up list of all sub-document _ref's that we need to find in the newly sav...
Create a single row in a collection @param {string} collection The collection where to create the row @param {string} id The ID of the row (if any) @param {Object} row The (flattened) row contents to create @param {function} callback(err) Callback to chainable async function
[ "Create", "a", "single", "row", "in", "a", "collection" ]
e50ed7f2f420fb0df317c1ef1b5262fd354c4b78
https://github.com/hash-bang/Node-Mongoose-Scenario/blob/e50ed7f2f420fb0df317c1ef1b5262fd354c4b78/index.js#L348-L387
train
overlookmotel/bluebird-extra
lib/extensions.js
function(arr, iterator) { if (typeof iterator !== 'function') return apiRejection('iterator must be a function'); var self = this; var i = 0; return Promise.resolve().then(function iterate() { if (i == arr.length) return; return Promise.resolve(iterator.call(self, arr[i])) .then(function(resul...
javascript
function(arr, iterator) { if (typeof iterator !== 'function') return apiRejection('iterator must be a function'); var self = this; var i = 0; return Promise.resolve().then(function iterate() { if (i == arr.length) return; return Promise.resolve(iterator.call(self, arr[i])) .then(function(resul...
[ "function", "(", "arr", ",", "iterator", ")", "{", "if", "(", "typeof", "iterator", "!==", "'function'", ")", "return", "apiRejection", "(", "'iterator must be a function'", ")", ";", "var", "self", "=", "this", ";", "var", "i", "=", "0", ";", "return", ...
run iterator on each item in array in series return first result from iterator that is not undefined
[ "run", "iterator", "on", "each", "item", "in", "array", "in", "series", "return", "first", "result", "from", "iterator", "that", "is", "not", "undefined" ]
b6b1aa8e8a72edab34364e2059cf2ec270b8b455
https://github.com/overlookmotel/bluebird-extra/blob/b6b1aa8e8a72edab34364e2059cf2ec270b8b455/lib/extensions.js#L74-L90
train
overlookmotel/bluebird-extra
lib/extensions.js
function(value, ifFn, elseFn) { if ((ifFn && typeof ifFn !== 'function') || (elseFn && typeof elseFn !== 'function')) return apiRejection('ifFn and elseFn must be functions'); var fn = value ? ifFn : elseFn; if (!fn) return Promise.resolve(value); return Promise.resolve(fn.call(this, value)); }
javascript
function(value, ifFn, elseFn) { if ((ifFn && typeof ifFn !== 'function') || (elseFn && typeof elseFn !== 'function')) return apiRejection('ifFn and elseFn must be functions'); var fn = value ? ifFn : elseFn; if (!fn) return Promise.resolve(value); return Promise.resolve(fn.call(this, value)); }
[ "function", "(", "value", ",", "ifFn", ",", "elseFn", ")", "{", "if", "(", "(", "ifFn", "&&", "typeof", "ifFn", "!==", "'function'", ")", "||", "(", "elseFn", "&&", "typeof", "elseFn", "!==", "'function'", ")", ")", "return", "apiRejection", "(", "'ifF...
if value is truthy, run ifFn, otherwise run elseFn returns value for whichever function is run
[ "if", "value", "is", "truthy", "run", "ifFn", "otherwise", "run", "elseFn", "returns", "value", "for", "whichever", "function", "is", "run" ]
b6b1aa8e8a72edab34364e2059cf2ec270b8b455
https://github.com/overlookmotel/bluebird-extra/blob/b6b1aa8e8a72edab34364e2059cf2ec270b8b455/lib/extensions.js#L94-L101
train
owstack/ows-common
lib/buffer.js
fill
function fill(buffer, value) { $.checkArgumentType(buffer, 'Buffer', 'buffer'); $.checkArgumentType(value, 'number', 'value'); var length = buffer.length; for (var i = 0; i < length; i++) { buffer[i] = value; } return buffer; }
javascript
function fill(buffer, value) { $.checkArgumentType(buffer, 'Buffer', 'buffer'); $.checkArgumentType(value, 'number', 'value'); var length = buffer.length; for (var i = 0; i < length; i++) { buffer[i] = value; } return buffer; }
[ "function", "fill", "(", "buffer", ",", "value", ")", "{", "$", ".", "checkArgumentType", "(", "buffer", ",", "'Buffer'", ",", "'buffer'", ")", ";", "$", ".", "checkArgumentType", "(", "value", ",", "'number'", ",", "'value'", ")", ";", "var", "length", ...
Fill a buffer with a value. @param {Buffer} buffer @param {number} value @return {Buffer}
[ "Fill", "a", "buffer", "with", "a", "value", "." ]
aa2a7970547cf451c06e528472ee965d3b4cac36
https://github.com/owstack/ows-common/blob/aa2a7970547cf451c06e528472ee965d3b4cac36/lib/buffer.js#L30-L38
train
owstack/ows-common
lib/buffer.js
emptyBuffer
function emptyBuffer(bytes) { $.checkArgumentType(bytes, 'number', 'bytes'); var result = new buffer.Buffer(bytes); for (var i = 0; i < bytes; i++) { result.write('\0', i); } return result; }
javascript
function emptyBuffer(bytes) { $.checkArgumentType(bytes, 'number', 'bytes'); var result = new buffer.Buffer(bytes); for (var i = 0; i < bytes; i++) { result.write('\0', i); } return result; }
[ "function", "emptyBuffer", "(", "bytes", ")", "{", "$", ".", "checkArgumentType", "(", "bytes", ",", "'number'", ",", "'bytes'", ")", ";", "var", "result", "=", "new", "buffer", ".", "Buffer", "(", "bytes", ")", ";", "for", "(", "var", "i", "=", "0",...
Returns a zero-filled byte array @param {number} bytes @return {Buffer}
[ "Returns", "a", "zero", "-", "filled", "byte", "array" ]
aa2a7970547cf451c06e528472ee965d3b4cac36
https://github.com/owstack/ows-common/blob/aa2a7970547cf451c06e528472ee965d3b4cac36/lib/buffer.js#L69-L76
train
owstack/ows-common
lib/buffer.js
integerAsBuffer
function integerAsBuffer(integer) { $.checkArgumentType(integer, 'number', 'integer'); var bytes = []; bytes.push((integer >> 24) & 0xff); bytes.push((integer >> 16) & 0xff); bytes.push((integer >> 8) & 0xff); bytes.push(integer & 0xff); return new Buffer(bytes); }
javascript
function integerAsBuffer(integer) { $.checkArgumentType(integer, 'number', 'integer'); var bytes = []; bytes.push((integer >> 24) & 0xff); bytes.push((integer >> 16) & 0xff); bytes.push((integer >> 8) & 0xff); bytes.push(integer & 0xff); return new Buffer(bytes); }
[ "function", "integerAsBuffer", "(", "integer", ")", "{", "$", ".", "checkArgumentType", "(", "integer", ",", "'number'", ",", "'integer'", ")", ";", "var", "bytes", "=", "[", "]", ";", "bytes", ".", "push", "(", "(", "integer", ">>", "24", ")", "&", ...
Transform a 4-byte integer into a Buffer of length 4. @param {number} integer @return {Buffer}
[ "Transform", "a", "4", "-", "byte", "integer", "into", "a", "Buffer", "of", "length", "4", "." ]
aa2a7970547cf451c06e528472ee965d3b4cac36
https://github.com/owstack/ows-common/blob/aa2a7970547cf451c06e528472ee965d3b4cac36/lib/buffer.js#L105-L113
train