id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
51,400
slikts/delta-ticker
index.js
_start
function _start() { var now = Date.now(); var config = this._config; var missing = !config ? required : required.filter(function(key) { return config[key] === undefined; }); if (missing.length) { throw TypeError('Missing config properties: ' + missing.join(', ')); } if (this._started) { throw Error('Ticker already started'); } this._started = now; this._before = now - config.delay; this._tick(); return this; }
javascript
function _start() { var now = Date.now(); var config = this._config; var missing = !config ? required : required.filter(function(key) { return config[key] === undefined; }); if (missing.length) { throw TypeError('Missing config properties: ' + missing.join(', ')); } if (this._started) { throw Error('Ticker already started'); } this._started = now; this._before = now - config.delay; this._tick(); return this; }
[ "function", "_start", "(", ")", "{", "var", "now", "=", "Date", ".", "now", "(", ")", ";", "var", "config", "=", "this", ".", "_config", ";", "var", "missing", "=", "!", "config", "?", "required", ":", "required", ".", "filter", "(", "function", "(", "key", ")", "{", "return", "config", "[", "key", "]", "===", "undefined", ";", "}", ")", ";", "if", "(", "missing", ".", "length", ")", "{", "throw", "TypeError", "(", "'Missing config properties: '", "+", "missing", ".", "join", "(", "', '", ")", ")", ";", "}", "if", "(", "this", ".", "_started", ")", "{", "throw", "Error", "(", "'Ticker already started'", ")", ";", "}", "this", ".", "_started", "=", "now", ";", "this", ".", "_before", "=", "now", "-", "config", ".", "delay", ";", "this", ".", "_tick", "(", ")", ";", "return", "this", ";", "}" ]
Used with config.limit Start the ticker, setting the timeout for the first tick. @returns {Ticker}
[ "Used", "with", "config", ".", "limit", "Start", "the", "ticker", "setting", "the", "timeout", "for", "the", "first", "tick", "." ]
8cab89af6fa175df5dabce17bf654d163578ce2e
https://github.com/slikts/delta-ticker/blob/8cab89af6fa175df5dabce17bf654d163578ce2e/index.js#L51-L73
51,401
slikts/delta-ticker
index.js
_stop
function _stop() { if (!this._started) { throw Error('Ticker not started'); } clearTimeout(this._timeout); delete this._started; delete this._before; delete this._count; if (this._config.stop) { this._config.stop(); } return this; }
javascript
function _stop() { if (!this._started) { throw Error('Ticker not started'); } clearTimeout(this._timeout); delete this._started; delete this._before; delete this._count; if (this._config.stop) { this._config.stop(); } return this; }
[ "function", "_stop", "(", ")", "{", "if", "(", "!", "this", ".", "_started", ")", "{", "throw", "Error", "(", "'Ticker not started'", ")", ";", "}", "clearTimeout", "(", "this", ".", "_timeout", ")", ";", "delete", "this", ".", "_started", ";", "delete", "this", ".", "_before", ";", "delete", "this", ".", "_count", ";", "if", "(", "this", ".", "_config", ".", "stop", ")", "{", "this", ".", "_config", ".", "stop", "(", ")", ";", "}", "return", "this", ";", "}" ]
Stop the ticker, clearing any currently set timeouts. @returns {Ticker}
[ "Stop", "the", "ticker", "clearing", "any", "currently", "set", "timeouts", "." ]
8cab89af6fa175df5dabce17bf654d163578ce2e
https://github.com/slikts/delta-ticker/blob/8cab89af6fa175df5dabce17bf654d163578ce2e/index.js#L79-L93
51,402
slikts/delta-ticker
index.js
_use
function _use(config) { var _config = this._config; Object.keys(config).forEach(function(key) { _config[key] = config[key]; }); return this; }
javascript
function _use(config) { var _config = this._config; Object.keys(config).forEach(function(key) { _config[key] = config[key]; }); return this; }
[ "function", "_use", "(", "config", ")", "{", "var", "_config", "=", "this", ".", "_config", ";", "Object", ".", "keys", "(", "config", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "_config", "[", "key", "]", "=", "config", "[", "key", "]", ";", "}", ")", ";", "return", "this", ";", "}" ]
Extend the ticker's config. @param {{ limit: Number, async: Boolean, task: Function, stop: Function }} config @returns {Ticker}
[ "Extend", "the", "ticker", "s", "config", "." ]
8cab89af6fa175df5dabce17bf654d163578ce2e
https://github.com/slikts/delta-ticker/blob/8cab89af6fa175df5dabce17bf654d163578ce2e/index.js#L99-L107
51,403
slikts/delta-ticker
index.js
_tick
function _tick() { var config = this._config; var now = Date.now(); var dt = now - this._before; if (!this._started) { // The ticker has been stopped return; } if (config.async) { config.task(this._tock, dt); } else { config.task(dt); this._tock(); } }
javascript
function _tick() { var config = this._config; var now = Date.now(); var dt = now - this._before; if (!this._started) { // The ticker has been stopped return; } if (config.async) { config.task(this._tock, dt); } else { config.task(dt); this._tock(); } }
[ "function", "_tick", "(", ")", "{", "var", "config", "=", "this", ".", "_config", ";", "var", "now", "=", "Date", ".", "now", "(", ")", ";", "var", "dt", "=", "now", "-", "this", ".", "_before", ";", "if", "(", "!", "this", ".", "_started", ")", "{", "// The ticker has been stopped", "return", ";", "}", "if", "(", "config", ".", "async", ")", "{", "config", ".", "task", "(", "this", ".", "_tock", ",", "dt", ")", ";", "}", "else", "{", "config", ".", "task", "(", "dt", ")", ";", "this", ".", "_tock", "(", ")", ";", "}", "}" ]
The first part of an iteration that determines how to call the task
[ "The", "first", "part", "of", "an", "iteration", "that", "determines", "how", "to", "call", "the", "task" ]
8cab89af6fa175df5dabce17bf654d163578ce2e
https://github.com/slikts/delta-ticker/blob/8cab89af6fa175df5dabce17bf654d163578ce2e/index.js#L109-L125
51,404
slikts/delta-ticker
index.js
_tock
function _tock() { var config = this._config; var now = Date.now(); var taskTime = now - this._started; // The time it took to finish the last task var delay = Math.max(0, config.delay - (taskTime)); // Delay until the next task is run if (config.limit) { this._count += 1; if (this._count >= config.limit) { this.stop(); return; } } this._before = this._started; this._started = now + delay; this._timeout = setTimeout(this._tick, delay); }
javascript
function _tock() { var config = this._config; var now = Date.now(); var taskTime = now - this._started; // The time it took to finish the last task var delay = Math.max(0, config.delay - (taskTime)); // Delay until the next task is run if (config.limit) { this._count += 1; if (this._count >= config.limit) { this.stop(); return; } } this._before = this._started; this._started = now + delay; this._timeout = setTimeout(this._tick, delay); }
[ "function", "_tock", "(", ")", "{", "var", "config", "=", "this", ".", "_config", ";", "var", "now", "=", "Date", ".", "now", "(", ")", ";", "var", "taskTime", "=", "now", "-", "this", ".", "_started", ";", "// The time it took to finish the last task", "var", "delay", "=", "Math", ".", "max", "(", "0", ",", "config", ".", "delay", "-", "(", "taskTime", ")", ")", ";", "// Delay until the next task is run", "if", "(", "config", ".", "limit", ")", "{", "this", ".", "_count", "+=", "1", ";", "if", "(", "this", ".", "_count", ">=", "config", ".", "limit", ")", "{", "this", ".", "stop", "(", ")", ";", "return", ";", "}", "}", "this", ".", "_before", "=", "this", ".", "_started", ";", "this", ".", "_started", "=", "now", "+", "delay", ";", "this", ".", "_timeout", "=", "setTimeout", "(", "this", ".", "_tick", ",", "delay", ")", ";", "}" ]
The second part of an iteration that is called after the task is done
[ "The", "second", "part", "of", "an", "iteration", "that", "is", "called", "after", "the", "task", "is", "done" ]
8cab89af6fa175df5dabce17bf654d163578ce2e
https://github.com/slikts/delta-ticker/blob/8cab89af6fa175df5dabce17bf654d163578ce2e/index.js#L128-L148
51,405
tolokoban/ToloFrameWork
ker/mod/interact.js
indexOfDeepestElement
function indexOfDeepestElement (elements) { var dropzone, deepestZone = elements[0], index = deepestZone? 0: -1, parent, deepestZoneParents = [], dropzoneParents = [], child, i, n; for (i = 1; i < elements.length; i++) { dropzone = elements[i]; // an element might belong to multiple selector dropzones if (!dropzone || dropzone === deepestZone) { continue; } if (!deepestZone) { deepestZone = dropzone; index = i; continue; } // check if the deepest or current are document.documentElement or document.rootElement // - if the current dropzone is, do nothing and continue if (dropzone.parentNode === dropzone.ownerDocument) { continue; } // - if deepest is, update with the current dropzone and continue to next else if (deepestZone.parentNode === dropzone.ownerDocument) { deepestZone = dropzone; index = i; continue; } if (!deepestZoneParents.length) { parent = deepestZone; while (parent.parentNode && parent.parentNode !== parent.ownerDocument) { deepestZoneParents.unshift(parent); parent = parent.parentNode; } } // if this element is an svg element and the current deepest is // an HTMLElement if (deepestZone instanceof HTMLElement && dropzone instanceof SVGElement && !(dropzone instanceof SVGSVGElement)) { if (dropzone === deepestZone.parentNode) { continue; } parent = dropzone.ownerSVGElement; } else { parent = dropzone; } dropzoneParents = []; while (parent.parentNode !== parent.ownerDocument) { dropzoneParents.unshift(parent); parent = parent.parentNode; } n = 0; // get (position of last common ancestor) + 1 while (dropzoneParents[n] && dropzoneParents[n] === deepestZoneParents[n]) { n++; } var parents = [ dropzoneParents[n - 1], dropzoneParents[n], deepestZoneParents[n] ]; child = parents[0].lastChild; while (child) { if (child === parents[1]) { deepestZone = dropzone; index = i; deepestZoneParents = []; break; } else if (child === parents[2]) { break; } child = child.previousSibling; } } return index; }
javascript
function indexOfDeepestElement (elements) { var dropzone, deepestZone = elements[0], index = deepestZone? 0: -1, parent, deepestZoneParents = [], dropzoneParents = [], child, i, n; for (i = 1; i < elements.length; i++) { dropzone = elements[i]; // an element might belong to multiple selector dropzones if (!dropzone || dropzone === deepestZone) { continue; } if (!deepestZone) { deepestZone = dropzone; index = i; continue; } // check if the deepest or current are document.documentElement or document.rootElement // - if the current dropzone is, do nothing and continue if (dropzone.parentNode === dropzone.ownerDocument) { continue; } // - if deepest is, update with the current dropzone and continue to next else if (deepestZone.parentNode === dropzone.ownerDocument) { deepestZone = dropzone; index = i; continue; } if (!deepestZoneParents.length) { parent = deepestZone; while (parent.parentNode && parent.parentNode !== parent.ownerDocument) { deepestZoneParents.unshift(parent); parent = parent.parentNode; } } // if this element is an svg element and the current deepest is // an HTMLElement if (deepestZone instanceof HTMLElement && dropzone instanceof SVGElement && !(dropzone instanceof SVGSVGElement)) { if (dropzone === deepestZone.parentNode) { continue; } parent = dropzone.ownerSVGElement; } else { parent = dropzone; } dropzoneParents = []; while (parent.parentNode !== parent.ownerDocument) { dropzoneParents.unshift(parent); parent = parent.parentNode; } n = 0; // get (position of last common ancestor) + 1 while (dropzoneParents[n] && dropzoneParents[n] === deepestZoneParents[n]) { n++; } var parents = [ dropzoneParents[n - 1], dropzoneParents[n], deepestZoneParents[n] ]; child = parents[0].lastChild; while (child) { if (child === parents[1]) { deepestZone = dropzone; index = i; deepestZoneParents = []; break; } else if (child === parents[2]) { break; } child = child.previousSibling; } } return index; }
[ "function", "indexOfDeepestElement", "(", "elements", ")", "{", "var", "dropzone", ",", "deepestZone", "=", "elements", "[", "0", "]", ",", "index", "=", "deepestZone", "?", "0", ":", "-", "1", ",", "parent", ",", "deepestZoneParents", "=", "[", "]", ",", "dropzoneParents", "=", "[", "]", ",", "child", ",", "i", ",", "n", ";", "for", "(", "i", "=", "1", ";", "i", "<", "elements", ".", "length", ";", "i", "++", ")", "{", "dropzone", "=", "elements", "[", "i", "]", ";", "// an element might belong to multiple selector dropzones", "if", "(", "!", "dropzone", "||", "dropzone", "===", "deepestZone", ")", "{", "continue", ";", "}", "if", "(", "!", "deepestZone", ")", "{", "deepestZone", "=", "dropzone", ";", "index", "=", "i", ";", "continue", ";", "}", "// check if the deepest or current are document.documentElement or document.rootElement", "// - if the current dropzone is, do nothing and continue", "if", "(", "dropzone", ".", "parentNode", "===", "dropzone", ".", "ownerDocument", ")", "{", "continue", ";", "}", "// - if deepest is, update with the current dropzone and continue to next", "else", "if", "(", "deepestZone", ".", "parentNode", "===", "dropzone", ".", "ownerDocument", ")", "{", "deepestZone", "=", "dropzone", ";", "index", "=", "i", ";", "continue", ";", "}", "if", "(", "!", "deepestZoneParents", ".", "length", ")", "{", "parent", "=", "deepestZone", ";", "while", "(", "parent", ".", "parentNode", "&&", "parent", ".", "parentNode", "!==", "parent", ".", "ownerDocument", ")", "{", "deepestZoneParents", ".", "unshift", "(", "parent", ")", ";", "parent", "=", "parent", ".", "parentNode", ";", "}", "}", "// if this element is an svg element and the current deepest is", "// an HTMLElement", "if", "(", "deepestZone", "instanceof", "HTMLElement", "&&", "dropzone", "instanceof", "SVGElement", "&&", "!", "(", "dropzone", "instanceof", "SVGSVGElement", ")", ")", "{", "if", "(", "dropzone", "===", "deepestZone", ".", "parentNode", ")", "{", "continue", ";", "}", "parent", "=", "dropzone", ".", "ownerSVGElement", ";", "}", "else", "{", "parent", "=", "dropzone", ";", "}", "dropzoneParents", "=", "[", "]", ";", "while", "(", "parent", ".", "parentNode", "!==", "parent", ".", "ownerDocument", ")", "{", "dropzoneParents", ".", "unshift", "(", "parent", ")", ";", "parent", "=", "parent", ".", "parentNode", ";", "}", "n", "=", "0", ";", "// get (position of last common ancestor) + 1", "while", "(", "dropzoneParents", "[", "n", "]", "&&", "dropzoneParents", "[", "n", "]", "===", "deepestZoneParents", "[", "n", "]", ")", "{", "n", "++", ";", "}", "var", "parents", "=", "[", "dropzoneParents", "[", "n", "-", "1", "]", ",", "dropzoneParents", "[", "n", "]", ",", "deepestZoneParents", "[", "n", "]", "]", ";", "child", "=", "parents", "[", "0", "]", ".", "lastChild", ";", "while", "(", "child", ")", "{", "if", "(", "child", "===", "parents", "[", "1", "]", ")", "{", "deepestZone", "=", "dropzone", ";", "index", "=", "i", ";", "deepestZoneParents", "=", "[", "]", ";", "break", ";", "}", "else", "if", "(", "child", "===", "parents", "[", "2", "]", ")", "{", "break", ";", "}", "child", "=", "child", ".", "previousSibling", ";", "}", "}", "return", "index", ";", "}" ]
Test for the element that's "above" all other qualifiers
[ "Test", "for", "the", "element", "that", "s", "above", "all", "other", "qualifiers" ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/interact.js#L1064-L1164
51,406
tolokoban/ToloFrameWork
ker/mod/interact.js
function (pointer, event, eventTarget, curEventTarget, matches, matchElements) { var target = this.target; if (!this.prepared.name && this.mouse) { var action; // update pointer coords for defaultActionChecker to use this.setEventXY(this.curCoords, [pointer]); if (matches) { action = this.validateSelector(pointer, event, matches, matchElements); } else if (target) { action = validateAction(target.getAction(this.pointers[0], event, this, this.element), this.target); } if (target && target.options.styleCursor) { if (action) { target._doc.documentElement.style.cursor = getActionCursor(action); } else { target._doc.documentElement.style.cursor = ''; } } } else if (this.prepared.name) { this.checkAndPreventDefault(event, target, this.element); } }
javascript
function (pointer, event, eventTarget, curEventTarget, matches, matchElements) { var target = this.target; if (!this.prepared.name && this.mouse) { var action; // update pointer coords for defaultActionChecker to use this.setEventXY(this.curCoords, [pointer]); if (matches) { action = this.validateSelector(pointer, event, matches, matchElements); } else if (target) { action = validateAction(target.getAction(this.pointers[0], event, this, this.element), this.target); } if (target && target.options.styleCursor) { if (action) { target._doc.documentElement.style.cursor = getActionCursor(action); } else { target._doc.documentElement.style.cursor = ''; } } } else if (this.prepared.name) { this.checkAndPreventDefault(event, target, this.element); } }
[ "function", "(", "pointer", ",", "event", ",", "eventTarget", ",", "curEventTarget", ",", "matches", ",", "matchElements", ")", "{", "var", "target", "=", "this", ".", "target", ";", "if", "(", "!", "this", ".", "prepared", ".", "name", "&&", "this", ".", "mouse", ")", "{", "var", "action", ";", "// update pointer coords for defaultActionChecker to use", "this", ".", "setEventXY", "(", "this", ".", "curCoords", ",", "[", "pointer", "]", ")", ";", "if", "(", "matches", ")", "{", "action", "=", "this", ".", "validateSelector", "(", "pointer", ",", "event", ",", "matches", ",", "matchElements", ")", ";", "}", "else", "if", "(", "target", ")", "{", "action", "=", "validateAction", "(", "target", ".", "getAction", "(", "this", ".", "pointers", "[", "0", "]", ",", "event", ",", "this", ",", "this", ".", "element", ")", ",", "this", ".", "target", ")", ";", "}", "if", "(", "target", "&&", "target", ".", "options", ".", "styleCursor", ")", "{", "if", "(", "action", ")", "{", "target", ".", "_doc", ".", "documentElement", ".", "style", ".", "cursor", "=", "getActionCursor", "(", "action", ")", ";", "}", "else", "{", "target", ".", "_doc", ".", "documentElement", ".", "style", ".", "cursor", "=", "''", ";", "}", "}", "}", "else", "if", "(", "this", ".", "prepared", ".", "name", ")", "{", "this", ".", "checkAndPreventDefault", "(", "event", ",", "target", ",", "this", ".", "element", ")", ";", "}", "}" ]
Check what action would be performed on pointerMove target if a mouse button were pressed and change the cursor accordingly
[ "Check", "what", "action", "would", "be", "performed", "on", "pointerMove", "target", "if", "a", "mouse", "button", "were", "pressed", "and", "change", "the", "cursor", "accordingly" ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/interact.js#L1402-L1431
51,407
tolokoban/ToloFrameWork
ker/mod/interact.js
function (dragElement) { // get dropzones and their elements that could receive the draggable var possibleDrops = this.collectDrops(dragElement, true); this.activeDrops.dropzones = possibleDrops.dropzones; this.activeDrops.elements = possibleDrops.elements; this.activeDrops.rects = []; for (var i = 0; i < this.activeDrops.dropzones.length; i++) { this.activeDrops.rects[i] = this.activeDrops.dropzones[i].getRect(this.activeDrops.elements[i]); } }
javascript
function (dragElement) { // get dropzones and their elements that could receive the draggable var possibleDrops = this.collectDrops(dragElement, true); this.activeDrops.dropzones = possibleDrops.dropzones; this.activeDrops.elements = possibleDrops.elements; this.activeDrops.rects = []; for (var i = 0; i < this.activeDrops.dropzones.length; i++) { this.activeDrops.rects[i] = this.activeDrops.dropzones[i].getRect(this.activeDrops.elements[i]); } }
[ "function", "(", "dragElement", ")", "{", "// get dropzones and their elements that could receive the draggable", "var", "possibleDrops", "=", "this", ".", "collectDrops", "(", "dragElement", ",", "true", ")", ";", "this", ".", "activeDrops", ".", "dropzones", "=", "possibleDrops", ".", "dropzones", ";", "this", ".", "activeDrops", ".", "elements", "=", "possibleDrops", ".", "elements", ";", "this", ".", "activeDrops", ".", "rects", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "activeDrops", ".", "dropzones", ".", "length", ";", "i", "++", ")", "{", "this", ".", "activeDrops", ".", "rects", "[", "i", "]", "=", "this", ".", "activeDrops", ".", "dropzones", "[", "i", "]", ".", "getRect", "(", "this", ".", "activeDrops", ".", "elements", "[", "i", "]", ")", ";", "}", "}" ]
Collect a new set of possible drops and save them in activeDrops. setActiveDrops should always be called when a drag has just started or a drag event happens while dynamicDrop is true
[ "Collect", "a", "new", "set", "of", "possible", "drops", "and", "save", "them", "in", "activeDrops", ".", "setActiveDrops", "should", "always", "be", "called", "when", "a", "drag", "has", "just", "started", "or", "a", "drag", "event", "happens", "while", "dynamicDrop", "is", "true" ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/interact.js#L2471-L2482
51,408
tolokoban/ToloFrameWork
ker/mod/interact.js
validateAction
function validateAction (action, interactable) { if (!isObject(action)) { return null; } var actionName = action.name, options = interactable.options; if (( (actionName === 'resize' && options.resize.enabled ) || (actionName === 'drag' && options.drag.enabled ) || (actionName === 'gesture' && options.gesture.enabled)) && actionIsEnabled[actionName]) { if (actionName === 'resize' || actionName === 'resizeyx') { actionName = 'resizexy'; } return action; } return null; }
javascript
function validateAction (action, interactable) { if (!isObject(action)) { return null; } var actionName = action.name, options = interactable.options; if (( (actionName === 'resize' && options.resize.enabled ) || (actionName === 'drag' && options.drag.enabled ) || (actionName === 'gesture' && options.gesture.enabled)) && actionIsEnabled[actionName]) { if (actionName === 'resize' || actionName === 'resizeyx') { actionName = 'resizexy'; } return action; } return null; }
[ "function", "validateAction", "(", "action", ",", "interactable", ")", "{", "if", "(", "!", "isObject", "(", "action", ")", ")", "{", "return", "null", ";", "}", "var", "actionName", "=", "action", ".", "name", ",", "options", "=", "interactable", ".", "options", ";", "if", "(", "(", "(", "actionName", "===", "'resize'", "&&", "options", ".", "resize", ".", "enabled", ")", "||", "(", "actionName", "===", "'drag'", "&&", "options", ".", "drag", ".", "enabled", ")", "||", "(", "actionName", "===", "'gesture'", "&&", "options", ".", "gesture", ".", "enabled", ")", ")", "&&", "actionIsEnabled", "[", "actionName", "]", ")", "{", "if", "(", "actionName", "===", "'resize'", "||", "actionName", "===", "'resizeyx'", ")", "{", "actionName", "=", "'resizexy'", ";", "}", "return", "action", ";", "}", "return", "null", ";", "}" ]
Check if action is enabled globally and the current target supports it If so, return the validated action. Otherwise, return null
[ "Check", "if", "action", "is", "enabled", "globally", "and", "the", "current", "target", "supports", "it", "If", "so", "return", "the", "validated", "action", ".", "Otherwise", "return", "null" ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/interact.js#L3753-L3771
51,409
tolokoban/ToloFrameWork
ker/mod/interact.js
delegateListener
function delegateListener (event, useCapture) { var fakeEvent = {}, delegated = delegatedEvents[event.type], eventTarget = getActualElement(event.path ? event.path[0] : event.target), element = eventTarget; useCapture = useCapture? true: false; // duplicate the event so that currentTarget can be changed for (var prop in event) { fakeEvent[prop] = event[prop]; } fakeEvent.originalEvent = event; fakeEvent.preventDefault = preventOriginalDefault; // climb up document tree looking for selector matches while (isElement(element)) { for (var i = 0; i < delegated.selectors.length; i++) { var selector = delegated.selectors[i], context = delegated.contexts[i]; if (matchesSelector(element, selector) && nodeContains(context, eventTarget) && nodeContains(context, element)) { var listeners = delegated.listeners[i]; fakeEvent.currentTarget = element; for (var j = 0; j < listeners.length; j++) { if (listeners[j][1] === useCapture) { listeners[j][0](fakeEvent); } } } } element = parentElement(element); } }
javascript
function delegateListener (event, useCapture) { var fakeEvent = {}, delegated = delegatedEvents[event.type], eventTarget = getActualElement(event.path ? event.path[0] : event.target), element = eventTarget; useCapture = useCapture? true: false; // duplicate the event so that currentTarget can be changed for (var prop in event) { fakeEvent[prop] = event[prop]; } fakeEvent.originalEvent = event; fakeEvent.preventDefault = preventOriginalDefault; // climb up document tree looking for selector matches while (isElement(element)) { for (var i = 0; i < delegated.selectors.length; i++) { var selector = delegated.selectors[i], context = delegated.contexts[i]; if (matchesSelector(element, selector) && nodeContains(context, eventTarget) && nodeContains(context, element)) { var listeners = delegated.listeners[i]; fakeEvent.currentTarget = element; for (var j = 0; j < listeners.length; j++) { if (listeners[j][1] === useCapture) { listeners[j][0](fakeEvent); } } } } element = parentElement(element); } }
[ "function", "delegateListener", "(", "event", ",", "useCapture", ")", "{", "var", "fakeEvent", "=", "{", "}", ",", "delegated", "=", "delegatedEvents", "[", "event", ".", "type", "]", ",", "eventTarget", "=", "getActualElement", "(", "event", ".", "path", "?", "event", ".", "path", "[", "0", "]", ":", "event", ".", "target", ")", ",", "element", "=", "eventTarget", ";", "useCapture", "=", "useCapture", "?", "true", ":", "false", ";", "// duplicate the event so that currentTarget can be changed", "for", "(", "var", "prop", "in", "event", ")", "{", "fakeEvent", "[", "prop", "]", "=", "event", "[", "prop", "]", ";", "}", "fakeEvent", ".", "originalEvent", "=", "event", ";", "fakeEvent", ".", "preventDefault", "=", "preventOriginalDefault", ";", "// climb up document tree looking for selector matches", "while", "(", "isElement", "(", "element", ")", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "delegated", ".", "selectors", ".", "length", ";", "i", "++", ")", "{", "var", "selector", "=", "delegated", ".", "selectors", "[", "i", "]", ",", "context", "=", "delegated", ".", "contexts", "[", "i", "]", ";", "if", "(", "matchesSelector", "(", "element", ",", "selector", ")", "&&", "nodeContains", "(", "context", ",", "eventTarget", ")", "&&", "nodeContains", "(", "context", ",", "element", ")", ")", "{", "var", "listeners", "=", "delegated", ".", "listeners", "[", "i", "]", ";", "fakeEvent", ".", "currentTarget", "=", "element", ";", "for", "(", "var", "j", "=", "0", ";", "j", "<", "listeners", ".", "length", ";", "j", "++", ")", "{", "if", "(", "listeners", "[", "j", "]", "[", "1", "]", "===", "useCapture", ")", "{", "listeners", "[", "j", "]", "[", "0", "]", "(", "fakeEvent", ")", ";", "}", "}", "}", "}", "element", "=", "parentElement", "(", "element", ")", ";", "}", "}" ]
bound to the interactable context when a DOM event listener is added to a selector interactable
[ "bound", "to", "the", "interactable", "context", "when", "a", "DOM", "event", "listener", "is", "added", "to", "a", "selector", "interactable" ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/interact.js#L3789-L3831
51,410
asavoy/grunt-requirejs-auto-bundles
lib/amd.js
modulePathToId
function modulePathToId(path) { // We can only transform if there's no plugin used. if (path.indexOf('!') === -1) { // If it ends with ".js", chop it off. var extension = '.js' if (path.slice(-extension.length) === '.js') { path = path.slice(0, path.length - extension.length); } } return path; }
javascript
function modulePathToId(path) { // We can only transform if there's no plugin used. if (path.indexOf('!') === -1) { // If it ends with ".js", chop it off. var extension = '.js' if (path.slice(-extension.length) === '.js') { path = path.slice(0, path.length - extension.length); } } return path; }
[ "function", "modulePathToId", "(", "path", ")", "{", "// We can only transform if there's no plugin used.", "if", "(", "path", ".", "indexOf", "(", "'!'", ")", "===", "-", "1", ")", "{", "// If it ends with \".js\", chop it off.", "var", "extension", "=", "'.js'", "if", "(", "path", ".", "slice", "(", "-", "extension", ".", "length", ")", "===", "'.js'", ")", "{", "path", "=", "path", ".", "slice", "(", "0", ",", "path", ".", "length", "-", "extension", ".", "length", ")", ";", "}", "}", "return", "path", ";", "}" ]
Convert a module path into a module ID.
[ "Convert", "a", "module", "path", "into", "a", "module", "ID", "." ]
c0f587c9720943dd32098203d2c71ab1387f1700
https://github.com/asavoy/grunt-requirejs-auto-bundles/blob/c0f587c9720943dd32098203d2c71ab1387f1700/lib/amd.js#L9-L19
51,411
asavoy/grunt-requirejs-auto-bundles
lib/amd.js
moduleSize
function moduleSize(id, paths) { var path = id; var extension = '.js'; // Use `paths:` to resolve an alias. if (paths[id]) { path = paths[id]; } // Does the dependency reference a plugin? if (path.indexOf('!') !== -1) { // Split into plugin and path. var pathParts = path.split('!'); // Often, the plugin maps to the extension it handles. extension = '.' + pathParts[0]; path = pathParts[1]; } // Try to get the file at the path. var stats; try { stats = fs.statSync(path); return stats['size']; } catch(e) {} // Didn't find it? Let's try again with the extension added. if (path.slice(-extension.length) !== extension) { path = path + extension; } try { stats = fs.statSync(path); return stats['size']; } catch(e) {} // Still didn't find the file. return null; }
javascript
function moduleSize(id, paths) { var path = id; var extension = '.js'; // Use `paths:` to resolve an alias. if (paths[id]) { path = paths[id]; } // Does the dependency reference a plugin? if (path.indexOf('!') !== -1) { // Split into plugin and path. var pathParts = path.split('!'); // Often, the plugin maps to the extension it handles. extension = '.' + pathParts[0]; path = pathParts[1]; } // Try to get the file at the path. var stats; try { stats = fs.statSync(path); return stats['size']; } catch(e) {} // Didn't find it? Let's try again with the extension added. if (path.slice(-extension.length) !== extension) { path = path + extension; } try { stats = fs.statSync(path); return stats['size']; } catch(e) {} // Still didn't find the file. return null; }
[ "function", "moduleSize", "(", "id", ",", "paths", ")", "{", "var", "path", "=", "id", ";", "var", "extension", "=", "'.js'", ";", "// Use `paths:` to resolve an alias.", "if", "(", "paths", "[", "id", "]", ")", "{", "path", "=", "paths", "[", "id", "]", ";", "}", "// Does the dependency reference a plugin?", "if", "(", "path", ".", "indexOf", "(", "'!'", ")", "!==", "-", "1", ")", "{", "// Split into plugin and path.", "var", "pathParts", "=", "path", ".", "split", "(", "'!'", ")", ";", "// Often, the plugin maps to the extension it handles.", "extension", "=", "'.'", "+", "pathParts", "[", "0", "]", ";", "path", "=", "pathParts", "[", "1", "]", ";", "}", "// Try to get the file at the path.", "var", "stats", ";", "try", "{", "stats", "=", "fs", ".", "statSync", "(", "path", ")", ";", "return", "stats", "[", "'size'", "]", ";", "}", "catch", "(", "e", ")", "{", "}", "// Didn't find it? Let's try again with the extension added.", "if", "(", "path", ".", "slice", "(", "-", "extension", ".", "length", ")", "!==", "extension", ")", "{", "path", "=", "path", "+", "extension", ";", "}", "try", "{", "stats", "=", "fs", ".", "statSync", "(", "path", ")", ";", "return", "stats", "[", "'size'", "]", ";", "}", "catch", "(", "e", ")", "{", "}", "// Still didn't find the file.", "return", "null", ";", "}" ]
Returns the size of a module given its ID. At best this can be considered an estimate because it will return the size before compression, and doesn't take into consideration the effect of plugins. If the module cannot be resolved to a file, returns null.
[ "Returns", "the", "size", "of", "a", "module", "given", "its", "ID", ".", "At", "best", "this", "can", "be", "considered", "an", "estimate", "because", "it", "will", "return", "the", "size", "before", "compression", "and", "doesn", "t", "take", "into", "consideration", "the", "effect", "of", "plugins", ".", "If", "the", "module", "cannot", "be", "resolved", "to", "a", "file", "returns", "null", "." ]
c0f587c9720943dd32098203d2c71ab1387f1700
https://github.com/asavoy/grunt-requirejs-auto-bundles/blob/c0f587c9720943dd32098203d2c71ab1387f1700/lib/amd.js#L42-L77
51,412
jasonsites/proxy-es-aws
src/http/app.js
createHandler
function createHandler(options) { /** * Client request handler * Data from the incoming request (plus options) is forwarded to the AWS module */ return async (ctx) => { const { credentials, endpoint, region } = options const { rawBody: body, header: headers, method, url: path } = ctx.request console.log(chalk.cyan(method, path)) const params = { body, credentials, endpoint, headers, method, path, region } const req = createSignedAWSRequest(params) const res = await sendAWSRequest(req) ctx.status = 200 ctx.type = 'application/json' ctx.response.header = stripProxyResHeaders(res) ctx.body = res.body } }
javascript
function createHandler(options) { /** * Client request handler * Data from the incoming request (plus options) is forwarded to the AWS module */ return async (ctx) => { const { credentials, endpoint, region } = options const { rawBody: body, header: headers, method, url: path } = ctx.request console.log(chalk.cyan(method, path)) const params = { body, credentials, endpoint, headers, method, path, region } const req = createSignedAWSRequest(params) const res = await sendAWSRequest(req) ctx.status = 200 ctx.type = 'application/json' ctx.response.header = stripProxyResHeaders(res) ctx.body = res.body } }
[ "function", "createHandler", "(", "options", ")", "{", "/**\n * Client request handler\n * Data from the incoming request (plus options) is forwarded to the AWS module\n */", "return", "async", "(", "ctx", ")", "=>", "{", "const", "{", "credentials", ",", "endpoint", ",", "region", "}", "=", "options", "const", "{", "rawBody", ":", "body", ",", "header", ":", "headers", ",", "method", ",", "url", ":", "path", "}", "=", "ctx", ".", "request", "console", ".", "log", "(", "chalk", ".", "cyan", "(", "method", ",", "path", ")", ")", "const", "params", "=", "{", "body", ",", "credentials", ",", "endpoint", ",", "headers", ",", "method", ",", "path", ",", "region", "}", "const", "req", "=", "createSignedAWSRequest", "(", "params", ")", "const", "res", "=", "await", "sendAWSRequest", "(", "req", ")", "ctx", ".", "status", "=", "200", "ctx", ".", "type", "=", "'application/json'", "ctx", ".", "response", ".", "header", "=", "stripProxyResHeaders", "(", "res", ")", "ctx", ".", "body", "=", "res", ".", "body", "}", "}" ]
Creates request handler middleware @param {Object} options.credentials - aws credentials object @param {Object} options.endpoint - aws elasticsearch endpoint @param {Object} options.region - aws region
[ "Creates", "request", "handler", "middleware" ]
b2625106d877fea76f74b0b88ed8568a8ff61612
https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/http/app.js#L54-L74
51,413
jasonsites/proxy-es-aws
src/http/app.js
getInitOptions
async function getInitOptions(args) { const { debug, endpoint, host, port, profile, region } = args const options = { debug, host, port, profile, region } options.endpoint = getAWSEndpoint({ endpoint }) options.credentials = await getAWSCredentials() return options }
javascript
async function getInitOptions(args) { const { debug, endpoint, host, port, profile, region } = args const options = { debug, host, port, profile, region } options.endpoint = getAWSEndpoint({ endpoint }) options.credentials = await getAWSCredentials() return options }
[ "async", "function", "getInitOptions", "(", "args", ")", "{", "const", "{", "debug", ",", "endpoint", ",", "host", ",", "port", ",", "profile", ",", "region", "}", "=", "args", "const", "options", "=", "{", "debug", ",", "host", ",", "port", ",", "profile", ",", "region", "}", "options", ".", "endpoint", "=", "getAWSEndpoint", "(", "{", "endpoint", "}", ")", "options", ".", "credentials", "=", "await", "getAWSCredentials", "(", ")", "return", "options", "}" ]
Composes server initialization options from CLI arguments @param {Boolean} args.debug - debug flag @param {String} args.endpoint - aws elasticsearch endpoint @param {String} args.host - proxy host @param {Number} args.port - proxy port @param {String} args.profile - aws credentials profile @param {String} args.region - aws region @return {Promise}
[ "Composes", "server", "initialization", "options", "from", "CLI", "arguments" ]
b2625106d877fea76f74b0b88ed8568a8ff61612
https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/http/app.js#L86-L92
51,414
jasonsites/proxy-es-aws
src/http/app.js
registerListeners
function registerListeners() { const exit = function exit(signal) { console.log(chalk.bgBlack.yellow(`Received ${signal} => Exiting`)) process.exit() } const SIGABRT = 'SIGABRT' const SIGHUP = 'SIGHUP' const SIGINT = 'SIGINT' const SIGQUIT = 'SIGQUIT' const SIGTERM = 'SIGTERM' process.on(SIGABRT, () => exit(SIGABRT)) process.on(SIGHUP, () => exit(SIGHUP)) process.on(SIGINT, () => exit(SIGINT)) process.on(SIGQUIT, () => exit(SIGQUIT)) process.on(SIGTERM, () => exit(SIGTERM)) }
javascript
function registerListeners() { const exit = function exit(signal) { console.log(chalk.bgBlack.yellow(`Received ${signal} => Exiting`)) process.exit() } const SIGABRT = 'SIGABRT' const SIGHUP = 'SIGHUP' const SIGINT = 'SIGINT' const SIGQUIT = 'SIGQUIT' const SIGTERM = 'SIGTERM' process.on(SIGABRT, () => exit(SIGABRT)) process.on(SIGHUP, () => exit(SIGHUP)) process.on(SIGINT, () => exit(SIGINT)) process.on(SIGQUIT, () => exit(SIGQUIT)) process.on(SIGTERM, () => exit(SIGTERM)) }
[ "function", "registerListeners", "(", ")", "{", "const", "exit", "=", "function", "exit", "(", "signal", ")", "{", "console", ".", "log", "(", "chalk", ".", "bgBlack", ".", "yellow", "(", "`", "${", "signal", "}", "`", ")", ")", "process", ".", "exit", "(", ")", "}", "const", "SIGABRT", "=", "'SIGABRT'", "const", "SIGHUP", "=", "'SIGHUP'", "const", "SIGINT", "=", "'SIGINT'", "const", "SIGQUIT", "=", "'SIGQUIT'", "const", "SIGTERM", "=", "'SIGTERM'", "process", ".", "on", "(", "SIGABRT", ",", "(", ")", "=>", "exit", "(", "SIGABRT", ")", ")", "process", ".", "on", "(", "SIGHUP", ",", "(", ")", "=>", "exit", "(", "SIGHUP", ")", ")", "process", ".", "on", "(", "SIGINT", ",", "(", ")", "=>", "exit", "(", "SIGINT", ")", ")", "process", ".", "on", "(", "SIGQUIT", ",", "(", ")", "=>", "exit", "(", "SIGQUIT", ")", ")", "process", ".", "on", "(", "SIGTERM", ",", "(", ")", "=>", "exit", "(", "SIGTERM", ")", ")", "}" ]
Register process signal listeners @return {undefined}
[ "Register", "process", "signal", "listeners" ]
b2625106d877fea76f74b0b88ed8568a8ff61612
https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/http/app.js#L98-L114
51,415
jasonsites/proxy-es-aws
src/http/app.js
stripProxyResHeaders
function stripProxyResHeaders(res) { return Object.entries(res.headers).reduce((memo, header) => { const [key, val] = header const invalid = [undefined, 'connection', 'content-encoding'] if (invalid.indexOf(key) === -1) { memo[key] = val // eslint-disable-line } return memo }, {}) }
javascript
function stripProxyResHeaders(res) { return Object.entries(res.headers).reduce((memo, header) => { const [key, val] = header const invalid = [undefined, 'connection', 'content-encoding'] if (invalid.indexOf(key) === -1) { memo[key] = val // eslint-disable-line } return memo }, {}) }
[ "function", "stripProxyResHeaders", "(", "res", ")", "{", "return", "Object", ".", "entries", "(", "res", ".", "headers", ")", ".", "reduce", "(", "(", "memo", ",", "header", ")", "=>", "{", "const", "[", "key", ",", "val", "]", "=", "header", "const", "invalid", "=", "[", "undefined", ",", "'connection'", ",", "'content-encoding'", "]", "if", "(", "invalid", ".", "indexOf", "(", "key", ")", "===", "-", "1", ")", "{", "memo", "[", "key", "]", "=", "val", "// eslint-disable-line", "}", "return", "memo", "}", ",", "{", "}", ")", "}" ]
Strip connection control and transport encoding headers from the proxy response @param {Object} res - proxy response @return {Object}
[ "Strip", "connection", "control", "and", "transport", "encoding", "headers", "from", "the", "proxy", "response" ]
b2625106d877fea76f74b0b88ed8568a8ff61612
https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/http/app.js#L121-L130
51,416
goddyZhao/sf-transfer
lib/sf.js
transfer
function transfer(xmlFiles, output, dir, needAppend, _callback){ /** * If needAppend is true, output must be a file but not a directory */ Step( function(){ if(typeof output === 'undefined'){ output = path.dirname(xmlFiles[0]); } output = output.indexOf(path.sep) === 0 ? output : path.join(process.cwd(), output); fs.stat(output, this); }, function(err, stat){ if(err){ throw err; } if(needAppend){ if(!stat.isFile()){ throw new Error('Output must be a file but not a directory when --append is enabled'); } }else{ if(!stat.isDirectory()){ throw new Error('Output must be a directory'); } output = path.join(output, 'nproxy-rule.js'); } return output; }, function transferBatch(err, outputFile){ var group; if(err){ throw err; } group = this.group(); xmlFiles.forEach(function(xmlFile){ transferSingleFile(xmlFile, dir, group()); }); }, function append(err, rules){ var wrapperTpl; var result; var isTargetEmpty = true; if(err){ throw err; } if(needAppend){ wrapperTpl = fs.readFileSync(output, 'utf-8'); isTargetEmpty = false; }else{ wrapperTpl = [ 'module.exports = [/*{{more}}*/', '];' ].join(EOL); } return _append(wrapperTpl, rules, isTargetEmpty); }, function writeOutput(err, content){ if(err){ throw err; } fs.writeFile(output, content, 'utf-8', function(err){ if(err){ throw err}; log.info('Write output file successfully!'); if(typeof _callback === 'function'){ _callback(null); } }); } ); }
javascript
function transfer(xmlFiles, output, dir, needAppend, _callback){ /** * If needAppend is true, output must be a file but not a directory */ Step( function(){ if(typeof output === 'undefined'){ output = path.dirname(xmlFiles[0]); } output = output.indexOf(path.sep) === 0 ? output : path.join(process.cwd(), output); fs.stat(output, this); }, function(err, stat){ if(err){ throw err; } if(needAppend){ if(!stat.isFile()){ throw new Error('Output must be a file but not a directory when --append is enabled'); } }else{ if(!stat.isDirectory()){ throw new Error('Output must be a directory'); } output = path.join(output, 'nproxy-rule.js'); } return output; }, function transferBatch(err, outputFile){ var group; if(err){ throw err; } group = this.group(); xmlFiles.forEach(function(xmlFile){ transferSingleFile(xmlFile, dir, group()); }); }, function append(err, rules){ var wrapperTpl; var result; var isTargetEmpty = true; if(err){ throw err; } if(needAppend){ wrapperTpl = fs.readFileSync(output, 'utf-8'); isTargetEmpty = false; }else{ wrapperTpl = [ 'module.exports = [/*{{more}}*/', '];' ].join(EOL); } return _append(wrapperTpl, rules, isTargetEmpty); }, function writeOutput(err, content){ if(err){ throw err; } fs.writeFile(output, content, 'utf-8', function(err){ if(err){ throw err}; log.info('Write output file successfully!'); if(typeof _callback === 'function'){ _callback(null); } }); } ); }
[ "function", "transfer", "(", "xmlFiles", ",", "output", ",", "dir", ",", "needAppend", ",", "_callback", ")", "{", "/**\n * If needAppend is true, output must be a file but not a directory\n */", "Step", "(", "function", "(", ")", "{", "if", "(", "typeof", "output", "===", "'undefined'", ")", "{", "output", "=", "path", ".", "dirname", "(", "xmlFiles", "[", "0", "]", ")", ";", "}", "output", "=", "output", ".", "indexOf", "(", "path", ".", "sep", ")", "===", "0", "?", "output", ":", "path", ".", "join", "(", "process", ".", "cwd", "(", ")", ",", "output", ")", ";", "fs", ".", "stat", "(", "output", ",", "this", ")", ";", "}", ",", "function", "(", "err", ",", "stat", ")", "{", "if", "(", "err", ")", "{", "throw", "err", ";", "}", "if", "(", "needAppend", ")", "{", "if", "(", "!", "stat", ".", "isFile", "(", ")", ")", "{", "throw", "new", "Error", "(", "'Output must be a file but not a directory when --append is enabled'", ")", ";", "}", "}", "else", "{", "if", "(", "!", "stat", ".", "isDirectory", "(", ")", ")", "{", "throw", "new", "Error", "(", "'Output must be a directory'", ")", ";", "}", "output", "=", "path", ".", "join", "(", "output", ",", "'nproxy-rule.js'", ")", ";", "}", "return", "output", ";", "}", ",", "function", "transferBatch", "(", "err", ",", "outputFile", ")", "{", "var", "group", ";", "if", "(", "err", ")", "{", "throw", "err", ";", "}", "group", "=", "this", ".", "group", "(", ")", ";", "xmlFiles", ".", "forEach", "(", "function", "(", "xmlFile", ")", "{", "transferSingleFile", "(", "xmlFile", ",", "dir", ",", "group", "(", ")", ")", ";", "}", ")", ";", "}", ",", "function", "append", "(", "err", ",", "rules", ")", "{", "var", "wrapperTpl", ";", "var", "result", ";", "var", "isTargetEmpty", "=", "true", ";", "if", "(", "err", ")", "{", "throw", "err", ";", "}", "if", "(", "needAppend", ")", "{", "wrapperTpl", "=", "fs", ".", "readFileSync", "(", "output", ",", "'utf-8'", ")", ";", "isTargetEmpty", "=", "false", ";", "}", "else", "{", "wrapperTpl", "=", "[", "'module.exports = [/*{{more}}*/'", ",", "'];'", "]", ".", "join", "(", "EOL", ")", ";", "}", "return", "_append", "(", "wrapperTpl", ",", "rules", ",", "isTargetEmpty", ")", ";", "}", ",", "function", "writeOutput", "(", "err", ",", "content", ")", "{", "if", "(", "err", ")", "{", "throw", "err", ";", "}", "fs", ".", "writeFile", "(", "output", ",", "content", ",", "'utf-8'", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "throw", "err", "}", ";", "log", ".", "info", "(", "'Write output file successfully!'", ")", ";", "if", "(", "typeof", "_callback", "===", "'function'", ")", "{", "_callback", "(", "null", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}" ]
Transfer sf rules in inputs to nproxy rule file @param {Array} xmlFiles xml files @param {String} output output dir or file when append is true @param {String} dir dir in the rule files @param {Boolean} needAppend if true, the transfered rule will be appended
[ "Transfer", "sf", "rules", "in", "inputs", "to", "nproxy", "rule", "file" ]
23d5ebf109f3673b89e2b777e956d6e3eecbdff6
https://github.com/goddyZhao/sf-transfer/blob/23d5ebf109f3673b89e2b777e956d6e3eecbdff6/lib/sf.js#L19-L104
51,417
goddyZhao/sf-transfer
lib/sf.js
transferSingleFile
function transferSingleFile(sfXML, dir, callback){ var xmlParser; var groups; var responders = []; var fileList = []; var entry; var responder; var stat; if(typeof sfXML === 'undefined'){ throw new Error('No input file specified'); } if(!/\.xml$/.test(sfXML)){ throw new Error('Input file must be a xml file!'); } sfXML = sfXML.indexOf(path.sep) === 0 ? sfXML : path.join(process.pwd, sfXML); xmlParser = new xml2js.Parser(); fs.readFile(sfXML, function(err, xml){ if(err){ throw err; } xmlParser.parseString(xml, function(err, result){ var groupParser = function(group){ var groupId; var resources; if(typeof group['$'] === 'undefined'){ return; } groupId = group['$']['id']; if(typeof groupId !== 'undefined'){ resources = group['resource']; entry = { comment: '// pattern for ' + groupId, pattern: groupId, responder: { dir: dir || 'fill the dir', src: [] } }; responder = entry.responder; if(typeof resources === 'object' && typeof resources['$'] === 'object' && typeof resources['$']['uri'] === 'string'){ responder.src.push(resources['$']['uri']); } if(Array.isArray(resources)){ resources.forEach(function(resource){ if(typeof resource['$'] === 'object' && typeof resource['$']['uri'] === 'string'){ responder.src.push(resource['$']['uri']); } }); } responders.push(entry); } } groups = result.groupdefinition.groups[0].group; if(Array.isArray(groups)){ groups.forEach(groupParser); }else if(typeof groups === 'object'){ groupParser(groups); } }); _getRuleAsString(responders, callback); }); }
javascript
function transferSingleFile(sfXML, dir, callback){ var xmlParser; var groups; var responders = []; var fileList = []; var entry; var responder; var stat; if(typeof sfXML === 'undefined'){ throw new Error('No input file specified'); } if(!/\.xml$/.test(sfXML)){ throw new Error('Input file must be a xml file!'); } sfXML = sfXML.indexOf(path.sep) === 0 ? sfXML : path.join(process.pwd, sfXML); xmlParser = new xml2js.Parser(); fs.readFile(sfXML, function(err, xml){ if(err){ throw err; } xmlParser.parseString(xml, function(err, result){ var groupParser = function(group){ var groupId; var resources; if(typeof group['$'] === 'undefined'){ return; } groupId = group['$']['id']; if(typeof groupId !== 'undefined'){ resources = group['resource']; entry = { comment: '// pattern for ' + groupId, pattern: groupId, responder: { dir: dir || 'fill the dir', src: [] } }; responder = entry.responder; if(typeof resources === 'object' && typeof resources['$'] === 'object' && typeof resources['$']['uri'] === 'string'){ responder.src.push(resources['$']['uri']); } if(Array.isArray(resources)){ resources.forEach(function(resource){ if(typeof resource['$'] === 'object' && typeof resource['$']['uri'] === 'string'){ responder.src.push(resource['$']['uri']); } }); } responders.push(entry); } } groups = result.groupdefinition.groups[0].group; if(Array.isArray(groups)){ groups.forEach(groupParser); }else if(typeof groups === 'object'){ groupParser(groups); } }); _getRuleAsString(responders, callback); }); }
[ "function", "transferSingleFile", "(", "sfXML", ",", "dir", ",", "callback", ")", "{", "var", "xmlParser", ";", "var", "groups", ";", "var", "responders", "=", "[", "]", ";", "var", "fileList", "=", "[", "]", ";", "var", "entry", ";", "var", "responder", ";", "var", "stat", ";", "if", "(", "typeof", "sfXML", "===", "'undefined'", ")", "{", "throw", "new", "Error", "(", "'No input file specified'", ")", ";", "}", "if", "(", "!", "/", "\\.xml$", "/", ".", "test", "(", "sfXML", ")", ")", "{", "throw", "new", "Error", "(", "'Input file must be a xml file!'", ")", ";", "}", "sfXML", "=", "sfXML", ".", "indexOf", "(", "path", ".", "sep", ")", "===", "0", "?", "sfXML", ":", "path", ".", "join", "(", "process", ".", "pwd", ",", "sfXML", ")", ";", "xmlParser", "=", "new", "xml2js", ".", "Parser", "(", ")", ";", "fs", ".", "readFile", "(", "sfXML", ",", "function", "(", "err", ",", "xml", ")", "{", "if", "(", "err", ")", "{", "throw", "err", ";", "}", "xmlParser", ".", "parseString", "(", "xml", ",", "function", "(", "err", ",", "result", ")", "{", "var", "groupParser", "=", "function", "(", "group", ")", "{", "var", "groupId", ";", "var", "resources", ";", "if", "(", "typeof", "group", "[", "'$'", "]", "===", "'undefined'", ")", "{", "return", ";", "}", "groupId", "=", "group", "[", "'$'", "]", "[", "'id'", "]", ";", "if", "(", "typeof", "groupId", "!==", "'undefined'", ")", "{", "resources", "=", "group", "[", "'resource'", "]", ";", "entry", "=", "{", "comment", ":", "'// pattern for '", "+", "groupId", ",", "pattern", ":", "groupId", ",", "responder", ":", "{", "dir", ":", "dir", "||", "'fill the dir'", ",", "src", ":", "[", "]", "}", "}", ";", "responder", "=", "entry", ".", "responder", ";", "if", "(", "typeof", "resources", "===", "'object'", "&&", "typeof", "resources", "[", "'$'", "]", "===", "'object'", "&&", "typeof", "resources", "[", "'$'", "]", "[", "'uri'", "]", "===", "'string'", ")", "{", "responder", ".", "src", ".", "push", "(", "resources", "[", "'$'", "]", "[", "'uri'", "]", ")", ";", "}", "if", "(", "Array", ".", "isArray", "(", "resources", ")", ")", "{", "resources", ".", "forEach", "(", "function", "(", "resource", ")", "{", "if", "(", "typeof", "resource", "[", "'$'", "]", "===", "'object'", "&&", "typeof", "resource", "[", "'$'", "]", "[", "'uri'", "]", "===", "'string'", ")", "{", "responder", ".", "src", ".", "push", "(", "resource", "[", "'$'", "]", "[", "'uri'", "]", ")", ";", "}", "}", ")", ";", "}", "responders", ".", "push", "(", "entry", ")", ";", "}", "}", "groups", "=", "result", ".", "groupdefinition", ".", "groups", "[", "0", "]", ".", "group", ";", "if", "(", "Array", ".", "isArray", "(", "groups", ")", ")", "{", "groups", ".", "forEach", "(", "groupParser", ")", ";", "}", "else", "if", "(", "typeof", "groups", "===", "'object'", ")", "{", "groupParser", "(", "groups", ")", ";", "}", "}", ")", ";", "_getRuleAsString", "(", "responders", ",", "callback", ")", ";", "}", ")", ";", "}" ]
Transfer the input xml to output js for nproxy @param {String} sfXML file path of sf combo configuration xml file @param {String} dir dir in the rule file
[ "Transfer", "the", "input", "xml", "to", "output", "js", "for", "nproxy" ]
23d5ebf109f3673b89e2b777e956d6e3eecbdff6
https://github.com/goddyZhao/sf-transfer/blob/23d5ebf109f3673b89e2b777e956d6e3eecbdff6/lib/sf.js#L112-L192
51,418
goddyZhao/sf-transfer
lib/sf.js
_getRuleAsString
function _getRuleAsString(responders, callback){ var respondersArr = []; var respondersLen = responders.length; var srcLen; var fileStr; responders.forEach(function(entry, i){ respondersArr.push(TAP + '{'); respondersArr.push(TAP + TAP + 'pattern: \'' + entry.pattern + '\',' + entry.comment); respondersArr.push(TAP + TAP + 'responder: {'); respondersArr.push(TAP + TAP + TAP + 'dir: ' + '\'' + entry.responder.dir + '\','); respondersArr.push(TAP + TAP + TAP + 'src: ['); srcLen = entry.responder.src.length; entry.responder.src.forEach(function(file, j){ fileStr = TAP + TAP + TAP + TAP + '\'' + file + '\''; if(j < srcLen - 1){ fileStr += ','; } respondersArr.push(fileStr); }); respondersArr.push(TAP + TAP + TAP + ']'); respondersArr.push(TAP + TAP + '}'); if( i < respondersLen - 1){ respondersArr.push(TAP + '},'); }else{ respondersArr.push(TAP + '}'); } }); if(typeof callback === 'function'){ callback(null, respondersArr.join(EOL)); } }
javascript
function _getRuleAsString(responders, callback){ var respondersArr = []; var respondersLen = responders.length; var srcLen; var fileStr; responders.forEach(function(entry, i){ respondersArr.push(TAP + '{'); respondersArr.push(TAP + TAP + 'pattern: \'' + entry.pattern + '\',' + entry.comment); respondersArr.push(TAP + TAP + 'responder: {'); respondersArr.push(TAP + TAP + TAP + 'dir: ' + '\'' + entry.responder.dir + '\','); respondersArr.push(TAP + TAP + TAP + 'src: ['); srcLen = entry.responder.src.length; entry.responder.src.forEach(function(file, j){ fileStr = TAP + TAP + TAP + TAP + '\'' + file + '\''; if(j < srcLen - 1){ fileStr += ','; } respondersArr.push(fileStr); }); respondersArr.push(TAP + TAP + TAP + ']'); respondersArr.push(TAP + TAP + '}'); if( i < respondersLen - 1){ respondersArr.push(TAP + '},'); }else{ respondersArr.push(TAP + '}'); } }); if(typeof callback === 'function'){ callback(null, respondersArr.join(EOL)); } }
[ "function", "_getRuleAsString", "(", "responders", ",", "callback", ")", "{", "var", "respondersArr", "=", "[", "]", ";", "var", "respondersLen", "=", "responders", ".", "length", ";", "var", "srcLen", ";", "var", "fileStr", ";", "responders", ".", "forEach", "(", "function", "(", "entry", ",", "i", ")", "{", "respondersArr", ".", "push", "(", "TAP", "+", "'{'", ")", ";", "respondersArr", ".", "push", "(", "TAP", "+", "TAP", "+", "'pattern: \\''", "+", "entry", ".", "pattern", "+", "'\\','", "+", "entry", ".", "comment", ")", ";", "respondersArr", ".", "push", "(", "TAP", "+", "TAP", "+", "'responder: {'", ")", ";", "respondersArr", ".", "push", "(", "TAP", "+", "TAP", "+", "TAP", "+", "'dir: '", "+", "'\\''", "+", "entry", ".", "responder", ".", "dir", "+", "'\\','", ")", ";", "respondersArr", ".", "push", "(", "TAP", "+", "TAP", "+", "TAP", "+", "'src: ['", ")", ";", "srcLen", "=", "entry", ".", "responder", ".", "src", ".", "length", ";", "entry", ".", "responder", ".", "src", ".", "forEach", "(", "function", "(", "file", ",", "j", ")", "{", "fileStr", "=", "TAP", "+", "TAP", "+", "TAP", "+", "TAP", "+", "'\\''", "+", "file", "+", "'\\''", ";", "if", "(", "j", "<", "srcLen", "-", "1", ")", "{", "fileStr", "+=", "','", ";", "}", "respondersArr", ".", "push", "(", "fileStr", ")", ";", "}", ")", ";", "respondersArr", ".", "push", "(", "TAP", "+", "TAP", "+", "TAP", "+", "']'", ")", ";", "respondersArr", ".", "push", "(", "TAP", "+", "TAP", "+", "'}'", ")", ";", "if", "(", "i", "<", "respondersLen", "-", "1", ")", "{", "respondersArr", ".", "push", "(", "TAP", "+", "'},'", ")", ";", "}", "else", "{", "respondersArr", ".", "push", "(", "TAP", "+", "'}'", ")", ";", "}", "}", ")", ";", "if", "(", "typeof", "callback", "===", "'function'", ")", "{", "callback", "(", "null", ",", "respondersArr", ".", "join", "(", "EOL", ")", ")", ";", "}", "}" ]
Get the transferd rules as a string @param {Object} responders the object of responder @param {Function} callback
[ "Get", "the", "transferd", "rules", "as", "a", "string" ]
23d5ebf109f3673b89e2b777e956d6e3eecbdff6
https://github.com/goddyZhao/sf-transfer/blob/23d5ebf109f3673b89e2b777e956d6e3eecbdff6/lib/sf.js#L200-L239
51,419
goddyZhao/sf-transfer
lib/sf.js
_append
function _append(target, rules, isTargetEmpty){ var concatedRules = []; var rulesContent; var l = rules.length; rules.forEach(function(rule, i){ if(i < l - 1){ concatedRules.push(rule + ','); }else{ concatedRules.push(rule + '/*{{more}}*/'); } }); if(isTargetEmpty){ rulesContent = EOL + concatedRules.join(EOL); }else{ rulesContent = ',' + EOL + concatedRules.join(EOL); } return target.replace(/\/\*{{more}}\*\//, rulesContent); }
javascript
function _append(target, rules, isTargetEmpty){ var concatedRules = []; var rulesContent; var l = rules.length; rules.forEach(function(rule, i){ if(i < l - 1){ concatedRules.push(rule + ','); }else{ concatedRules.push(rule + '/*{{more}}*/'); } }); if(isTargetEmpty){ rulesContent = EOL + concatedRules.join(EOL); }else{ rulesContent = ',' + EOL + concatedRules.join(EOL); } return target.replace(/\/\*{{more}}\*\//, rulesContent); }
[ "function", "_append", "(", "target", ",", "rules", ",", "isTargetEmpty", ")", "{", "var", "concatedRules", "=", "[", "]", ";", "var", "rulesContent", ";", "var", "l", "=", "rules", ".", "length", ";", "rules", ".", "forEach", "(", "function", "(", "rule", ",", "i", ")", "{", "if", "(", "i", "<", "l", "-", "1", ")", "{", "concatedRules", ".", "push", "(", "rule", "+", "','", ")", ";", "}", "else", "{", "concatedRules", ".", "push", "(", "rule", "+", "'/*{{more}}*/'", ")", ";", "}", "}", ")", ";", "if", "(", "isTargetEmpty", ")", "{", "rulesContent", "=", "EOL", "+", "concatedRules", ".", "join", "(", "EOL", ")", ";", "}", "else", "{", "rulesContent", "=", "','", "+", "EOL", "+", "concatedRules", ".", "join", "(", "EOL", ")", ";", "}", "return", "target", ".", "replace", "(", "/", "\\/\\*{{more}}\\*\\/", "/", ",", "rulesContent", ")", ";", "}" ]
Append rules to target one by one @param {String} target @param {Årray} rules @param {Boolean} isTargetEmpty whether the target is empty @api private
[ "Append", "rules", "to", "target", "one", "by", "one" ]
23d5ebf109f3673b89e2b777e956d6e3eecbdff6
https://github.com/goddyZhao/sf-transfer/blob/23d5ebf109f3673b89e2b777e956d6e3eecbdff6/lib/sf.js#L251-L270
51,420
vesln/copycat
index.js
end
function end() { var group = stack.pop(); if (!requests) return; var data = JSON.stringify(requests); var dest = path.join(options.fixtures, group + '.json'); fs.writeFileSync(dest, data, 'utf8'); requests = null; }
javascript
function end() { var group = stack.pop(); if (!requests) return; var data = JSON.stringify(requests); var dest = path.join(options.fixtures, group + '.json'); fs.writeFileSync(dest, data, 'utf8'); requests = null; }
[ "function", "end", "(", ")", "{", "var", "group", "=", "stack", ".", "pop", "(", ")", ";", "if", "(", "!", "requests", ")", "return", ";", "var", "data", "=", "JSON", ".", "stringify", "(", "requests", ")", ";", "var", "dest", "=", "path", ".", "join", "(", "options", ".", "fixtures", ",", "group", "+", "'.json'", ")", ";", "fs", ".", "writeFileSync", "(", "dest", ",", "data", ",", "'utf8'", ")", ";", "requests", "=", "null", ";", "}" ]
End and store the last group. @api public
[ "End", "and", "store", "the", "last", "group", "." ]
a2d7b0172d06afd5d6018fc19990863584767cf8
https://github.com/vesln/copycat/blob/a2d7b0172d06afd5d6018fc19990863584767cf8/index.js#L61-L68
51,421
vesln/copycat
index.js
recorder
function recorder(opts, fn) { var group = stack[stack.length - 1]; var response = null; assert(group, 'please specify copycat group'); recordings = load(group) || []; recordings.forEach(function(recording) { if (!deepEqual(recording.opts, opts)) return; response = recording; }); if (response) { return fn(response.err, response.res, response.body); } request(opts, function(err, res, body) { requests = requests || []; requests.push({ opts: opts, err: err, res: res, body: body }); fn.apply(null, arguments); }); }
javascript
function recorder(opts, fn) { var group = stack[stack.length - 1]; var response = null; assert(group, 'please specify copycat group'); recordings = load(group) || []; recordings.forEach(function(recording) { if (!deepEqual(recording.opts, opts)) return; response = recording; }); if (response) { return fn(response.err, response.res, response.body); } request(opts, function(err, res, body) { requests = requests || []; requests.push({ opts: opts, err: err, res: res, body: body }); fn.apply(null, arguments); }); }
[ "function", "recorder", "(", "opts", ",", "fn", ")", "{", "var", "group", "=", "stack", "[", "stack", ".", "length", "-", "1", "]", ";", "var", "response", "=", "null", ";", "assert", "(", "group", ",", "'please specify copycat group'", ")", ";", "recordings", "=", "load", "(", "group", ")", "||", "[", "]", ";", "recordings", ".", "forEach", "(", "function", "(", "recording", ")", "{", "if", "(", "!", "deepEqual", "(", "recording", ".", "opts", ",", "opts", ")", ")", "return", ";", "response", "=", "recording", ";", "}", ")", ";", "if", "(", "response", ")", "{", "return", "fn", "(", "response", ".", "err", ",", "response", ".", "res", ",", "response", ".", "body", ")", ";", "}", "request", "(", "opts", ",", "function", "(", "err", ",", "res", ",", "body", ")", "{", "requests", "=", "requests", "||", "[", "]", ";", "requests", ".", "push", "(", "{", "opts", ":", "opts", ",", "err", ":", "err", ",", "res", ":", "res", ",", "body", ":", "body", "}", ")", ";", "fn", ".", "apply", "(", "null", ",", "arguments", ")", ";", "}", ")", ";", "}" ]
Request copycat. @param {Object} options @param {Function} fn @api public
[ "Request", "copycat", "." ]
a2d7b0172d06afd5d6018fc19990863584767cf8
https://github.com/vesln/copycat/blob/a2d7b0172d06afd5d6018fc19990863584767cf8/index.js#L78-L99
51,422
vesln/copycat
index.js
load
function load(group) { var dest = path.join(options.fixtures, group + '.json'); var ret = null; var json = null; try { json = fs.readFileSync(dest, 'utf8'); ret = JSON.parse(json); } catch (err) {} return ret; }
javascript
function load(group) { var dest = path.join(options.fixtures, group + '.json'); var ret = null; var json = null; try { json = fs.readFileSync(dest, 'utf8'); ret = JSON.parse(json); } catch (err) {} return ret; }
[ "function", "load", "(", "group", ")", "{", "var", "dest", "=", "path", ".", "join", "(", "options", ".", "fixtures", ",", "group", "+", "'.json'", ")", ";", "var", "ret", "=", "null", ";", "var", "json", "=", "null", ";", "try", "{", "json", "=", "fs", ".", "readFileSync", "(", "dest", ",", "'utf8'", ")", ";", "ret", "=", "JSON", ".", "parse", "(", "json", ")", ";", "}", "catch", "(", "err", ")", "{", "}", "return", "ret", ";", "}" ]
Load stored requests and responses for `group`. @param {Strin} group @returns {Array} @api private
[ "Load", "stored", "requests", "and", "responses", "for", "group", "." ]
a2d7b0172d06afd5d6018fc19990863584767cf8
https://github.com/vesln/copycat/blob/a2d7b0172d06afd5d6018fc19990863584767cf8/index.js#L109-L120
51,423
node-neatly/neatly
lib/bootstrap.js
createRunQueue
function createRunQueue(modules) { return modules .map((mod) => mod._runQueue) .reduce((acc, res) => acc.concat(res), []); }
javascript
function createRunQueue(modules) { return modules .map((mod) => mod._runQueue) .reduce((acc, res) => acc.concat(res), []); }
[ "function", "createRunQueue", "(", "modules", ")", "{", "return", "modules", ".", "map", "(", "(", "mod", ")", "=>", "mod", ".", "_runQueue", ")", ".", "reduce", "(", "(", "acc", ",", "res", ")", "=>", "acc", ".", "concat", "(", "res", ")", ",", "[", "]", ")", ";", "}" ]
Runs recursively through modules and their dependency-modules and creates an array with handlers to invoke later by app-instance after startup. @param {Object} module Module instance @return {Array} Array of run handlers.
[ "Runs", "recursively", "through", "modules", "and", "their", "dependency", "-", "modules", "and", "creates", "an", "array", "with", "handlers", "to", "invoke", "later", "by", "app", "-", "instance", "after", "startup", "." ]
732d9729bce84013b5516fe7c239dd672d138dd8
https://github.com/node-neatly/neatly/blob/732d9729bce84013b5516fe7c239dd672d138dd8/lib/bootstrap.js#L107-L113
51,424
rqt/github
build/api/repos/create.js
create
async function create(options) { const { org, name, description, homepage, license_template, gitignore_template, auto_init = false, } = options const p = org ? `orgs/${org}` : 'user' const endpoint = `/${p}/repos` const { body } = await this._request({ data: { name, description, homepage, gitignore_template, license_template, auto_init, }, endpoint, }) /** @type {Repository} */ const r = body return r }
javascript
async function create(options) { const { org, name, description, homepage, license_template, gitignore_template, auto_init = false, } = options const p = org ? `orgs/${org}` : 'user' const endpoint = `/${p}/repos` const { body } = await this._request({ data: { name, description, homepage, gitignore_template, license_template, auto_init, }, endpoint, }) /** @type {Repository} */ const r = body return r }
[ "async", "function", "create", "(", "options", ")", "{", "const", "{", "org", ",", "name", ",", "description", ",", "homepage", ",", "license_template", ",", "gitignore_template", ",", "auto_init", "=", "false", ",", "}", "=", "options", "const", "p", "=", "org", "?", "`", "${", "org", "}", "`", ":", "'user'", "const", "endpoint", "=", "`", "${", "p", "}", "`", "const", "{", "body", "}", "=", "await", "this", ".", "_request", "(", "{", "data", ":", "{", "name", ",", "description", ",", "homepage", ",", "gitignore_template", ",", "license_template", ",", "auto_init", ",", "}", ",", "endpoint", ",", "}", ")", "/** @type {Repository} */", "const", "r", "=", "body", "return", "r", "}" ]
Create a new repository for the authenticated user. @param {CreateRepository} options Options to create a repository. @param {string} [options.org] The organisation on which to create the repository (if not adding to the user account). @param {string} options.name The name of the repository. @param {string} [options.description] A short description of the repository. @param {string} [options.homepage] A URL with more information about the repository. @param {string} [options.license_template] Choose an [open source license template](https://choosealicense.com/) that best suits your needs, and then use the [license keyword](https://help.github.com/articles/licensing-a-repository/#searching-github-by-license-type) as the license_template string. For example, "mit" or "mpl-2.0". @param {string} [options.gitignore_template] Desired language or platform .gitignore template to apply. Use the name of the template without the extension. For example, "Haskell". @param {boolean} [options.auto_init=false] Pass `true` to create an initial commit with empty README. Default `false`.
[ "Create", "a", "new", "repository", "for", "the", "authenticated", "user", "." ]
e6d3cdd8633628cd4aba30e70d8258aa7f6f0c5a
https://github.com/rqt/github/blob/e6d3cdd8633628cd4aba30e70d8258aa7f6f0c5a/build/api/repos/create.js#L12-L38
51,425
kevinoid/promised-read
lib/timeout-error.js
TimeoutError
function TimeoutError(message) { // Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message if (!(this instanceof TimeoutError)) { return new TimeoutError(message); } Error.captureStackTrace(this, TimeoutError); if (message !== undefined) { Object.defineProperty(this, 'message', { value: String(message), configurable: true, writable: true }); } }
javascript
function TimeoutError(message) { // Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message if (!(this instanceof TimeoutError)) { return new TimeoutError(message); } Error.captureStackTrace(this, TimeoutError); if (message !== undefined) { Object.defineProperty(this, 'message', { value: String(message), configurable: true, writable: true }); } }
[ "function", "TimeoutError", "(", "message", ")", "{", "// Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message", "if", "(", "!", "(", "this", "instanceof", "TimeoutError", ")", ")", "{", "return", "new", "TimeoutError", "(", "message", ")", ";", "}", "Error", ".", "captureStackTrace", "(", "this", ",", "TimeoutError", ")", ";", "if", "(", "message", "!==", "undefined", ")", "{", "Object", ".", "defineProperty", "(", "this", ",", "'message'", ",", "{", "value", ":", "String", "(", "message", ")", ",", "configurable", ":", "true", ",", "writable", ":", "true", "}", ")", ";", "}", "}" ]
Constructs a TimeoutError. @class Represents an error caused by a timeout expiring. @constructor @param {string=} message Human-readable description of the error.
[ "Constructs", "a", "TimeoutError", "." ]
c6adf477f4a64d5142363d84f7f83f5f07b8f682
https://github.com/kevinoid/promised-read/blob/c6adf477f4a64d5142363d84f7f83f5f07b8f682/lib/timeout-error.js#L16-L27
51,426
mdasberg/grunt-code-quality-report
tasks/code_quality_report.js
parseCoverageResults
function parseCoverageResults(src) { var collector = new istanbul.Collector(); var utils = istanbul.utils; var results = []; grunt.file.expand({filter: 'isFile'}, src).forEach(function (file) { var browser = path.dirname(file).substring(path.dirname(file).lastIndexOf("/")+1) collector.add(JSON.parse(grunt.file.read(file))); var summary = utils.summarizeCoverage(collector.getFinalCoverage()); results.push({ browser: browser, lines: Number(summary.lines.pct), branches: Number(summary.branches.pct), functions: Number(summary.functions.pct), statements: Number(summary.statements.pct) }); }); return results; }
javascript
function parseCoverageResults(src) { var collector = new istanbul.Collector(); var utils = istanbul.utils; var results = []; grunt.file.expand({filter: 'isFile'}, src).forEach(function (file) { var browser = path.dirname(file).substring(path.dirname(file).lastIndexOf("/")+1) collector.add(JSON.parse(grunt.file.read(file))); var summary = utils.summarizeCoverage(collector.getFinalCoverage()); results.push({ browser: browser, lines: Number(summary.lines.pct), branches: Number(summary.branches.pct), functions: Number(summary.functions.pct), statements: Number(summary.statements.pct) }); }); return results; }
[ "function", "parseCoverageResults", "(", "src", ")", "{", "var", "collector", "=", "new", "istanbul", ".", "Collector", "(", ")", ";", "var", "utils", "=", "istanbul", ".", "utils", ";", "var", "results", "=", "[", "]", ";", "grunt", ".", "file", ".", "expand", "(", "{", "filter", ":", "'isFile'", "}", ",", "src", ")", ".", "forEach", "(", "function", "(", "file", ")", "{", "var", "browser", "=", "path", ".", "dirname", "(", "file", ")", ".", "substring", "(", "path", ".", "dirname", "(", "file", ")", ".", "lastIndexOf", "(", "\"/\"", ")", "+", "1", ")", "collector", ".", "add", "(", "JSON", ".", "parse", "(", "grunt", ".", "file", ".", "read", "(", "file", ")", ")", ")", ";", "var", "summary", "=", "utils", ".", "summarizeCoverage", "(", "collector", ".", "getFinalCoverage", "(", ")", ")", ";", "results", ".", "push", "(", "{", "browser", ":", "browser", ",", "lines", ":", "Number", "(", "summary", ".", "lines", ".", "pct", ")", ",", "branches", ":", "Number", "(", "summary", ".", "branches", ".", "pct", ")", ",", "functions", ":", "Number", "(", "summary", ".", "functions", ".", "pct", ")", ",", "statements", ":", "Number", "(", "summary", ".", "statements", ".", "pct", ")", "}", ")", ";", "}", ")", ";", "return", "results", ";", "}" ]
Parse the coverage results @param coverage The coverage location. @returns {{coverage: {}}}
[ "Parse", "the", "coverage", "results" ]
065f6e9356b0bbcb8d366e8ae9cbddbd623de872
https://github.com/mdasberg/grunt-code-quality-report/blob/065f6e9356b0bbcb8d366e8ae9cbddbd623de872/tasks/code_quality_report.js#L150-L169
51,427
mdasberg/grunt-code-quality-report
tasks/code_quality_report.js
parseJshintResults
function parseJshintResults(fileName, showDetails) { var result = {}; if (grunt.file.exists(fileName)) { var content = grunt.file.read(fileName); xml2js.parseString(content, {}, function (err, res) { var consoleStatements = content.match(/(console.*)/g); result = { tests: Number(res.testsuite.$.tests), failures: Number(res.testsuite.$.failures), errors: Number(res.testsuite.$.errors), consoleStatements: consoleStatements != null ? consoleStatements.length : 0 }; if (showDetails) { var details = {}; res.testsuite.testcase.forEach(function (key) { if(typeof key.failure !== 'undefined') { var filename = key.$.name.substring(key.$.name.search(/[^\/]+$/g)); var failures = key.failure[0]._.replace(/\n/g, "###").split("###"); failures.shift(); failures.pop(); details[filename] = failures; } }); result.failureDetails = details; } }); } return result; }
javascript
function parseJshintResults(fileName, showDetails) { var result = {}; if (grunt.file.exists(fileName)) { var content = grunt.file.read(fileName); xml2js.parseString(content, {}, function (err, res) { var consoleStatements = content.match(/(console.*)/g); result = { tests: Number(res.testsuite.$.tests), failures: Number(res.testsuite.$.failures), errors: Number(res.testsuite.$.errors), consoleStatements: consoleStatements != null ? consoleStatements.length : 0 }; if (showDetails) { var details = {}; res.testsuite.testcase.forEach(function (key) { if(typeof key.failure !== 'undefined') { var filename = key.$.name.substring(key.$.name.search(/[^\/]+$/g)); var failures = key.failure[0]._.replace(/\n/g, "###").split("###"); failures.shift(); failures.pop(); details[filename] = failures; } }); result.failureDetails = details; } }); } return result; }
[ "function", "parseJshintResults", "(", "fileName", ",", "showDetails", ")", "{", "var", "result", "=", "{", "}", ";", "if", "(", "grunt", ".", "file", ".", "exists", "(", "fileName", ")", ")", "{", "var", "content", "=", "grunt", ".", "file", ".", "read", "(", "fileName", ")", ";", "xml2js", ".", "parseString", "(", "content", ",", "{", "}", ",", "function", "(", "err", ",", "res", ")", "{", "var", "consoleStatements", "=", "content", ".", "match", "(", "/", "(console.*)", "/", "g", ")", ";", "result", "=", "{", "tests", ":", "Number", "(", "res", ".", "testsuite", ".", "$", ".", "tests", ")", ",", "failures", ":", "Number", "(", "res", ".", "testsuite", ".", "$", ".", "failures", ")", ",", "errors", ":", "Number", "(", "res", ".", "testsuite", ".", "$", ".", "errors", ")", ",", "consoleStatements", ":", "consoleStatements", "!=", "null", "?", "consoleStatements", ".", "length", ":", "0", "}", ";", "if", "(", "showDetails", ")", "{", "var", "details", "=", "{", "}", ";", "res", ".", "testsuite", ".", "testcase", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "typeof", "key", ".", "failure", "!==", "'undefined'", ")", "{", "var", "filename", "=", "key", ".", "$", ".", "name", ".", "substring", "(", "key", ".", "$", ".", "name", ".", "search", "(", "/", "[^\\/]+$", "/", "g", ")", ")", ";", "var", "failures", "=", "key", ".", "failure", "[", "0", "]", ".", "_", ".", "replace", "(", "/", "\\n", "/", "g", ",", "\"###\"", ")", ".", "split", "(", "\"###\"", ")", ";", "failures", ".", "shift", "(", ")", ";", "failures", ".", "pop", "(", ")", ";", "details", "[", "filename", "]", "=", "failures", ";", "}", "}", ")", ";", "result", ".", "failureDetails", "=", "details", ";", "}", "}", ")", ";", "}", "return", "result", ";", "}" ]
Parse the jshint results. @param fileName The filename. @returns {{junit: {}}}
[ "Parse", "the", "jshint", "results", "." ]
065f6e9356b0bbcb8d366e8ae9cbddbd623de872
https://github.com/mdasberg/grunt-code-quality-report/blob/065f6e9356b0bbcb8d366e8ae9cbddbd623de872/tasks/code_quality_report.js#L176-L205
51,428
mariusc23/express-query-date
lib/parse.js
parse
function parse(obj, options) { var result = {}, key, value, momentValue; for (key in obj) { if (obj.hasOwnProperty(key)) { value = obj[key]; if (typeof value === 'string' || typeof value === 'number') { momentValue = moment.call(null, value, options.formats, options.strict); if (momentValue.isValid()) { result[key] = momentValue.toDate(); } else { result[key] = value; } } else if (value.constructor === Object) { result[key] = parse(value, options); } else { result[key] = value; } } } return result; }
javascript
function parse(obj, options) { var result = {}, key, value, momentValue; for (key in obj) { if (obj.hasOwnProperty(key)) { value = obj[key]; if (typeof value === 'string' || typeof value === 'number') { momentValue = moment.call(null, value, options.formats, options.strict); if (momentValue.isValid()) { result[key] = momentValue.toDate(); } else { result[key] = value; } } else if (value.constructor === Object) { result[key] = parse(value, options); } else { result[key] = value; } } } return result; }
[ "function", "parse", "(", "obj", ",", "options", ")", "{", "var", "result", "=", "{", "}", ",", "key", ",", "value", ",", "momentValue", ";", "for", "(", "key", "in", "obj", ")", "{", "if", "(", "obj", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "value", "=", "obj", "[", "key", "]", ";", "if", "(", "typeof", "value", "===", "'string'", "||", "typeof", "value", "===", "'number'", ")", "{", "momentValue", "=", "moment", ".", "call", "(", "null", ",", "value", ",", "options", ".", "formats", ",", "options", ".", "strict", ")", ";", "if", "(", "momentValue", ".", "isValid", "(", ")", ")", "{", "result", "[", "key", "]", "=", "momentValue", ".", "toDate", "(", ")", ";", "}", "else", "{", "result", "[", "key", "]", "=", "value", ";", "}", "}", "else", "if", "(", "value", ".", "constructor", "===", "Object", ")", "{", "result", "[", "key", "]", "=", "parse", "(", "value", ",", "options", ")", ";", "}", "else", "{", "result", "[", "key", "]", "=", "value", ";", "}", "}", "}", "return", "result", ";", "}" ]
Attempts to recursively convert object properties to dates. @param {Object} obj - Object to iterate over. @param {Object} options - Options. @param {Array} options.formats - Array of formats moment should accept. @param {Boolean} options.strict - Whether moment should parse in strict mode. @return {Object} Returns new object (shallow copy).
[ "Attempts", "to", "recursively", "convert", "object", "properties", "to", "dates", "." ]
7aae8448342f13130a3b52807638c34eef882825
https://github.com/mariusc23/express-query-date/blob/7aae8448342f13130a3b52807638c34eef882825/lib/parse.js#L13-L43
51,429
0x333333/wiki-infobox-parser-core
index.js
main
function main(content, callback) { parser(content, function(error, result) { if (error) { callback(error); } else { callback(null, result); } }); }
javascript
function main(content, callback) { parser(content, function(error, result) { if (error) { callback(error); } else { callback(null, result); } }); }
[ "function", "main", "(", "content", ",", "callback", ")", "{", "parser", "(", "content", ",", "function", "(", "error", ",", "result", ")", "{", "if", "(", "error", ")", "{", "callback", "(", "error", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "result", ")", ";", "}", "}", ")", ";", "}" ]
Wiki Infobox parser main function @method main @param {string} content wiki text to parse @param {function} callback callback function
[ "Wiki", "Infobox", "parser", "main", "function" ]
74fcd4387393b80940945c05f76f2ce8fe1be769
https://github.com/0x333333/wiki-infobox-parser-core/blob/74fcd4387393b80940945c05f76f2ce8fe1be769/index.js#L9-L17
51,430
byron-dupreez/aws-stream-consumer-core
persisting.js
toBatchStateItem
function toBatchStateItem(batch, context) { const states = batch.states; // const messages = batch.allMessages(); const messages = batch.messages; const rejectedMessages = batch.rejectedMessages; const unusableRecords = batch.unusableRecords; // Resolve the messages' states to be saved (if any) const messageStates = messages && messages.length > 0 ? messages.map(msg => toStorableMessageState(states.get(msg), msg, context)).filter(s => !!s) : []; // Resolve the rejected messages' states to be saved (if any) const rejectedMessageStates = rejectedMessages && rejectedMessages.length > 0 ? rejectedMessages.map(msg => toStorableMessageState(states.get(msg), msg, context)).filter(s => !!s) : []; // Resolve the unusable records' states to be saved (if any) const unusableRecordStates = unusableRecords && unusableRecords.length > 0 ? unusableRecords.map(uRec => toStorableUnusableRecordState(states.get(uRec), uRec, context)).filter(s => !!s) : []; const batchState = toStorableBatchState(states.get(batch), batch, context); return { streamConsumerId: batch.streamConsumerId, // hash key shardOrEventID: batch.shardOrEventID, // range key messageStates: messageStates, rejectedMessageStates: rejectedMessageStates, unusableRecordStates: unusableRecordStates, batchState: batchState || null }; }
javascript
function toBatchStateItem(batch, context) { const states = batch.states; // const messages = batch.allMessages(); const messages = batch.messages; const rejectedMessages = batch.rejectedMessages; const unusableRecords = batch.unusableRecords; // Resolve the messages' states to be saved (if any) const messageStates = messages && messages.length > 0 ? messages.map(msg => toStorableMessageState(states.get(msg), msg, context)).filter(s => !!s) : []; // Resolve the rejected messages' states to be saved (if any) const rejectedMessageStates = rejectedMessages && rejectedMessages.length > 0 ? rejectedMessages.map(msg => toStorableMessageState(states.get(msg), msg, context)).filter(s => !!s) : []; // Resolve the unusable records' states to be saved (if any) const unusableRecordStates = unusableRecords && unusableRecords.length > 0 ? unusableRecords.map(uRec => toStorableUnusableRecordState(states.get(uRec), uRec, context)).filter(s => !!s) : []; const batchState = toStorableBatchState(states.get(batch), batch, context); return { streamConsumerId: batch.streamConsumerId, // hash key shardOrEventID: batch.shardOrEventID, // range key messageStates: messageStates, rejectedMessageStates: rejectedMessageStates, unusableRecordStates: unusableRecordStates, batchState: batchState || null }; }
[ "function", "toBatchStateItem", "(", "batch", ",", "context", ")", "{", "const", "states", "=", "batch", ".", "states", ";", "// const messages = batch.allMessages();", "const", "messages", "=", "batch", ".", "messages", ";", "const", "rejectedMessages", "=", "batch", ".", "rejectedMessages", ";", "const", "unusableRecords", "=", "batch", ".", "unusableRecords", ";", "// Resolve the messages' states to be saved (if any)", "const", "messageStates", "=", "messages", "&&", "messages", ".", "length", ">", "0", "?", "messages", ".", "map", "(", "msg", "=>", "toStorableMessageState", "(", "states", ".", "get", "(", "msg", ")", ",", "msg", ",", "context", ")", ")", ".", "filter", "(", "s", "=>", "!", "!", "s", ")", ":", "[", "]", ";", "// Resolve the rejected messages' states to be saved (if any)", "const", "rejectedMessageStates", "=", "rejectedMessages", "&&", "rejectedMessages", ".", "length", ">", "0", "?", "rejectedMessages", ".", "map", "(", "msg", "=>", "toStorableMessageState", "(", "states", ".", "get", "(", "msg", ")", ",", "msg", ",", "context", ")", ")", ".", "filter", "(", "s", "=>", "!", "!", "s", ")", ":", "[", "]", ";", "// Resolve the unusable records' states to be saved (if any)", "const", "unusableRecordStates", "=", "unusableRecords", "&&", "unusableRecords", ".", "length", ">", "0", "?", "unusableRecords", ".", "map", "(", "uRec", "=>", "toStorableUnusableRecordState", "(", "states", ".", "get", "(", "uRec", ")", ",", "uRec", ",", "context", ")", ")", ".", "filter", "(", "s", "=>", "!", "!", "s", ")", ":", "[", "]", ";", "const", "batchState", "=", "toStorableBatchState", "(", "states", ".", "get", "(", "batch", ")", ",", "batch", ",", "context", ")", ";", "return", "{", "streamConsumerId", ":", "batch", ".", "streamConsumerId", ",", "// hash key", "shardOrEventID", ":", "batch", ".", "shardOrEventID", ",", "// range key", "messageStates", ":", "messageStates", ",", "rejectedMessageStates", ":", "rejectedMessageStates", ",", "unusableRecordStates", ":", "unusableRecordStates", ",", "batchState", ":", "batchState", "||", "null", "}", ";", "}" ]
Converts the given batch into a stream consumer batch state item to be subsequently persisted to DynamoDB. @param {Batch} batch - the batch to be converted into a batch state item @param {StreamProcessing} context - the context to use @returns {BatchStateItem} the stream consumer batch state item
[ "Converts", "the", "given", "batch", "into", "a", "stream", "consumer", "batch", "state", "item", "to", "be", "subsequently", "persisted", "to", "DynamoDB", "." ]
9b256084297f80d373bcf483aaf68a9da176b3d7
https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L225-L254
51,431
byron-dupreez/aws-stream-consumer-core
persisting.js
toStorableMessageState
function toStorableMessageState(messageState, message, context) { if (!messageState) { context.warn(`Skipping save of state for message, since it has no state - message (${JSON.stringify(message)})`); return undefined; } // Convert the message's state into a safely storable object to get a clean, simplified version of its state const state = dynamoDBUtils.toStorableObject(messageState); // If state has no message identifier then have no way to identify the message ... so attach a safely storable copy of // its original message, user record or record (if any) (i.e. without its legacy state, if any, for later matching)! if (!hasMessageIdentifier(messageState)) { message = message || messageState.message; if (message) { // Make a storable copy of the message & attach it to the storable state state.message = dynamoDBUtils.toStorableObject(message); // Remove the message copy's LEGACY state (if any) to get back to the original message tracking.deleteLegacyState(message, context); } else if (messageState.userRecord) { // If has no message, then attach a copy of its user record // Make a storable copy of the unusable user record & attach it to the storable state state.userRecord = dynamoDBUtils.toStorableObject(messageState.userRecord); // Remove the unusable user record copy's LEGACY state (if any) to get back to the original user record tracking.deleteLegacyState(state.userRecord, context); } else if (messageState.record) { // If has no message AND no user record, then attach a copy of its record // Make a storable copy of the unusable record & attach it to the storable state state.record = dynamoDBUtils.toStorableObject(messageState.record); // remove the unusable record copy's LEGACY state (if any) to get back to the original record tracking.deleteLegacyState(state.record, context); } } return state; }
javascript
function toStorableMessageState(messageState, message, context) { if (!messageState) { context.warn(`Skipping save of state for message, since it has no state - message (${JSON.stringify(message)})`); return undefined; } // Convert the message's state into a safely storable object to get a clean, simplified version of its state const state = dynamoDBUtils.toStorableObject(messageState); // If state has no message identifier then have no way to identify the message ... so attach a safely storable copy of // its original message, user record or record (if any) (i.e. without its legacy state, if any, for later matching)! if (!hasMessageIdentifier(messageState)) { message = message || messageState.message; if (message) { // Make a storable copy of the message & attach it to the storable state state.message = dynamoDBUtils.toStorableObject(message); // Remove the message copy's LEGACY state (if any) to get back to the original message tracking.deleteLegacyState(message, context); } else if (messageState.userRecord) { // If has no message, then attach a copy of its user record // Make a storable copy of the unusable user record & attach it to the storable state state.userRecord = dynamoDBUtils.toStorableObject(messageState.userRecord); // Remove the unusable user record copy's LEGACY state (if any) to get back to the original user record tracking.deleteLegacyState(state.userRecord, context); } else if (messageState.record) { // If has no message AND no user record, then attach a copy of its record // Make a storable copy of the unusable record & attach it to the storable state state.record = dynamoDBUtils.toStorableObject(messageState.record); // remove the unusable record copy's LEGACY state (if any) to get back to the original record tracking.deleteLegacyState(state.record, context); } } return state; }
[ "function", "toStorableMessageState", "(", "messageState", ",", "message", ",", "context", ")", "{", "if", "(", "!", "messageState", ")", "{", "context", ".", "warn", "(", "`", "${", "JSON", ".", "stringify", "(", "message", ")", "}", "`", ")", ";", "return", "undefined", ";", "}", "// Convert the message's state into a safely storable object to get a clean, simplified version of its state", "const", "state", "=", "dynamoDBUtils", ".", "toStorableObject", "(", "messageState", ")", ";", "// If state has no message identifier then have no way to identify the message ... so attach a safely storable copy of", "// its original message, user record or record (if any) (i.e. without its legacy state, if any, for later matching)!", "if", "(", "!", "hasMessageIdentifier", "(", "messageState", ")", ")", "{", "message", "=", "message", "||", "messageState", ".", "message", ";", "if", "(", "message", ")", "{", "// Make a storable copy of the message & attach it to the storable state", "state", ".", "message", "=", "dynamoDBUtils", ".", "toStorableObject", "(", "message", ")", ";", "// Remove the message copy's LEGACY state (if any) to get back to the original message", "tracking", ".", "deleteLegacyState", "(", "message", ",", "context", ")", ";", "}", "else", "if", "(", "messageState", ".", "userRecord", ")", "{", "// If has no message, then attach a copy of its user record", "// Make a storable copy of the unusable user record & attach it to the storable state", "state", ".", "userRecord", "=", "dynamoDBUtils", ".", "toStorableObject", "(", "messageState", ".", "userRecord", ")", ";", "// Remove the unusable user record copy's LEGACY state (if any) to get back to the original user record", "tracking", ".", "deleteLegacyState", "(", "state", ".", "userRecord", ",", "context", ")", ";", "}", "else", "if", "(", "messageState", ".", "record", ")", "{", "// If has no message AND no user record, then attach a copy of its record", "// Make a storable copy of the unusable record & attach it to the storable state", "state", ".", "record", "=", "dynamoDBUtils", ".", "toStorableObject", "(", "messageState", ".", "record", ")", ";", "// remove the unusable record copy's LEGACY state (if any) to get back to the original record", "tracking", ".", "deleteLegacyState", "(", "state", ".", "record", ",", "context", ")", ";", "}", "}", "return", "state", ";", "}" ]
Converts the given message state into a storable version of itself. @param {MessageState} messageState @param {Message} message @param {StreamProcessing} context @return {MessageStateItem|undefined}
[ "Converts", "the", "given", "message", "state", "into", "a", "storable", "version", "of", "itself", "." ]
9b256084297f80d373bcf483aaf68a9da176b3d7
https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L263-L299
51,432
byron-dupreez/aws-stream-consumer-core
persisting.js
toStorableUnusableRecordState
function toStorableUnusableRecordState(unusableRecordState, unusableRecord, context) { if (!unusableRecordState) { context.warn(`Skipping save of state for unusable record, since it has no state - record (${JSON.stringify(unusableRecord)})`); return undefined; } // Convert the record's state into a safely storable object to get a clean, simplified version of its state const state = dynamoDBUtils.toStorableObject(unusableRecordState); // If state has no record identifier then have no way to identify the unusable record ... so attach a safely storable // copy of its original user record or record (if any) (without its legacy state, if any) for later matching! if (!hasUnusableRecordIdentifier(unusableRecordState)) { unusableRecord = unusableRecord || unusableRecordState.unusableRecord; if (unusableRecord) { // Make a storable copy of the unusable record & attach it to the storable state state.unusableRecord = dynamoDBUtils.toStorableObject(unusableRecord); // Remove the unusable record copy's LEGACY state (if any) to get back to the original unusable record tracking.deleteLegacyState(unusableRecord, context); } if (unusableRecordState.userRecord) { // Make a storable copy of the unusable record's user record & attach it to the storable state state.userRecord = dynamoDBUtils.toStorableObject(unusableRecordState.userRecord); // Remove the unusable record's user record copy's LEGACY state (if any) to get back to the original user record tracking.deleteLegacyState(state.userRecord, context); } else if (unusableRecordState.record) { // Make a storable copy of the unusable record's record & attach it to the storable state state.record = dynamoDBUtils.toStorableObject(unusableRecordState.record); // remove the unusable record's record copy's LEGACY state (if any) to get back to the original record tracking.deleteLegacyState(state.record, context); } } return state; }
javascript
function toStorableUnusableRecordState(unusableRecordState, unusableRecord, context) { if (!unusableRecordState) { context.warn(`Skipping save of state for unusable record, since it has no state - record (${JSON.stringify(unusableRecord)})`); return undefined; } // Convert the record's state into a safely storable object to get a clean, simplified version of its state const state = dynamoDBUtils.toStorableObject(unusableRecordState); // If state has no record identifier then have no way to identify the unusable record ... so attach a safely storable // copy of its original user record or record (if any) (without its legacy state, if any) for later matching! if (!hasUnusableRecordIdentifier(unusableRecordState)) { unusableRecord = unusableRecord || unusableRecordState.unusableRecord; if (unusableRecord) { // Make a storable copy of the unusable record & attach it to the storable state state.unusableRecord = dynamoDBUtils.toStorableObject(unusableRecord); // Remove the unusable record copy's LEGACY state (if any) to get back to the original unusable record tracking.deleteLegacyState(unusableRecord, context); } if (unusableRecordState.userRecord) { // Make a storable copy of the unusable record's user record & attach it to the storable state state.userRecord = dynamoDBUtils.toStorableObject(unusableRecordState.userRecord); // Remove the unusable record's user record copy's LEGACY state (if any) to get back to the original user record tracking.deleteLegacyState(state.userRecord, context); } else if (unusableRecordState.record) { // Make a storable copy of the unusable record's record & attach it to the storable state state.record = dynamoDBUtils.toStorableObject(unusableRecordState.record); // remove the unusable record's record copy's LEGACY state (if any) to get back to the original record tracking.deleteLegacyState(state.record, context); } } return state; }
[ "function", "toStorableUnusableRecordState", "(", "unusableRecordState", ",", "unusableRecord", ",", "context", ")", "{", "if", "(", "!", "unusableRecordState", ")", "{", "context", ".", "warn", "(", "`", "${", "JSON", ".", "stringify", "(", "unusableRecord", ")", "}", "`", ")", ";", "return", "undefined", ";", "}", "// Convert the record's state into a safely storable object to get a clean, simplified version of its state", "const", "state", "=", "dynamoDBUtils", ".", "toStorableObject", "(", "unusableRecordState", ")", ";", "// If state has no record identifier then have no way to identify the unusable record ... so attach a safely storable", "// copy of its original user record or record (if any) (without its legacy state, if any) for later matching!", "if", "(", "!", "hasUnusableRecordIdentifier", "(", "unusableRecordState", ")", ")", "{", "unusableRecord", "=", "unusableRecord", "||", "unusableRecordState", ".", "unusableRecord", ";", "if", "(", "unusableRecord", ")", "{", "// Make a storable copy of the unusable record & attach it to the storable state", "state", ".", "unusableRecord", "=", "dynamoDBUtils", ".", "toStorableObject", "(", "unusableRecord", ")", ";", "// Remove the unusable record copy's LEGACY state (if any) to get back to the original unusable record", "tracking", ".", "deleteLegacyState", "(", "unusableRecord", ",", "context", ")", ";", "}", "if", "(", "unusableRecordState", ".", "userRecord", ")", "{", "// Make a storable copy of the unusable record's user record & attach it to the storable state", "state", ".", "userRecord", "=", "dynamoDBUtils", ".", "toStorableObject", "(", "unusableRecordState", ".", "userRecord", ")", ";", "// Remove the unusable record's user record copy's LEGACY state (if any) to get back to the original user record", "tracking", ".", "deleteLegacyState", "(", "state", ".", "userRecord", ",", "context", ")", ";", "}", "else", "if", "(", "unusableRecordState", ".", "record", ")", "{", "// Make a storable copy of the unusable record's record & attach it to the storable state", "state", ".", "record", "=", "dynamoDBUtils", ".", "toStorableObject", "(", "unusableRecordState", ".", "record", ")", ";", "// remove the unusable record's record copy's LEGACY state (if any) to get back to the original record", "tracking", ".", "deleteLegacyState", "(", "state", ".", "record", ",", "context", ")", ";", "}", "}", "return", "state", ";", "}" ]
Converts the given unusable record state into a storable version of itself. @param {UnusableRecordState} unusableRecordState @param {UnusableRecord|undefined} unusableRecord @param {StreamProcessing} context @return {UnusableRecordStateItem|undefined}
[ "Converts", "the", "given", "unusable", "record", "state", "into", "a", "storable", "version", "of", "itself", "." ]
9b256084297f80d373bcf483aaf68a9da176b3d7
https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L308-L342
51,433
byron-dupreez/aws-stream-consumer-core
persisting.js
updateBatchWithPriorState
function updateBatchWithPriorState(batch, item, context) { restoreMessageAndRejectedMessageStates(batch, item, context); restoreUnusableRecordStates(batch, item, context); }
javascript
function updateBatchWithPriorState(batch, item, context) { restoreMessageAndRejectedMessageStates(batch, item, context); restoreUnusableRecordStates(batch, item, context); }
[ "function", "updateBatchWithPriorState", "(", "batch", ",", "item", ",", "context", ")", "{", "restoreMessageAndRejectedMessageStates", "(", "batch", ",", "item", ",", "context", ")", ";", "restoreUnusableRecordStates", "(", "batch", ",", "item", ",", "context", ")", ";", "}" ]
Updates the given batch with the previous message states, previous unusable record states and previous batch state on the given item, which was loaded from the database. @param {Batch} batch - the batch to update @param {BatchStateItem} item - a previously loaded batch state item @param context
[ "Updates", "the", "given", "batch", "with", "the", "previous", "message", "states", "previous", "unusable", "record", "states", "and", "previous", "batch", "state", "on", "the", "given", "item", "which", "was", "loaded", "from", "the", "database", "." ]
9b256084297f80d373bcf483aaf68a9da176b3d7
https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L447-L450
51,434
byron-dupreez/aws-stream-consumer-core
persisting.js
hasMessageIdentifier
function hasMessageIdentifier(msgState) { const md5s = msgState.md5s; return isNotBlank(msgState.eventID) || // isNotBlank(msgState.eventSeqNo) || isNotBlank(msgState.eventSubSeqNo) || (msgState.idVals && msgState.idVals.some(isNotBlank)) || ((msgState.keyVals && msgState.keyVals.some(isNotBlank)) && (msgState.seqNoVals && msgState.seqNoVals.some(isNotBlank))) || (md5s && (isNotBlank(md5s.msg) || isNotBlank(md5s.userRec) || isNotBlank(md5s.rec) || isNotBlank(md5s.data))); }
javascript
function hasMessageIdentifier(msgState) { const md5s = msgState.md5s; return isNotBlank(msgState.eventID) || // isNotBlank(msgState.eventSeqNo) || isNotBlank(msgState.eventSubSeqNo) || (msgState.idVals && msgState.idVals.some(isNotBlank)) || ((msgState.keyVals && msgState.keyVals.some(isNotBlank)) && (msgState.seqNoVals && msgState.seqNoVals.some(isNotBlank))) || (md5s && (isNotBlank(md5s.msg) || isNotBlank(md5s.userRec) || isNotBlank(md5s.rec) || isNotBlank(md5s.data))); }
[ "function", "hasMessageIdentifier", "(", "msgState", ")", "{", "const", "md5s", "=", "msgState", ".", "md5s", ";", "return", "isNotBlank", "(", "msgState", ".", "eventID", ")", "||", "// isNotBlank(msgState.eventSeqNo) || isNotBlank(msgState.eventSubSeqNo) ||", "(", "msgState", ".", "idVals", "&&", "msgState", ".", "idVals", ".", "some", "(", "isNotBlank", ")", ")", "||", "(", "(", "msgState", ".", "keyVals", "&&", "msgState", ".", "keyVals", ".", "some", "(", "isNotBlank", ")", ")", "&&", "(", "msgState", ".", "seqNoVals", "&&", "msgState", ".", "seqNoVals", ".", "some", "(", "isNotBlank", ")", ")", ")", "||", "(", "md5s", "&&", "(", "isNotBlank", "(", "md5s", ".", "msg", ")", "||", "isNotBlank", "(", "md5s", ".", "userRec", ")", "||", "isNotBlank", "(", "md5s", ".", "rec", ")", "||", "isNotBlank", "(", "md5s", ".", "data", ")", ")", ")", ";", "}" ]
Returns true if the given message state has at least one non-blank identifier; otherwise false. @param {MessageState} msgState - the tracked state of a message @return {boolean}
[ "Returns", "true", "if", "the", "given", "message", "state", "has", "at", "least", "one", "non", "-", "blank", "identifier", ";", "otherwise", "false", "." ]
9b256084297f80d373bcf483aaf68a9da176b3d7
https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L457-L464
51,435
byron-dupreez/aws-stream-consumer-core
persisting.js
hasUnusableRecordIdentifier
function hasUnusableRecordIdentifier(recState) { const md5s = recState.md5s; return isNotBlank(recState.eventID) || // isNotBlank(recState.eventSeqNo) || isNotBlank(recState.eventSubSeqNo) || (md5s && (isNotBlank(md5s.userRec) || isNotBlank(md5s.rec) || isNotBlank(md5s.data))); }
javascript
function hasUnusableRecordIdentifier(recState) { const md5s = recState.md5s; return isNotBlank(recState.eventID) || // isNotBlank(recState.eventSeqNo) || isNotBlank(recState.eventSubSeqNo) || (md5s && (isNotBlank(md5s.userRec) || isNotBlank(md5s.rec) || isNotBlank(md5s.data))); }
[ "function", "hasUnusableRecordIdentifier", "(", "recState", ")", "{", "const", "md5s", "=", "recState", ".", "md5s", ";", "return", "isNotBlank", "(", "recState", ".", "eventID", ")", "||", "// isNotBlank(recState.eventSeqNo) || isNotBlank(recState.eventSubSeqNo) ||", "(", "md5s", "&&", "(", "isNotBlank", "(", "md5s", ".", "userRec", ")", "||", "isNotBlank", "(", "md5s", ".", "rec", ")", "||", "isNotBlank", "(", "md5s", ".", "data", ")", ")", ")", ";", "}" ]
Returns true if the given unusable record state has at least one non-blank identifier; otherwise false. @param {UnusableRecordState} recState - the tracked state of an unusable record @return {boolean}
[ "Returns", "true", "if", "the", "given", "unusable", "record", "state", "has", "at", "least", "one", "non", "-", "blank", "identifier", ";", "otherwise", "false", "." ]
9b256084297f80d373bcf483aaf68a9da176b3d7
https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/persisting.js#L489-L493
51,436
appcelerator-archive/appc-connector-utils
lib/tools/dataValidator.js
validate
function validate (data, schema) { if (!data || !schema) { throw new Error('Trying to validate without passing data and schema') } return Joi.validate(data, schema) }
javascript
function validate (data, schema) { if (!data || !schema) { throw new Error('Trying to validate without passing data and schema') } return Joi.validate(data, schema) }
[ "function", "validate", "(", "data", ",", "schema", ")", "{", "if", "(", "!", "data", "||", "!", "schema", ")", "{", "throw", "new", "Error", "(", "'Trying to validate without passing data and schema'", ")", "}", "return", "Joi", ".", "validate", "(", "data", ",", "schema", ")", "}" ]
Validates data based on Joi schemas @param {Object} data the data to be validated @param {Object} schema the object schema specified in Joi against which data is validated
[ "Validates", "data", "based", "on", "Joi", "schemas" ]
4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8
https://github.com/appcelerator-archive/appc-connector-utils/blob/4af3bb7d24c5780270d7ba0ec98017b1f58f1aa8/lib/tools/dataValidator.js#L13-L18
51,437
esiglabs/eslutils
build/validation.js
verifyChain
function verifyChain(certificate, chain, trustedCAs) { if (certificate === null) return Promise.resolve(false); return Promise.resolve().then(function () { var certificateChainEngine = new pkijs.CertificateChainValidationEngine({ certs: chain, trustedCerts: trustedCAs.filter(function (cert) { return typeof cert !== 'undefined'; }) }); certificateChainEngine.certs.push(certificate); return certificateChainEngine.verify(); }).then(function (result) { return result.result; }, function (result) { return false; }); }
javascript
function verifyChain(certificate, chain, trustedCAs) { if (certificate === null) return Promise.resolve(false); return Promise.resolve().then(function () { var certificateChainEngine = new pkijs.CertificateChainValidationEngine({ certs: chain, trustedCerts: trustedCAs.filter(function (cert) { return typeof cert !== 'undefined'; }) }); certificateChainEngine.certs.push(certificate); return certificateChainEngine.verify(); }).then(function (result) { return result.result; }, function (result) { return false; }); }
[ "function", "verifyChain", "(", "certificate", ",", "chain", ",", "trustedCAs", ")", "{", "if", "(", "certificate", "===", "null", ")", "return", "Promise", ".", "resolve", "(", "false", ")", ";", "return", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "function", "(", ")", "{", "var", "certificateChainEngine", "=", "new", "pkijs", ".", "CertificateChainValidationEngine", "(", "{", "certs", ":", "chain", ",", "trustedCerts", ":", "trustedCAs", ".", "filter", "(", "function", "(", "cert", ")", "{", "return", "typeof", "cert", "!==", "'undefined'", ";", "}", ")", "}", ")", ";", "certificateChainEngine", ".", "certs", ".", "push", "(", "certificate", ")", ";", "return", "certificateChainEngine", ".", "verify", "(", ")", ";", "}", ")", ".", "then", "(", "function", "(", "result", ")", "{", "return", "result", ".", "result", ";", "}", ",", "function", "(", "result", ")", "{", "return", "false", ";", "}", ")", ";", "}" ]
Verify if a certificate chains to some trusted CAs. @param {pkijs.Certificate} certificate - The certificate that will be checked. @param {Array<pkijs.Certificate>} chain - Additional certificates in the chain. @param {Array<pkijs.Certificate>} trustedCAs - The trusted CAs @return {Promise<boolean>} A promise that is resolved with a boolean value stating if the certificate was verified or not.
[ "Verify", "if", "a", "certificate", "chains", "to", "some", "trusted", "CAs", "." ]
00ff5967fd37c27235e25e583ee17008d4c3ce8a
https://github.com/esiglabs/eslutils/blob/00ff5967fd37c27235e25e583ee17008d4c3ce8a/build/validation.js#L24-L42
51,438
prezzemolo/accettare
index.js
getProperties
function getProperties (header) { return header.split(',').map((split) => { const components = split.replace(/\s+/, '').split(';'); const priorityRegex = /^q=([0-1](\.[0-9]{1,3})?)$/; /* assign null to priority when invaild quarity values */ return { lang: components[0], priority: components[1] ? priorityRegex.test(components[1]) ? parseFloat(components[1].split('=')[1]) : null : 1 } }).filter((property) => { return property.priority === null ? false : bcp47.check(property.lang); }).sort((a, b) => { return a.priority < b.priority ? 1 : a.priority > b.priority ? -1 : 0; }); }
javascript
function getProperties (header) { return header.split(',').map((split) => { const components = split.replace(/\s+/, '').split(';'); const priorityRegex = /^q=([0-1](\.[0-9]{1,3})?)$/; /* assign null to priority when invaild quarity values */ return { lang: components[0], priority: components[1] ? priorityRegex.test(components[1]) ? parseFloat(components[1].split('=')[1]) : null : 1 } }).filter((property) => { return property.priority === null ? false : bcp47.check(property.lang); }).sort((a, b) => { return a.priority < b.priority ? 1 : a.priority > b.priority ? -1 : 0; }); }
[ "function", "getProperties", "(", "header", ")", "{", "return", "header", ".", "split", "(", "','", ")", ".", "map", "(", "(", "split", ")", "=>", "{", "const", "components", "=", "split", ".", "replace", "(", "/", "\\s+", "/", ",", "''", ")", ".", "split", "(", "';'", ")", ";", "const", "priorityRegex", "=", "/", "^q=([0-1](\\.[0-9]{1,3})?)$", "/", ";", "/* assign null to priority when invaild quarity values */", "return", "{", "lang", ":", "components", "[", "0", "]", ",", "priority", ":", "components", "[", "1", "]", "?", "priorityRegex", ".", "test", "(", "components", "[", "1", "]", ")", "?", "parseFloat", "(", "components", "[", "1", "]", ".", "split", "(", "'='", ")", "[", "1", "]", ")", ":", "null", ":", "1", "}", "}", ")", ".", "filter", "(", "(", "property", ")", "=>", "{", "return", "property", ".", "priority", "===", "null", "?", "false", ":", "bcp47", ".", "check", "(", "property", ".", "lang", ")", ";", "}", ")", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "{", "return", "a", ".", "priority", "<", "b", ".", "priority", "?", "1", ":", "a", ".", "priority", ">", "b", ".", "priority", "?", "-", "1", ":", "0", ";", "}", ")", ";", "}" ]
analyze HTTP accept-language header @param {string} header @return {array}
[ "analyze", "HTTP", "accept", "-", "language", "header" ]
8a75066f1ee69c2a6d282a424b8401208b9159d2
https://github.com/prezzemolo/accettare/blob/8a75066f1ee69c2a6d282a424b8401208b9159d2/index.js#L45-L60
51,439
prezzemolo/accettare
index.js
matchAccept
function matchAccept (properties, langs) { let match = null; let priority = 0; base: for(const lang of langs) { for (const property of properties) { if (property.priority === 0) { break; } if (priority < property.priority){ if (lang.lang === property.lang) { match = lang.raw; priority = property.priority + 0.001; break; } if (lang.bcp47.language === property.bcp47.language) { match = lang.raw; priority = property.priority; break; } } } } return match; }
javascript
function matchAccept (properties, langs) { let match = null; let priority = 0; base: for(const lang of langs) { for (const property of properties) { if (property.priority === 0) { break; } if (priority < property.priority){ if (lang.lang === property.lang) { match = lang.raw; priority = property.priority + 0.001; break; } if (lang.bcp47.language === property.bcp47.language) { match = lang.raw; priority = property.priority; break; } } } } return match; }
[ "function", "matchAccept", "(", "properties", ",", "langs", ")", "{", "let", "match", "=", "null", ";", "let", "priority", "=", "0", ";", "base", ":", "for", "(", "const", "lang", "of", "langs", ")", "{", "for", "(", "const", "property", "of", "properties", ")", "{", "if", "(", "property", ".", "priority", "===", "0", ")", "{", "break", ";", "}", "if", "(", "priority", "<", "property", ".", "priority", ")", "{", "if", "(", "lang", ".", "lang", "===", "property", ".", "lang", ")", "{", "match", "=", "lang", ".", "raw", ";", "priority", "=", "property", ".", "priority", "+", "0.001", ";", "break", ";", "}", "if", "(", "lang", ".", "bcp47", ".", "language", "===", "property", ".", "bcp47", ".", "language", ")", "{", "match", "=", "lang", ".", "raw", ";", "priority", "=", "property", ".", "priority", ";", "break", ";", "}", "}", "}", "}", "return", "match", ";", "}" ]
search match by BCP47 Objects @param {Array} properties @param {Array} langs @return {string}
[ "search", "match", "by", "BCP47", "Objects" ]
8a75066f1ee69c2a6d282a424b8401208b9159d2
https://github.com/prezzemolo/accettare/blob/8a75066f1ee69c2a6d282a424b8401208b9159d2/index.js#L68-L94
51,440
nearform/docker-container
lib/dockerBuilder.js
function() { var stat = fs.existsSync('/var/run/docker.sock'); if (!stat) { stat = process.env.DOCKER_HOST || false; } return stat; }
javascript
function() { var stat = fs.existsSync('/var/run/docker.sock'); if (!stat) { stat = process.env.DOCKER_HOST || false; } return stat; }
[ "function", "(", ")", "{", "var", "stat", "=", "fs", ".", "existsSync", "(", "'/var/run/docker.sock'", ")", ";", "if", "(", "!", "stat", ")", "{", "stat", "=", "process", ".", "env", ".", "DOCKER_HOST", "||", "false", ";", "}", "return", "stat", ";", "}" ]
check that docker is able to run on this system
[ "check", "that", "docker", "is", "able", "to", "run", "on", "this", "system" ]
724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17
https://github.com/nearform/docker-container/blob/724ff6a9d8d3c116f9a6b8239594c4b5cd5e8e17/lib/dockerBuilder.js#L36-L42
51,441
vmarkdown/vremark-parse
packages/vremark-toc/mdast-util-toc/lib/contents.js
contents
function contents(map, tight) { var minDepth = Infinity; var index = -1; var length = map.length; var table; /* * Find minimum depth. */ while (++index < length) { if (map[index].depth < minDepth) { minDepth = map[index].depth; } } /* * Normalize depth. */ index = -1; while (++index < length) { map[index].depth -= minDepth - 1; } /* * Construct the main list. */ table = list(); /* * Add TOC to list. */ index = -1; while (++index < length) { insert(map[index], table, tight); } return table; }
javascript
function contents(map, tight) { var minDepth = Infinity; var index = -1; var length = map.length; var table; /* * Find minimum depth. */ while (++index < length) { if (map[index].depth < minDepth) { minDepth = map[index].depth; } } /* * Normalize depth. */ index = -1; while (++index < length) { map[index].depth -= minDepth - 1; } /* * Construct the main list. */ table = list(); /* * Add TOC to list. */ index = -1; while (++index < length) { insert(map[index], table, tight); } return table; }
[ "function", "contents", "(", "map", ",", "tight", ")", "{", "var", "minDepth", "=", "Infinity", ";", "var", "index", "=", "-", "1", ";", "var", "length", "=", "map", ".", "length", ";", "var", "table", ";", "/*\n * Find minimum depth.\n */", "while", "(", "++", "index", "<", "length", ")", "{", "if", "(", "map", "[", "index", "]", ".", "depth", "<", "minDepth", ")", "{", "minDepth", "=", "map", "[", "index", "]", ".", "depth", ";", "}", "}", "/*\n * Normalize depth.\n */", "index", "=", "-", "1", ";", "while", "(", "++", "index", "<", "length", ")", "{", "map", "[", "index", "]", ".", "depth", "-=", "minDepth", "-", "1", ";", "}", "/*\n * Construct the main list.\n */", "table", "=", "list", "(", ")", ";", "/*\n * Add TOC to list.\n */", "index", "=", "-", "1", ";", "while", "(", "++", "index", "<", "length", ")", "{", "insert", "(", "map", "[", "index", "]", ",", "table", ",", "tight", ")", ";", "}", "return", "table", ";", "}" ]
Transform a list of heading objects to a markdown list. @param {Array.<Object>} map - Heading-map to insert. @param {boolean?} [tight] - Prefer tight list-items. @return {Object} - List node.
[ "Transform", "a", "list", "of", "heading", "objects", "to", "a", "markdown", "list", "." ]
d7b353dcb5d021eeceb40f3c505ece893202db7a
https://github.com/vmarkdown/vremark-parse/blob/d7b353dcb5d021eeceb40f3c505ece893202db7a/packages/vremark-toc/mdast-util-toc/lib/contents.js#L23-L66
51,442
marcojonker/data-elevator
lib/utils/command-line-utils.js
function() { var cmdArguments = process.argv.slice(2) var lookup = { values: [], keyValues: {} }; cmdArguments.forEach(function(cmdArgument) { var keyValue = cmdArgument.split('='); //Flag of key value type if(typeof keyValue[0] === 'string' && keyValue[0].charAt(0) === '-') { var value = keyValue.length === 2 ? _removeQuotes(keyValue[1]) : true; var keyName = keyValue[0]; lookup.keyValues[keyName] = value; //Value type } else { lookup.values.push(_removeQuotes(cmdArgument)); } }) return lookup; }
javascript
function() { var cmdArguments = process.argv.slice(2) var lookup = { values: [], keyValues: {} }; cmdArguments.forEach(function(cmdArgument) { var keyValue = cmdArgument.split('='); //Flag of key value type if(typeof keyValue[0] === 'string' && keyValue[0].charAt(0) === '-') { var value = keyValue.length === 2 ? _removeQuotes(keyValue[1]) : true; var keyName = keyValue[0]; lookup.keyValues[keyName] = value; //Value type } else { lookup.values.push(_removeQuotes(cmdArgument)); } }) return lookup; }
[ "function", "(", ")", "{", "var", "cmdArguments", "=", "process", ".", "argv", ".", "slice", "(", "2", ")", "var", "lookup", "=", "{", "values", ":", "[", "]", ",", "keyValues", ":", "{", "}", "}", ";", "cmdArguments", ".", "forEach", "(", "function", "(", "cmdArgument", ")", "{", "var", "keyValue", "=", "cmdArgument", ".", "split", "(", "'='", ")", ";", "//Flag of key value type", "if", "(", "typeof", "keyValue", "[", "0", "]", "===", "'string'", "&&", "keyValue", "[", "0", "]", ".", "charAt", "(", "0", ")", "===", "'-'", ")", "{", "var", "value", "=", "keyValue", ".", "length", "===", "2", "?", "_removeQuotes", "(", "keyValue", "[", "1", "]", ")", ":", "true", ";", "var", "keyName", "=", "keyValue", "[", "0", "]", ";", "lookup", ".", "keyValues", "[", "keyName", "]", "=", "value", ";", "//Value type", "}", "else", "{", "lookup", ".", "values", ".", "push", "(", "_removeQuotes", "(", "cmdArgument", ")", ")", ";", "}", "}", ")", "return", "lookup", ";", "}" ]
Create lookup table for process arguments @result object
[ "Create", "lookup", "table", "for", "process", "arguments" ]
7d56e5b2e8ca24b9576066e5265713db6452f289
https://github.com/marcojonker/data-elevator/blob/7d56e5b2e8ca24b9576066e5265713db6452f289/lib/utils/command-line-utils.js#L25-L46
51,443
Psychopoulet/node-promfs
lib/extends/_directoryToStream.js
_directoryToStream
function _directoryToStream (directory, separator, callback) { if ("undefined" === typeof directory) { throw new ReferenceError("missing \"directory\" argument"); } else if ("string" !== typeof directory) { throw new TypeError("\"directory\" argument is not a string"); } else if ("" === directory.trim()) { throw new Error("\"directory\" argument is empty"); } else if ("undefined" === typeof callback && "undefined" === typeof separator) { throw new ReferenceError("missing \"callback\" argument"); } else if ("function" !== typeof callback && "function" !== typeof separator) { throw new TypeError("\"callback\" argument is not a function"); } else { extractFiles(directory, (err, files) => { const _callback = "undefined" === typeof callback ? separator : callback; return err ? _callback(err) : filesToStream(files, separator, _callback); }); } }
javascript
function _directoryToStream (directory, separator, callback) { if ("undefined" === typeof directory) { throw new ReferenceError("missing \"directory\" argument"); } else if ("string" !== typeof directory) { throw new TypeError("\"directory\" argument is not a string"); } else if ("" === directory.trim()) { throw new Error("\"directory\" argument is empty"); } else if ("undefined" === typeof callback && "undefined" === typeof separator) { throw new ReferenceError("missing \"callback\" argument"); } else if ("function" !== typeof callback && "function" !== typeof separator) { throw new TypeError("\"callback\" argument is not a function"); } else { extractFiles(directory, (err, files) => { const _callback = "undefined" === typeof callback ? separator : callback; return err ? _callback(err) : filesToStream(files, separator, _callback); }); } }
[ "function", "_directoryToStream", "(", "directory", ",", "separator", ",", "callback", ")", "{", "if", "(", "\"undefined\"", "===", "typeof", "directory", ")", "{", "throw", "new", "ReferenceError", "(", "\"missing \\\"directory\\\" argument\"", ")", ";", "}", "else", "if", "(", "\"string\"", "!==", "typeof", "directory", ")", "{", "throw", "new", "TypeError", "(", "\"\\\"directory\\\" argument is not a string\"", ")", ";", "}", "else", "if", "(", "\"\"", "===", "directory", ".", "trim", "(", ")", ")", "{", "throw", "new", "Error", "(", "\"\\\"directory\\\" argument is empty\"", ")", ";", "}", "else", "if", "(", "\"undefined\"", "===", "typeof", "callback", "&&", "\"undefined\"", "===", "typeof", "separator", ")", "{", "throw", "new", "ReferenceError", "(", "\"missing \\\"callback\\\" argument\"", ")", ";", "}", "else", "if", "(", "\"function\"", "!==", "typeof", "callback", "&&", "\"function\"", "!==", "typeof", "separator", ")", "{", "throw", "new", "TypeError", "(", "\"\\\"callback\\\" argument is not a function\"", ")", ";", "}", "else", "{", "extractFiles", "(", "directory", ",", "(", "err", ",", "files", ")", "=>", "{", "const", "_callback", "=", "\"undefined\"", "===", "typeof", "callback", "?", "separator", ":", "callback", ";", "return", "err", "?", "_callback", "(", "err", ")", ":", "filesToStream", "(", "files", ",", "separator", ",", "_callback", ")", ";", "}", ")", ";", "}", "}" ]
methods Async directoryToStream @param {string} directory : directory to work with @param {string} separator : used to separate content (can be "") @param {function|null} callback : operation's result @returns {void}
[ "methods", "Async", "directoryToStream" ]
016e272fc58c6ef6eae5ea551a0e8873f0ac20cc
https://github.com/Psychopoulet/node-promfs/blob/016e272fc58c6ef6eae5ea551a0e8873f0ac20cc/lib/extends/_directoryToStream.js#L23-L51
51,444
dominhhai/express-authen
index.js
requireLogin
function requireLogin (options) { // merge with default options options = mergeOptions({ 'login': '/login', 'home': '/', 'user': 'user', 'referer': 'referer', 'excepts': [] }, options) // add login to except page options.excepts.push(options.login) return function(req, res, next) { var url = req.originalUrl , user = req.session[options.user] // go to homepage where: // 1. logged-in, and // 2. on login page if (user && url === options.login) return res.redirect(options.home) // stay on page wherether: // 1. logged-in, or // 2. on login page, or // 3. on non-required login page if (user || options.excepts.indexOf(url) > -1) return next() // save referer into session req.session[options.referer] = url // redirect to login page if not login return res.redirect(options.login) } }
javascript
function requireLogin (options) { // merge with default options options = mergeOptions({ 'login': '/login', 'home': '/', 'user': 'user', 'referer': 'referer', 'excepts': [] }, options) // add login to except page options.excepts.push(options.login) return function(req, res, next) { var url = req.originalUrl , user = req.session[options.user] // go to homepage where: // 1. logged-in, and // 2. on login page if (user && url === options.login) return res.redirect(options.home) // stay on page wherether: // 1. logged-in, or // 2. on login page, or // 3. on non-required login page if (user || options.excepts.indexOf(url) > -1) return next() // save referer into session req.session[options.referer] = url // redirect to login page if not login return res.redirect(options.login) } }
[ "function", "requireLogin", "(", "options", ")", "{", "// merge with default options", "options", "=", "mergeOptions", "(", "{", "'login'", ":", "'/login'", ",", "'home'", ":", "'/'", ",", "'user'", ":", "'user'", ",", "'referer'", ":", "'referer'", ",", "'excepts'", ":", "[", "]", "}", ",", "options", ")", "// add login to except page", "options", ".", "excepts", ".", "push", "(", "options", ".", "login", ")", "return", "function", "(", "req", ",", "res", ",", "next", ")", "{", "var", "url", "=", "req", ".", "originalUrl", ",", "user", "=", "req", ".", "session", "[", "options", ".", "user", "]", "// go to homepage where:", "// 1. logged-in, and", "// 2. on login page", "if", "(", "user", "&&", "url", "===", "options", ".", "login", ")", "return", "res", ".", "redirect", "(", "options", ".", "home", ")", "// stay on page wherether:", "// 1. logged-in, or", "// 2. on login page, or", "// 3. on non-required login page", "if", "(", "user", "||", "options", ".", "excepts", ".", "indexOf", "(", "url", ")", ">", "-", "1", ")", "return", "next", "(", ")", "// save referer into session", "req", ".", "session", "[", "options", ".", "referer", "]", "=", "url", "// redirect to login page if not login", "return", "res", ".", "redirect", "(", "options", ".", "login", ")", "}", "}" ]
Control direct page when require auth. 1. Auto redirect to login page when non-logged in user access the required-auth page 2. Save the referer into session @param {Object} middleware options @login: login page path @home: default redirected page after logged-in @excepts: non-required auth page @user: session' key for determine wherether user logged-in @referer: session' key for save the referer page @return {Function} Expressjs Middleware
[ "Control", "direct", "page", "when", "require", "auth", ".", "1", ".", "Auto", "redirect", "to", "login", "page", "when", "non", "-", "logged", "in", "user", "access", "the", "required", "-", "auth", "page", "2", ".", "Save", "the", "referer", "into", "session" ]
4ad4ee97087544a17c9cd87fb15c4abb06dfefcc
https://github.com/dominhhai/express-authen/blob/4ad4ee97087544a17c9cd87fb15c4abb06dfefcc/index.js#L26-L59
51,445
realm-js/realm-router
backend.js
Dispatcher
function Dispatcher(req, res, next) { _classCallCheck(this, Dispatcher); this.req = req; this.res = res; this.next = next; }
javascript
function Dispatcher(req, res, next) { _classCallCheck(this, Dispatcher); this.req = req; this.res = res; this.next = next; }
[ "function", "Dispatcher", "(", "req", ",", "res", ",", "next", ")", "{", "_classCallCheck", "(", "this", ",", "Dispatcher", ")", ";", "this", ".", "req", "=", "req", ";", "this", ".", "res", "=", "res", ";", "this", ".", "next", "=", "next", ";", "}" ]
constructor - description @param {type} req description @param {type} res description @param {type} next description @return {type} description
[ "constructor", "-", "description" ]
91c1d8b69c4b29fd5791cc98b8403cda038b544f
https://github.com/realm-js/realm-router/blob/91c1d8b69c4b29fd5791cc98b8403cda038b544f/backend.js#L113-L119
51,446
create-conform/allume
bin/allume.js
getUrlParameters
function getUrlParameters() { var params = [ "allume" ]; location.search.substr(1).split("&").forEach(function (part) { if (!part) return; var item = part.split("="); params.push(decodeURIComponent(item[0])); }); return params; }
javascript
function getUrlParameters() { var params = [ "allume" ]; location.search.substr(1).split("&").forEach(function (part) { if (!part) return; var item = part.split("="); params.push(decodeURIComponent(item[0])); }); return params; }
[ "function", "getUrlParameters", "(", ")", "{", "var", "params", "=", "[", "\"allume\"", "]", ";", "location", ".", "search", ".", "substr", "(", "1", ")", ".", "split", "(", "\"&\"", ")", ".", "forEach", "(", "function", "(", "part", ")", "{", "if", "(", "!", "part", ")", "return", ";", "var", "item", "=", "part", ".", "split", "(", "\"=\"", ")", ";", "params", ".", "push", "(", "decodeURIComponent", "(", "item", "[", "0", "]", ")", ")", ";", "}", ")", ";", "return", "params", ";", "}" ]
getUrlParameters Returns url parameters if running inside browser, else returns an array containing one string; which is the name of the command invoked 'allume' to be compatible with CLI runtimes.
[ "getUrlParameters", "Returns", "url", "parameters", "if", "running", "inside", "browser", "else", "returns", "an", "array", "containing", "one", "string", ";", "which", "is", "the", "name", "of", "the", "command", "invoked", "allume", "to", "be", "compatible", "with", "CLI", "runtimes", "." ]
5fdc87804f1e2309c155d001e64d23029c781491
https://github.com/create-conform/allume/blob/5fdc87804f1e2309c155d001e64d23029c781491/bin/allume.js#L77-L85
51,447
create-conform/allume
bin/allume.js
getNodeParameters
function getNodeParameters() { return typeof process !== "undefined" && process.argv && process.argv.length > 1 ? process.argv.slice(1) : null; }
javascript
function getNodeParameters() { return typeof process !== "undefined" && process.argv && process.argv.length > 1 ? process.argv.slice(1) : null; }
[ "function", "getNodeParameters", "(", ")", "{", "return", "typeof", "process", "!==", "\"undefined\"", "&&", "process", ".", "argv", "&&", "process", ".", "argv", ".", "length", ">", "1", "?", "process", ".", "argv", ".", "slice", "(", "1", ")", ":", "null", ";", "}" ]
getNodeParameters Returns cli parameters when running from inside node.js, else returns null.
[ "getNodeParameters", "Returns", "cli", "parameters", "when", "running", "from", "inside", "node", ".", "js", "else", "returns", "null", "." ]
5fdc87804f1e2309c155d001e64d23029c781491
https://github.com/create-conform/allume/blob/5fdc87804f1e2309c155d001e64d23029c781491/bin/allume.js#L106-L108
51,448
redisjs/jsr-server
lib/command/pubsub/pubsub.js
channels
function channels(req, res) { res.send(null, this.state.pubsub.getChannels(req.args[0])); }
javascript
function channels(req, res) { res.send(null, this.state.pubsub.getChannels(req.args[0])); }
[ "function", "channels", "(", "req", ",", "res", ")", "{", "res", ".", "send", "(", "null", ",", "this", ".", "state", ".", "pubsub", ".", "getChannels", "(", "req", ".", "args", "[", "0", "]", ")", ")", ";", "}" ]
Respond to the CHANNELS subcommand.
[ "Respond", "to", "the", "CHANNELS", "subcommand", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/pubsub.js#L19-L21
51,449
redisjs/jsr-server
lib/command/pubsub/pubsub.js
numsub
function numsub(req, res) { res.send(null, this.state.pubsub.getChannelList(req.args)); }
javascript
function numsub(req, res) { res.send(null, this.state.pubsub.getChannelList(req.args)); }
[ "function", "numsub", "(", "req", ",", "res", ")", "{", "res", ".", "send", "(", "null", ",", "this", ".", "state", ".", "pubsub", ".", "getChannelList", "(", "req", ".", "args", ")", ")", ";", "}" ]
Respond to the NUMSUB subcommand.
[ "Respond", "to", "the", "NUMSUB", "subcommand", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/pubsub.js#L26-L28
51,450
redisjs/jsr-server
lib/command/pubsub/pubsub.js
validate
function validate(cmd, args, info) { AbstractCommand.prototype.validate.apply(this, arguments); var sub = info.command.sub , cmd = sub.cmd , args = sub.args if(('' + cmd) === Constants.SUBCOMMAND.pubsub.channels.name) { if(args.length > 1) { throw UnknownSubcommand; } } }
javascript
function validate(cmd, args, info) { AbstractCommand.prototype.validate.apply(this, arguments); var sub = info.command.sub , cmd = sub.cmd , args = sub.args if(('' + cmd) === Constants.SUBCOMMAND.pubsub.channels.name) { if(args.length > 1) { throw UnknownSubcommand; } } }
[ "function", "validate", "(", "cmd", ",", "args", ",", "info", ")", "{", "AbstractCommand", ".", "prototype", ".", "validate", ".", "apply", "(", "this", ",", "arguments", ")", ";", "var", "sub", "=", "info", ".", "command", ".", "sub", ",", "cmd", "=", "sub", ".", "cmd", ",", "args", "=", "sub", ".", "args", "if", "(", "(", "''", "+", "cmd", ")", "===", "Constants", ".", "SUBCOMMAND", ".", "pubsub", ".", "channels", ".", "name", ")", "{", "if", "(", "args", ".", "length", ">", "1", ")", "{", "throw", "UnknownSubcommand", ";", "}", "}", "}" ]
Validate the PUBSUB subcommands.
[ "Validate", "the", "PUBSUB", "subcommands", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/pubsub.js#L40-L50
51,451
Nazariglez/perenquen
lib/pixi/src/filters/gray/GrayFilter.js
GrayFilter
function GrayFilter() { core.AbstractFilter.call(this, // vertex shader null, // fragment shader fs.readFileSync(__dirname + '/gray.frag', 'utf8'), // set the uniforms { gray: { type: '1f', value: 1 } } ); }
javascript
function GrayFilter() { core.AbstractFilter.call(this, // vertex shader null, // fragment shader fs.readFileSync(__dirname + '/gray.frag', 'utf8'), // set the uniforms { gray: { type: '1f', value: 1 } } ); }
[ "function", "GrayFilter", "(", ")", "{", "core", ".", "AbstractFilter", ".", "call", "(", "this", ",", "// vertex shader", "null", ",", "// fragment shader", "fs", ".", "readFileSync", "(", "__dirname", "+", "'/gray.frag'", ",", "'utf8'", ")", ",", "// set the uniforms", "{", "gray", ":", "{", "type", ":", "'1f'", ",", "value", ":", "1", "}", "}", ")", ";", "}" ]
This greyscales the palette of your Display Objects. @class @extends AbstractFilter @memberof PIXI.filters
[ "This", "greyscales", "the", "palette", "of", "your", "Display", "Objects", "." ]
e023964d05afeefebdcac4e2044819fdfa3899ae
https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/gray/GrayFilter.js#L12-L24
51,452
Nazariglez/perenquen
lib/pixi/src/core/textures/Texture.js
Texture
function Texture(baseTexture, frame, crop, trim, rotate) { EventEmitter.call(this); /** * Does this Texture have any frame data assigned to it? * * @member {boolean} */ this.noFrame = false; if (!frame) { this.noFrame = true; frame = new math.Rectangle(0, 0, 1, 1); } if (baseTexture instanceof Texture) { baseTexture = baseTexture.baseTexture; } // console.log(frame); /** * The base texture that this texture uses. * * @member {BaseTexture} */ this.baseTexture = baseTexture; /** * The frame specifies the region of the base texture that this texture uses * * @member {Rectangle} * @private */ this._frame = frame; /** * The texture trim data. * * @member {Rectangle} */ this.trim = trim; /** * This will let the renderer know if the texture is valid. If it's not then it cannot be rendered. * * @member {boolean} */ this.valid = false; /** * This will let a renderer know that a texture has been updated (used mainly for webGL uv updates) * * @member {boolean} */ this.requiresUpdate = false; /** * The WebGL UV data cache. * * @member {TextureUvs} * @private */ this._uvs = null; /** * The width of the Texture in pixels. * * @member {number} */ this.width = 0; /** * The height of the Texture in pixels. * * @member {number} */ this.height = 0; /** * This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, * irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases) * * @member {Rectangle} */ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); /** * Indicates whether the texture should be rotated by 90 degrees * * @private * @member {boolean} */ this.rotate = !!rotate; if (baseTexture.hasLoaded) { if (this.noFrame) { frame = new math.Rectangle(0, 0, baseTexture.width, baseTexture.height); // if there is no frame we should monitor for any base texture changes.. baseTexture.on('update', this.onBaseTextureUpdated, this); } this.frame = frame; } else { baseTexture.once('loaded', this.onBaseTextureLoaded, this); } }
javascript
function Texture(baseTexture, frame, crop, trim, rotate) { EventEmitter.call(this); /** * Does this Texture have any frame data assigned to it? * * @member {boolean} */ this.noFrame = false; if (!frame) { this.noFrame = true; frame = new math.Rectangle(0, 0, 1, 1); } if (baseTexture instanceof Texture) { baseTexture = baseTexture.baseTexture; } // console.log(frame); /** * The base texture that this texture uses. * * @member {BaseTexture} */ this.baseTexture = baseTexture; /** * The frame specifies the region of the base texture that this texture uses * * @member {Rectangle} * @private */ this._frame = frame; /** * The texture trim data. * * @member {Rectangle} */ this.trim = trim; /** * This will let the renderer know if the texture is valid. If it's not then it cannot be rendered. * * @member {boolean} */ this.valid = false; /** * This will let a renderer know that a texture has been updated (used mainly for webGL uv updates) * * @member {boolean} */ this.requiresUpdate = false; /** * The WebGL UV data cache. * * @member {TextureUvs} * @private */ this._uvs = null; /** * The width of the Texture in pixels. * * @member {number} */ this.width = 0; /** * The height of the Texture in pixels. * * @member {number} */ this.height = 0; /** * This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, * irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases) * * @member {Rectangle} */ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); /** * Indicates whether the texture should be rotated by 90 degrees * * @private * @member {boolean} */ this.rotate = !!rotate; if (baseTexture.hasLoaded) { if (this.noFrame) { frame = new math.Rectangle(0, 0, baseTexture.width, baseTexture.height); // if there is no frame we should monitor for any base texture changes.. baseTexture.on('update', this.onBaseTextureUpdated, this); } this.frame = frame; } else { baseTexture.once('loaded', this.onBaseTextureLoaded, this); } }
[ "function", "Texture", "(", "baseTexture", ",", "frame", ",", "crop", ",", "trim", ",", "rotate", ")", "{", "EventEmitter", ".", "call", "(", "this", ")", ";", "/**\n * Does this Texture have any frame data assigned to it?\n *\n * @member {boolean}\n */", "this", ".", "noFrame", "=", "false", ";", "if", "(", "!", "frame", ")", "{", "this", ".", "noFrame", "=", "true", ";", "frame", "=", "new", "math", ".", "Rectangle", "(", "0", ",", "0", ",", "1", ",", "1", ")", ";", "}", "if", "(", "baseTexture", "instanceof", "Texture", ")", "{", "baseTexture", "=", "baseTexture", ".", "baseTexture", ";", "}", "// console.log(frame);", "/**\n * The base texture that this texture uses.\n *\n * @member {BaseTexture}\n */", "this", ".", "baseTexture", "=", "baseTexture", ";", "/**\n * The frame specifies the region of the base texture that this texture uses\n *\n * @member {Rectangle}\n * @private\n */", "this", ".", "_frame", "=", "frame", ";", "/**\n * The texture trim data.\n *\n * @member {Rectangle}\n */", "this", ".", "trim", "=", "trim", ";", "/**\n * This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.\n *\n * @member {boolean}\n */", "this", ".", "valid", "=", "false", ";", "/**\n * This will let a renderer know that a texture has been updated (used mainly for webGL uv updates)\n *\n * @member {boolean}\n */", "this", ".", "requiresUpdate", "=", "false", ";", "/**\n * The WebGL UV data cache.\n *\n * @member {TextureUvs}\n * @private\n */", "this", ".", "_uvs", "=", "null", ";", "/**\n * The width of the Texture in pixels.\n *\n * @member {number}\n */", "this", ".", "width", "=", "0", ";", "/**\n * The height of the Texture in pixels.\n *\n * @member {number}\n */", "this", ".", "height", "=", "0", ";", "/**\n * This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering,\n * irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)\n *\n * @member {Rectangle}\n */", "this", ".", "crop", "=", "crop", "||", "frame", ";", "//new math.Rectangle(0, 0, 1, 1);", "/**\n * Indicates whether the texture should be rotated by 90 degrees\n *\n * @private\n * @member {boolean}\n */", "this", ".", "rotate", "=", "!", "!", "rotate", ";", "if", "(", "baseTexture", ".", "hasLoaded", ")", "{", "if", "(", "this", ".", "noFrame", ")", "{", "frame", "=", "new", "math", ".", "Rectangle", "(", "0", ",", "0", ",", "baseTexture", ".", "width", ",", "baseTexture", ".", "height", ")", ";", "// if there is no frame we should monitor for any base texture changes..", "baseTexture", ".", "on", "(", "'update'", ",", "this", ".", "onBaseTextureUpdated", ",", "this", ")", ";", "}", "this", ".", "frame", "=", "frame", ";", "}", "else", "{", "baseTexture", ".", "once", "(", "'loaded'", ",", "this", ".", "onBaseTextureLoaded", ",", "this", ")", ";", "}", "}" ]
A texture stores the information that represents an image or part of an image. It cannot be added to the display list directly. Instead use it as the texture for a Sprite. If no frame is provided then the whole image is used. You can directly create a texture from an image and then reuse it multiple times like this : ```js var texture = PIXI.Texture.fromImage('assets/image.png'); var sprite1 = new PIXI.Sprite(texture); var sprite2 = new PIXI.Sprite(texture); ``` @class @memberof PIXI @param baseTexture {BaseTexture} The base texture source to create the texture from @param [frame] {Rectangle} The rectangle frame of the texture to show @param [crop] {Rectangle} The area of original texture @param [trim] {Rectangle} Trimmed texture rectangle @param [rotate] {boolean} indicates whether the texture should be rotated by 90 degrees ( used by texture packer )
[ "A", "texture", "stores", "the", "information", "that", "represents", "an", "image", "or", "part", "of", "an", "image", ".", "It", "cannot", "be", "added", "to", "the", "display", "list", "directly", ".", "Instead", "use", "it", "as", "the", "texture", "for", "a", "Sprite", ".", "If", "no", "frame", "is", "provided", "then", "the", "whole", "image", "is", "used", "." ]
e023964d05afeefebdcac4e2044819fdfa3899ae
https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/textures/Texture.js#L28-L141
51,453
mobilehero-archive/aplus-babel
aplus-babel.js
plugin
function plugin(params) { logger = params.logger; params.dirname = params.dirname ? _.template(params.dirname)(params) : params.event.dir.resourcesPlatform; logger.trace("running babel in directory: " + params.dirname); _.defaults(params, { options: {}, includes: ["**/*.js", "!backbone.js"] }); if (params.code) { params.code = transformCode(params.code, params.options); } else { var files = findFiles(params.dirname, params.includes); _.forEach(files, function(file) { transformFile(path.join(params.dirname, file), params.options); }); } }
javascript
function plugin(params) { logger = params.logger; params.dirname = params.dirname ? _.template(params.dirname)(params) : params.event.dir.resourcesPlatform; logger.trace("running babel in directory: " + params.dirname); _.defaults(params, { options: {}, includes: ["**/*.js", "!backbone.js"] }); if (params.code) { params.code = transformCode(params.code, params.options); } else { var files = findFiles(params.dirname, params.includes); _.forEach(files, function(file) { transformFile(path.join(params.dirname, file), params.options); }); } }
[ "function", "plugin", "(", "params", ")", "{", "logger", "=", "params", ".", "logger", ";", "params", ".", "dirname", "=", "params", ".", "dirname", "?", "_", ".", "template", "(", "params", ".", "dirname", ")", "(", "params", ")", ":", "params", ".", "event", ".", "dir", ".", "resourcesPlatform", ";", "logger", ".", "trace", "(", "\"running babel in directory: \"", "+", "params", ".", "dirname", ")", ";", "_", ".", "defaults", "(", "params", ",", "{", "options", ":", "{", "}", ",", "includes", ":", "[", "\"**/*.js\"", ",", "\"!backbone.js\"", "]", "}", ")", ";", "if", "(", "params", ".", "code", ")", "{", "params", ".", "code", "=", "transformCode", "(", "params", ".", "code", ",", "params", ".", "options", ")", ";", "}", "else", "{", "var", "files", "=", "findFiles", "(", "params", ".", "dirname", ",", "params", ".", "includes", ")", ";", "_", ".", "forEach", "(", "files", ",", "function", "(", "file", ")", "{", "transformFile", "(", "path", ".", "join", "(", "params", ".", "dirname", ",", "file", ")", ",", "params", ".", "options", ")", ";", "}", ")", ";", "}", "}" ]
Run babel tranformations on Alloy source code @param {Object} params - parameters available for executing of Alloy+ plugin. @param {Object} params.event - Provides a set of objects and values which may be useful for building tasks: @param {Object} params.event.alloyConfig - Contains Alloy compiler configuration information. @param {string} params.event.alloyConfig.platform - either android, ios, mobileweb or windows. @param {string} [params.event.alloyConfig.file] - file to target for selective compilation. @param {string} params.event.alloyConfig.deploytype - compilation environment type: either development, test or production. @param {string} params.event.alloyConfig.beautify - if set to true, the output from UglifyJS will be beautified. @param {string} params.event.autoStyle - If set to true, autostyle is enabled for the entire project. @param {Object} params.event.dependencies - If set to true, autostyle is enabled for the entire project. @param {Object} params.event.dir - Contains directory paths to various resources. @param {string} params.event.dir.home - absolute path to the Alloy project's app directory. @param {string} params.event.dir.project - absolute path to the Alloy project's root directory. @param {string} params.event.dir.resources - absolute path to the Alloy project's Resource directory. @param {string} params.event.dir.resourcesAlloy - absolute path to the Alloy project's Resource/alloy directory. @param {string} params.event.dir.resourcesPlatform - absolute path to the Alloy project's Resource/{platform} directory. (i.e. /Resources/iphone) @param {string} params.event.dir.assets - absolute path to the Alloy project's assets. @param {string} params.event.dir.config - absolute path to the Alloy project's config. @param {string} params.event.dir.controllers - absolute path to the Alloy project's controllers. @param {string} params.event.dir.migrations - absolute path to the Alloy project's migrations. @param {string} params.event.dir.models - absolute path to the Alloy project's models. @param {string} params.event.dir.styles - absolute path to the Alloy project's styles. @param {string} params.event.dir.themes - absolute path to the Alloy project's themes. @param {string} params.event.dir.views - absolute path to the Alloy project's views. @param {string} params.event.dir.widgets - absolute path to the Alloy project's widgets. @param {string} params.event.dir.builtins - absolute path to the Alloy project's builtins. @param {string} params.event.dir.template - absolute path to the Alloy project's template. @param {string} params.event.sourcemap - If true, generates the source mapping files for use with the Studio debugger and other functions. These files maps the generated Titanium files in the Resources directory to the ones in the app directory. @param {string} params.event.theme - Name of the theme being used. @param {string} [params.event.code] - Only present for the appjs build hook. Contains the contents of the app.js file. @param {string} [params.event.appJSFile] - Only present for the appjs build hook. Contains the the absolute path to the app.js file. @param {Object} params.logger - Alloy logger object @param {string[]} [params.includes] - Array of glob patterns to match files to be included in transformation @param {string} [params.code] @param {Object} params.options - babel configuration object (see http://babeljs.io/docs/usage/options/) @param {string[]} [params.options.presets=[]] - List of presets (a set of plugins) to load and use.. @param {string[]} [options.plugins=[]] - List of plugins to load and use. @param {boolean} [params.options.babelrc=true] - Specify whether or not to use .babelrc and .babelignore files. @param {boolean} [params.options.ast=true] - Include the AST in the returned object @param {boolean} [params.options.minified=true] - Should the output be minified (not printing last semicolons in blocks, printing literal string values instead of escaped ones, stripping () from new when safe) @param {boolean} [params.options.comments=true] - Output comments in generated output. @param {Object} [params.options.env={}] - This is an object of keys that represent different environments. For example, you may have: { env: { production: { someOption: true } } } which will use those options when the enviroment variable BABEL_ENV is set to "production". If BABEL_ENV isn’t set then NODE_ENV will be used, if it’s not set then it defaults to "development" @param {string} [params.options.extends=null] - A path to an .babelrc file to extend
[ "Run", "babel", "tranformations", "on", "Alloy", "source", "code" ]
83c8bca88e9059a60e3bc960bdfaefd7475c8042
https://github.com/mobilehero-archive/aplus-babel/blob/83c8bca88e9059a60e3bc960bdfaefd7475c8042/aplus-babel.js#L84-L104
51,454
mobilehero-archive/aplus-babel
aplus-babel.js
transformFile
function transformFile(filepath, options) { logger.trace("transforming file - " + filepath); var content = fs.readFileSync(filepath, 'utf8'); var result = transformCode(content, options); fs.writeFileSync(filepath, result); }
javascript
function transformFile(filepath, options) { logger.trace("transforming file - " + filepath); var content = fs.readFileSync(filepath, 'utf8'); var result = transformCode(content, options); fs.writeFileSync(filepath, result); }
[ "function", "transformFile", "(", "filepath", ",", "options", ")", "{", "logger", ".", "trace", "(", "\"transforming file - \"", "+", "filepath", ")", ";", "var", "content", "=", "fs", ".", "readFileSync", "(", "filepath", ",", "'utf8'", ")", ";", "var", "result", "=", "transformCode", "(", "content", ",", "options", ")", ";", "fs", ".", "writeFileSync", "(", "filepath", ",", "result", ")", ";", "}" ]
Transform a file with babeljs using babel config @param {string} filepath - absolute path of the file to be transformed @param {Object} options - babel configuration object (see http://babeljs.io/docs/usage/options/) @param {string[]} [options.presets=[]] - List of presets (a set of plugins) to load and use.. @param {string[]} [options.plugins=[]] - List of plugins to load and use. @param {boolean} [options.babelrc=true] - Specify whether or not to use .babelrc and .babelignore files. @param {boolean} [options.ast=true] - Include the AST in the returned object @param {boolean} [options.minified=true] - Should the output be minified (not printing last semicolons in blocks, printing literal string values instead of escaped ones, stripping () from new when safe) @param {boolean} [options.comments=true] - Output comments in generated output. @param {Object} [options.env={}] - This is an object of keys that represent different environments. For example, you may have: { env: { production: { someOption: true } } } which will use those options when the enviroment variable BABEL_ENV is set to "production". If BABEL_ENV isn’t set then NODE_ENV will be used, if it’s not set then it defaults to "development" @param {string} [options.extends=null] - A path to an .babelrc file to extend
[ "Transform", "a", "file", "with", "babeljs", "using", "babel", "config" ]
83c8bca88e9059a60e3bc960bdfaefd7475c8042
https://github.com/mobilehero-archive/aplus-babel/blob/83c8bca88e9059a60e3bc960bdfaefd7475c8042/aplus-babel.js#L197-L202
51,455
mobilehero-archive/aplus-babel
aplus-babel.js
transformCode
function transformCode(code, options) { var result = babel.transform(code, options); var modified = result.code; return modified; }
javascript
function transformCode(code, options) { var result = babel.transform(code, options); var modified = result.code; return modified; }
[ "function", "transformCode", "(", "code", ",", "options", ")", "{", "var", "result", "=", "babel", ".", "transform", "(", "code", ",", "options", ")", ";", "var", "modified", "=", "result", ".", "code", ";", "return", "modified", ";", "}" ]
Transform the code with bablejs using babel config. @param {string} code - code to transform using babeljs @param {Object} options - babel configuration object (see http://babeljs.io/docs/usage/options/) @param {string[]} [options.presets=[]] - List of presets (a set of plugins) to load and use.. @param {string[]} [options.plugins=[]] - List of plugins to load and use. @param {boolean} [options.babelrc=true] - Specify whether or not to use .babelrc and .babelignore files. @param {boolean} [options.ast=true] - Include the AST in the returned object @param {boolean} [options.minified=true] - Should the output be minified (not printing last semicolons in blocks, printing literal string values instead of escaped ones, stripping () from new when safe) @param {boolean} [options.comments=true] - Output comments in generated output. @param {Object} [options.env={}] - This is an object of keys that represent different environments. For example, you may have: { env: { production: { someOption: true } } } which will use those options when the enviroment variable BABEL_ENV is set to "production". If BABEL_ENV isn’t set then NODE_ENV will be used, if it’s not set then it defaults to "development" @param {string} [options.extends=null] - A path to an .babelrc file to extend
[ "Transform", "the", "code", "with", "bablejs", "using", "babel", "config", "." ]
83c8bca88e9059a60e3bc960bdfaefd7475c8042
https://github.com/mobilehero-archive/aplus-babel/blob/83c8bca88e9059a60e3bc960bdfaefd7475c8042/aplus-babel.js#L218-L222
51,456
benaston/kwire
dist/kwire.js
kwire
function kwire(appRoot, globalShadow) { appRoot = appRoot == null ? {} : appRoot; globalShadow = globalShadow || window; if (typeof appRoot !== 'object') { throw 'root object must be an object.' } if (isServerSide() || isUsingRequireJS() || rootIsAlreadyConfigured(globalShadow)) { return; } globalShadow.module = { set exports(value) { if (value === undefined) { throw 'module not defined.'; } if (value === null) { // null or undefined. return; } if (!value.hasOwnProperty('_path_')) { throw '_path_ own-property must be present on modules registered with kwire.'; } if (typeof value._path_ !== 'string') { throw '_path_ own-property must be a string.'; } appRoot[value._path_] = value; } }; /** * cb is optional. */ globalShadow.require = function(value, cb) { var valueIsArray = Array.isArray(value); if (value == null) { throw 'value not defined.' } if (typeof value !== 'string' && !valueIsArray) { throw 'value must be a string or an array.' } if (cb) { if (!valueIsArray) { return cb(appRoot[value]); } return cb.apply(null, value.map(function(v) { return appRoot[v]; })); } var result = appRoot[value]; return result === undefined ? globalShadow[camelify(value)] : result; }; }
javascript
function kwire(appRoot, globalShadow) { appRoot = appRoot == null ? {} : appRoot; globalShadow = globalShadow || window; if (typeof appRoot !== 'object') { throw 'root object must be an object.' } if (isServerSide() || isUsingRequireJS() || rootIsAlreadyConfigured(globalShadow)) { return; } globalShadow.module = { set exports(value) { if (value === undefined) { throw 'module not defined.'; } if (value === null) { // null or undefined. return; } if (!value.hasOwnProperty('_path_')) { throw '_path_ own-property must be present on modules registered with kwire.'; } if (typeof value._path_ !== 'string') { throw '_path_ own-property must be a string.'; } appRoot[value._path_] = value; } }; /** * cb is optional. */ globalShadow.require = function(value, cb) { var valueIsArray = Array.isArray(value); if (value == null) { throw 'value not defined.' } if (typeof value !== 'string' && !valueIsArray) { throw 'value must be a string or an array.' } if (cb) { if (!valueIsArray) { return cb(appRoot[value]); } return cb.apply(null, value.map(function(v) { return appRoot[v]; })); } var result = appRoot[value]; return result === undefined ? globalShadow[camelify(value)] : result; }; }
[ "function", "kwire", "(", "appRoot", ",", "globalShadow", ")", "{", "appRoot", "=", "appRoot", "==", "null", "?", "{", "}", ":", "appRoot", ";", "globalShadow", "=", "globalShadow", "||", "window", ";", "if", "(", "typeof", "appRoot", "!==", "'object'", ")", "{", "throw", "'root object must be an object.'", "}", "if", "(", "isServerSide", "(", ")", "||", "isUsingRequireJS", "(", ")", "||", "rootIsAlreadyConfigured", "(", "globalShadow", ")", ")", "{", "return", ";", "}", "globalShadow", ".", "module", "=", "{", "set", "exports", "(", "value", ")", "{", "if", "(", "value", "===", "undefined", ")", "{", "throw", "'module not defined.'", ";", "}", "if", "(", "value", "===", "null", ")", "{", "// null or undefined.", "return", ";", "}", "if", "(", "!", "value", ".", "hasOwnProperty", "(", "'_path_'", ")", ")", "{", "throw", "'_path_ own-property must be present on modules registered with kwire.'", ";", "}", "if", "(", "typeof", "value", ".", "_path_", "!==", "'string'", ")", "{", "throw", "'_path_ own-property must be a string.'", ";", "}", "appRoot", "[", "value", ".", "_path_", "]", "=", "value", ";", "}", "}", ";", "/**\n\t\t * cb is optional.\n\t\t */", "globalShadow", ".", "require", "=", "function", "(", "value", ",", "cb", ")", "{", "var", "valueIsArray", "=", "Array", ".", "isArray", "(", "value", ")", ";", "if", "(", "value", "==", "null", ")", "{", "throw", "'value not defined.'", "}", "if", "(", "typeof", "value", "!==", "'string'", "&&", "!", "valueIsArray", ")", "{", "throw", "'value must be a string or an array.'", "}", "if", "(", "cb", ")", "{", "if", "(", "!", "valueIsArray", ")", "{", "return", "cb", "(", "appRoot", "[", "value", "]", ")", ";", "}", "return", "cb", ".", "apply", "(", "null", ",", "value", ".", "map", "(", "function", "(", "v", ")", "{", "return", "appRoot", "[", "v", "]", ";", "}", ")", ")", ";", "}", "var", "result", "=", "appRoot", "[", "value", "]", ";", "return", "result", "===", "undefined", "?", "globalShadow", "[", "camelify", "(", "value", ")", "]", ":", "result", ";", "}", ";", "}" ]
Augments the window object with a module and a require property to emulate CommonJS in the browser. @param {Object} appRoot The object to use as the root object for your 'modules' reqistered with kwire. @param {Object} globalShadow An object to shadow the global object for testing purposes.
[ "Augments", "the", "window", "object", "with", "a", "module", "and", "a", "require", "property", "to", "emulate", "CommonJS", "in", "the", "browser", "." ]
96e852221a71a9c6b52d59b49d4d16b47e259c0c
https://github.com/benaston/kwire/blob/96e852221a71a9c6b52d59b49d4d16b47e259c0c/dist/kwire.js#L19-L80
51,457
JerryC8080/skipper-upyun
standalone/build-upyun-receiver-stream.js
getInstance
function getInstance(options) { var bucket = options.bucket; var upyunInstance = instances[bucket]; // If can not found instance, then new one. if (!upyunInstance) { instances[bucket] = upyunInstance = new UPYUN(options.bucket, options.operator, options.password, options.endpoing, options.apiVersion); } return upyunInstance; }
javascript
function getInstance(options) { var bucket = options.bucket; var upyunInstance = instances[bucket]; // If can not found instance, then new one. if (!upyunInstance) { instances[bucket] = upyunInstance = new UPYUN(options.bucket, options.operator, options.password, options.endpoing, options.apiVersion); } return upyunInstance; }
[ "function", "getInstance", "(", "options", ")", "{", "var", "bucket", "=", "options", ".", "bucket", ";", "var", "upyunInstance", "=", "instances", "[", "bucket", "]", ";", "// If can not found instance, then new one.", "if", "(", "!", "upyunInstance", ")", "{", "instances", "[", "bucket", "]", "=", "upyunInstance", "=", "new", "UPYUN", "(", "options", ".", "bucket", ",", "options", ".", "operator", ",", "options", ".", "password", ",", "options", ".", "endpoing", ",", "options", ".", "apiVersion", ")", ";", "}", "return", "upyunInstance", ";", "}" ]
Get upyun instance
[ "Get", "upyun", "instance" ]
97a4445e3c4913d26f0c6a131386fff34ef8c76c
https://github.com/JerryC8080/skipper-upyun/blob/97a4445e3c4913d26f0c6a131386fff34ef8c76c/standalone/build-upyun-receiver-stream.js#L21-L31
51,458
JerryC8080/skipper-upyun
standalone/build-upyun-receiver-stream.js
uploadToUpyun
function uploadToUpyun(path, file, __newFile, done) { var options = this.options; var upyun = getInstance(options); upyun.uploadFile(path, file, __newFile.headers['content-type'], true, function (err, data) { if (err) { return done(err); } if (!data) { return done(new Error('Upload failed!')); } if (data && data.statusCode != 200) { return done(new Error(data.error['message'])); } __newFile.fd = options.domain + path; return done(); }); }
javascript
function uploadToUpyun(path, file, __newFile, done) { var options = this.options; var upyun = getInstance(options); upyun.uploadFile(path, file, __newFile.headers['content-type'], true, function (err, data) { if (err) { return done(err); } if (!data) { return done(new Error('Upload failed!')); } if (data && data.statusCode != 200) { return done(new Error(data.error['message'])); } __newFile.fd = options.domain + path; return done(); }); }
[ "function", "uploadToUpyun", "(", "path", ",", "file", ",", "__newFile", ",", "done", ")", "{", "var", "options", "=", "this", ".", "options", ";", "var", "upyun", "=", "getInstance", "(", "options", ")", ";", "upyun", ".", "uploadFile", "(", "path", ",", "file", ",", "__newFile", ".", "headers", "[", "'content-type'", "]", ",", "true", ",", "function", "(", "err", ",", "data", ")", "{", "if", "(", "err", ")", "{", "return", "done", "(", "err", ")", ";", "}", "if", "(", "!", "data", ")", "{", "return", "done", "(", "new", "Error", "(", "'Upload failed!'", ")", ")", ";", "}", "if", "(", "data", "&&", "data", ".", "statusCode", "!=", "200", ")", "{", "return", "done", "(", "new", "Error", "(", "data", ".", "error", "[", "'message'", "]", ")", ")", ";", "}", "__newFile", ".", "fd", "=", "options", ".", "domain", "+", "path", ";", "return", "done", "(", ")", ";", "}", ")", ";", "}" ]
Upload the file to remote service of upyun @param {} path @param {} file @param {} __newFile @param {} done
[ "Upload", "the", "file", "to", "remote", "service", "of", "upyun" ]
97a4445e3c4913d26f0c6a131386fff34ef8c76c
https://github.com/JerryC8080/skipper-upyun/blob/97a4445e3c4913d26f0c6a131386fff34ef8c76c/standalone/build-upyun-receiver-stream.js#L40-L56
51,459
JerryC8080/skipper-upyun
standalone/build-upyun-receiver-stream.js
buildUpyunReceiverStream
function buildUpyunReceiverStream(opts) { var options = opts || {}; _.defaults(options, { endpoing: 'v0', apiVersion: 'legacy', // Upload limit (in bytes) // defaults to ~15MB maxBytes: 15000000, // Upload limit for per coming file (in bytes) // falsy means no limit perMaxBytes: 15000000, // Upload limit for per file (in content-type) // falsy means accept all the type acceptTypes: null, }); var receiver__ = WritableStream({ objectMode: true }); // if onProgress handler was provided, bind an event automatically: if (_.isFunction(options.onProgress)) { receiver__.on('progress', options.onProgress); } // Track the progress of all file uploads that pass through this receiver // through one or more attached Upstream(s). receiver__._files = []; // This `_write` method is invoked each time a new file is received // from the Readable stream (Upstream) which is pumping filestreams // into this receiver. (filename === `__newFile.filename`). receiver__._write = onFile.bind({ options }); return receiver__; }
javascript
function buildUpyunReceiverStream(opts) { var options = opts || {}; _.defaults(options, { endpoing: 'v0', apiVersion: 'legacy', // Upload limit (in bytes) // defaults to ~15MB maxBytes: 15000000, // Upload limit for per coming file (in bytes) // falsy means no limit perMaxBytes: 15000000, // Upload limit for per file (in content-type) // falsy means accept all the type acceptTypes: null, }); var receiver__ = WritableStream({ objectMode: true }); // if onProgress handler was provided, bind an event automatically: if (_.isFunction(options.onProgress)) { receiver__.on('progress', options.onProgress); } // Track the progress of all file uploads that pass through this receiver // through one or more attached Upstream(s). receiver__._files = []; // This `_write` method is invoked each time a new file is received // from the Readable stream (Upstream) which is pumping filestreams // into this receiver. (filename === `__newFile.filename`). receiver__._write = onFile.bind({ options }); return receiver__; }
[ "function", "buildUpyunReceiverStream", "(", "opts", ")", "{", "var", "options", "=", "opts", "||", "{", "}", ";", "_", ".", "defaults", "(", "options", ",", "{", "endpoing", ":", "'v0'", ",", "apiVersion", ":", "'legacy'", ",", "// Upload limit (in bytes)", "// defaults to ~15MB", "maxBytes", ":", "15000000", ",", "// Upload limit for per coming file (in bytes)", "// falsy means no limit", "perMaxBytes", ":", "15000000", ",", "// Upload limit for per file (in content-type)", "// falsy means accept all the type", "acceptTypes", ":", "null", ",", "}", ")", ";", "var", "receiver__", "=", "WritableStream", "(", "{", "objectMode", ":", "true", "}", ")", ";", "// if onProgress handler was provided, bind an event automatically:", "if", "(", "_", ".", "isFunction", "(", "options", ".", "onProgress", ")", ")", "{", "receiver__", ".", "on", "(", "'progress'", ",", "options", ".", "onProgress", ")", ";", "}", "// Track the progress of all file uploads that pass through this receiver", "// through one or more attached Upstream(s).", "receiver__", ".", "_files", "=", "[", "]", ";", "// This `_write` method is invoked each time a new file is received", "// from the Readable stream (Upstream) which is pumping filestreams", "// into this receiver. (filename === `__newFile.filename`).", "receiver__", ".", "_write", "=", "onFile", ".", "bind", "(", "{", "options", "}", ")", ";", "return", "receiver__", ";", "}" ]
A upyun receiver for Skipper that writes Upstreams to upyun at the configured path. @param {Object} opts @return {Stream.Writable}
[ "A", "upyun", "receiver", "for", "Skipper", "that", "writes", "Upstreams", "to", "upyun", "at", "the", "configured", "path", "." ]
97a4445e3c4913d26f0c6a131386fff34ef8c76c
https://github.com/JerryC8080/skipper-upyun/blob/97a4445e3c4913d26f0c6a131386fff34ef8c76c/standalone/build-upyun-receiver-stream.js#L105-L144
51,460
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(o) { return gui.Type.isGuiClass(o) && gui.Class.ancestorsAndSelf(o).some(function(C) { return C === edb.Object || C === edb.Array; }); }
javascript
function(o) { return gui.Type.isGuiClass(o) && gui.Class.ancestorsAndSelf(o).some(function(C) { return C === edb.Object || C === edb.Array; }); }
[ "function", "(", "o", ")", "{", "return", "gui", ".", "Type", ".", "isGuiClass", "(", "o", ")", "&&", "gui", ".", "Class", ".", "ancestorsAndSelf", "(", "o", ")", ".", "some", "(", "function", "(", "C", ")", "{", "return", "C", "===", "edb", ".", "Object", "||", "C", "===", "edb", ".", "Array", ";", "}", ")", ";", "}" ]
Something is a Type constructor? @param {object} o @returns {boolean}
[ "Something", "is", "a", "Type", "constructor?" ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L187-L192
51,461
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function() { return Array.map(this, function(thing) { if (edb.Type.is(thing)) { return thing.toJSON(); } return thing; }); }
javascript
function() { return Array.map(this, function(thing) { if (edb.Type.is(thing)) { return thing.toJSON(); } return thing; }); }
[ "function", "(", ")", "{", "return", "Array", ".", "map", "(", "this", ",", "function", "(", "thing", ")", "{", "if", "(", "edb", ".", "Type", ".", "is", "(", "thing", ")", ")", "{", "return", "thing", ".", "toJSON", "(", ")", ";", "}", "return", "thing", ";", "}", ")", ";", "}" ]
Create true array without expando properties, recursively normalizing nested EDB types. Returns the type of array we would typically transmit back to the server or something. @returns {Array}
[ "Create", "true", "array", "without", "expando", "properties", "recursively", "normalizing", "nested", "EDB", "types", ".", "Returns", "the", "type", "of", "array", "we", "would", "typically", "transmit", "back", "to", "the", "server", "or", "something", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L746-L753
51,462
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
observes
function observes(array) { var key = array.$instanceid; return edb.Array._observers[key] ? true : false; }
javascript
function observes(array) { var key = array.$instanceid; return edb.Array._observers[key] ? true : false; }
[ "function", "observes", "(", "array", ")", "{", "var", "key", "=", "array", ".", "$instanceid", ";", "return", "edb", ".", "Array", ".", "_observers", "[", "key", "]", "?", "true", ":", "false", ";", "}" ]
Array is being observed? @param {edb.Array} array @returns {boolean}
[ "Array", "is", "being", "observed?" ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L786-L789
51,463
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(tick) { var snapshot, handlers, observers = this._observers; if (tick.type === edb.TICK_PUBLISH_CHANGES) { snapshot = gui.Object.copy(this._changes); this._changes = Object.create(null); gui.Object.each(snapshot, function(instanceid, changes) { if ((handlers = observers[instanceid])) { handlers.forEach(function(handler) { handler.onchange(changes); }); } }); } }
javascript
function(tick) { var snapshot, handlers, observers = this._observers; if (tick.type === edb.TICK_PUBLISH_CHANGES) { snapshot = gui.Object.copy(this._changes); this._changes = Object.create(null); gui.Object.each(snapshot, function(instanceid, changes) { if ((handlers = observers[instanceid])) { handlers.forEach(function(handler) { handler.onchange(changes); }); } }); } }
[ "function", "(", "tick", ")", "{", "var", "snapshot", ",", "handlers", ",", "observers", "=", "this", ".", "_observers", ";", "if", "(", "tick", ".", "type", "===", "edb", ".", "TICK_PUBLISH_CHANGES", ")", "{", "snapshot", "=", "gui", ".", "Object", ".", "copy", "(", "this", ".", "_changes", ")", ";", "this", ".", "_changes", "=", "Object", ".", "create", "(", "null", ")", ";", "gui", ".", "Object", ".", "each", "(", "snapshot", ",", "function", "(", "instanceid", ",", "changes", ")", "{", "if", "(", "(", "handlers", "=", "observers", "[", "instanceid", "]", ")", ")", "{", "handlers", ".", "forEach", "(", "function", "(", "handler", ")", "{", "handler", ".", "onchange", "(", "changes", ")", ";", "}", ")", ";", "}", "}", ")", ";", "}", "}" ]
Publishing change summaries async. @param {gui.Tick} tick
[ "Publishing", "change", "summaries", "async", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L822-L835
51,464
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
decorateAccess
function decorateAccess(proto, methods) { methods.forEach(function(method) { proto[method] = beforeaccess(proto[method]); }); }
javascript
function decorateAccess(proto, methods) { methods.forEach(function(method) { proto[method] = beforeaccess(proto[method]); }); }
[ "function", "decorateAccess", "(", "proto", ",", "methods", ")", "{", "methods", ".", "forEach", "(", "function", "(", "method", ")", "{", "proto", "[", "method", "]", "=", "beforeaccess", "(", "proto", "[", "method", "]", ")", ";", "}", ")", ";", "}" ]
Decorate getter methods on prototype. @param {object} proto Prototype to decorate @param {Array<String>} methods List of method names @returns {object}
[ "Decorate", "getter", "methods", "on", "prototype", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L906-L910
51,465
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
lookupDescriptor
function lookupDescriptor(proto, key) { if (proto.hasOwnProperty(key)) { return Object.getOwnPropertyDescriptor(proto, key); } else if ((proto = Object.getPrototypeOf(proto))) { return lookupDescriptor(proto, key); } else { return null; } }
javascript
function lookupDescriptor(proto, key) { if (proto.hasOwnProperty(key)) { return Object.getOwnPropertyDescriptor(proto, key); } else if ((proto = Object.getPrototypeOf(proto))) { return lookupDescriptor(proto, key); } else { return null; } }
[ "function", "lookupDescriptor", "(", "proto", ",", "key", ")", "{", "if", "(", "proto", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "return", "Object", ".", "getOwnPropertyDescriptor", "(", "proto", ",", "key", ")", ";", "}", "else", "if", "(", "(", "proto", "=", "Object", ".", "getPrototypeOf", "(", "proto", ")", ")", ")", "{", "return", "lookupDescriptor", "(", "proto", ",", "key", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Lookup property descriptor for key. @param {object} proto @param {string} key @returns {object}
[ "Lookup", "property", "descriptor", "for", "key", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1053-L1061
51,466
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
guidedconvert
function guidedconvert(args, array) { return args.map(function(o) { if (o !== undefined) { if (gui.Type.isConstructor(array.$of)) { o = constructas(array.$of, o); } else { o = filterfrom(function(x) { return array.$of(x); }, o); } } return o; }); }
javascript
function guidedconvert(args, array) { return args.map(function(o) { if (o !== undefined) { if (gui.Type.isConstructor(array.$of)) { o = constructas(array.$of, o); } else { o = filterfrom(function(x) { return array.$of(x); }, o); } } return o; }); }
[ "function", "guidedconvert", "(", "args", ",", "array", ")", "{", "return", "args", ".", "map", "(", "function", "(", "o", ")", "{", "if", "(", "o", "!==", "undefined", ")", "{", "if", "(", "gui", ".", "Type", ".", "isConstructor", "(", "array", ".", "$of", ")", ")", "{", "o", "=", "constructas", "(", "array", ".", "$of", ",", "o", ")", ";", "}", "else", "{", "o", "=", "filterfrom", "(", "function", "(", "x", ")", "{", "return", "array", ".", "$of", "(", "x", ")", ";", "}", ",", "o", ")", ";", "}", "}", "return", "o", ";", "}", ")", ";", "}" ]
Convert via constructor or via filter function which returns a constructor. @param {Array} args @param {edb.Array} array @returns {Array<edb.Type>}
[ "Convert", "via", "constructor", "or", "via", "filter", "function", "which", "returns", "a", "constructor", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1244-L1257
51,467
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(array, args) { args = gui.Array.from(args); if (!gui.Type.isNull(array.$of)) { if (gui.Type.isFunction(array.$of)) { return guidedconvert(args, array); } else { var type = gui.Type.of(array.$of); throw new Error(array + ' cannot be $of ' + type); } } else { return autoconvert(args); } }
javascript
function(array, args) { args = gui.Array.from(args); if (!gui.Type.isNull(array.$of)) { if (gui.Type.isFunction(array.$of)) { return guidedconvert(args, array); } else { var type = gui.Type.of(array.$of); throw new Error(array + ' cannot be $of ' + type); } } else { return autoconvert(args); } }
[ "function", "(", "array", ",", "args", ")", "{", "args", "=", "gui", ".", "Array", ".", "from", "(", "args", ")", ";", "if", "(", "!", "gui", ".", "Type", ".", "isNull", "(", "array", ".", "$of", ")", ")", "{", "if", "(", "gui", ".", "Type", ".", "isFunction", "(", "array", ".", "$of", ")", ")", "{", "return", "guidedconvert", "(", "args", ",", "array", ")", ";", "}", "else", "{", "var", "type", "=", "gui", ".", "Type", ".", "of", "(", "array", ".", "$of", ")", ";", "throw", "new", "Error", "(", "array", "+", "' cannot be $of '", "+", "type", ")", ";", "}", "}", "else", "{", "return", "autoconvert", "(", "args", ")", ";", "}", "}" ]
Convert arguments. @param {edb.Array} array @param {Arguments|array} args @returns {Array}
[ "Convert", "arguments", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1310-L1322
51,468
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
getter
function getter(key, base) { return function() { var result = base.apply(this); if (edb.$accessaware && !suspend) { edb.Object.$onaccess(this, key); } return result; }; }
javascript
function getter(key, base) { return function() { var result = base.apply(this); if (edb.$accessaware && !suspend) { edb.Object.$onaccess(this, key); } return result; }; }
[ "function", "getter", "(", "key", ",", "base", ")", "{", "return", "function", "(", ")", "{", "var", "result", "=", "base", ".", "apply", "(", "this", ")", ";", "if", "(", "edb", ".", "$accessaware", "&&", "!", "suspend", ")", "{", "edb", ".", "Object", ".", "$onaccess", "(", "this", ",", "key", ")", ";", "}", "return", "result", ";", "}", ";", "}" ]
Create observable getter for key. @param {String} key @param {function} base @returns {function}
[ "Create", "observable", "getter", "for", "key", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1347-L1355
51,469
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(type, target) { var handler, input = this._configure(type.constructor, type); if (target) { console.error("Deprecated API is deprecated", target.spirit); if ((handler = target.$oninput || target.oninput)) { handler.call(target, input); } } else { gui.Broadcast.dispatch(edb.BROADCAST_OUTPUT, input); } }
javascript
function(type, target) { var handler, input = this._configure(type.constructor, type); if (target) { console.error("Deprecated API is deprecated", target.spirit); if ((handler = target.$oninput || target.oninput)) { handler.call(target, input); } } else { gui.Broadcast.dispatch(edb.BROADCAST_OUTPUT, input); } }
[ "function", "(", "type", ",", "target", ")", "{", "var", "handler", ",", "input", "=", "this", ".", "_configure", "(", "type", ".", "constructor", ",", "type", ")", ";", "if", "(", "target", ")", "{", "console", ".", "error", "(", "\"Deprecated API is deprecated\"", ",", "target", ".", "spirit", ")", ";", "if", "(", "(", "handler", "=", "target", ".", "$oninput", "||", "target", ".", "oninput", ")", ")", "{", "handler", ".", "call", "(", "target", ",", "input", ")", ";", "}", "}", "else", "{", "gui", ".", "Broadcast", ".", "dispatch", "(", "edb", ".", "BROADCAST_OUTPUT", ",", "input", ")", ";", "}", "}" ]
Output Type instance. @returns {edb.Object|edb.Array} @param @optional {object} target TODO: rename to 'output'?
[ "Output", "Type", "instance", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1649-L1659
51,470
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(Type) { if (Type) { if (this._map) { var classid = Type.$classid; var typeobj = this._map[classid]; return typeobj ? true : false; } return false; } else { throw new Error("Something is undefined"); } }
javascript
function(Type) { if (Type) { if (this._map) { var classid = Type.$classid; var typeobj = this._map[classid]; return typeobj ? true : false; } return false; } else { throw new Error("Something is undefined"); } }
[ "function", "(", "Type", ")", "{", "if", "(", "Type", ")", "{", "if", "(", "this", ".", "_map", ")", "{", "var", "classid", "=", "Type", ".", "$classid", ";", "var", "typeobj", "=", "this", ".", "_map", "[", "classid", "]", ";", "return", "typeobj", "?", "true", ":", "false", ";", "}", "return", "false", ";", "}", "else", "{", "throw", "new", "Error", "(", "\"Something is undefined\"", ")", ";", "}", "}" ]
Instance of given Type has been output to context? @param {function} type Type constructor @returns {boolean}
[ "Instance", "of", "given", "Type", "has", "been", "output", "to", "context?" ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1681-L1692
51,471
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(Type, type) { var classid = Type.$classid; this._map[classid] = type; return new edb.Input(Type, type); }
javascript
function(Type, type) { var classid = Type.$classid; this._map[classid] = type; return new edb.Input(Type, type); }
[ "function", "(", "Type", ",", "type", ")", "{", "var", "classid", "=", "Type", ".", "$classid", ";", "this", ".", "_map", "[", "classid", "]", "=", "type", ";", "return", "new", "edb", ".", "Input", "(", "Type", ",", "type", ")", ";", "}" ]
Configure Type instance for output. @param {function} Type constructor @param {edb.Object|edb.Array} type instance @returns {edb.Input}
[ "Configure", "Type", "instance", "for", "output", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1709-L1713
51,472
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(type, filter, tabs) { if (isType(type)) { return JSON.stringify(parse(type), filter, tabs); } else { throw new TypeError("Expected edb.Object|edb.Array"); } }
javascript
function(type, filter, tabs) { if (isType(type)) { return JSON.stringify(parse(type), filter, tabs); } else { throw new TypeError("Expected edb.Object|edb.Array"); } }
[ "function", "(", "type", ",", "filter", ",", "tabs", ")", "{", "if", "(", "isType", "(", "type", ")", ")", "{", "return", "JSON", ".", "stringify", "(", "parse", "(", "type", ")", ",", "filter", ",", "tabs", ")", ";", "}", "else", "{", "throw", "new", "TypeError", "(", "\"Expected edb.Object|edb.Array\"", ")", ";", "}", "}" ]
Serialize type. @param {edb.Object|edb.Array} type @param @optional {function} filter @param @optional {String|number} tabs @returns {String}
[ "Serialize", "type", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1818-L1824
51,473
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
asObject
function asObject(type) { var map = gui.Object.map(type, mapObject, type); return { $object: gui.Object.extend({ $classname: type.$classname, $instanceid: type.$instanceid, $originalid: type.$originalid }, map) }; }
javascript
function asObject(type) { var map = gui.Object.map(type, mapObject, type); return { $object: gui.Object.extend({ $classname: type.$classname, $instanceid: type.$instanceid, $originalid: type.$originalid }, map) }; }
[ "function", "asObject", "(", "type", ")", "{", "var", "map", "=", "gui", ".", "Object", ".", "map", "(", "type", ",", "mapObject", ",", "type", ")", ";", "return", "{", "$object", ":", "gui", ".", "Object", ".", "extend", "(", "{", "$classname", ":", "type", ".", "$classname", ",", "$instanceid", ":", "type", ".", "$instanceid", ",", "$originalid", ":", "type", ".", "$originalid", "}", ",", "map", ")", "}", ";", "}" ]
Compute object node. @param {edb.Object|edb.Array} type @returns {object}
[ "Compute", "object", "node", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1863-L1872
51,474
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
mapObject
function mapObject(key, value) { var c = key.charAt(0); if (c === "_" || c === "$") { return undefined; } else if (isArray(this) && key.match(INTRINSIC)) { return undefined; } else if (isType(value)) { return parse(value); } else if (gui.Type.isComplex(value)) { switch (value.constructor) { case Object: case Array: return value; } return undefined; } else { if (isType(this)) { var base = this.constructor.prototype; var desc = Object.getOwnPropertyDescriptor(base, key); if (desc && (desc.set || desc.get)) { return undefined; } } return value; } }
javascript
function mapObject(key, value) { var c = key.charAt(0); if (c === "_" || c === "$") { return undefined; } else if (isArray(this) && key.match(INTRINSIC)) { return undefined; } else if (isType(value)) { return parse(value); } else if (gui.Type.isComplex(value)) { switch (value.constructor) { case Object: case Array: return value; } return undefined; } else { if (isType(this)) { var base = this.constructor.prototype; var desc = Object.getOwnPropertyDescriptor(base, key); if (desc && (desc.set || desc.get)) { return undefined; } } return value; } }
[ "function", "mapObject", "(", "key", ",", "value", ")", "{", "var", "c", "=", "key", ".", "charAt", "(", "0", ")", ";", "if", "(", "c", "===", "\"_\"", "||", "c", "===", "\"$\"", ")", "{", "return", "undefined", ";", "}", "else", "if", "(", "isArray", "(", "this", ")", "&&", "key", ".", "match", "(", "INTRINSIC", ")", ")", "{", "return", "undefined", ";", "}", "else", "if", "(", "isType", "(", "value", ")", ")", "{", "return", "parse", "(", "value", ")", ";", "}", "else", "if", "(", "gui", ".", "Type", ".", "isComplex", "(", "value", ")", ")", "{", "switch", "(", "value", ".", "constructor", ")", "{", "case", "Object", ":", "case", "Array", ":", "return", "value", ";", "}", "return", "undefined", ";", "}", "else", "{", "if", "(", "isType", "(", "this", ")", ")", "{", "var", "base", "=", "this", ".", "constructor", ".", "prototype", ";", "var", "desc", "=", "Object", ".", "getOwnPropertyDescriptor", "(", "base", ",", "key", ")", ";", "if", "(", "desc", "&&", "(", "desc", ".", "set", "||", "desc", ".", "get", ")", ")", "{", "return", "undefined", ";", "}", "}", "return", "value", ";", "}", "}" ]
Map the object properties of a type. - Skip private (underscore) fields. - Skip all array intrinsic properties. - Skip what looks like instance objects. - Skip getters and setters. @param {String} key @param {object} value
[ "Map", "the", "object", "properties", "of", "a", "type", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1895-L1920
51,475
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
mapArray
function mapArray(type) { return Array.map(type, function(thing) { return isType(thing) ? parse(thing) : thing; }); }
javascript
function mapArray(type) { return Array.map(type, function(thing) { return isType(thing) ? parse(thing) : thing; }); }
[ "function", "mapArray", "(", "type", ")", "{", "return", "Array", ".", "map", "(", "type", ",", "function", "(", "thing", ")", "{", "return", "isType", "(", "thing", ")", "?", "parse", "(", "thing", ")", ":", "thing", ";", "}", ")", ";", "}" ]
Map array members. @param {edb.Array} type
[ "Map", "array", "members", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L1926-L1930
51,476
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(input) { var needstesting = !this._matches.length; if (needstesting || this._matches.every(function(match) { return match.$instanceid !== input.$instanceid; })) { return this._maybeinput(input); } return false; }
javascript
function(input) { var needstesting = !this._matches.length; if (needstesting || this._matches.every(function(match) { return match.$instanceid !== input.$instanceid; })) { return this._maybeinput(input); } return false; }
[ "function", "(", "input", ")", "{", "var", "needstesting", "=", "!", "this", ".", "_matches", ".", "length", ";", "if", "(", "needstesting", "||", "this", ".", "_matches", ".", "every", "(", "function", "(", "match", ")", "{", "return", "match", ".", "$instanceid", "!==", "input", ".", "$instanceid", ";", "}", ")", ")", "{", "return", "this", ".", "_maybeinput", "(", "input", ")", ";", "}", "return", "false", ";", "}" ]
Collect matching input. @param {edb.Input} input
[ "Collect", "matching", "input", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2153-L2161
51,477
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(types, handler, required) { types.forEach(function(Type) { if (gui.Type.isDefined(Type)) { this._addchecks(Type.$classid, [handler]); this._watches.push(Type); if (required) { this._needing.push(Type); } } else { throw new TypeError("Could not register input for undefined Type"); } }, this); types.forEach(function(Type) { gui.Class.descendantsAndSelf(Type, function(T) { if (T.out(this.context)) { // type has been output already? this._maybeinput(edb.Output.$get(T)); } }, this); }, this); }
javascript
function(types, handler, required) { types.forEach(function(Type) { if (gui.Type.isDefined(Type)) { this._addchecks(Type.$classid, [handler]); this._watches.push(Type); if (required) { this._needing.push(Type); } } else { throw new TypeError("Could not register input for undefined Type"); } }, this); types.forEach(function(Type) { gui.Class.descendantsAndSelf(Type, function(T) { if (T.out(this.context)) { // type has been output already? this._maybeinput(edb.Output.$get(T)); } }, this); }, this); }
[ "function", "(", "types", ",", "handler", ",", "required", ")", "{", "types", ".", "forEach", "(", "function", "(", "Type", ")", "{", "if", "(", "gui", ".", "Type", ".", "isDefined", "(", "Type", ")", ")", "{", "this", ".", "_addchecks", "(", "Type", ".", "$classid", ",", "[", "handler", "]", ")", ";", "this", ".", "_watches", ".", "push", "(", "Type", ")", ";", "if", "(", "required", ")", "{", "this", ".", "_needing", ".", "push", "(", "Type", ")", ";", "}", "}", "else", "{", "throw", "new", "TypeError", "(", "\"Could not register input for undefined Type\"", ")", ";", "}", "}", ",", "this", ")", ";", "types", ".", "forEach", "(", "function", "(", "Type", ")", "{", "gui", ".", "Class", ".", "descendantsAndSelf", "(", "Type", ",", "function", "(", "T", ")", "{", "if", "(", "T", ".", "out", "(", "this", ".", "context", ")", ")", "{", "// type has been output already?", "this", ".", "_maybeinput", "(", "edb", ".", "Output", ".", "$get", "(", "T", ")", ")", ";", "}", "}", ",", "this", ")", ";", "}", ",", "this", ")", ";", "}" ]
Add input handler for types. @param {Array<function>} types @param {IInputHandler} handler @param {boolean} required
[ "Add", "input", "handler", "for", "types", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2206-L2225
51,478
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(types, handler) { types.forEach(function(Type) { gui.Array.remove(this._watches, Type); gui.Array.remove(this._needing, Type); this._removechecks(Type.$classid, [handler]); if (!this._watches.length) { this._subscribe(false); } }, this); }
javascript
function(types, handler) { types.forEach(function(Type) { gui.Array.remove(this._watches, Type); gui.Array.remove(this._needing, Type); this._removechecks(Type.$classid, [handler]); if (!this._watches.length) { this._subscribe(false); } }, this); }
[ "function", "(", "types", ",", "handler", ")", "{", "types", ".", "forEach", "(", "function", "(", "Type", ")", "{", "gui", ".", "Array", ".", "remove", "(", "this", ".", "_watches", ",", "Type", ")", ";", "gui", ".", "Array", ".", "remove", "(", "this", ".", "_needing", ",", "Type", ")", ";", "this", ".", "_removechecks", "(", "Type", ".", "$classid", ",", "[", "handler", "]", ")", ";", "if", "(", "!", "this", ".", "_watches", ".", "length", ")", "{", "this", ".", "_subscribe", "(", "false", ")", ";", "}", "}", ",", "this", ")", ";", "}" ]
Remove input handler for types. @param {Array<function>} types @param {IInputHandler} handler
[ "Remove", "input", "handler", "for", "types", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2232-L2241
51,479
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(input) { var best = edb.InputPlugin._bestmatch(input.type, this._watches, true); if (best) { this._updatematch(input, best); this.done = this._done(); this._updatehandlers(input); return true; } return false; }
javascript
function(input) { var best = edb.InputPlugin._bestmatch(input.type, this._watches, true); if (best) { this._updatematch(input, best); this.done = this._done(); this._updatehandlers(input); return true; } return false; }
[ "function", "(", "input", ")", "{", "var", "best", "=", "edb", ".", "InputPlugin", ".", "_bestmatch", "(", "input", ".", "type", ",", "this", ".", "_watches", ",", "true", ")", ";", "if", "(", "best", ")", "{", "this", ".", "_updatematch", "(", "input", ",", "best", ")", ";", "this", ".", "done", "=", "this", ".", "_done", "(", ")", ";", "this", ".", "_updatehandlers", "(", "input", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
If input matches registered type, update handlers. @param {edb.Input} input
[ "If", "input", "matches", "registered", "type", "update", "handlers", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2247-L2256
51,480
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(input) { var matches = this._matches; var watches = this._watches; var best = edb.InputPlugin._bestmatch(input.type, watches, true); if (best) { var oldinput = matches.filter(function(input) { return input.type === best; })[0]; var index = matches.indexOf(oldinput); matches.splice(index, 1); this.done = this._done(); if (!this.done) { input.revoked = true; this._updatehandlers(input); } } }
javascript
function(input) { var matches = this._matches; var watches = this._watches; var best = edb.InputPlugin._bestmatch(input.type, watches, true); if (best) { var oldinput = matches.filter(function(input) { return input.type === best; })[0]; var index = matches.indexOf(oldinput); matches.splice(index, 1); this.done = this._done(); if (!this.done) { input.revoked = true; this._updatehandlers(input); } } }
[ "function", "(", "input", ")", "{", "var", "matches", "=", "this", ".", "_matches", ";", "var", "watches", "=", "this", ".", "_watches", ";", "var", "best", "=", "edb", ".", "InputPlugin", ".", "_bestmatch", "(", "input", ".", "type", ",", "watches", ",", "true", ")", ";", "if", "(", "best", ")", "{", "var", "oldinput", "=", "matches", ".", "filter", "(", "function", "(", "input", ")", "{", "return", "input", ".", "type", "===", "best", ";", "}", ")", "[", "0", "]", ";", "var", "index", "=", "matches", ".", "indexOf", "(", "oldinput", ")", ";", "matches", ".", "splice", "(", "index", ",", "1", ")", ";", "this", ".", "done", "=", "this", ".", "_done", "(", ")", ";", "if", "(", "!", "this", ".", "done", ")", "{", "input", ".", "revoked", "=", "true", ";", "this", ".", "_updatehandlers", "(", "input", ")", ";", "}", "}", "}" ]
Evaluate revoked output. @param {edb.Input} input
[ "Evaluate", "revoked", "output", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2262-L2278
51,481
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(input) { gui.Class.ancestorsAndSelf(input.type, function(Type) { var list = this._trackedtypes[Type.$classid]; if (list) { list.forEach(function(checks) { var handler = checks[0]; handler.oninput(input); }); } }, this); }
javascript
function(input) { gui.Class.ancestorsAndSelf(input.type, function(Type) { var list = this._trackedtypes[Type.$classid]; if (list) { list.forEach(function(checks) { var handler = checks[0]; handler.oninput(input); }); } }, this); }
[ "function", "(", "input", ")", "{", "gui", ".", "Class", ".", "ancestorsAndSelf", "(", "input", ".", "type", ",", "function", "(", "Type", ")", "{", "var", "list", "=", "this", ".", "_trackedtypes", "[", "Type", ".", "$classid", "]", ";", "if", "(", "list", ")", "{", "list", ".", "forEach", "(", "function", "(", "checks", ")", "{", "var", "handler", "=", "checks", "[", "0", "]", ";", "handler", ".", "oninput", "(", "input", ")", ";", "}", ")", ";", "}", "}", ",", "this", ")", ";", "}" ]
Update input handlers. @param {edb.Input} input
[ "Update", "input", "handlers", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2307-L2317
51,482
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function() { var needs = this._needing; var haves = this._matches; return needs.every(function(Type) { return haves.some(function(input) { return (input.data instanceof Type); }); }); }
javascript
function() { var needs = this._needing; var haves = this._matches; return needs.every(function(Type) { return haves.some(function(input) { return (input.data instanceof Type); }); }); }
[ "function", "(", ")", "{", "var", "needs", "=", "this", ".", "_needing", ";", "var", "haves", "=", "this", ".", "_matches", ";", "return", "needs", ".", "every", "(", "function", "(", "Type", ")", "{", "return", "haves", ".", "some", "(", "function", "(", "input", ")", "{", "return", "(", "input", ".", "data", "instanceof", "Type", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
All required inputs has been aquired? @returns {boolean}
[ "All", "required", "inputs", "has", "been", "aquired?" ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2323-L2331
51,483
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(arg, context) { switch (gui.Type.of(arg)) { case "function": return [arg]; case "string": return this._breakarray(arg.split(" "), context); case "object": console.error("Expected function. Got object."); } }
javascript
function(arg, context) { switch (gui.Type.of(arg)) { case "function": return [arg]; case "string": return this._breakarray(arg.split(" "), context); case "object": console.error("Expected function. Got object."); } }
[ "function", "(", "arg", ",", "context", ")", "{", "switch", "(", "gui", ".", "Type", ".", "of", "(", "arg", ")", ")", "{", "case", "\"function\"", ":", "return", "[", "arg", "]", ";", "case", "\"string\"", ":", "return", "this", ".", "_breakarray", "(", "arg", ".", "split", "(", "\" \"", ")", ",", "context", ")", ";", "case", "\"object\"", ":", "console", ".", "error", "(", "\"Expected function. Got object.\"", ")", ";", "}", "}" ]
Breakdown unarray. @param {function|String|object} arg @returns {Array<function>} @param {Window} context @returns {Array<function>}
[ "Breakdown", "unarray", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2384-L2393
51,484
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(target, types, up, action) { types.forEach(function(type) { action(type, this._rateone( up ? target : type, up ? type : target )); }, this); }
javascript
function(target, types, up, action) { types.forEach(function(type) { action(type, this._rateone( up ? target : type, up ? type : target )); }, this); }
[ "function", "(", "target", ",", "types", ",", "up", ",", "action", ")", "{", "types", ".", "forEach", "(", "function", "(", "type", ")", "{", "action", "(", "type", ",", "this", ".", "_rateone", "(", "up", "?", "target", ":", "type", ",", "up", "?", "type", ":", "target", ")", ")", ";", "}", ",", "this", ")", ";", "}" ]
Rate all types. @param {function} t @param {Array<function>} types @param {boolean} up Rate ancestor? @param {function} action
[ "Rate", "all", "types", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2421-L2427
51,485
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(id) { var config, script; return { as: function($edbml) { config = edbml.$runtimeconfigure($edbml); script = gui.Object.assert(id, config); script.$bind = function() { console.error('Deprecated API is deprecated: $bind'); }; script.lock = function(out) { return script({ $out: out }); }; return this; }, withInstructions: function(pis) { script.$instructions = pis; } }; }
javascript
function(id) { var config, script; return { as: function($edbml) { config = edbml.$runtimeconfigure($edbml); script = gui.Object.assert(id, config); script.$bind = function() { console.error('Deprecated API is deprecated: $bind'); }; script.lock = function(out) { return script({ $out: out }); }; return this; }, withInstructions: function(pis) { script.$instructions = pis; } }; }
[ "function", "(", "id", ")", "{", "var", "config", ",", "script", ";", "return", "{", "as", ":", "function", "(", "$edbml", ")", "{", "config", "=", "edbml", ".", "$runtimeconfigure", "(", "$edbml", ")", ";", "script", "=", "gui", ".", "Object", ".", "assert", "(", "id", ",", "config", ")", ";", "script", ".", "$bind", "=", "function", "(", ")", "{", "console", ".", "error", "(", "'Deprecated API is deprecated: $bind'", ")", ";", "}", ";", "script", ".", "lock", "=", "function", "(", "out", ")", "{", "return", "script", "(", "{", "$out", ":", "out", "}", ")", ";", "}", ";", "return", "this", ";", "}", ",", "withInstructions", ":", "function", "(", "pis", ")", "{", "script", ".", "$instructions", "=", "pis", ";", "}", "}", ";", "}" ]
EDBML script declaration micro DSL. @param {String} id
[ "EDBML", "script", "declaration", "micro", "DSL", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2506-L2526
51,486
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function($edbml) { return function configured($in) { $edbml.$out = ($in && $in.$out) ? $in.$out : new edbml.Out(); $edbml.$att = new edbml.Att(); $edbml.$input = function(Type) { return this.script.$input.get(Type); }.bind(this); return $edbml.apply(this, arguments); }; }
javascript
function($edbml) { return function configured($in) { $edbml.$out = ($in && $in.$out) ? $in.$out : new edbml.Out(); $edbml.$att = new edbml.Att(); $edbml.$input = function(Type) { return this.script.$input.get(Type); }.bind(this); return $edbml.apply(this, arguments); }; }
[ "function", "(", "$edbml", ")", "{", "return", "function", "configured", "(", "$in", ")", "{", "$edbml", ".", "$out", "=", "(", "$in", "&&", "$in", ".", "$out", ")", "?", "$in", ".", "$out", ":", "new", "edbml", ".", "Out", "(", ")", ";", "$edbml", ".", "$att", "=", "new", "edbml", ".", "Att", "(", ")", ";", "$edbml", ".", "$input", "=", "function", "(", "Type", ")", "{", "return", "this", ".", "script", ".", "$input", ".", "get", "(", "Type", ")", ";", "}", ".", "bind", "(", "this", ")", ";", "return", "$edbml", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}" ]
Configure EDBML function for runtime use. Note that `this` refers to the spirit instance here. @see {ts.gui.ScriptPlugin#_runtimeconfigure} @param {function} $edbml The (compiled) function as served to the page @returns {function}
[ "Configure", "EDBML", "function", "for", "runtime", "use", ".", "Note", "that", "this", "refers", "to", "the", "spirit", "instance", "here", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2581-L2590
51,487
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(func, thisp) { var key = gui.KeyMaster.generateKey(); this._invokables[key] = function(value, checked) { return func.apply(thisp, [gui.Type.cast(value), checked]); }; return key; }
javascript
function(func, thisp) { var key = gui.KeyMaster.generateKey(); this._invokables[key] = function(value, checked) { return func.apply(thisp, [gui.Type.cast(value), checked]); }; return key; }
[ "function", "(", "func", ",", "thisp", ")", "{", "var", "key", "=", "gui", ".", "KeyMaster", ".", "generateKey", "(", ")", ";", "this", ".", "_invokables", "[", "key", "]", "=", "function", "(", "value", ",", "checked", ")", "{", "return", "func", ".", "apply", "(", "thisp", ",", "[", "gui", ".", "Type", ".", "cast", "(", "value", ")", ",", "checked", "]", ")", ";", "}", ";", "return", "key", ";", "}" ]
Map function to generated key and return the key. @param {function} func @param {object} thisp @returns {String}
[ "Map", "function", "to", "generated", "key", "and", "return", "the", "key", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2614-L2620
51,488
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(e) { this._latestevent = e ? { type: e.type, value: e.target.value, checked: e.target.checked } : null; }
javascript
function(e) { this._latestevent = e ? { type: e.type, value: e.target.value, checked: e.target.checked } : null; }
[ "function", "(", "e", ")", "{", "this", ".", "_latestevent", "=", "e", "?", "{", "type", ":", "e", ".", "type", ",", "value", ":", "e", ".", "target", ".", "value", ",", "checked", ":", "e", ".", "target", ".", "checked", "}", ":", "null", ";", "}" ]
Keep a log on the latest DOM event. Perhaps it's because events don't take to async implementation, though it's probably so we can send it to sandbox. @param {Event} e
[ "Keep", "a", "log", "on", "the", "latest", "DOM", "event", ".", "Perhaps", "it", "s", "because", "events", "don", "t", "take", "to", "async", "implementation", "though", "it", "s", "probably", "so", "we", "can", "send", "it", "to", "sandbox", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2701-L2707
51,489
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function() { var html = ""; gui.Object.nonmethods(this).forEach(function(att) { html += this._out(att); }, this); return html; }
javascript
function() { var html = ""; gui.Object.nonmethods(this).forEach(function(att) { html += this._out(att); }, this); return html; }
[ "function", "(", ")", "{", "var", "html", "=", "\"\"", ";", "gui", ".", "Object", ".", "nonmethods", "(", "this", ")", ".", "forEach", "(", "function", "(", "att", ")", "{", "html", "+=", "this", ".", "_out", "(", "att", ")", ";", "}", ",", "this", ")", ";", "return", "html", ";", "}" ]
Resolve all key-values to HTML attribute declarations. @returns {String}
[ "Resolve", "all", "key", "-", "values", "to", "HTML", "attribute", "declarations", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L2772-L2778
51,490
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(html) { this._newdom = this._parse(html); this._crawl(this._newdom, this._olddom, this._newdom, this._keyid, {}); this._olddom = this._newdom; }
javascript
function(html) { this._newdom = this._parse(html); this._crawl(this._newdom, this._olddom, this._newdom, this._keyid, {}); this._olddom = this._newdom; }
[ "function", "(", "html", ")", "{", "this", ".", "_newdom", "=", "this", ".", "_parse", "(", "html", ")", ";", "this", ".", "_crawl", "(", "this", ".", "_newdom", ",", "this", ".", "_olddom", ",", "this", ".", "_newdom", ",", "this", ".", "_keyid", ",", "{", "}", ")", ";", "this", ".", "_olddom", "=", "this", ".", "_newdom", ";", "}" ]
Next update. @param {String} html
[ "Next", "update", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L3052-L3056
51,491
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(newnode, oldnode, lastnode, id, ids) { var result = true, oldid = this._assistant.id(oldnode); if ((result = this._check(newnode, oldnode, lastnode, id, ids))) { if (oldid) { ids = gui.Object.copy(ids); lastnode = newnode; ids[oldid] = true; id = oldid; } result = this._crawl(newnode.firstChild, oldnode.firstChild, lastnode, id, ids); } return result; }
javascript
function(newnode, oldnode, lastnode, id, ids) { var result = true, oldid = this._assistant.id(oldnode); if ((result = this._check(newnode, oldnode, lastnode, id, ids))) { if (oldid) { ids = gui.Object.copy(ids); lastnode = newnode; ids[oldid] = true; id = oldid; } result = this._crawl(newnode.firstChild, oldnode.firstChild, lastnode, id, ids); } return result; }
[ "function", "(", "newnode", ",", "oldnode", ",", "lastnode", ",", "id", ",", "ids", ")", "{", "var", "result", "=", "true", ",", "oldid", "=", "this", ".", "_assistant", ".", "id", "(", "oldnode", ")", ";", "if", "(", "(", "result", "=", "this", ".", "_check", "(", "newnode", ",", "oldnode", ",", "lastnode", ",", "id", ",", "ids", ")", ")", ")", "{", "if", "(", "oldid", ")", "{", "ids", "=", "gui", ".", "Object", ".", "copy", "(", "ids", ")", ";", "lastnode", "=", "newnode", ";", "ids", "[", "oldid", "]", "=", "true", ";", "id", "=", "oldid", ";", "}", "result", "=", "this", ".", "_crawl", "(", "newnode", ".", "firstChild", ",", "oldnode", ".", "firstChild", ",", "lastnode", ",", "id", ",", "ids", ")", ";", "}", "return", "result", ";", "}" ]
Scan elements. @param {Element} newnode @param {Element} oldnode @param {Element} lastnode @param {String} id @param {Map<String,boolean>} ids @returns {boolean}
[ "Scan", "elements", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L3107-L3120
51,492
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(newnode, oldnode, ids) { var result = true; var update = null; if (this._attschanged(newnode.attributes, oldnode.attributes, ids)) { var newid = this._assistant.id(newnode); var oldid = this._assistant.id(oldnode); if (newid && newid === oldid) { update = new edbml.AttsUpdate(this._doc).setup(oldid, newnode, oldnode); this._updates.collect(update, ids); } else { result = false; } } return result; }
javascript
function(newnode, oldnode, ids) { var result = true; var update = null; if (this._attschanged(newnode.attributes, oldnode.attributes, ids)) { var newid = this._assistant.id(newnode); var oldid = this._assistant.id(oldnode); if (newid && newid === oldid) { update = new edbml.AttsUpdate(this._doc).setup(oldid, newnode, oldnode); this._updates.collect(update, ids); } else { result = false; } } return result; }
[ "function", "(", "newnode", ",", "oldnode", ",", "ids", ")", "{", "var", "result", "=", "true", ";", "var", "update", "=", "null", ";", "if", "(", "this", ".", "_attschanged", "(", "newnode", ".", "attributes", ",", "oldnode", ".", "attributes", ",", "ids", ")", ")", "{", "var", "newid", "=", "this", ".", "_assistant", ".", "id", "(", "newnode", ")", ";", "var", "oldid", "=", "this", ".", "_assistant", ".", "id", "(", "oldnode", ")", ";", "if", "(", "newid", "&&", "newid", "===", "oldid", ")", "{", "update", "=", "new", "edbml", ".", "AttsUpdate", "(", "this", ".", "_doc", ")", ".", "setup", "(", "oldid", ",", "newnode", ",", "oldnode", ")", ";", "this", ".", "_updates", ".", "collect", "(", "update", ",", "ids", ")", ";", "}", "else", "{", "result", "=", "false", ";", "}", "}", "return", "result", ";", "}" ]
Same id trigges attribute synchronization; different id triggers hard update of ancestor. @param {Element} newnode @param {Element} oldnode @param {Map<String,boolean>} ids @returns {boolean} When false, replace "hard" and stop crawling.
[ "Same", "id", "trigges", "attribute", "synchronization", ";", "different", "id", "triggers", "hard", "update", "of", "ancestor", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L3194-L3208
51,493
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(newnode, oldnode) { if (newnode && oldnode) { return newnode.id && newnode.id === oldnode.id && this._maybesoft(newnode) && this._maybesoft(oldnode); } else { return Array.every(newnode.childNodes, function(node) { var res = true; switch (node.nodeType) { case Node.TEXT_NODE: res = node.data.trim() === ""; break; case Node.ELEMENT_NODE: res = this._assistant.id(node) !== null; break; } return res; }, this); } }
javascript
function(newnode, oldnode) { if (newnode && oldnode) { return newnode.id && newnode.id === oldnode.id && this._maybesoft(newnode) && this._maybesoft(oldnode); } else { return Array.every(newnode.childNodes, function(node) { var res = true; switch (node.nodeType) { case Node.TEXT_NODE: res = node.data.trim() === ""; break; case Node.ELEMENT_NODE: res = this._assistant.id(node) !== null; break; } return res; }, this); } }
[ "function", "(", "newnode", ",", "oldnode", ")", "{", "if", "(", "newnode", "&&", "oldnode", ")", "{", "return", "newnode", ".", "id", "&&", "newnode", ".", "id", "===", "oldnode", ".", "id", "&&", "this", ".", "_maybesoft", "(", "newnode", ")", "&&", "this", ".", "_maybesoft", "(", "oldnode", ")", ";", "}", "else", "{", "return", "Array", ".", "every", "(", "newnode", ".", "childNodes", ",", "function", "(", "node", ")", "{", "var", "res", "=", "true", ";", "switch", "(", "node", ".", "nodeType", ")", "{", "case", "Node", ".", "TEXT_NODE", ":", "res", "=", "node", ".", "data", ".", "trim", "(", ")", "===", "\"\"", ";", "break", ";", "case", "Node", ".", "ELEMENT_NODE", ":", "res", "=", "this", ".", "_assistant", ".", "id", "(", "node", ")", "!==", "null", ";", "break", ";", "}", "return", "res", ";", "}", ",", "this", ")", ";", "}", "}" ]
Are element children candidates for "soft" sibling updates? 1) Both parents must have the same ID 2) All children must have a specified ID 3) All children must be elements or whitespace-only textnodes @param {Element} newnode @param {Element} oldnode @return {boolean}
[ "Are", "element", "children", "candidates", "for", "soft", "sibling", "updates?", "1", ")", "Both", "parents", "must", "have", "the", "same", "ID", "2", ")", "All", "children", "must", "have", "a", "specified", "ID", "3", ")", "All", "children", "must", "be", "elements", "or", "whitespace", "-", "only", "textnodes" ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L3267-L3286
51,494
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(newnode, oldnode, ids) { var updates = []; var news = this._assistant.index(newnode.childNodes); var olds = this._assistant.index(oldnode.childNodes); /* * Add elements? */ var child = newnode.lastElementChild, topid = this._assistant.id(oldnode), oldid = null, newid = null; while (child) { newid = this._assistant.id(child); if (!olds[newid]) { if (oldid) { updates.push( new edbml.InsertUpdate(this._doc).setup(oldid, child) ); } else { updates.push( new edbml.AppendUpdate(this._doc).setup(topid, child) ); } } else { oldid = newid; } child = child.previousElementSibling; } /* * Remove elements? */ Object.keys(olds).forEach(function(id) { if (!news[id]) { updates.push( new edbml.RemoveUpdate(this._doc).setup(id) ); updates.push( new edbml.FunctionUpdate(this._doc).setup(id) ); } else { // note that crawling continues here... var n1 = news[id]; var n2 = olds[id]; this._scan(n1, n2, n1, id, ids); } }, this); /* * Register updates */ updates.reverse().forEach(function(update) { this._updates.collect(update, ids); }, this); }
javascript
function(newnode, oldnode, ids) { var updates = []; var news = this._assistant.index(newnode.childNodes); var olds = this._assistant.index(oldnode.childNodes); /* * Add elements? */ var child = newnode.lastElementChild, topid = this._assistant.id(oldnode), oldid = null, newid = null; while (child) { newid = this._assistant.id(child); if (!olds[newid]) { if (oldid) { updates.push( new edbml.InsertUpdate(this._doc).setup(oldid, child) ); } else { updates.push( new edbml.AppendUpdate(this._doc).setup(topid, child) ); } } else { oldid = newid; } child = child.previousElementSibling; } /* * Remove elements? */ Object.keys(olds).forEach(function(id) { if (!news[id]) { updates.push( new edbml.RemoveUpdate(this._doc).setup(id) ); updates.push( new edbml.FunctionUpdate(this._doc).setup(id) ); } else { // note that crawling continues here... var n1 = news[id]; var n2 = olds[id]; this._scan(n1, n2, n1, id, ids); } }, this); /* * Register updates */ updates.reverse().forEach(function(update) { this._updates.collect(update, ids); }, this); }
[ "function", "(", "newnode", ",", "oldnode", ",", "ids", ")", "{", "var", "updates", "=", "[", "]", ";", "var", "news", "=", "this", ".", "_assistant", ".", "index", "(", "newnode", ".", "childNodes", ")", ";", "var", "olds", "=", "this", ".", "_assistant", ".", "index", "(", "oldnode", ".", "childNodes", ")", ";", "/*\n\t\t * Add elements?\n\t\t */", "var", "child", "=", "newnode", ".", "lastElementChild", ",", "topid", "=", "this", ".", "_assistant", ".", "id", "(", "oldnode", ")", ",", "oldid", "=", "null", ",", "newid", "=", "null", ";", "while", "(", "child", ")", "{", "newid", "=", "this", ".", "_assistant", ".", "id", "(", "child", ")", ";", "if", "(", "!", "olds", "[", "newid", "]", ")", "{", "if", "(", "oldid", ")", "{", "updates", ".", "push", "(", "new", "edbml", ".", "InsertUpdate", "(", "this", ".", "_doc", ")", ".", "setup", "(", "oldid", ",", "child", ")", ")", ";", "}", "else", "{", "updates", ".", "push", "(", "new", "edbml", ".", "AppendUpdate", "(", "this", ".", "_doc", ")", ".", "setup", "(", "topid", ",", "child", ")", ")", ";", "}", "}", "else", "{", "oldid", "=", "newid", ";", "}", "child", "=", "child", ".", "previousElementSibling", ";", "}", "/*\n\t\t * Remove elements?\n\t\t */", "Object", ".", "keys", "(", "olds", ")", ".", "forEach", "(", "function", "(", "id", ")", "{", "if", "(", "!", "news", "[", "id", "]", ")", "{", "updates", ".", "push", "(", "new", "edbml", ".", "RemoveUpdate", "(", "this", ".", "_doc", ")", ".", "setup", "(", "id", ")", ")", ";", "updates", ".", "push", "(", "new", "edbml", ".", "FunctionUpdate", "(", "this", ".", "_doc", ")", ".", "setup", "(", "id", ")", ")", ";", "}", "else", "{", "// note that crawling continues here...", "var", "n1", "=", "news", "[", "id", "]", ";", "var", "n2", "=", "olds", "[", "id", "]", ";", "this", ".", "_scan", "(", "n1", ",", "n2", ",", "n1", ",", "id", ",", "ids", ")", ";", "}", "}", ",", "this", ")", ";", "/*\n\t\t * Register updates\n\t\t */", "updates", ".", "reverse", "(", ")", ".", "forEach", "(", "function", "(", "update", ")", "{", "this", ".", "_updates", ".", "collect", "(", "update", ",", "ids", ")", ";", "}", ",", "this", ")", ";", "}" ]
Update "soft" siblings. @param {Element} newnode @param {Element} oldnode @param {Map<String,boolean>} ids @return {boolean}
[ "Update", "soft", "siblings", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L3321-L3372
51,495
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(update, ids) { this._updates.push(update); if (update.type === edbml.Update.TYPE_HARD) { this._hardupdates[update.id] = true; } else { update.ids = ids || {}; } return this; }
javascript
function(update, ids) { this._updates.push(update); if (update.type === edbml.Update.TYPE_HARD) { this._hardupdates[update.id] = true; } else { update.ids = ids || {}; } return this; }
[ "function", "(", "update", ",", "ids", ")", "{", "this", ".", "_updates", ".", "push", "(", "update", ")", ";", "if", "(", "update", ".", "type", "===", "edbml", ".", "Update", ".", "TYPE_HARD", ")", "{", "this", ".", "_hardupdates", "[", "update", ".", "id", "]", "=", "true", ";", "}", "else", "{", "update", ".", "ids", "=", "ids", "||", "{", "}", ";", "}", "return", "this", ";", "}" ]
Collect update candidate. All updates may not be evaluated, see below. @param {edbml.Update} update @param {Map<String,boolean>} ids Indexing ID of ancestor elements @returns {edbml.UpdateCollector}
[ "Collect", "update", "candidate", ".", "All", "updates", "may", "not", "be", "evaluated", "see", "below", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L3399-L3407
51,496
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function(report) { if (edbml.debug) { if (gui.KeyMaster.isKey(this.id)) { report = report.replace(this.id, "(anonymous)"); } console.debug(report); } }
javascript
function(report) { if (edbml.debug) { if (gui.KeyMaster.isKey(this.id)) { report = report.replace(this.id, "(anonymous)"); } console.debug(report); } }
[ "function", "(", "report", ")", "{", "if", "(", "edbml", ".", "debug", ")", "{", "if", "(", "gui", ".", "KeyMaster", ".", "isKey", "(", "this", ".", "id", ")", ")", "{", "report", "=", "report", ".", "replace", "(", "this", ".", "id", ",", "\"(anonymous)\"", ")", ";", "}", "console", ".", "debug", "(", "report", ")", ";", "}", "}" ]
Report update in debug mode. @param {String} report
[ "Report", "update", "in", "debug", "mode", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L3596-L3603
51,497
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function() { edbml.Update.prototype.update.call(this); var element = this.element(); if (this._beforeUpdate(element)) { this._update(element); this._afterUpdate(element); this._report(); } }
javascript
function() { edbml.Update.prototype.update.call(this); var element = this.element(); if (this._beforeUpdate(element)) { this._update(element); this._afterUpdate(element); this._report(); } }
[ "function", "(", ")", "{", "edbml", ".", "Update", ".", "prototype", ".", "update", ".", "call", "(", "this", ")", ";", "var", "element", "=", "this", ".", "element", "(", ")", ";", "if", "(", "this", ".", "_beforeUpdate", "(", "element", ")", ")", "{", "this", ".", "_update", "(", "element", ")", ";", "this", ".", "_afterUpdate", "(", "element", ")", ";", "this", ".", "_report", "(", ")", ";", "}", "}" ]
Update attributes.
[ "Update", "attributes", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L3713-L3721
51,498
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function() { var summary = this._summary.join(', '); var message = 'edbml.AttsUpdate "#' + this.id + '" ' + summary; edbml.Update.prototype._report.call(this, message); // TODO: this would break super keyword algorithm!!! // edbml.Update.prototype._report.call(this, edbml.AttsUpdate \# + // this.id + \ + this._summary.join(this, )); }
javascript
function() { var summary = this._summary.join(', '); var message = 'edbml.AttsUpdate "#' + this.id + '" ' + summary; edbml.Update.prototype._report.call(this, message); // TODO: this would break super keyword algorithm!!! // edbml.Update.prototype._report.call(this, edbml.AttsUpdate \# + // this.id + \ + this._summary.join(this, )); }
[ "function", "(", ")", "{", "var", "summary", "=", "this", ".", "_summary", ".", "join", "(", "', '", ")", ";", "var", "message", "=", "'edbml.AttsUpdate \"#'", "+", "this", ".", "id", "+", "'\" '", "+", "summary", ";", "edbml", ".", "Update", ".", "prototype", ".", "_report", ".", "call", "(", "this", ",", "message", ")", ";", "// TODO: this would break super keyword algorithm!!!", "// edbml.Update.prototype._report.call(this, edbml.AttsUpdate \\# +", "//\tthis.id + \\ + this._summary.join(this, ));", "}" ]
Debug changes.
[ "Debug", "changes", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L3818-L3825
51,499
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-edb.js
function() { edbml.Update.prototype.update.call(this); var element = this.element(); if (element && this._beforeUpdate(element)) { //gui.DOMPlugin.html ( element, this.xelement.outerHTML ); gui.DOMPlugin.html(element, this.xelement.innerHTML); this._afterUpdate(element); this._report(); } }
javascript
function() { edbml.Update.prototype.update.call(this); var element = this.element(); if (element && this._beforeUpdate(element)) { //gui.DOMPlugin.html ( element, this.xelement.outerHTML ); gui.DOMPlugin.html(element, this.xelement.innerHTML); this._afterUpdate(element); this._report(); } }
[ "function", "(", ")", "{", "edbml", ".", "Update", ".", "prototype", ".", "update", ".", "call", "(", "this", ")", ";", "var", "element", "=", "this", ".", "element", "(", ")", ";", "if", "(", "element", "&&", "this", ".", "_beforeUpdate", "(", "element", ")", ")", "{", "//gui.DOMPlugin.html ( element, this.xelement.outerHTML );", "gui", ".", "DOMPlugin", ".", "html", "(", "element", ",", "this", ".", "xelement", ".", "innerHTML", ")", ";", "this", ".", "_afterUpdate", "(", "element", ")", ";", "this", ".", "_report", "(", ")", ";", "}", "}" ]
Replace target subtree.
[ "Replace", "target", "subtree", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-edb.js#L3864-L3873