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
kawanet/promisen
promisen.js
nodeify
function nodeify(task) { task = promisen(task); return nodeifyTask; function nodeifyTask(args, callback) { args = Array.prototype.slice.call(arguments); callback = (args[args.length - 1] instanceof Function) && args.pop(); if (!callback) callback = NOP; var onResolve = callback.bind...
javascript
function nodeify(task) { task = promisen(task); return nodeifyTask; function nodeifyTask(args, callback) { args = Array.prototype.slice.call(arguments); callback = (args[args.length - 1] instanceof Function) && args.pop(); if (!callback) callback = NOP; var onResolve = callback.bind...
[ "function", "nodeify", "(", "task", ")", "{", "task", "=", "promisen", "(", "task", ")", ";", "return", "nodeifyTask", ";", "function", "nodeifyTask", "(", "args", ",", "callback", ")", "{", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "c...
creates a Node.js-style function from a promise-returning function or any object. @class promisen @static @function nodeify @param task {Function|Promise|thenable|*} promise-returning function or any object @returns {Function} Node.js-style function @example var promisen = require("promisen"); var task = nodeify(func...
[ "creates", "a", "Node", ".", "js", "-", "style", "function", "from", "a", "promise", "-", "returning", "function", "or", "any", "object", "." ]
71093972cf8d3cfb8e316f48498f1aa9999f169c
https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L830-L842
train
kawanet/promisen
promisen.js
memoize
function memoize(task, expire, hasher) { var memo = memoizeTask.memo = {}; expire -= 0; var timers = {}; if (!hasher) hasher = JSON.stringify.bind(JSON); return memoizeTask; function memoizeTask(value) { return waterfall([hasher, readCache]).call(this, value); // read previous resu...
javascript
function memoize(task, expire, hasher) { var memo = memoizeTask.memo = {}; expire -= 0; var timers = {}; if (!hasher) hasher = JSON.stringify.bind(JSON); return memoizeTask; function memoizeTask(value) { return waterfall([hasher, readCache]).call(this, value); // read previous resu...
[ "function", "memoize", "(", "task", ",", "expire", ",", "hasher", ")", "{", "var", "memo", "=", "memoizeTask", ".", "memo", "=", "{", "}", ";", "expire", "-=", "0", ";", "var", "timers", "=", "{", "}", ";", "if", "(", "!", "hasher", ")", "hasher"...
creates a promise-returning function which caches a result of task. The cache of result is exposed as the memo property of the function returned by memoize. @class promisen @static @function memoize @param task {Function} task to wrap @param expire {Number} millisecond until cache expired @param [hasher] {Function} d...
[ "creates", "a", "promise", "-", "returning", "function", "which", "caches", "a", "result", "of", "task", "." ]
71093972cf8d3cfb8e316f48498f1aa9999f169c
https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L904-L938
train
kawanet/promisen
promisen.js
writeCache
function writeCache(result) { result = memo[hash] = resolve(result); if (expire) { // cancel previous timer if (timers[hash]) clearTimeout(timers[hash]); // add new timer timers[hash] = setTimeout(clearCache, expire); } return resul...
javascript
function writeCache(result) { result = memo[hash] = resolve(result); if (expire) { // cancel previous timer if (timers[hash]) clearTimeout(timers[hash]); // add new timer timers[hash] = setTimeout(clearCache, expire); } return resul...
[ "function", "writeCache", "(", "result", ")", "{", "result", "=", "memo", "[", "hash", "]", "=", "resolve", "(", "result", ")", ";", "if", "(", "expire", ")", "{", "// cancel previous timer", "if", "(", "timers", "[", "hash", "]", ")", "clearTimeout", ...
write new result to cache
[ "write", "new", "result", "to", "cache" ]
71093972cf8d3cfb8e316f48498f1aa9999f169c
https://github.com/kawanet/promisen/blob/71093972cf8d3cfb8e316f48498f1aa9999f169c/promisen.js#L920-L929
train
tolokoban/ToloFrameWork
ker/mod/tfw.view.combo.js
manageIfFewItems
function manageIfFewItems() { const itemsCount = getLength.call( this, this.items ); if ( itemsCount < 2 ) return true; if ( itemsCount === 2 ) { this.index = 1 - this.index; this.expanded = false; return true; } // More than 2 items to manage. return false; }
javascript
function manageIfFewItems() { const itemsCount = getLength.call( this, this.items ); if ( itemsCount < 2 ) return true; if ( itemsCount === 2 ) { this.index = 1 - this.index; this.expanded = false; return true; } // More than 2 items to manage. return false; }
[ "function", "manageIfFewItems", "(", ")", "{", "const", "itemsCount", "=", "getLength", ".", "call", "(", "this", ",", "this", ".", "items", ")", ";", "if", "(", "itemsCount", "<", "2", ")", "return", "true", ";", "if", "(", "itemsCount", "===", "2", ...
For two items, we never show the whole list, but we just change the selection on click. @this ViewXJS @returns {boolean} `true` if there are at most 2 items.
[ "For", "two", "items", "we", "never", "show", "the", "whole", "list", "but", "we", "just", "change", "the", "selection", "on", "click", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.combo.js#L50-L60
train
tolokoban/ToloFrameWork
ker/mod/tfw.view.combo.js
moveList
function moveList( collapsedList, expandedList ) { const rect = collapsedList.getBoundingClientRect(), left = rect.left; let top = rect.top; while ( top <= 0 ) top += ITEM_HEIGHT; Dom.css( expandedList, { left: `${left}px`, top: `${top}px` } ); }
javascript
function moveList( collapsedList, expandedList ) { const rect = collapsedList.getBoundingClientRect(), left = rect.left; let top = rect.top; while ( top <= 0 ) top += ITEM_HEIGHT; Dom.css( expandedList, { left: `${left}px`, top: `${top}px` } ); }
[ "function", "moveList", "(", "collapsedList", ",", "expandedList", ")", "{", "const", "rect", "=", "collapsedList", ".", "getBoundingClientRect", "(", ")", ",", "left", "=", "rect", ".", "left", ";", "let", "top", "=", "rect", ".", "top", ";", "while", "...
Try to move `expandedList` to make the selected item be exactly above the same item in `collapsedItem`. If it is not possible, a scroll bar will appear. @param {DOMElement} collapsedList - DIV showing only one item bcause the rest is hidden. @param {DOMElement} expandedList - DIV showing the most items as it can. @retu...
[ "Try", "to", "move", "expandedList", "to", "make", "the", "selected", "item", "be", "exactly", "above", "the", "same", "item", "in", "collapsedItem", ".", "If", "it", "is", "not", "possible", "a", "scroll", "bar", "will", "appear", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.combo.js#L169-L179
train
tolokoban/ToloFrameWork
ker/mod/tfw.view.combo.js
copyContentOf
function copyContentOf() { const that = this, items = this.items, div = Dom.div( "thm-ele8" ); items.forEach( function ( item, index ) { const clonedItem = Dom.div( that.index === index ? "thm-bgSL" : "thm-bg3" ); if ( typeof item === 'string' ) { clonedItem.t...
javascript
function copyContentOf() { const that = this, items = this.items, div = Dom.div( "thm-ele8" ); items.forEach( function ( item, index ) { const clonedItem = Dom.div( that.index === index ? "thm-bgSL" : "thm-bg3" ); if ( typeof item === 'string' ) { clonedItem.t...
[ "function", "copyContentOf", "(", ")", "{", "const", "that", "=", "this", ",", "items", "=", "this", ".", "items", ",", "div", "=", "Dom", ".", "div", "(", "\"thm-ele8\"", ")", ";", "items", ".", "forEach", "(", "function", "(", "item", ",", "index",...
We sill copy the innerHTML of items and add a Touchable behaviour on each of them. @this ViewXJS @returns {DOMElement} DIV with all cloned items.
[ "We", "sill", "copy", "the", "innerHTML", "of", "items", "and", "add", "a", "Touchable", "behaviour", "on", "each", "of", "them", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.combo.js#L186-L206
train
tolokoban/ToloFrameWork
ker/mod/tfw.view.combo.js
onKeyDown
function onKeyDown( evt ) { switch ( evt.key ) { case 'Space': this.expanded = !this.expanded; evt.preventDefault(); break; case 'Enter': this.action = this.value; break; case 'ArrowDown': selectNext.call( this ); evt.preventDefault(); brea...
javascript
function onKeyDown( evt ) { switch ( evt.key ) { case 'Space': this.expanded = !this.expanded; evt.preventDefault(); break; case 'Enter': this.action = this.value; break; case 'ArrowDown': selectNext.call( this ); evt.preventDefault(); brea...
[ "function", "onKeyDown", "(", "evt", ")", "{", "switch", "(", "evt", ".", "key", ")", "{", "case", "'Space'", ":", "this", ".", "expanded", "=", "!", "this", ".", "expanded", ";", "evt", ".", "preventDefault", "(", ")", ";", "break", ";", "case", "...
Space will expand the combo, Escape will collapse it and Enter will trigger an action. @this ViewXJS @param {[type]} evt [description] @returns {[type]} [description]
[ "Space", "will", "expand", "the", "combo", "Escape", "will", "collapse", "it", "and", "Enter", "will", "trigger", "an", "action", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.combo.js#L253-L281
train
tolokoban/ToloFrameWork
ker/mod/tfw.view.combo.js
selectNext
function selectNext() { this.index = ( this.index + 1 ) % this.items.length; if ( this.expanded ) { collapse.call( this ); expand.call( this, false ); } }
javascript
function selectNext() { this.index = ( this.index + 1 ) % this.items.length; if ( this.expanded ) { collapse.call( this ); expand.call( this, false ); } }
[ "function", "selectNext", "(", ")", "{", "this", ".", "index", "=", "(", "this", ".", "index", "+", "1", ")", "%", "this", ".", "items", ".", "length", ";", "if", "(", "this", ".", "expanded", ")", "{", "collapse", ".", "call", "(", "this", ")", ...
Select next item. @this ViewXJS @returns {undefined}
[ "Select", "next", "item", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.combo.js#L289-L295
train
JohnnieFucker/dreamix-rpc
lib/rpc-client/mailstation.js
doFilter
function doFilter(tracer, err, serverId, msg, opts, filters, index, operate, cb) { if (index < filters.length) { tracer.info('client', __filename, 'doFilter', `do ${operate} filter ${filters[index].name}`); } if (index >= filters.length || !!err) { utils.invokeCallback(cb, tracer, err, serve...
javascript
function doFilter(tracer, err, serverId, msg, opts, filters, index, operate, cb) { if (index < filters.length) { tracer.info('client', __filename, 'doFilter', `do ${operate} filter ${filters[index].name}`); } if (index >= filters.length || !!err) { utils.invokeCallback(cb, tracer, err, serve...
[ "function", "doFilter", "(", "tracer", ",", "err", ",", "serverId", ",", "msg", ",", "opts", ",", "filters", ",", "index", ",", "operate", ",", "cb", ")", "{", "if", "(", "index", "<", "filters", ".", "length", ")", "{", "tracer", ".", "info", "(",...
Do before or after filter
[ "Do", "before", "or", "after", "filter" ]
eb29e247214148c025456b2bb0542e1094fd2edb
https://github.com/JohnnieFucker/dreamix-rpc/blob/eb29e247214148c025456b2bb0542e1094fd2edb/lib/rpc-client/mailstation.js#L74-L108
train
koop-retired/koop-server
lib/PostGIS.js
function(err, data){ if (err) error = err; allLayers.push(data); if (allLayers.length == totalLayers){ callback(error, allLayers); } }
javascript
function(err, data){ if (err) error = err; allLayers.push(data); if (allLayers.length == totalLayers){ callback(error, allLayers); } }
[ "function", "(", "err", ",", "data", ")", "{", "if", "(", "err", ")", "error", "=", "err", ";", "allLayers", ".", "push", "(", "data", ")", ";", "if", "(", "allLayers", ".", "length", "==", "totalLayers", ")", "{", "callback", "(", "error", ",", ...
closure to check each layer and send back when done
[ "closure", "to", "check", "each", "layer", "and", "send", "back", "when", "done" ]
7b4404aa0db92023bfd59b475ad43aa36e02aee8
https://github.com/koop-retired/koop-server/blob/7b4404aa0db92023bfd59b475ad43aa36e02aee8/lib/PostGIS.js#L196-L202
train
fernandofranca/launchpod
lib/utils.js
readConfigFile
function readConfigFile(configJSONPath) { var confiJSONFullPath = path.join(process.cwd(), configJSONPath); try{ var configStr = fs.readFileSync(confiJSONFullPath, {encoding:'utf8'}); return JSON.parse(configStr); } catch (err){ throw new Error(`Invalid launcher configuration file: ${confiJSONFullP...
javascript
function readConfigFile(configJSONPath) { var confiJSONFullPath = path.join(process.cwd(), configJSONPath); try{ var configStr = fs.readFileSync(confiJSONFullPath, {encoding:'utf8'}); return JSON.parse(configStr); } catch (err){ throw new Error(`Invalid launcher configuration file: ${confiJSONFullP...
[ "function", "readConfigFile", "(", "configJSONPath", ")", "{", "var", "confiJSONFullPath", "=", "path", ".", "join", "(", "process", ".", "cwd", "(", ")", ",", "configJSONPath", ")", ";", "try", "{", "var", "configStr", "=", "fs", ".", "readFileSync", "(",...
When a simple require will reload the targeted file
[ "When", "a", "simple", "require", "will", "reload", "the", "targeted", "file" ]
882d614a4271846e17b3ba0ca319340a607580bc
https://github.com/fernandofranca/launchpod/blob/882d614a4271846e17b3ba0ca319340a607580bc/lib/utils.js#L8-L18
train
lui89/postcss-sass-colors
index.js
colorConvert
function colorConvert( percentage, option, colorValue ) { var color = require( 'color' ); var newColor = color( colorValue.trim() ); var newValue = ''; switch ( option.trim() ) { case 'darken': newValue = newColor.darken( percentage ).hexString(); brea...
javascript
function colorConvert( percentage, option, colorValue ) { var color = require( 'color' ); var newColor = color( colorValue.trim() ); var newValue = ''; switch ( option.trim() ) { case 'darken': newValue = newColor.darken( percentage ).hexString(); brea...
[ "function", "colorConvert", "(", "percentage", ",", "option", ",", "colorValue", ")", "{", "var", "color", "=", "require", "(", "'color'", ")", ";", "var", "newColor", "=", "color", "(", "colorValue", ".", "trim", "(", ")", ")", ";", "var", "newValue", ...
Calls the Color.js library for the conversion
[ "Calls", "the", "Color", ".", "js", "library", "for", "the", "conversion" ]
0b116e65c15bfabe1b4766b9f6cc787c7c896421
https://github.com/lui89/postcss-sass-colors/blob/0b116e65c15bfabe1b4766b9f6cc787c7c896421/index.js#L7-L30
train
lui89/postcss-sass-colors
index.js
colorInit
function colorInit( oldValue ) { var color, percentage, colorArgs, colorValue, cssString; var balanced = require( 'balanced-match' ); // cssString = balanced( '(', ')', oldValue ); colorArgs = balanced( '(', ')', cssString.body ); colorValue = balanced( '(', ')', color...
javascript
function colorInit( oldValue ) { var color, percentage, colorArgs, colorValue, cssString; var balanced = require( 'balanced-match' ); // cssString = balanced( '(', ')', oldValue ); colorArgs = balanced( '(', ')', cssString.body ); colorValue = balanced( '(', ')', color...
[ "function", "colorInit", "(", "oldValue", ")", "{", "var", "color", ",", "percentage", ",", "colorArgs", ",", "colorValue", ",", "cssString", ";", "var", "balanced", "=", "require", "(", "'balanced-match'", ")", ";", "//", "cssString", "=", "balanced", "(", ...
Gets the type of conversion is needed for the current string
[ "Gets", "the", "type", "of", "conversion", "is", "needed", "for", "the", "current", "string" ]
0b116e65c15bfabe1b4766b9f6cc787c7c896421
https://github.com/lui89/postcss-sass-colors/blob/0b116e65c15bfabe1b4766b9f6cc787c7c896421/index.js#L33-L70
train
Insorum/hubot-youtube-feed
src/lib/video-fetcher.js
function(username) { var result = q.defer(); this.robot.http('https://gdata.youtube.com/feeds/api/users/' + username + '/uploads?alt=json') .header('Accept', 'application/json') .get()(function (err, res, body) { if (err) { result.reject(err); ...
javascript
function(username) { var result = q.defer(); this.robot.http('https://gdata.youtube.com/feeds/api/users/' + username + '/uploads?alt=json') .header('Accept', 'application/json') .get()(function (err, res, body) { if (err) { result.reject(err); ...
[ "function", "(", "username", ")", "{", "var", "result", "=", "q", ".", "defer", "(", ")", ";", "this", ".", "robot", ".", "http", "(", "'https://gdata.youtube.com/feeds/api/users/'", "+", "username", "+", "'/uploads?alt=json'", ")", ".", "header", "(", "'Acc...
Fetches latest video list for the given user @param {string} username - The account to check @returns {promise} promise that resolves to {id: string, link: string}[], a list of id's and links for each video
[ "Fetches", "latest", "video", "list", "for", "the", "given", "user" ]
6f55979733fd75c3bb7b8ba0b15ed8da99f85d4b
https://github.com/Insorum/hubot-youtube-feed/blob/6f55979733fd75c3bb7b8ba0b15ed8da99f85d4b/src/lib/video-fetcher.js#L13-L50
train
tyler-johnson/assign-props
index.js
assignProps
function assignProps(obj, key, val, opts) { var k; // accept object syntax if (typeof key === "object") { for (k in key) { if (hasOwn.call(key, k)) assignProps(obj, k, key[k], val); } return; } var desc = {}; opts = opts || {}; // build base descriptor for (k in defaults) { desc[k] = typeof opts[k...
javascript
function assignProps(obj, key, val, opts) { var k; // accept object syntax if (typeof key === "object") { for (k in key) { if (hasOwn.call(key, k)) assignProps(obj, k, key[k], val); } return; } var desc = {}; opts = opts || {}; // build base descriptor for (k in defaults) { desc[k] = typeof opts[k...
[ "function", "assignProps", "(", "obj", ",", "key", ",", "val", ",", "opts", ")", "{", "var", "k", ";", "// accept object syntax", "if", "(", "typeof", "key", "===", "\"object\"", ")", "{", "for", "(", "k", "in", "key", ")", "{", "if", "(", "hasOwn", ...
defines protected, immutable properties
[ "defines", "protected", "immutable", "properties" ]
b88543c5e1a850f8a5400f554935d1eddd8f891e
https://github.com/tyler-johnson/assign-props/blob/b88543c5e1a850f8a5400f554935d1eddd8f891e/index.js#L9-L38
train
fiveisprime/iron-cache
lib/ironcache.js
handleResponse
function handleResponse(done, err, response, body) { if (err) return done(err, null); if (response.statusCode !== 200) return done(new Error(body.msg || 'Unknown error'), null); done(null, body); }
javascript
function handleResponse(done, err, response, body) { if (err) return done(err, null); if (response.statusCode !== 200) return done(new Error(body.msg || 'Unknown error'), null); done(null, body); }
[ "function", "handleResponse", "(", "done", ",", "err", ",", "response", ",", "body", ")", "{", "if", "(", "err", ")", "return", "done", "(", "err", ",", "null", ")", ";", "if", "(", "response", ".", "statusCode", "!==", "200", ")", "return", "done", ...
Generic handler for API responses. Includes default error handling.
[ "Generic", "handler", "for", "API", "responses", ".", "Includes", "default", "error", "handling", "." ]
2ce8b12e52d14ee908787552cf32f5f8d3109e24
https://github.com/fiveisprime/iron-cache/blob/2ce8b12e52d14ee908787552cf32f5f8d3109e24/lib/ironcache.js#L12-L17
train
hbouvier/node-diagnostics
lib/diagnostics.js
setLevel
function setLevel(level) { if (typeof(level) === "number") { if (level >= 0 && level <= 5) { _level = level; } else { invalidParameter(level); } } else if (typeof(level) === 'string') { if (Level.hasOwnProperty(level)) { ...
javascript
function setLevel(level) { if (typeof(level) === "number") { if (level >= 0 && level <= 5) { _level = level; } else { invalidParameter(level); } } else if (typeof(level) === 'string') { if (Level.hasOwnProperty(level)) { ...
[ "function", "setLevel", "(", "level", ")", "{", "if", "(", "typeof", "(", "level", ")", "===", "\"number\"", ")", "{", "if", "(", "level", ">=", "0", "&&", "level", "<=", "5", ")", "{", "_level", "=", "level", ";", "}", "else", "{", "invalidParamet...
set the logging level @param: level The verbosity of the logger.
[ "set", "the", "logging", "level" ]
0e03567662960b9ae710cc2effb2214aa90c0b1d
https://github.com/hbouvier/node-diagnostics/blob/0e03567662960b9ae710cc2effb2214aa90c0b1d/lib/diagnostics.js#L28-L45
train
jmendiara/gitftw
src/resolvable.js
resolveArray
function resolveArray(arg) { var resolvedArray = new Array(arg.length); return arg .reduce(function(soFar, value, index) { return soFar .then(resolveItem.bind(null, value)) .then(function(value) { resolvedArray[index] = value; }); }, Promise.reso...
javascript
function resolveArray(arg) { var resolvedArray = new Array(arg.length); return arg .reduce(function(soFar, value, index) { return soFar .then(resolveItem.bind(null, value)) .then(function(value) { resolvedArray[index] = value; }); }, Promise.reso...
[ "function", "resolveArray", "(", "arg", ")", "{", "var", "resolvedArray", "=", "new", "Array", "(", "arg", ".", "length", ")", ";", "return", "arg", ".", "reduce", "(", "function", "(", "soFar", ",", "value", ",", "index", ")", "{", "return", "soFar", ...
Resolves an array @private @param {Array} arg The array to resolve @returns {Promise} The resolved array
[ "Resolves", "an", "array" ]
ba91b0d68b7791b5b557addc685737f6c912b4f3
https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/resolvable.js#L71-L84
train
jmendiara/gitftw
src/resolvable.js
resolveObject
function resolveObject(arg) { var resolvedObject = {}; return Object.keys(arg) .reduce(function(soFar, key) { return soFar .then(resolveItem.bind(null, arg[key])) .then(function(value) { resolvedObject[key] = value; }); }, Promise.resolve()) ...
javascript
function resolveObject(arg) { var resolvedObject = {}; return Object.keys(arg) .reduce(function(soFar, key) { return soFar .then(resolveItem.bind(null, arg[key])) .then(function(value) { resolvedObject[key] = value; }); }, Promise.resolve()) ...
[ "function", "resolveObject", "(", "arg", ")", "{", "var", "resolvedObject", "=", "{", "}", ";", "return", "Object", ".", "keys", "(", "arg", ")", ".", "reduce", "(", "function", "(", "soFar", ",", "key", ")", "{", "return", "soFar", ".", "then", "(",...
Resolves an object @private @param {Object} arg The object to resolve @returns {Promise} The resolved object
[ "Resolves", "an", "object" ]
ba91b0d68b7791b5b557addc685737f6c912b4f3
https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/resolvable.js#L93-L106
train
jmendiara/gitftw
src/resolvable.js
resolveItem
function resolveItem(arg) { if (Array.isArray(arg)) { return resolveArray(arg); } else if (Object.prototype.toString.call(arg) === '[object Function]') { //is a function return Promise.method(arg)().then(resolveItem); } else if (isThenable(arg)) { //is a promise return arg.then(resolveItem); ...
javascript
function resolveItem(arg) { if (Array.isArray(arg)) { return resolveArray(arg); } else if (Object.prototype.toString.call(arg) === '[object Function]') { //is a function return Promise.method(arg)().then(resolveItem); } else if (isThenable(arg)) { //is a promise return arg.then(resolveItem); ...
[ "function", "resolveItem", "(", "arg", ")", "{", "if", "(", "Array", ".", "isArray", "(", "arg", ")", ")", "{", "return", "resolveArray", "(", "arg", ")", ";", "}", "else", "if", "(", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "...
Resolves something resolvable @private @param {*} arg The argument to resolve @returns {Promise} The resolved
[ "Resolves", "something", "resolvable" ]
ba91b0d68b7791b5b557addc685737f6c912b4f3
https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/resolvable.js#L115-L138
train
doctape/doctape-client-js
src/core.js
function (path, data, cb) { var lines = []; var field; for (field in data) { lines.push(field + '=' + encodeURIComponent(data[field])); } this.env.req({ method: 'POST', protocol: this.options.authPt.protocol, host: this.options.authPt.host, port: this.options....
javascript
function (path, data, cb) { var lines = []; var field; for (field in data) { lines.push(field + '=' + encodeURIComponent(data[field])); } this.env.req({ method: 'POST', protocol: this.options.authPt.protocol, host: this.options.authPt.host, port: this.options....
[ "function", "(", "path", ",", "data", ",", "cb", ")", "{", "var", "lines", "=", "[", "]", ";", "var", "field", ";", "for", "(", "field", "in", "data", ")", "{", "lines", ".", "push", "(", "field", "+", "'='", "+", "encodeURIComponent", "(", "data...
Not for direct use. Perform a standard POST-request to the auth point with raw form post data. @param {string} path @param {Object} data @param {function (Object, Object=)} cb
[ "Not", "for", "direct", "use", ".", "Perform", "a", "standard", "POST", "-", "request", "to", "the", "auth", "point", "with", "raw", "form", "post", "data", "." ]
3052007a55a45e0b654d572f68473250daab83bb
https://github.com/doctape/doctape-client-js/blob/3052007a55a45e0b654d572f68473250daab83bb/src/core.js#L120-L135
train
doctape/doctape-client-js
src/core.js
function (error_msg) { var self = this; return function (err, resp) { self._lock_refresh = undefined; if (!err) { var auth = JSON.parse(resp); if (!auth.error) { setToken.call(self, auth); return emit.call(self, 'auth.refresh', token.call(self)); } ...
javascript
function (error_msg) { var self = this; return function (err, resp) { self._lock_refresh = undefined; if (!err) { var auth = JSON.parse(resp); if (!auth.error) { setToken.call(self, auth); return emit.call(self, 'auth.refresh', token.call(self)); } ...
[ "function", "(", "error_msg", ")", "{", "var", "self", "=", "this", ";", "return", "function", "(", "err", ",", "resp", ")", "{", "self", ".", "_lock_refresh", "=", "undefined", ";", "if", "(", "!", "err", ")", "{", "var", "auth", "=", "JSON", ".",...
Private helper function for registering a new token. @param {string} error_msg
[ "Private", "helper", "function", "for", "registering", "a", "new", "token", "." ]
3052007a55a45e0b654d572f68473250daab83bb
https://github.com/doctape/doctape-client-js/blob/3052007a55a45e0b654d572f68473250daab83bb/src/core.js#L240-L254
train
sendanor/nor-nopg
src/nopg.js
_get_ms
function _get_ms(a, b) { debug.assert(a).is('date'); debug.assert(b).is('date'); if(a < b) { return b.getTime() - a.getTime(); } return a.getTime() - b.getTime(); }
javascript
function _get_ms(a, b) { debug.assert(a).is('date'); debug.assert(b).is('date'); if(a < b) { return b.getTime() - a.getTime(); } return a.getTime() - b.getTime(); }
[ "function", "_get_ms", "(", "a", ",", "b", ")", "{", "debug", ".", "assert", "(", "a", ")", ".", "is", "(", "'date'", ")", ";", "debug", ".", "assert", "(", "b", ")", ".", "is", "(", "'date'", ")", ";", "if", "(", "a", "<", "b", ")", "{", ...
Returns seconds between two date values @returns {number} Time between two values (ms)
[ "Returns", "seconds", "between", "two", "date", "values" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L80-L87
train
sendanor/nor-nopg
src/nopg.js
_log_time
function _log_time(sample) { debug.assert(sample).is('object'); debug.assert(sample.event).is('string'); debug.assert(sample.start).is('date'); debug.assert(sample.end).is('date'); debug.assert(sample.duration).ignore(undefined).is('number'); debug.assert(sample.query).ignore(undefined).is('string'); debug.asse...
javascript
function _log_time(sample) { debug.assert(sample).is('object'); debug.assert(sample.event).is('string'); debug.assert(sample.start).is('date'); debug.assert(sample.end).is('date'); debug.assert(sample.duration).ignore(undefined).is('number'); debug.assert(sample.query).ignore(undefined).is('string'); debug.asse...
[ "function", "_log_time", "(", "sample", ")", "{", "debug", ".", "assert", "(", "sample", ")", ".", "is", "(", "'object'", ")", ";", "debug", ".", "assert", "(", "sample", ".", "event", ")", ".", "is", "(", "'string'", ")", ";", "debug", ".", "asser...
Optionally log time
[ "Optionally", "log", "time" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L90-L115
train
sendanor/nor-nopg
src/nopg.js
_get_result
function _get_result(Type) { return function(rows) { if(!rows) { throw new TypeError("failed to parse result"); } var doc = rows.shift(); if(!doc) { return; } if(doc instanceof Type) { return doc; } var obj = {}; ARRAY(Object.keys(doc)).forEach(function(key) { if(key === 'documents') { obj['...
javascript
function _get_result(Type) { return function(rows) { if(!rows) { throw new TypeError("failed to parse result"); } var doc = rows.shift(); if(!doc) { return; } if(doc instanceof Type) { return doc; } var obj = {}; ARRAY(Object.keys(doc)).forEach(function(key) { if(key === 'documents') { obj['...
[ "function", "_get_result", "(", "Type", ")", "{", "return", "function", "(", "rows", ")", "{", "if", "(", "!", "rows", ")", "{", "throw", "new", "TypeError", "(", "\"failed to parse result\"", ")", ";", "}", "var", "doc", "=", "rows", ".", "shift", "("...
Take first result from the database query and returns new instance of `Type`
[ "Take", "first", "result", "from", "the", "database", "query", "and", "returns", "new", "instance", "of", "Type" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L195-L227
train
sendanor/nor-nopg
src/nopg.js
parse_predicate_pgtype
function parse_predicate_pgtype(ObjType, document_type, key) { debug.assert(ObjType).is('function'); debug.assert(document_type).ignore(undefined).is('object'); var schema = (document_type && document_type.$schema) || {}; debug.assert(schema).is('object'); if(key[0] === '$') { // FIXME: Change this to do dir...
javascript
function parse_predicate_pgtype(ObjType, document_type, key) { debug.assert(ObjType).is('function'); debug.assert(document_type).ignore(undefined).is('object'); var schema = (document_type && document_type.$schema) || {}; debug.assert(schema).is('object'); if(key[0] === '$') { // FIXME: Change this to do dir...
[ "function", "parse_predicate_pgtype", "(", "ObjType", ",", "document_type", ",", "key", ")", "{", "debug", ".", "assert", "(", "ObjType", ")", ".", "is", "(", "'function'", ")", ";", "debug", ".", "assert", "(", "document_type", ")", ".", "ignore", "(", ...
Returns PostgreSQL type for key based on the schema @FIXME Detect correct types for all keys
[ "Returns", "PostgreSQL", "type", "for", "key", "based", "on", "the", "schema" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L710-L750
train
sendanor/nor-nopg
src/nopg.js
_parse_function_predicate
function _parse_function_predicate(ObjType, q, def_op, o, ret_type, traits) { debug.assert(o).is('array'); ret_type = ret_type || 'boolean'; var func = ARRAY(o).find(is.func); debug.assert(func).is('function'); var i = o.indexOf(func); debug.assert(i).is('number'); var input_nopg_keys = o.slice(0, i); var ...
javascript
function _parse_function_predicate(ObjType, q, def_op, o, ret_type, traits) { debug.assert(o).is('array'); ret_type = ret_type || 'boolean'; var func = ARRAY(o).find(is.func); debug.assert(func).is('function'); var i = o.indexOf(func); debug.assert(i).is('number'); var input_nopg_keys = o.slice(0, i); var ...
[ "function", "_parse_function_predicate", "(", "ObjType", ",", "q", ",", "def_op", ",", "o", ",", "ret_type", ",", "traits", ")", "{", "debug", ".", "assert", "(", "o", ")", ".", "is", "(", "'array'", ")", ";", "ret_type", "=", "ret_type", "||", "'boole...
Parse array predicate
[ "Parse", "array", "predicate" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L759-L801
train
sendanor/nor-nopg
src/nopg.js
parse_operator_type
function parse_operator_type(op, def) { op = ''+op; if(op.indexOf(':') === -1) { return def || 'boolean'; } return op.split(':')[1]; }
javascript
function parse_operator_type(op, def) { op = ''+op; if(op.indexOf(':') === -1) { return def || 'boolean'; } return op.split(':')[1]; }
[ "function", "parse_operator_type", "(", "op", ",", "def", ")", "{", "op", "=", "''", "+", "op", ";", "if", "(", "op", ".", "indexOf", "(", "':'", ")", "===", "-", "1", ")", "{", "return", "def", "||", "'boolean'", ";", "}", "return", "op", ".", ...
Returns true if op is AND, OR or BIND
[ "Returns", "true", "if", "op", "is", "AND", "OR", "or", "BIND" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L811-L817
train
sendanor/nor-nopg
src/nopg.js
parse_search_traits
function parse_search_traits(traits) { traits = traits || {}; // Initialize fields as all fields if(!traits.fields) { traits.fields = ['$*']; } // If fields was not an array (but is not negative -- check previous if clause), lets make it that. if(!is.array(traits.fields)) { traits.fields = [traits.fields]; ...
javascript
function parse_search_traits(traits) { traits = traits || {}; // Initialize fields as all fields if(!traits.fields) { traits.fields = ['$*']; } // If fields was not an array (but is not negative -- check previous if clause), lets make it that. if(!is.array(traits.fields)) { traits.fields = [traits.fields]; ...
[ "function", "parse_search_traits", "(", "traits", ")", "{", "traits", "=", "traits", "||", "{", "}", ";", "// Initialize fields as all fields", "if", "(", "!", "traits", ".", "fields", ")", "{", "traits", ".", "fields", "=", "[", "'$*'", "]", ";", "}", "...
Parse traits object
[ "Parse", "traits", "object" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L877-L947
train
sendanor/nor-nopg
src/nopg.js
parse_select_fields
function parse_select_fields(ObjType, traits) { debug.assert(ObjType).is('function'); debug.assert(traits).ignore(undefined).is('object'); return ARRAY(traits.fields).map(function(f) { return _parse_predicate_key(ObjType, {'traits': traits, 'epoch':false}, f); }).valueOf(); }
javascript
function parse_select_fields(ObjType, traits) { debug.assert(ObjType).is('function'); debug.assert(traits).ignore(undefined).is('object'); return ARRAY(traits.fields).map(function(f) { return _parse_predicate_key(ObjType, {'traits': traits, 'epoch':false}, f); }).valueOf(); }
[ "function", "parse_select_fields", "(", "ObjType", ",", "traits", ")", "{", "debug", ".", "assert", "(", "ObjType", ")", ".", "is", "(", "'function'", ")", ";", "debug", ".", "assert", "(", "traits", ")", ".", "ignore", "(", "undefined", ")", ".", "is"...
Parses internal fields from nopg style fields
[ "Parses", "internal", "fields", "from", "nopg", "style", "fields" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L952-L958
train
sendanor/nor-nopg
src/nopg.js
parse_search_opts
function parse_search_opts(opts, traits) { if(opts === undefined) { return; } if(is.array(opts)) { if( (opts.length >= 1) && is.obj(opts[0]) ) { return [ ((traits.match === 'any') ? 'OR' : 'AND') ].concat(opts); } return opts; } if(opts instanceof NoPg.Type) { return [ "AND", { "$id": opts.$id } ];...
javascript
function parse_search_opts(opts, traits) { if(opts === undefined) { return; } if(is.array(opts)) { if( (opts.length >= 1) && is.obj(opts[0]) ) { return [ ((traits.match === 'any') ? 'OR' : 'AND') ].concat(opts); } return opts; } if(opts instanceof NoPg.Type) { return [ "AND", { "$id": opts.$id } ];...
[ "function", "parse_search_opts", "(", "opts", ",", "traits", ")", "{", "if", "(", "opts", "===", "undefined", ")", "{", "return", ";", "}", "if", "(", "is", ".", "array", "(", "opts", ")", ")", "{", "if", "(", "(", "opts", ".", "length", ">=", "1...
Parse opts object
[ "Parse", "opts", "object" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L961-L983
train
sendanor/nor-nopg
src/nopg.js
_parse_select_order
function _parse_select_order(ObjType, document_type, order, q, traits) { debug.assert(ObjType).is('function'); debug.assert(document_type).ignore(undefined).is('object'); debug.assert(order).is('array'); return ARRAY(order).map(function(o) { var key, type, rest; if(is.array(o)) { key = parse_operator_name(...
javascript
function _parse_select_order(ObjType, document_type, order, q, traits) { debug.assert(ObjType).is('function'); debug.assert(document_type).ignore(undefined).is('object'); debug.assert(order).is('array'); return ARRAY(order).map(function(o) { var key, type, rest; if(is.array(o)) { key = parse_operator_name(...
[ "function", "_parse_select_order", "(", "ObjType", ",", "document_type", ",", "order", ",", "q", ",", "traits", ")", "{", "debug", ".", "assert", "(", "ObjType", ")", ".", "is", "(", "'function'", ")", ";", "debug", ".", "assert", "(", "document_type", "...
Generate ORDER BY using `traits.order`
[ "Generate", "ORDER", "BY", "using", "traits", ".", "order" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L986-L1016
train
sendanor/nor-nopg
src/nopg.js
do_select
function do_select(self, types, search_opts, traits) { return nr_fcall("nopg:do_select", function() { return prepare_select_query(self, types, search_opts, traits).then(function(q) { var result = q.compile(); // Unnecessary since do_query() does it too //if(NoPg.debug) { // debug.log('query = ', result....
javascript
function do_select(self, types, search_opts, traits) { return nr_fcall("nopg:do_select", function() { return prepare_select_query(self, types, search_opts, traits).then(function(q) { var result = q.compile(); // Unnecessary since do_query() does it too //if(NoPg.debug) { // debug.log('query = ', result....
[ "function", "do_select", "(", "self", ",", "types", ",", "search_opts", ",", "traits", ")", "{", "return", "nr_fcall", "(", "\"nopg:do_select\"", ",", "function", "(", ")", "{", "return", "prepare_select_query", "(", "self", ",", "types", ",", "search_opts", ...
Generic SELECT query @param self {object} The NoPg connection/transaction object @param types {} @param search_opts {} @param traits {object}
[ "Generic", "SELECT", "query" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1177-L1215
train
sendanor/nor-nopg
src/nopg.js
do_insert
function do_insert(self, ObjType, data) { return nr_fcall("nopg:do_insert", function() { return prepare_insert_query(self, ObjType, data).then(function(q) { var result = q.compile(); return do_query(self, result.query, result.params); }); }); }
javascript
function do_insert(self, ObjType, data) { return nr_fcall("nopg:do_insert", function() { return prepare_insert_query(self, ObjType, data).then(function(q) { var result = q.compile(); return do_query(self, result.query, result.params); }); }); }
[ "function", "do_insert", "(", "self", ",", "ObjType", ",", "data", ")", "{", "return", "nr_fcall", "(", "\"nopg:do_insert\"", ",", "function", "(", ")", "{", "return", "prepare_insert_query", "(", "self", ",", "ObjType", ",", "data", ")", ".", "then", "(",...
Internal INSERT query
[ "Internal", "INSERT", "query" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1256-L1263
train
sendanor/nor-nopg
src/nopg.js
json_cmp
function json_cmp(a, b) { a = JSON.stringify(a); b = JSON.stringify(b); var ret = (a === b) ? true : false; return ret; }
javascript
function json_cmp(a, b) { a = JSON.stringify(a); b = JSON.stringify(b); var ret = (a === b) ? true : false; return ret; }
[ "function", "json_cmp", "(", "a", ",", "b", ")", "{", "a", "=", "JSON", ".", "stringify", "(", "a", ")", ";", "b", "=", "JSON", ".", "stringify", "(", "b", ")", ";", "var", "ret", "=", "(", "a", "===", "b", ")", "?", "true", ":", "false", "...
Compare two variables as JSON strings
[ "Compare", "two", "variables", "as", "JSON", "strings" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1266-L1271
train
sendanor/nor-nopg
src/nopg.js
do_update
function do_update(self, ObjType, obj, orig_data) { return nr_fcall("nopg:do_update", function() { var query, params, data, where = {}; if(obj.$id) { where.$id = obj.$id; } else if(obj.$name) { where.$name = obj.$name; } else { throw new TypeError("Cannot know what to update!"); } if(orig_data =...
javascript
function do_update(self, ObjType, obj, orig_data) { return nr_fcall("nopg:do_update", function() { var query, params, data, where = {}; if(obj.$id) { where.$id = obj.$id; } else if(obj.$name) { where.$name = obj.$name; } else { throw new TypeError("Cannot know what to update!"); } if(orig_data =...
[ "function", "do_update", "(", "self", ",", "ObjType", ",", "obj", ",", "orig_data", ")", "{", "return", "nr_fcall", "(", "\"nopg:do_update\"", ",", "function", "(", ")", "{", "var", "query", ",", "params", ",", "data", ",", "where", "=", "{", "}", ";",...
Internal UPDATE query
[ "Internal", "UPDATE", "query" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1274-L1340
train
sendanor/nor-nopg
src/nopg.js
do_delete
function do_delete(self, ObjType, obj) { return nr_fcall("nopg:do_delete", function() { if(!(obj && obj.$id)) { throw new TypeError("opts.$id invalid: " + util.inspect(obj) ); } var query, params; query = "DELETE FROM " + (ObjType.meta.table) + " WHERE id = $1"; params = [obj.$id]; return do_query(self, quer...
javascript
function do_delete(self, ObjType, obj) { return nr_fcall("nopg:do_delete", function() { if(!(obj && obj.$id)) { throw new TypeError("opts.$id invalid: " + util.inspect(obj) ); } var query, params; query = "DELETE FROM " + (ObjType.meta.table) + " WHERE id = $1"; params = [obj.$id]; return do_query(self, quer...
[ "function", "do_delete", "(", "self", ",", "ObjType", ",", "obj", ")", "{", "return", "nr_fcall", "(", "\"nopg:do_delete\"", ",", "function", "(", ")", "{", "if", "(", "!", "(", "obj", "&&", "obj", ".", "$id", ")", ")", "{", "throw", "new", "TypeErro...
Internal DELETE query
[ "Internal", "DELETE", "query" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1343-L1351
train
sendanor/nor-nopg
src/nopg.js
pg_table_exists
function pg_table_exists(self, name) { return do_query(self, 'SELECT * FROM information_schema.tables WHERE table_name = $1 LIMIT 1', [name]).then(function(rows) { if(!rows) { throw new TypeError("Unexpected result from query: " + util.inspect(rows)); } return rows.length !== 0; }); }
javascript
function pg_table_exists(self, name) { return do_query(self, 'SELECT * FROM information_schema.tables WHERE table_name = $1 LIMIT 1', [name]).then(function(rows) { if(!rows) { throw new TypeError("Unexpected result from query: " + util.inspect(rows)); } return rows.length !== 0; }); }
[ "function", "pg_table_exists", "(", "self", ",", "name", ")", "{", "return", "do_query", "(", "self", ",", "'SELECT * FROM information_schema.tables WHERE table_name = $1 LIMIT 1'", ",", "[", "name", "]", ")", ".", "then", "(", "function", "(", "rows", ")", "{", ...
Returns `true` if PostgreSQL database table exists. @todo Implement this in nor-pg and use here.
[ "Returns", "true", "if", "PostgreSQL", "database", "table", "exists", "." ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1357-L1362
train
sendanor/nor-nopg
src/nopg.js
pg_get_indexdef
function pg_get_indexdef(self, name) { return do_query(self, 'SELECT indexdef FROM pg_indexes WHERE indexname = $1 LIMIT 1', [name]).then(function(rows) { if(!rows) { throw new TypeError("Unexpected result from query: " + util.inspect(rows)); } if(rows.length === 0) { throw new TypeError("Index does not exist: ...
javascript
function pg_get_indexdef(self, name) { return do_query(self, 'SELECT indexdef FROM pg_indexes WHERE indexname = $1 LIMIT 1', [name]).then(function(rows) { if(!rows) { throw new TypeError("Unexpected result from query: " + util.inspect(rows)); } if(rows.length === 0) { throw new TypeError("Index does not exist: ...
[ "function", "pg_get_indexdef", "(", "self", ",", "name", ")", "{", "return", "do_query", "(", "self", ",", "'SELECT indexdef FROM pg_indexes WHERE indexname = $1 LIMIT 1'", ",", "[", "name", "]", ")", ".", "then", "(", "function", "(", "rows", ")", "{", "if", ...
Returns `true` if PostgreSQL database table has index like this one. @todo Implement this in nor-pg and use here.
[ "Returns", "true", "if", "PostgreSQL", "database", "table", "has", "index", "like", "this", "one", "." ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1379-L1387
train
sendanor/nor-nopg
src/nopg.js
pg_create_index_name
function pg_create_index_name(self, ObjType, type, field, typefield) { var name; var colname = _parse_predicate_key(ObjType, {'epoch':false}, field); var datakey = colname.getMeta('datakey'); var field_name = (datakey ? datakey + '.' : '' ) + colname.getMeta('key'); if( (ObjType === NoPg.Document) && (typefield !=...
javascript
function pg_create_index_name(self, ObjType, type, field, typefield) { var name; var colname = _parse_predicate_key(ObjType, {'epoch':false}, field); var datakey = colname.getMeta('datakey'); var field_name = (datakey ? datakey + '.' : '' ) + colname.getMeta('key'); if( (ObjType === NoPg.Document) && (typefield !=...
[ "function", "pg_create_index_name", "(", "self", ",", "ObjType", ",", "type", ",", "field", ",", "typefield", ")", "{", "var", "name", ";", "var", "colname", "=", "_parse_predicate_key", "(", "ObjType", ",", "{", "'epoch'", ":", "false", "}", ",", "field",...
Returns index name @param self @param ObjType @param type @param field @param typefield @return {*}
[ "Returns", "index", "name" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1405-L1419
train
sendanor/nor-nopg
src/nopg.js
wrap_casts
function wrap_casts(x) { x = '' + x; if(/^\(.+\)$/.test(x)) { return '(' + x + ')'; } if(/::[a-z]+$/.test(x)) { if(/^[a-z]+ \->> /.test(x)) { return '((' + x + '))'; } return '(' + x + ')'; } return x; }
javascript
function wrap_casts(x) { x = '' + x; if(/^\(.+\)$/.test(x)) { return '(' + x + ')'; } if(/::[a-z]+$/.test(x)) { if(/^[a-z]+ \->> /.test(x)) { return '((' + x + '))'; } return '(' + x + ')'; } return x; }
[ "function", "wrap_casts", "(", "x", ")", "{", "x", "=", "''", "+", "x", ";", "if", "(", "/", "^\\(.+\\)$", "/", ".", "test", "(", "x", ")", ")", "{", "return", "'('", "+", "x", "+", "')'", ";", "}", "if", "(", "/", "::[a-z]+$", "/", ".", "t...
Wrap parenthesis around casts @param x @return {*}
[ "Wrap", "parenthesis", "around", "casts" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1448-L1460
train
sendanor/nor-nopg
src/nopg.js
pg_create_index_query_internal_v1
function pg_create_index_query_internal_v1(self, ObjType, type, field, typefield, is_unique) { var query; var pgcast = parse_predicate_pgcast(ObjType, type, field); var colname = _parse_predicate_key(ObjType, {'epoch':false}, field); var name = pg_create_index_name(self, ObjType, type, field, typefield); query = "...
javascript
function pg_create_index_query_internal_v1(self, ObjType, type, field, typefield, is_unique) { var query; var pgcast = parse_predicate_pgcast(ObjType, type, field); var colname = _parse_predicate_key(ObjType, {'epoch':false}, field); var name = pg_create_index_name(self, ObjType, type, field, typefield); query = "...
[ "function", "pg_create_index_query_internal_v1", "(", "self", ",", "ObjType", ",", "type", ",", "field", ",", "typefield", ",", "is_unique", ")", "{", "var", "query", ";", "var", "pgcast", "=", "parse_predicate_pgcast", "(", "ObjType", ",", "type", ",", "field...
Returns index query @param self @param ObjType @param type @param field @param typefield @param is_unique @return {string | *}
[ "Returns", "index", "query" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1471-L1486
train
sendanor/nor-nopg
src/nopg.js
pg_declare_index
function pg_declare_index(self, ObjType, type, field, typefield, is_unique) { var colname = _parse_predicate_key(ObjType, {'epoch':false}, field); var datakey = colname.getMeta('datakey'); var field_name = (datakey ? datakey + '.' : '' ) + colname.getMeta('key'); var name = pg_create_index_name(self, ObjType, type,...
javascript
function pg_declare_index(self, ObjType, type, field, typefield, is_unique) { var colname = _parse_predicate_key(ObjType, {'epoch':false}, field); var datakey = colname.getMeta('datakey'); var field_name = (datakey ? datakey + '.' : '' ) + colname.getMeta('key'); var name = pg_create_index_name(self, ObjType, type,...
[ "function", "pg_declare_index", "(", "self", ",", "ObjType", ",", "type", ",", "field", ",", "typefield", ",", "is_unique", ")", "{", "var", "colname", "=", "_parse_predicate_key", "(", "ObjType", ",", "{", "'epoch'", ":", "false", "}", ",", "field", ")", ...
Internal CREATE INDEX query that will create the index only if the relation does not exists already @param self @param ObjType @param type @param field @param typefield @param is_unique @return {Promise.<TResult>}
[ "Internal", "CREATE", "INDEX", "query", "that", "will", "create", "the", "index", "only", "if", "the", "relation", "does", "not", "exists", "already" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1594-L1622
train
sendanor/nor-nopg
src/nopg.js
pg_query
function pg_query(query, params) { return function(db) { var start_time = new Date(); return do_query(db, query, params).then(function() { var end_time = new Date(); db._record_sample({ 'event': 'query', 'start': start_time, 'end': end_time, 'query': query, 'params': params }); r...
javascript
function pg_query(query, params) { return function(db) { var start_time = new Date(); return do_query(db, query, params).then(function() { var end_time = new Date(); db._record_sample({ 'event': 'query', 'start': start_time, 'end': end_time, 'query': query, 'params': params }); r...
[ "function", "pg_query", "(", "query", ",", "params", ")", "{", "return", "function", "(", "db", ")", "{", "var", "start_time", "=", "new", "Date", "(", ")", ";", "return", "do_query", "(", "db", ",", "query", ",", "params", ")", ".", "then", "(", "...
Run query on the PostgreSQL server @param query @param params @return {Function}
[ "Run", "query", "on", "the", "PostgreSQL", "server" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1731-L1749
train
sendanor/nor-nopg
src/nopg.js
create_watchdog
function create_watchdog(db, opts) { debug.assert(db).is('object'); opts = opts || {}; debug.assert(opts).is('object'); opts.timeout = opts.timeout || 30000; debug.assert(opts.timeout).is('number'); var w = {}; w.db = db; w.opts = opts; /* Setup */ w.timeout = setTimeout(function() { debug.warn('Got t...
javascript
function create_watchdog(db, opts) { debug.assert(db).is('object'); opts = opts || {}; debug.assert(opts).is('object'); opts.timeout = opts.timeout || 30000; debug.assert(opts.timeout).is('number'); var w = {}; w.db = db; w.opts = opts; /* Setup */ w.timeout = setTimeout(function() { debug.warn('Got t...
[ "function", "create_watchdog", "(", "db", ",", "opts", ")", "{", "debug", ".", "assert", "(", "db", ")", ".", "is", "(", "'object'", ")", ";", "opts", "=", "opts", "||", "{", "}", ";", "debug", ".", "assert", "(", "opts", ")", ".", "is", "(", "...
Create watchdog timer @param db @param opts @return {{}}
[ "Create", "watchdog", "timer" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L1756-L1847
train
sendanor/nor-nopg
src/nopg.js
create_tcn_listener
function create_tcn_listener(events, when) { debug.assert(events).is('object'); debug.assert(when).is('object'); // Normalize event object back to event name var when_str = NoPg.stringifyEventName(when); return function tcn_listener(payload) { payload = NoPg.parseTCNPayload(payload); var event = tcn_event_m...
javascript
function create_tcn_listener(events, when) { debug.assert(events).is('object'); debug.assert(when).is('object'); // Normalize event object back to event name var when_str = NoPg.stringifyEventName(when); return function tcn_listener(payload) { payload = NoPg.parseTCNPayload(payload); var event = tcn_event_m...
[ "function", "create_tcn_listener", "(", "events", ",", "when", ")", "{", "debug", ".", "assert", "(", "events", ")", ".", "is", "(", "'object'", ")", ";", "debug", ".", "assert", "(", "when", ")", ".", "is", "(", "'object'", ")", ";", "// Normalize eve...
Returns a listener for notifications from TCN extension @param events {EventEmitter} The event emitter where we should trigger matching events. @param when {object} We should only trigger events that match this specification. Object with optional properties `type`, `id` and `name`.
[ "Returns", "a", "listener", "for", "notifications", "from", "TCN", "extension" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L2456-L2485
train
sendanor/nor-nopg
src/nopg.js
new_listener
function new_listener(event/*, listener*/) { // Ignore if not tcn event if(NoPg.isLocalEventName(event)) { return; } event = NoPg.parseEventName(event); // Stringifying back the event normalizes the original event name var event_name = NoPg.stringifyEventName(event); var channel_name = NoPg...
javascript
function new_listener(event/*, listener*/) { // Ignore if not tcn event if(NoPg.isLocalEventName(event)) { return; } event = NoPg.parseEventName(event); // Stringifying back the event normalizes the original event name var event_name = NoPg.stringifyEventName(event); var channel_name = NoPg...
[ "function", "new_listener", "(", "event", "/*, listener*/", ")", "{", "// Ignore if not tcn event", "if", "(", "NoPg", ".", "isLocalEventName", "(", "event", ")", ")", "{", "return", ";", "}", "event", "=", "NoPg", ".", "parseEventName", "(", "event", ")", "...
Listener for new listeners
[ "Listener", "for", "new", "listeners" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L2508-L2540
train
sendanor/nor-nopg
src/nopg.js
remove_listener
function remove_listener(event/*, listener*/) { // Ignore if not tcn event if(NoPg.isLocalEventName(event)) { return; } event = NoPg.parseEventName(event); // Stringifying back the event normalizes the original event name var event_name = NoPg.stringifyEventName(event); var channel_name = N...
javascript
function remove_listener(event/*, listener*/) { // Ignore if not tcn event if(NoPg.isLocalEventName(event)) { return; } event = NoPg.parseEventName(event); // Stringifying back the event normalizes the original event name var event_name = NoPg.stringifyEventName(event); var channel_name = N...
[ "function", "remove_listener", "(", "event", "/*, listener*/", ")", "{", "// Ignore if not tcn event", "if", "(", "NoPg", ".", "isLocalEventName", "(", "event", ")", ")", "{", "return", ";", "}", "event", "=", "NoPg", ".", "parseEventName", "(", "event", ")", ...
Listener for removing listeners
[ "Listener", "for", "removing", "listeners" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L2543-L2564
train
sendanor/nor-nopg
src/nopg.js
pad
function pad(num, size) { var s = num+""; while (s.length < size) { s = "0" + s; } return s; }
javascript
function pad(num, size) { var s = num+""; while (s.length < size) { s = "0" + s; } return s; }
[ "function", "pad", "(", "num", ",", "size", ")", "{", "var", "s", "=", "num", "+", "\"\"", ";", "while", "(", "s", ".", "length", "<", "size", ")", "{", "s", "=", "\"0\"", "+", "s", ";", "}", "return", "s", ";", "}" ]
Returns a number padded to specific width @param num @param size @return {string}
[ "Returns", "a", "number", "padded", "to", "specific", "width" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L2655-L2661
train
sendanor/nor-nopg
src/nopg.js
reset_methods
function reset_methods(doc) { if(is.array(doc)) { return ARRAY(doc).map(reset_methods).valueOf(); } if(is.object(doc)) { ARRAY(methods).forEach(function(method) { delete doc[method.$name]; }); } return doc; }
javascript
function reset_methods(doc) { if(is.array(doc)) { return ARRAY(doc).map(reset_methods).valueOf(); } if(is.object(doc)) { ARRAY(methods).forEach(function(method) { delete doc[method.$name]; }); } return doc; }
[ "function", "reset_methods", "(", "doc", ")", "{", "if", "(", "is", ".", "array", "(", "doc", ")", ")", "{", "return", "ARRAY", "(", "doc", ")", ".", "map", "(", "reset_methods", ")", ".", "valueOf", "(", ")", ";", "}", "if", "(", "is", ".", "o...
Removes methods from doc
[ "Removes", "methods", "from", "doc" ]
0d99b86c1a1996b5828b56de8de23700df8bbc0c
https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/nopg.js#L3175-L3188
train
gyuwon/node-fwalker
fwalker.js
Walker
function Walker () { var self = this; var walkSync = function (dir, trace, callback) { fs.readdirSync(dir).forEach(function (name) { var file = path.join(dir, name) , stat = fs.lstatSync(file) , isDir = stat.isDirectory() , _trace = trace; try { callback(name, file, ...
javascript
function Walker () { var self = this; var walkSync = function (dir, trace, callback) { fs.readdirSync(dir).forEach(function (name) { var file = path.join(dir, name) , stat = fs.lstatSync(file) , isDir = stat.isDirectory() , _trace = trace; try { callback(name, file, ...
[ "function", "Walker", "(", ")", "{", "var", "self", "=", "this", ";", "var", "walkSync", "=", "function", "(", "dir", ",", "trace", ",", "callback", ")", "{", "fs", ".", "readdirSync", "(", "dir", ")", ".", "forEach", "(", "function", "(", "name", ...
Initialize a new instance of the simple file traversal modules.
[ "Initialize", "a", "new", "instance", "of", "the", "simple", "file", "traversal", "modules", "." ]
6e31a1f6da9b0be516ceab9035e87f2934d6aac6
https://github.com/gyuwon/node-fwalker/blob/6e31a1f6da9b0be516ceab9035e87f2934d6aac6/fwalker.js#L33-L77
train
MostlyJS/mostly-feathers-mongoose
src/mongoose.js
getModel
function getModel (app, name, Model) { const mongooseClient = app.get('mongoose'); assert(mongooseClient, 'mongoose client not set by app'); const modelNames = mongooseClient.modelNames(); if (modelNames.includes(name)) { return mongooseClient.model(name); } else { assert(Model && typeof Model === 'fu...
javascript
function getModel (app, name, Model) { const mongooseClient = app.get('mongoose'); assert(mongooseClient, 'mongoose client not set by app'); const modelNames = mongooseClient.modelNames(); if (modelNames.includes(name)) { return mongooseClient.model(name); } else { assert(Model && typeof Model === 'fu...
[ "function", "getModel", "(", "app", ",", "name", ",", "Model", ")", "{", "const", "mongooseClient", "=", "app", ".", "get", "(", "'mongoose'", ")", ";", "assert", "(", "mongooseClient", ",", "'mongoose client not set by app'", ")", ";", "const", "modelNames", ...
Get or create the mongoose model if not exists
[ "Get", "or", "create", "the", "mongoose", "model", "if", "not", "exists" ]
d20e150e054c784cc7db7c2487399e4f4eb730de
https://github.com/MostlyJS/mostly-feathers-mongoose/blob/d20e150e054c784cc7db7c2487399e4f4eb730de/src/mongoose.js#L46-L56
train
MostlyJS/mostly-feathers-mongoose
src/mongoose.js
createModel
function createModel (app, name, options) { const mongooseClient = app.get('mongoose'); assert(mongooseClient, 'mongoose client not set by app'); const schema = new mongooseClient.Schema({ any: {} }, {strict: false}); return mongooseClient.model(name, schema); }
javascript
function createModel (app, name, options) { const mongooseClient = app.get('mongoose'); assert(mongooseClient, 'mongoose client not set by app'); const schema = new mongooseClient.Schema({ any: {} }, {strict: false}); return mongooseClient.model(name, schema); }
[ "function", "createModel", "(", "app", ",", "name", ",", "options", ")", "{", "const", "mongooseClient", "=", "app", ".", "get", "(", "'mongoose'", ")", ";", "assert", "(", "mongooseClient", ",", "'mongoose client not set by app'", ")", ";", "const", "schema",...
Create a mongoose model with free schema
[ "Create", "a", "mongoose", "model", "with", "free", "schema" ]
d20e150e054c784cc7db7c2487399e4f4eb730de
https://github.com/MostlyJS/mostly-feathers-mongoose/blob/d20e150e054c784cc7db7c2487399e4f4eb730de/src/mongoose.js#L61-L66
train
MostlyJS/mostly-feathers-mongoose
src/mongoose.js
createService
function createService (app, Service, Model, options) { Model = options.Model || Model; if (typeof Model === 'function') { assert(options.ModelName, 'createService but options.ModelName not provided'); options.Model = Model(app, options.ModelName); } else { options.Model = Model; } const service =...
javascript
function createService (app, Service, Model, options) { Model = options.Model || Model; if (typeof Model === 'function') { assert(options.ModelName, 'createService but options.ModelName not provided'); options.Model = Model(app, options.ModelName); } else { options.Model = Model; } const service =...
[ "function", "createService", "(", "app", ",", "Service", ",", "Model", ",", "options", ")", "{", "Model", "=", "options", ".", "Model", "||", "Model", ";", "if", "(", "typeof", "Model", "===", "'function'", ")", "{", "assert", "(", "options", ".", "Mod...
Create a service with mogoose model
[ "Create", "a", "service", "with", "mogoose", "model" ]
d20e150e054c784cc7db7c2487399e4f4eb730de
https://github.com/MostlyJS/mostly-feathers-mongoose/blob/d20e150e054c784cc7db7c2487399e4f4eb730de/src/mongoose.js#L71-L81
train
gethuman/pancakes-angular
lib/ngapp/tpl.helper.js
setDefaults
function setDefaults(scope, defaults) { if (!defaults) { return; } // store defaults for use in generateRemodel scope.defaults = defaults; for (var name in defaults) { if (defaults.hasOwnProperty(name) && scope[name] === undefined) { scope[name] = defaults[n...
javascript
function setDefaults(scope, defaults) { if (!defaults) { return; } // store defaults for use in generateRemodel scope.defaults = defaults; for (var name in defaults) { if (defaults.hasOwnProperty(name) && scope[name] === undefined) { scope[name] = defaults[n...
[ "function", "setDefaults", "(", "scope", ",", "defaults", ")", "{", "if", "(", "!", "defaults", ")", "{", "return", ";", "}", "// store defaults for use in generateRemodel", "scope", ".", "defaults", "=", "defaults", ";", "for", "(", "var", "name", "in", "de...
Given a set of default values, add them to the scope if a value does not already exist. @param scope @param defaults
[ "Given", "a", "set", "of", "default", "values", "add", "them", "to", "the", "scope", "if", "a", "value", "does", "not", "already", "exist", "." ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/tpl.helper.js#L17-L28
train
gethuman/pancakes-angular
lib/ngapp/tpl.helper.js
addValidations
function addValidations(scope, validations) { for (var name in validations) { if (validations.hasOwnProperty(name) && validations[name]) { scope[name] = $injector.invoke(validations[name]); } } }
javascript
function addValidations(scope, validations) { for (var name in validations) { if (validations.hasOwnProperty(name) && validations[name]) { scope[name] = $injector.invoke(validations[name]); } } }
[ "function", "addValidations", "(", "scope", ",", "validations", ")", "{", "for", "(", "var", "name", "in", "validations", ")", "{", "if", "(", "validations", ".", "hasOwnProperty", "(", "name", ")", "&&", "validations", "[", "name", "]", ")", "{", "scope...
Add validations to the scope @param scope @param validations
[ "Add", "validations", "to", "the", "scope" ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/tpl.helper.js#L173-L179
train
gethuman/pancakes-angular
lib/ngapp/tpl.helper.js
attachToScope
function attachToScope(scope, itemsToAttach) { if (!itemsToAttach || !itemsToAttach.length) { return; } itemsToAttach.push(function () { var i, val; for (i = 0; i < arguments.length; i++) { val = arguments[i]; scope[itemsToAttach[i]] = val; ...
javascript
function attachToScope(scope, itemsToAttach) { if (!itemsToAttach || !itemsToAttach.length) { return; } itemsToAttach.push(function () { var i, val; for (i = 0; i < arguments.length; i++) { val = arguments[i]; scope[itemsToAttach[i]] = val; ...
[ "function", "attachToScope", "(", "scope", ",", "itemsToAttach", ")", "{", "if", "(", "!", "itemsToAttach", "||", "!", "itemsToAttach", ".", "length", ")", "{", "return", ";", "}", "itemsToAttach", ".", "push", "(", "function", "(", ")", "{", "var", "i",...
Given an array of items, instantiate them and attach them to the scope. @param scope @param itemsToAttach
[ "Given", "an", "array", "of", "items", "instantiate", "them", "and", "attach", "them", "to", "the", "scope", "." ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/tpl.helper.js#L186-L198
train
gethuman/pancakes-angular
lib/ngapp/tpl.helper.js
addInitModel
function addInitModel(scope, initialModel, pageName) { angular.extend(scope, initialModel); if (scope.pageHead && scope.pageHead.title) { var title = scope.pageHead.title; pageSettings.updateHead(title, scope.pageHead.description || title); pageSettings.updatePageSt...
javascript
function addInitModel(scope, initialModel, pageName) { angular.extend(scope, initialModel); if (scope.pageHead && scope.pageHead.title) { var title = scope.pageHead.title; pageSettings.updateHead(title, scope.pageHead.description || title); pageSettings.updatePageSt...
[ "function", "addInitModel", "(", "scope", ",", "initialModel", ",", "pageName", ")", "{", "angular", ".", "extend", "(", "scope", ",", "initialModel", ")", ";", "if", "(", "scope", ".", "pageHead", "&&", "scope", ".", "pageHead", ".", "title", ")", "{", ...
Add the initial model to the scope and set the page title, desc, etc. @param scope @param initialModel @param pageName
[ "Add", "the", "initial", "model", "to", "the", "scope", "and", "set", "the", "page", "title", "desc", "etc", "." ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/tpl.helper.js#L338-L346
train
gethuman/pancakes-angular
lib/ngapp/tpl.helper.js
registerListeners
function registerListeners(scope, listeners) { var fns = []; for (var name in listeners) { if (listeners.hasOwnProperty(name) && listeners[name]) { fns.push(eventBus.on(name, $injector.invoke(listeners[name]))); } } // make sure handlers are dest...
javascript
function registerListeners(scope, listeners) { var fns = []; for (var name in listeners) { if (listeners.hasOwnProperty(name) && listeners[name]) { fns.push(eventBus.on(name, $injector.invoke(listeners[name]))); } } // make sure handlers are dest...
[ "function", "registerListeners", "(", "scope", ",", "listeners", ")", "{", "var", "fns", "=", "[", "]", ";", "for", "(", "var", "name", "in", "listeners", ")", "{", "if", "(", "listeners", ".", "hasOwnProperty", "(", "name", ")", "&&", "listeners", "["...
Register listeners and make sure they will be destoryed once the scope is destroyed. @param scope @param listeners
[ "Register", "listeners", "and", "make", "sure", "they", "will", "be", "destoryed", "once", "the", "scope", "is", "destroyed", "." ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/tpl.helper.js#L355-L370
train
gethuman/pancakes-angular
lib/ngapp/tpl.helper.js
addEventHandlers
function addEventHandlers(scope, ctrlName, handlers) { if (!handlers) { return; } for (var name in handlers) { if (handlers.hasOwnProperty(name) && handlers[name]) { scope[name] = $injector.invoke(handlers[name]); // if it is not a function, throw error b/c ...
javascript
function addEventHandlers(scope, ctrlName, handlers) { if (!handlers) { return; } for (var name in handlers) { if (handlers.hasOwnProperty(name) && handlers[name]) { scope[name] = $injector.invoke(handlers[name]); // if it is not a function, throw error b/c ...
[ "function", "addEventHandlers", "(", "scope", ",", "ctrlName", ",", "handlers", ")", "{", "if", "(", "!", "handlers", ")", "{", "return", ";", "}", "for", "(", "var", "name", "in", "handlers", ")", "{", "if", "(", "handlers", ".", "hasOwnProperty", "("...
Add the UI event handlers to the scope @param scope @param ctrlName @param handlers
[ "Add", "the", "UI", "event", "handlers", "to", "the", "scope" ]
9589b7ba09619843e271293088005c62ed23f355
https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/tpl.helper.js#L378-L391
train
cliffano/bagofcli
lib/bagofcli.js
exec
function exec(command, fallthrough, cb) { execute(command, fallthrough, false, function(err, stdOutOuput, stdErrOuput, result) { // drop stdOutOuput and stdErrOuput parameters to keep exec backwards compatible. cb(err, result); }); }
javascript
function exec(command, fallthrough, cb) { execute(command, fallthrough, false, function(err, stdOutOuput, stdErrOuput, result) { // drop stdOutOuput and stdErrOuput parameters to keep exec backwards compatible. cb(err, result); }); }
[ "function", "exec", "(", "command", ",", "fallthrough", ",", "cb", ")", "{", "execute", "(", "command", ",", "fallthrough", ",", "false", ",", "function", "(", "err", ",", "stdOutOuput", ",", "stdErrOuput", ",", "result", ")", "{", "// drop stdOutOuput and s...
Execute a one-liner command. The output emitted on stderr and stdout of the child process will be written to process.stdout and process.stderr of this process. Fallthrough is handy in situation where there are multiple execs running in sequence/parallel, and they all have to be executed regardless of success/error on...
[ "Execute", "a", "one", "-", "liner", "command", "." ]
0950716c5a670ca5c73b3d27494b58d5b78f2179
https://github.com/cliffano/bagofcli/blob/0950716c5a670ca5c73b3d27494b58d5b78f2179/lib/bagofcli.js#L202-L207
train
cliffano/bagofcli
lib/bagofcli.js
execute
function execute(command, fallthrough, collectOutput, cb) { var collectedStdOut = ''; var collectedStdErr = ''; var _exec = child.exec(command, function (err) { var result; if (err && fallthrough) { // camouflage error to allow other execs to keep running result = err; err = null; }...
javascript
function execute(command, fallthrough, collectOutput, cb) { var collectedStdOut = ''; var collectedStdErr = ''; var _exec = child.exec(command, function (err) { var result; if (err && fallthrough) { // camouflage error to allow other execs to keep running result = err; err = null; }...
[ "function", "execute", "(", "command", ",", "fallthrough", ",", "collectOutput", ",", "cb", ")", "{", "var", "collectedStdOut", "=", "''", ";", "var", "collectedStdErr", "=", "''", ";", "var", "_exec", "=", "child", ".", "exec", "(", "command", ",", "fun...
not exported Execute a one-liner command. The output emitted on stderr and stdout of the child process will either be written to process.stdout and process.stderr of this process or collected and passed on to the given callback, depending on collectOutput. Fallthrough is handy in situation where there are multiple e...
[ "not", "exported", "Execute", "a", "one", "-", "liner", "command", "." ]
0950716c5a670ca5c73b3d27494b58d5b78f2179
https://github.com/cliffano/bagofcli/blob/0950716c5a670ca5c73b3d27494b58d5b78f2179/lib/bagofcli.js#L244-L273
train
cliffano/bagofcli
lib/bagofcli.js
exit
function exit(err, result) { if (err) { console.error(colors.red(err.message || JSON.stringify(err))); process.exit(1); } else { process.exit(0); } }
javascript
function exit(err, result) { if (err) { console.error(colors.red(err.message || JSON.stringify(err))); process.exit(1); } else { process.exit(0); } }
[ "function", "exit", "(", "err", ",", "result", ")", "{", "if", "(", "err", ")", "{", "console", ".", "error", "(", "colors", ".", "red", "(", "err", ".", "message", "||", "JSON", ".", "stringify", "(", "err", ")", ")", ")", ";", "process", ".", ...
Handle process exit based on the existence of error. This is handy for command-line tools to use as the final callback. Exit status code 1 indicates an error, exit status code 0 indicates a success. Error message will be logged to the console. Result object is only used for convenient debugging. @param {Error} err: er...
[ "Handle", "process", "exit", "based", "on", "the", "existence", "of", "error", ".", "This", "is", "handy", "for", "command", "-", "line", "tools", "to", "use", "as", "the", "final", "callback", ".", "Exit", "status", "code", "1", "indicates", "an", "erro...
0950716c5a670ca5c73b3d27494b58d5b78f2179
https://github.com/cliffano/bagofcli/blob/0950716c5a670ca5c73b3d27494b58d5b78f2179/lib/bagofcli.js#L284-L291
train
cliffano/bagofcli
lib/bagofcli.js
files
function files(items, opts) { opts = opts || {}; var data = []; function addMatch(item) { if (opts.match === undefined || (opts.match && item.match(new RegExp(opts.match)))) { data.push(item); } } items.forEach(function (item) { var stat = fs.statSync(item); if (stat.isFile()) { ...
javascript
function files(items, opts) { opts = opts || {}; var data = []; function addMatch(item) { if (opts.match === undefined || (opts.match && item.match(new RegExp(opts.match)))) { data.push(item); } } items.forEach(function (item) { var stat = fs.statSync(item); if (stat.isFile()) { ...
[ "function", "files", "(", "items", ",", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "var", "data", "=", "[", "]", ";", "function", "addMatch", "(", "item", ")", "{", "if", "(", "opts", ".", "match", "===", "undefined", "||", "(", ...
Get an array of files contained in specified items. When a directory is specified, all files contained within that directory and its sub-directories will be included. @param {Array} items: an array of files and/or directories @param {Object} opts: optional - match: regular expression to match against the file name @re...
[ "Get", "an", "array", "of", "files", "contained", "in", "specified", "items", ".", "When", "a", "directory", "is", "specified", "all", "files", "contained", "within", "that", "directory", "and", "its", "sub", "-", "directories", "will", "be", "included", "."...
0950716c5a670ca5c73b3d27494b58d5b78f2179
https://github.com/cliffano/bagofcli/blob/0950716c5a670ca5c73b3d27494b58d5b78f2179/lib/bagofcli.js#L335-L362
train
bcrespy/creenv-canvas
lib/index.js
Canvas
function Canvas (canvasElement, fullWindow, autoInit) { if( !(this instanceof Canvas) ) { return new Canvas.apply(null, arguments); } /** * @type {HTMLCanvasElement} * @public */ this.canvas = null; /** * @type {CanvasRenderingContext2D} * @public */ this.context = null; /** * ...
javascript
function Canvas (canvasElement, fullWindow, autoInit) { if( !(this instanceof Canvas) ) { return new Canvas.apply(null, arguments); } /** * @type {HTMLCanvasElement} * @public */ this.canvas = null; /** * @type {CanvasRenderingContext2D} * @public */ this.context = null; /** * ...
[ "function", "Canvas", "(", "canvasElement", ",", "fullWindow", ",", "autoInit", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Canvas", ")", ")", "{", "return", "new", "Canvas", ".", "apply", "(", "null", ",", "arguments", ")", ";", "}", "/**\n ...
The canvas class provides an interface to work with the html canvas API. Most of the drawing methods of this class directly call the built-in functions, it is just faster to write and think code using this @param {?HTMLCanvasElement} canvasElement the html canvas element, if none is provided, one will be added to the ...
[ "The", "canvas", "class", "provides", "an", "interface", "to", "work", "with", "the", "html", "canvas", "API", ".", "Most", "of", "the", "drawing", "methods", "of", "this", "class", "directly", "call", "the", "built", "-", "in", "functions", "it", "is", ...
7890ca08a9fafebb2cff1ea830d0523ab697dffe
https://github.com/bcrespy/creenv-canvas/blob/7890ca08a9fafebb2cff1ea830d0523ab697dffe/lib/index.js#L25-L93
train
bcrespy/creenv-canvas
lib/index.js
function (color) { if (color === undefined) { this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); } else { let fillstyle = this.context.fillStyle; this.fillStyle(color); this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); this.fillStyle(fillstyle); ...
javascript
function (color) { if (color === undefined) { this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); } else { let fillstyle = this.context.fillStyle; this.fillStyle(color); this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); this.fillStyle(fillstyle); ...
[ "function", "(", "color", ")", "{", "if", "(", "color", "===", "undefined", ")", "{", "this", ".", "context", ".", "fillRect", "(", "0", ",", "0", ",", "this", ".", "canvas", ".", "width", ",", "this", ".", "canvas", ".", "height", ")", ";", "}",...
"Rewriting" some of the most useful context functions so that coding goes faster Fills the canvas with the provided color, in no color is provided fills it with the active color. Fillstyle is reset to its previous value after this function's call @param {Color|string} color either a @creenv/color object or a html co...
[ "Rewriting", "some", "of", "the", "most", "useful", "context", "functions", "so", "that", "coding", "goes", "faster", "Fills", "the", "canvas", "with", "the", "provided", "color", "in", "no", "color", "is", "provided", "fills", "it", "with", "the", "active",...
7890ca08a9fafebb2cff1ea830d0523ab697dffe
https://github.com/bcrespy/creenv-canvas/blob/7890ca08a9fafebb2cff1ea830d0523ab697dffe/lib/index.js#L128-L137
train
bcrespy/creenv-canvas
lib/index.js
function (x, y) { if (!this.pathStarted) { this.context.beginPath(); this.context.moveTo(x,y); this.pathStarted = true; } else { this.context.lineTo(x,y); } }
javascript
function (x, y) { if (!this.pathStarted) { this.context.beginPath(); this.context.moveTo(x,y); this.pathStarted = true; } else { this.context.lineTo(x,y); } }
[ "function", "(", "x", ",", "y", ")", "{", "if", "(", "!", "this", ".", "pathStarted", ")", "{", "this", ".", "context", ".", "beginPath", "(", ")", ";", "this", ".", "context", ".", "moveTo", "(", "x", ",", "y", ")", ";", "this", ".", "pathStar...
Adds a point to the path. If a path has not been started, create one @param {number} x the x coordinate of the point @param {number} y the y coordinate of the point
[ "Adds", "a", "point", "to", "the", "path", ".", "If", "a", "path", "has", "not", "been", "started", "create", "one" ]
7890ca08a9fafebb2cff1ea830d0523ab697dffe
https://github.com/bcrespy/creenv-canvas/blob/7890ca08a9fafebb2cff1ea830d0523ab697dffe/lib/index.js#L201-L209
train
inviqa/deck-task-registry
src/styles/buildStyles.js
buildStyles
function buildStyles(conf, undertaker) { // Config that gets passed to node-sass. const sassConfig = conf.themeConfig.sass.nodeSassConf || {}; // If we're in production mode, then compress the output CSS. if (conf.productionMode) { sassConfig.outputStyle = 'compressed'; } // Any PostCSS...
javascript
function buildStyles(conf, undertaker) { // Config that gets passed to node-sass. const sassConfig = conf.themeConfig.sass.nodeSassConf || {}; // If we're in production mode, then compress the output CSS. if (conf.productionMode) { sassConfig.outputStyle = 'compressed'; } // Any PostCSS...
[ "function", "buildStyles", "(", "conf", ",", "undertaker", ")", "{", "// Config that gets passed to node-sass.", "const", "sassConfig", "=", "conf", ".", "themeConfig", ".", "sass", ".", "nodeSassConf", "||", "{", "}", ";", "// If we're in production mode, then compress...
Build project styles. @param {ConfigParser} conf A configuration parser object. @param {Undertaker} undertaker An Undertaker instance. @returns {Stream} A stream of files.
[ "Build", "project", "styles", "." ]
4c31787b978e9d99a47052e090d4589a50cd3015
https://github.com/inviqa/deck-task-registry/blob/4c31787b978e9d99a47052e090d4589a50cd3015/src/styles/buildStyles.js#L18-L46
train
Psychopoulet/node-promfs
lib/extends/_copyFile.js
_copyFile
function _copyFile (origin, target, callback) { if ("undefined" === typeof origin) { throw new ReferenceError("Missing \"origin\" argument"); } else if ("string" !== typeof origin) { throw new TypeError("\"origin\" argument is not a string"); } else if ("" === origin.trim()) { throw new...
javascript
function _copyFile (origin, target, callback) { if ("undefined" === typeof origin) { throw new ReferenceError("Missing \"origin\" argument"); } else if ("string" !== typeof origin) { throw new TypeError("\"origin\" argument is not a string"); } else if ("" === origin.trim()) { throw new...
[ "function", "_copyFile", "(", "origin", ",", "target", ",", "callback", ")", "{", "if", "(", "\"undefined\"", "===", "typeof", "origin", ")", "{", "throw", "new", "ReferenceError", "(", "\"Missing \\\"origin\\\" argument\"", ")", ";", "}", "else", "if", "(", ...
methods Async copyFile @param {string} origin : file to copy @param {string} target : file to copy in @param {function|null} callback : operation's result @returns {void}
[ "methods", "Async", "copyFile" ]
016e272fc58c6ef6eae5ea551a0e8873f0ac20cc
https://github.com/Psychopoulet/node-promfs/blob/016e272fc58c6ef6eae5ea551a0e8873f0ac20cc/lib/extends/_copyFile.js#L22-L75
train
aureooms/js-array
lib/reduce/reduce.js
reduce
function reduce(accumulator, iterable, initializer) { var i, len; i = 0; len = iterable.length; if (len === 0) { return initializer; } for (; i < len; ++i) { initializer = accumulator(initializer, iterable[i]); } return initializer; }
javascript
function reduce(accumulator, iterable, initializer) { var i, len; i = 0; len = iterable.length; if (len === 0) { return initializer; } for (; i < len; ++i) { initializer = accumulator(initializer, iterable[i]); } return initializer; }
[ "function", "reduce", "(", "accumulator", ",", "iterable", ",", "initializer", ")", "{", "var", "i", ",", "len", ";", "i", "=", "0", ";", "len", "=", "iterable", ".", "length", ";", "if", "(", "len", "===", "0", ")", "{", "return", "initializer", "...
Applies the accumulator function iteratively on the last return value of the accumulator and the next value in the iterable. The initial value is the initializer parameter. /!\ currently only works with an accumulator that is a function object and an array iterable
[ "Applies", "the", "accumulator", "function", "iteratively", "on", "the", "last", "return", "value", "of", "the", "accumulator", "and", "the", "next", "value", "in", "the", "iterable", ".", "The", "initial", "value", "is", "the", "initializer", "parameter", "."...
b062caceaf08f79cc5f36f6b265e50b984f5e85e
https://github.com/aureooms/js-array/blob/b062caceaf08f79cc5f36f6b265e50b984f5e85e/lib/reduce/reduce.js#L20-L37
train
fnogatz/tconsole
lib/index.js
load
function load (location) { var required = requireAll(location) var config = {} for (var key in required) { config[key.replace(/^array\./, 'array:')] = required[key] } var konsole = createConsole(config) return konsole }
javascript
function load (location) { var required = requireAll(location) var config = {} for (var key in required) { config[key.replace(/^array\./, 'array:')] = required[key] } var konsole = createConsole(config) return konsole }
[ "function", "load", "(", "location", ")", "{", "var", "required", "=", "requireAll", "(", "location", ")", "var", "config", "=", "{", "}", "for", "(", "var", "key", "in", "required", ")", "{", "config", "[", "key", ".", "replace", "(", "/", "^array\\...
Create a console by requiring all renderers in a given location. @param {String} location Filesystem path to use with require-all @return {tconsole}
[ "Create", "a", "console", "by", "requiring", "all", "renderers", "in", "a", "given", "location", "." ]
debcdaf916f7e8f43b35c4c907b585f5c1c69f0f
https://github.com/fnogatz/tconsole/blob/debcdaf916f7e8f43b35c4c907b585f5c1c69f0f/lib/index.js#L58-L66
train
fnogatz/tconsole
lib/index.js
combine
function combine () { var config = {} Array.prototype.forEach.call(arguments, function (tconsoleInstance) { mergeObject(config, tconsoleInstance._tconsoleConfig) }) return createConsole(config) }
javascript
function combine () { var config = {} Array.prototype.forEach.call(arguments, function (tconsoleInstance) { mergeObject(config, tconsoleInstance._tconsoleConfig) }) return createConsole(config) }
[ "function", "combine", "(", ")", "{", "var", "config", "=", "{", "}", "Array", ".", "prototype", ".", "forEach", ".", "call", "(", "arguments", ",", "function", "(", "tconsoleInstance", ")", "{", "mergeObject", "(", "config", ",", "tconsoleInstance", ".", ...
Combine multiple tconsole instances. @return {tconsole}
[ "Combine", "multiple", "tconsole", "instances", "." ]
debcdaf916f7e8f43b35c4c907b585f5c1c69f0f
https://github.com/fnogatz/tconsole/blob/debcdaf916f7e8f43b35c4c907b585f5c1c69f0f/lib/index.js#L72-L78
train
redisjs/jsr-store
lib/type/hash.js
HashMap
function HashMap(source) { this._rtype = TYPE_NAMES.HASH; this.reset(); if(source) { for(var k in source) { this.setKey(k, source[k]); } } }
javascript
function HashMap(source) { this._rtype = TYPE_NAMES.HASH; this.reset(); if(source) { for(var k in source) { this.setKey(k, source[k]); } } }
[ "function", "HashMap", "(", "source", ")", "{", "this", ".", "_rtype", "=", "TYPE_NAMES", ".", "HASH", ";", "this", ".", "reset", "(", ")", ";", "if", "(", "source", ")", "{", "for", "(", "var", "k", "in", "source", ")", "{", "this", ".", "setKey...
Represents the hash map type. This is actually a linked list. Keys are stored in an array so that calls to retrieve the keys do not need to call Object.keys(). Key list retrieval will be fast, sacrificing memory for less cpu under the assumption that it is easier to supply more memory and harder to supply more cpu cy...
[ "Represents", "the", "hash", "map", "type", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/hash.js#L21-L29
train
redisjs/jsr-store
lib/type/hash.js
setExpiry
function setExpiry(key, ms, req) { var rval = this.getRawKey(key); if(rval === undefined) return 0; // expiry is in the past or now, delete immediately // but return 1 to indicate the expiry was set if(ms <= Date.now()) { this.delKey(key, req); return 1; } if(!this._expires[key]) { this._ekeys...
javascript
function setExpiry(key, ms, req) { var rval = this.getRawKey(key); if(rval === undefined) return 0; // expiry is in the past or now, delete immediately // but return 1 to indicate the expiry was set if(ms <= Date.now()) { this.delKey(key, req); return 1; } if(!this._expires[key]) { this._ekeys...
[ "function", "setExpiry", "(", "key", ",", "ms", ",", "req", ")", "{", "var", "rval", "=", "this", ".", "getRawKey", "(", "key", ")", ";", "if", "(", "rval", "===", "undefined", ")", "return", "0", ";", "// expiry is in the past or now, delete immediately", ...
Set expiry on a key as a unix timestamp in ms.
[ "Set", "expiry", "on", "a", "key", "as", "a", "unix", "timestamp", "in", "ms", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/hash.js#L128-L143
train
redisjs/jsr-store
lib/type/hash.js
delExpiry
function delExpiry(key, req) { var rval = this.getRawKey(key); if(rval === undefined || rval.e === undefined) return 0; // the code flow ensures we have a valid // index into the expiring keys array this._ekeys.splice(ArrayIndex.indexOf(key, this._ekeys), 1); delete this._expires[key]; delete rval.e; re...
javascript
function delExpiry(key, req) { var rval = this.getRawKey(key); if(rval === undefined || rval.e === undefined) return 0; // the code flow ensures we have a valid // index into the expiring keys array this._ekeys.splice(ArrayIndex.indexOf(key, this._ekeys), 1); delete this._expires[key]; delete rval.e; re...
[ "function", "delExpiry", "(", "key", ",", "req", ")", "{", "var", "rval", "=", "this", ".", "getRawKey", "(", "key", ")", ";", "if", "(", "rval", "===", "undefined", "||", "rval", ".", "e", "===", "undefined", ")", "return", "0", ";", "// the code fl...
Delete expiry on a key.
[ "Delete", "expiry", "on", "a", "key", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/hash.js#L148-L157
train
redisjs/jsr-store
lib/type/hash.js
delExpiredKeys
function delExpiredKeys(num, threshold) { function removeExpiredKeys(count) { if(!this._ekeys.length) return 0; var num = num || 100 , threshold = threshold || 25 , count = count || 0 , i , key , ind; for(i = 0;i < num;i++) { ind = Math.floor(Math.random() * this._eke...
javascript
function delExpiredKeys(num, threshold) { function removeExpiredKeys(count) { if(!this._ekeys.length) return 0; var num = num || 100 , threshold = threshold || 25 , count = count || 0 , i , key , ind; for(i = 0;i < num;i++) { ind = Math.floor(Math.random() * this._eke...
[ "function", "delExpiredKeys", "(", "num", ",", "threshold", ")", "{", "function", "removeExpiredKeys", "(", "count", ")", "{", "if", "(", "!", "this", ".", "_ekeys", ".", "length", ")", "return", "0", ";", "var", "num", "=", "num", "||", "100", ",", ...
Passive expiry. Picks 100 keys at random from the list of expired keys and if the number of expired keys exceeds 25 continue to delete expired keys.
[ "Passive", "expiry", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/hash.js#L231-L261
train
redisjs/jsr-store
lib/type/hash.js
getValueBuffer
function getValueBuffer(key, req, stringify) { var val = this.getKey(key, req); // should have buffer, string or number if(val !== undefined) { if(typeof val === 'number' && !stringify) val = new Buffer([val]); val = (val instanceof Buffer) ? val : new Buffer('' + val); } return val; }
javascript
function getValueBuffer(key, req, stringify) { var val = this.getKey(key, req); // should have buffer, string or number if(val !== undefined) { if(typeof val === 'number' && !stringify) val = new Buffer([val]); val = (val instanceof Buffer) ? val : new Buffer('' + val); } return val; }
[ "function", "getValueBuffer", "(", "key", ",", "req", ",", "stringify", ")", "{", "var", "val", "=", "this", ".", "getKey", "(", "key", ",", "req", ")", ";", "// should have buffer, string or number", "if", "(", "val", "!==", "undefined", ")", "{", "if", ...
Get the value for a key as a buffer regardless of it being a string, number or existing buffer. @param key The key. @param req The request object. @param stringify Convert numbers to strings then buffer.
[ "Get", "the", "value", "for", "a", "key", "as", "a", "buffer", "regardless", "of", "it", "being", "a", "string", "number", "or", "existing", "buffer", "." ]
b2b5c5b0347819f8a388b5d67e121ee8d73f328c
https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/hash.js#L288-L296
train
bholloway/browserify-anonymous-labeler
lib/interleave.js
interleave
function interleave(additional) { return function reduce(reduced, value, i) { if (i === 0) { reduced.push(value); } else { reduced.push(additional, value); } return reduced; } }
javascript
function interleave(additional) { return function reduce(reduced, value, i) { if (i === 0) { reduced.push(value); } else { reduced.push(additional, value); } return reduced; } }
[ "function", "interleave", "(", "additional", ")", "{", "return", "function", "reduce", "(", "reduced", ",", "value", ",", "i", ")", "{", "if", "(", "i", "===", "0", ")", "{", "reduced", ".", "push", "(", "value", ")", ";", "}", "else", "{", "reduce...
Get a reduce method that interleaves the given additional value between each existing element in an array. @param {*} additional The value to interleave @returns {function} A method that reduces an array a returns an interleaved array
[ "Get", "a", "reduce", "method", "that", "interleaves", "the", "given", "additional", "value", "between", "each", "existing", "element", "in", "an", "array", "." ]
651b124eefe8d1a567b2a03a0b8a3dfea87c2703
https://github.com/bholloway/browserify-anonymous-labeler/blob/651b124eefe8d1a567b2a03a0b8a3dfea87c2703/lib/interleave.js#L8-L17
train
oconnore/harmony-enumerables
collections.js
Node
function Node(value, prev, next) { this.value = value; this.prev = prev; this.next = next; }
javascript
function Node(value, prev, next) { this.value = value; this.prev = prev; this.next = next; }
[ "function", "Node", "(", "value", ",", "prev", ",", "next", ")", "{", "this", ".", "value", "=", "value", ";", "this", ".", "prev", "=", "prev", ";", "this", ".", "next", "=", "next", ";", "}" ]
A doubly linked node
[ "A", "doubly", "linked", "node" ]
77a0a6b6726bcbb877c494f6c14f175de7225699
https://github.com/oconnore/harmony-enumerables/blob/77a0a6b6726bcbb877c494f6c14f175de7225699/collections.js#L68-L72
train
oconnore/harmony-enumerables
collections.js
Sequence
function Sequence(iterable) { this.sequence = null; this._size = 0; this.nodeMap = new rMap(); if (iterable) { if (typeof iterable.length === 'number') { for (var i = 0; i < iterable.length; i++) { this.add.apply(this, iterable[i]); } } else if (typeof iterable.entr...
javascript
function Sequence(iterable) { this.sequence = null; this._size = 0; this.nodeMap = new rMap(); if (iterable) { if (typeof iterable.length === 'number') { for (var i = 0; i < iterable.length; i++) { this.add.apply(this, iterable[i]); } } else if (typeof iterable.entr...
[ "function", "Sequence", "(", "iterable", ")", "{", "this", ".", "sequence", "=", "null", ";", "this", ".", "_size", "=", "0", ";", "this", ".", "nodeMap", "=", "new", "rMap", "(", ")", ";", "if", "(", "iterable", ")", "{", "if", "(", "typeof", "i...
A Sequence is a doubly linked list where the conses are also stored in a Map and accessible by a key.
[ "A", "Sequence", "is", "a", "doubly", "linked", "list", "where", "the", "conses", "are", "also", "stored", "in", "a", "Map", "and", "accessible", "by", "a", "key", "." ]
77a0a6b6726bcbb877c494f6c14f175de7225699
https://github.com/oconnore/harmony-enumerables/blob/77a0a6b6726bcbb877c494f6c14f175de7225699/collections.js#L99-L116
train
oconnore/harmony-enumerables
collections.js
bindHelper
function bindHelper(fn) { return function() { var p = priv.get(this); return fn.apply(p.sequence, Array.prototype.slice.call(arguments)); } }
javascript
function bindHelper(fn) { return function() { var p = priv.get(this); return fn.apply(p.sequence, Array.prototype.slice.call(arguments)); } }
[ "function", "bindHelper", "(", "fn", ")", "{", "return", "function", "(", ")", "{", "var", "p", "=", "priv", ".", "get", "(", "this", ")", ";", "return", "fn", ".", "apply", "(", "p", ".", "sequence", ",", "Array", ".", "prototype", ".", "slice", ...
bindHelper calls a function on our private internal Sequence. It is used by EnumMap and EnumSet to delegate to the private sequence object.
[ "bindHelper", "calls", "a", "function", "on", "our", "private", "internal", "Sequence", ".", "It", "is", "used", "by", "EnumMap", "and", "EnumSet", "to", "delegate", "to", "the", "private", "sequence", "object", "." ]
77a0a6b6726bcbb877c494f6c14f175de7225699
https://github.com/oconnore/harmony-enumerables/blob/77a0a6b6726bcbb877c494f6c14f175de7225699/collections.js#L189-L194
train
oconnore/harmony-enumerables
collections.js
EnumMap
function EnumMap(iter) { var p = {}; priv.set(this, p); var newIter = iter; if(iter && typeof iter.entries === 'function') { if (iter instanceof EnumSet) { newIter = { entries: function() { var pi = priv.get(iter); return new Iterator(pi.sequence.sequence,...
javascript
function EnumMap(iter) { var p = {}; priv.set(this, p); var newIter = iter; if(iter && typeof iter.entries === 'function') { if (iter instanceof EnumSet) { newIter = { entries: function() { var pi = priv.get(iter); return new Iterator(pi.sequence.sequence,...
[ "function", "EnumMap", "(", "iter", ")", "{", "var", "p", "=", "{", "}", ";", "priv", ".", "set", "(", "this", ",", "p", ")", ";", "var", "newIter", "=", "iter", ";", "if", "(", "iter", "&&", "typeof", "iter", ".", "entries", "===", "'function'",...
This is our poly-filled Map, which we can enumerate using Sequence
[ "This", "is", "our", "poly", "-", "filled", "Map", "which", "we", "can", "enumerate", "using", "Sequence" ]
77a0a6b6726bcbb877c494f6c14f175de7225699
https://github.com/oconnore/harmony-enumerables/blob/77a0a6b6726bcbb877c494f6c14f175de7225699/collections.js#L197-L212
train
oconnore/harmony-enumerables
collections.js
EnumSet
function EnumSet(iter) { var p = {}; priv.set(this, p); var newIter = iter; if (Array.isArray(iter)) { newIter = Array.prototype.map.call(iter, function(x) { return [x, x]; }); } else if(iter && typeof iter.entries === 'function') { if (iter instanceof EnumMap) { ne...
javascript
function EnumSet(iter) { var p = {}; priv.set(this, p); var newIter = iter; if (Array.isArray(iter)) { newIter = Array.prototype.map.call(iter, function(x) { return [x, x]; }); } else if(iter && typeof iter.entries === 'function') { if (iter instanceof EnumMap) { ne...
[ "function", "EnumSet", "(", "iter", ")", "{", "var", "p", "=", "{", "}", ";", "priv", ".", "set", "(", "this", ",", "p", ")", ";", "var", "newIter", "=", "iter", ";", "if", "(", "Array", ".", "isArray", "(", "iter", ")", ")", "{", "newIter", ...
This is our poly-filled Set, which we can enumerate using Sequence
[ "This", "is", "our", "poly", "-", "filled", "Set", "which", "we", "can", "enumerate", "using", "Sequence" ]
77a0a6b6726bcbb877c494f6c14f175de7225699
https://github.com/oconnore/harmony-enumerables/blob/77a0a6b6726bcbb877c494f6c14f175de7225699/collections.js#L235-L256
train
freshtilledsoil/FTS-grunt
Gruntfile.js
loadConfig
function loadConfig(path) { var glob = require('glob'); var object = {}; var key; glob.sync('*', {cwd: path}).forEach(function(option) { key = option.replace(/\.js$/,''); object[key] = require(path + option); }); return object; }
javascript
function loadConfig(path) { var glob = require('glob'); var object = {}; var key; glob.sync('*', {cwd: path}).forEach(function(option) { key = option.replace(/\.js$/,''); object[key] = require(path + option); }); return object; }
[ "function", "loadConfig", "(", "path", ")", "{", "var", "glob", "=", "require", "(", "'glob'", ")", ";", "var", "object", "=", "{", "}", ";", "var", "key", ";", "glob", ".", "sync", "(", "'*'", ",", "{", "cwd", ":", "path", "}", ")", ".", "forE...
Utility to load the different option files based on their names
[ "Utility", "to", "load", "the", "different", "option", "files", "based", "on", "their", "names" ]
955bafdffb57d7d2df08b6fdf67b56c75bb6c4ce
https://github.com/freshtilledsoil/FTS-grunt/blob/955bafdffb57d7d2df08b6fdf67b56c75bb6c4ce/Gruntfile.js#L5-L16
train
gethuman/pancakes-recipe
batch/db.clear/db.clear.batch.js
clearDatabase
function clearDatabase() { var promises = []; _.each(resources, function (resource) { var service = pancakes.getService(resource.name); if (service.removePermanently) { log.info('purging ' + resource.name); promises.push(service.removePermanently(...
javascript
function clearDatabase() { var promises = []; _.each(resources, function (resource) { var service = pancakes.getService(resource.name); if (service.removePermanently) { log.info('purging ' + resource.name); promises.push(service.removePermanently(...
[ "function", "clearDatabase", "(", ")", "{", "var", "promises", "=", "[", "]", ";", "_", ".", "each", "(", "resources", ",", "function", "(", "resource", ")", "{", "var", "service", "=", "pancakes", ".", "getService", "(", "resource", ".", "name", ")", ...
Purge everything in the database
[ "Purge", "everything", "in", "the", "database" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/batch/db.clear/db.clear.batch.js#L27-L39
train
gethuman/pancakes-recipe
batch/db.clear/db.clear.batch.js
confirmClear
function confirmClear() { var promptSchema = { properties: { confirm: { description: 'Delete everything in the ' + config.env.toUpperCase() + ' database? (y or n) ', pattern: /^[yn]$/, message: 'Please respond with y or n. '...
javascript
function confirmClear() { var promptSchema = { properties: { confirm: { description: 'Delete everything in the ' + config.env.toUpperCase() + ' database? (y or n) ', pattern: /^[yn]$/, message: 'Please respond with y or n. '...
[ "function", "confirmClear", "(", ")", "{", "var", "promptSchema", "=", "{", "properties", ":", "{", "confirm", ":", "{", "description", ":", "'Delete everything in the '", "+", "config", ".", "env", ".", "toUpperCase", "(", ")", "+", "' database? (y or n) '", ...
Confirm with the user that they definitately want to purge @returns {*}
[ "Confirm", "with", "the", "user", "that", "they", "definitately", "want", "to", "purge" ]
ea3feb8839e2edaf1b4577c052b8958953db4498
https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/batch/db.clear/db.clear.batch.js#L45-L80
train
blixt/js-workerproxy
index.js
createWorkerProxy
function createWorkerProxy(workersOrFunctions, opt_options) { var options = { // Automatically call the callback after a call if the return value is not // undefined. autoCallback: false, // Catch errors and automatically respond with an error callback. Off by // default since it break...
javascript
function createWorkerProxy(workersOrFunctions, opt_options) { var options = { // Automatically call the callback after a call if the return value is not // undefined. autoCallback: false, // Catch errors and automatically respond with an error callback. Off by // default since it break...
[ "function", "createWorkerProxy", "(", "workersOrFunctions", ",", "opt_options", ")", "{", "var", "options", "=", "{", "// Automatically call the callback after a call if the return value is not", "// undefined.", "autoCallback", ":", "false", ",", "// Catch errors and automatical...
Call this function with either a Worker instance, a list of them, or a map of functions that can be called inside the worker.
[ "Call", "this", "function", "with", "either", "a", "Worker", "instance", "a", "list", "of", "them", "or", "a", "map", "of", "functions", "that", "can", "be", "called", "inside", "the", "worker", "." ]
8e7649e1392a1e0d42e0fabce6245916fdc8fb01
https://github.com/blixt/js-workerproxy/blob/8e7649e1392a1e0d42e0fabce6245916fdc8fb01/index.js#L223-L258
train
sogko/pecker
lib/manifest.js
Manifest
function Manifest(options) { this.options = options; this.destDir = options.destDir || process.cwd(); this.content = {}; this.filePath = path.join(this.destDir, MANIFEST_FILENAME); // get or create manifest content this.content = this.read(); }
javascript
function Manifest(options) { this.options = options; this.destDir = options.destDir || process.cwd(); this.content = {}; this.filePath = path.join(this.destDir, MANIFEST_FILENAME); // get or create manifest content this.content = this.read(); }
[ "function", "Manifest", "(", "options", ")", "{", "this", ".", "options", "=", "options", ";", "this", ".", "destDir", "=", "options", ".", "destDir", "||", "process", ".", "cwd", "(", ")", ";", "this", ".", "content", "=", "{", "}", ";", "this", "...
Pecker.Manifest class @param options @constructor
[ "Pecker", ".", "Manifest", "class" ]
fc84cbcd06176e74a15d4e49cc366dbd0a7041b0
https://github.com/sogko/pecker/blob/fc84cbcd06176e74a15d4e49cc366dbd0a7041b0/lib/manifest.js#L22-L30
train
Runnable/cluster-man
index.js
ClusterManager
function ClusterManager(opts) { if (isFunction(opts)) { opts = { worker: opts }; } this.options = opts || {}; this.givenNumWorkers = exists(this.options.numWorkers) || exists(process.env.CLUSTER_WORKERS); defaults(this.options, { debugScope: process.env.CLUSTER_DEBUG || 'cluster-man', ma...
javascript
function ClusterManager(opts) { if (isFunction(opts)) { opts = { worker: opts }; } this.options = opts || {}; this.givenNumWorkers = exists(this.options.numWorkers) || exists(process.env.CLUSTER_WORKERS); defaults(this.options, { debugScope: process.env.CLUSTER_DEBUG || 'cluster-man', ma...
[ "function", "ClusterManager", "(", "opts", ")", "{", "if", "(", "isFunction", "(", "opts", ")", ")", "{", "opts", "=", "{", "worker", ":", "opts", "}", ";", "}", "this", ".", "options", "=", "opts", "||", "{", "}", ";", "this", ".", "givenNumWorker...
Utility class for creating new server clusters. @example var ClusterManager = require('cluster-man'); var server = require('./lib/server'); // Basic usage (if you only need to handle workers) new ClusterManager(server.start).start(); @example var ClusterManager = require('cluster-man'); var server = require('./lib/s...
[ "Utility", "class", "for", "creating", "new", "server", "clusters", "." ]
fa60bc78501c4261ad288b7e0d1fb661284cf640
https://github.com/Runnable/cluster-man/blob/fa60bc78501c4261ad288b7e0d1fb661284cf640/index.js#L72-L110
train
skpapam/i-encrypt
index.js
function(data){ return typeof data === 'object' ? JSON.stringify(data) : (typeof data === 'string' || typeof data === 'number' ? String(data) : null); }
javascript
function(data){ return typeof data === 'object' ? JSON.stringify(data) : (typeof data === 'string' || typeof data === 'number' ? String(data) : null); }
[ "function", "(", "data", ")", "{", "return", "typeof", "data", "===", "'object'", "?", "JSON", ".", "stringify", "(", "data", ")", ":", "(", "typeof", "data", "===", "'string'", "||", "typeof", "data", "===", "'number'", "?", "String", "(", "data", ")"...
Private serialization method @private @param data {Object} || {String} || {Number} @returns {String} or null on fail
[ "Private", "serialization", "method" ]
ebc93e25d7340817eaa8eccfde8b1b24aeb2f802
https://github.com/skpapam/i-encrypt/blob/ebc93e25d7340817eaa8eccfde8b1b24aeb2f802/index.js#L150-L154
train
andrewscwei/requiem
src/dom/getElementRegistry.js
getElementRegistry
function getElementRegistry(identifier) { if (!window.__private__) window.__private__ = {}; if (window.__private__.elementRegistry === undefined) window.__private__.elementRegistry = {}; if (typeof identifier === 'string') { if (!~identifier.indexOf('-')) identifier = identifier + '-element'; return windo...
javascript
function getElementRegistry(identifier) { if (!window.__private__) window.__private__ = {}; if (window.__private__.elementRegistry === undefined) window.__private__.elementRegistry = {}; if (typeof identifier === 'string') { if (!~identifier.indexOf('-')) identifier = identifier + '-element'; return windo...
[ "function", "getElementRegistry", "(", "identifier", ")", "{", "if", "(", "!", "window", ".", "__private__", ")", "window", ".", "__private__", "=", "{", "}", ";", "if", "(", "window", ".", "__private__", ".", "elementRegistry", "===", "undefined", ")", "w...
Gets the element registry. @param {string|Function} [identifier] - Either a tag or the element class to look for. If unspecified the entire registry will be returned. @return {Object} The element registry. @alias module:requiem~dom.getElementRegistry
[ "Gets", "the", "element", "registry", "." ]
c4182bfffc9841c6de5718f689ad3c2060511777
https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getElementRegistry.js#L16-L31
train
Encentivize/kwaai-crud
lib/crud.js
validated
function validated(invalid){ if (invalid) { return callback(invalid) } if(options.coerce){crudUtils.coerceData(options,coerced())} else{coerced(null,options.data)} }
javascript
function validated(invalid){ if (invalid) { return callback(invalid) } if(options.coerce){crudUtils.coerceData(options,coerced())} else{coerced(null,options.data)} }
[ "function", "validated", "(", "invalid", ")", "{", "if", "(", "invalid", ")", "{", "return", "callback", "(", "invalid", ")", "}", "if", "(", "options", ".", "coerce", ")", "{", "crudUtils", ".", "coerceData", "(", "options", ",", "coerced", "(", ")", ...
coerce to schema
[ "coerce", "to", "schema" ]
aefcfab619b4447f78c2e863e8bdb9035b021995
https://github.com/Encentivize/kwaai-crud/blob/aefcfab619b4447f78c2e863e8bdb9035b021995/lib/crud.js#L661-L665
train
gasolin/provecss
index.js
provecss
function provecss(string, options) { options = options || {}; this.browsers = options.browsers; if (options.path) { this.import_path = path.basename(options.path); this.import_base = options.base || path.dirname(options.path); } this.import_filter = options.import_filter; this.v...
javascript
function provecss(string, options) { options = options || {}; this.browsers = options.browsers; if (options.path) { this.import_path = path.basename(options.path); this.import_base = options.base || path.dirname(options.path); } this.import_filter = options.import_filter; this.v...
[ "function", "provecss", "(", "string", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "browsers", "=", "options", ".", "browsers", ";", "if", "(", "options", ".", "path", ")", "{", "this", ".", "import_path", "...
Rework a CSS `string` @param {String} string (optional) @param {Object} options (optional) @return {String}
[ "Rework", "a", "CSS", "string" ]
7d92512c0bbd600be83055231c5644dbd0cc704a
https://github.com/gasolin/provecss/blob/7d92512c0bbd600be83055231c5644dbd0cc704a/index.js#L26-L78
train
nodeGame/shelf.js
build/shelf.js
function (fileName, key, value) { var file = fileName || store.filename; if (!file) { store.log('You must specify a valid file.', 'ERR'); return false; } if (!key) return; var item = store.stringify(key) + ": " + ...
javascript
function (fileName, key, value) { var file = fileName || store.filename; if (!file) { store.log('You must specify a valid file.', 'ERR'); return false; } if (!key) return; var item = store.stringify(key) + ": " + ...
[ "function", "(", "fileName", ",", "key", ",", "value", ")", "{", "var", "file", "=", "fileName", "||", "store", ".", "filename", ";", "if", "(", "!", "file", ")", "{", "store", ".", "log", "(", "'You must specify a valid file.'", ",", "'ERR'", ")", ";"...
node 0.8
[ "node", "0", ".", "8" ]
49eabcf55337c2f70b7ba94a483952cc514c76e1
https://github.com/nodeGame/shelf.js/blob/49eabcf55337c2f70b7ba94a483952cc514c76e1/build/shelf.js#L1609-L1621
train
nodeGame/shelf.js
build/shelf.js
function (fileName, key, value) { var file = fileName || store.filename; if (!file) { store.log('You must specify a valid file.', 'ERR'); return false; } if (!key) return; var item = store.stringify(key) + ": " + ...
javascript
function (fileName, key, value) { var file = fileName || store.filename; if (!file) { store.log('You must specify a valid file.', 'ERR'); return false; } if (!key) return; var item = store.stringify(key) + ": " + ...
[ "function", "(", "fileName", ",", "key", ",", "value", ")", "{", "var", "file", "=", "fileName", "||", "store", ".", "filename", ";", "if", "(", "!", "file", ")", "{", "store", ".", "log", "(", "'You must specify a valid file.'", ",", "'ERR'", ")", ";"...
node < 0.8
[ "node", "<", "0", ".", "8" ]
49eabcf55337c2f70b7ba94a483952cc514c76e1
https://github.com/nodeGame/shelf.js/blob/49eabcf55337c2f70b7ba94a483952cc514c76e1/build/shelf.js#L1625-L1642
train
inviqa/deck-task-registry
src/other/default.js
defaultTask
function defaultTask(conf, undertaker, done) { return undertaker.series( require('../build/build').bind(null, conf, undertaker), require('../other/watch').bind(null, conf, undertaker) )(done); }
javascript
function defaultTask(conf, undertaker, done) { return undertaker.series( require('../build/build').bind(null, conf, undertaker), require('../other/watch').bind(null, conf, undertaker) )(done); }
[ "function", "defaultTask", "(", "conf", ",", "undertaker", ",", "done", ")", "{", "return", "undertaker", ".", "series", "(", "require", "(", "'../build/build'", ")", ".", "bind", "(", "null", ",", "conf", ",", "undertaker", ")", ",", "require", "(", "'....
The default task to be run. @param {ConfigParser} conf A configuration parser object. @param {Undertaker} undertaker An Undertaker instance. @returns {Stream} A stream of files.
[ "The", "default", "task", "to", "be", "run", "." ]
4c31787b978e9d99a47052e090d4589a50cd3015
https://github.com/inviqa/deck-task-registry/blob/4c31787b978e9d99a47052e090d4589a50cd3015/src/other/default.js#L11-L16
train
ianusmagnus/passport-relayr
lib/strategy.js
RelayrStrategy
function RelayrStrategy(options, verifyCallback) { if (!verifyCallback) { throw new TypeError('verify callback is required'); } options = options || {}; options.authorizationURL = options.authorizationURL || 'https://api.relayr.io/oauth2/auth'; options.responseType = options.responseType || 'token'; ...
javascript
function RelayrStrategy(options, verifyCallback) { if (!verifyCallback) { throw new TypeError('verify callback is required'); } options = options || {}; options.authorizationURL = options.authorizationURL || 'https://api.relayr.io/oauth2/auth'; options.responseType = options.responseType || 'token'; ...
[ "function", "RelayrStrategy", "(", "options", ",", "verifyCallback", ")", "{", "if", "(", "!", "verifyCallback", ")", "{", "throw", "new", "TypeError", "(", "'verify callback is required'", ")", ";", "}", "options", "=", "options", "||", "{", "}", ";", "opti...
`RelayrStrategy` constructor.
[ "RelayrStrategy", "constructor", "." ]
9b5e7ec8f9e759f5b34a486d14399a6ea7694db0
https://github.com/ianusmagnus/passport-relayr/blob/9b5e7ec8f9e759f5b34a486d14399a6ea7694db0/lib/strategy.js#L9-L26
train
Degree53/takeown
index.js
attemptCallback
function attemptCallback(filePath, callback, attempts) { try { callback(); return; } catch (error) { if (attempts === 0) { console.error('takeown: callback failed - exceeded attempts'); throw error; } switch (error.code) { case 'EPERM': case 'EACCES': case 'EBUSY': case 'ENOTEMPTY': ...
javascript
function attemptCallback(filePath, callback, attempts) { try { callback(); return; } catch (error) { if (attempts === 0) { console.error('takeown: callback failed - exceeded attempts'); throw error; } switch (error.code) { case 'EPERM': case 'EACCES': case 'EBUSY': case 'ENOTEMPTY': ...
[ "function", "attemptCallback", "(", "filePath", ",", "callback", ",", "attempts", ")", "{", "try", "{", "callback", "(", ")", ";", "return", ";", "}", "catch", "(", "error", ")", "{", "if", "(", "attempts", "===", "0", ")", "{", "console", ".", "erro...
Intentionally locks up javascript thread for a fixed number of recursive calls to give Windows time to get its arse in gear.
[ "Intentionally", "locks", "up", "javascript", "thread", "for", "a", "fixed", "number", "of", "recursive", "calls", "to", "give", "Windows", "time", "to", "get", "its", "arse", "in", "gear", "." ]
93040b0fadd1625a5dfa553e50cc16e10c8e361a
https://github.com/Degree53/takeown/blob/93040b0fadd1625a5dfa553e50cc16e10c8e361a/index.js#L14-L40
train
Degree53/takeown
index.js
takeOwnership
function takeOwnership(filePath) { try { var stats = fs.lstatSync(filePath); if (stats.isDirectory()) { execSyncElevated('takeown /f "' + filePath + '" /r /d y'); } else { execSyncElevated('takeown /f "' + filePath + '"'); } return; } catch (error) { if (error.code === 'ENOENT') { console.w...
javascript
function takeOwnership(filePath) { try { var stats = fs.lstatSync(filePath); if (stats.isDirectory()) { execSyncElevated('takeown /f "' + filePath + '" /r /d y'); } else { execSyncElevated('takeown /f "' + filePath + '"'); } return; } catch (error) { if (error.code === 'ENOENT') { console.w...
[ "function", "takeOwnership", "(", "filePath", ")", "{", "try", "{", "var", "stats", "=", "fs", ".", "lstatSync", "(", "filePath", ")", ";", "if", "(", "stats", ".", "isDirectory", "(", ")", ")", "{", "execSyncElevated", "(", "'takeown /f \"'", "+", "file...
Calls fire and forget Windows specific command to seize control of a file or directory. Never seems to fail but we don't get any confirmation of success.
[ "Calls", "fire", "and", "forget", "Windows", "specific", "command", "to", "seize", "control", "of", "a", "file", "or", "directory", ".", "Never", "seems", "to", "fail", "but", "we", "don", "t", "get", "any", "confirmation", "of", "success", "." ]
93040b0fadd1625a5dfa553e50cc16e10c8e361a
https://github.com/Degree53/takeown/blob/93040b0fadd1625a5dfa553e50cc16e10c8e361a/index.js#L45-L73
train
RoboterHund/April1
modules/spec.js
expand
function expand (node, args, i) { var n = args.length; var arg; for (; i < n; i++) { arg = args [i]; if (isNodeType (arg, types.MACRO)) { expand (node, arg, 1); } else { node.push (arg); } } return node; }
javascript
function expand (node, args, i) { var n = args.length; var arg; for (; i < n; i++) { arg = args [i]; if (isNodeType (arg, types.MACRO)) { expand (node, arg, 1); } else { node.push (arg); } } return node; }
[ "function", "expand", "(", "node", ",", "args", ",", "i", ")", "{", "var", "n", "=", "args", ".", "length", ";", "var", "arg", ";", "for", "(", ";", "i", "<", "n", ";", "i", "++", ")", "{", "arg", "=", "args", "[", "i", "]", ";", "if", "(...
push node items onto the spec node array expand macros @param {Array} node the spec node array to be generated @param args node items @param i @returns {Array} the spec node array, with the items appended
[ "push", "node", "items", "onto", "the", "spec", "node", "array", "expand", "macros" ]
f4fead4d8190d0b7bdc7b649f4c2c0e9728ef30b
https://github.com/RoboterHund/April1/blob/f4fead4d8190d0b7bdc7b649f4c2c0e9728ef30b/modules/spec.js#L27-L40
train