id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
49,500
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(spirit) { spirit.life.async = true; spirit.onasync(); // TODO: life cycle stuff goes here spirit.life.dispatch(gui.LIFE_ASYNC); }
javascript
function(spirit) { spirit.life.async = true; spirit.onasync(); // TODO: life cycle stuff goes here spirit.life.dispatch(gui.LIFE_ASYNC); }
[ "function", "(", "spirit", ")", "{", "spirit", ".", "life", ".", "async", "=", "true", ";", "spirit", ".", "onasync", "(", ")", ";", "// TODO: life cycle stuff goes here", "spirit", ".", "life", ".", "dispatch", "(", "gui", ".", "LIFE_ASYNC", ")", ";", "}" ]
Spirit async. @TODO: This should be evaluated after `appendChild` to another position. @param {gui.Spirit} spirit
[ "Spirit", "async", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L10279-L10283
49,501
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(spirit) { spirit.$debug(false); spirit.life.destructed = true; spirit.life.dispatch(gui.LIFE_DESTRUCT); spirit.ondestruct(); }
javascript
function(spirit) { spirit.$debug(false); spirit.life.destructed = true; spirit.life.dispatch(gui.LIFE_DESTRUCT); spirit.ondestruct(); }
[ "function", "(", "spirit", ")", "{", "spirit", ".", "$debug", "(", "false", ")", ";", "spirit", ".", "life", ".", "destructed", "=", "true", ";", "spirit", ".", "life", ".", "dispatch", "(", "gui", ".", "LIFE_DESTRUCT", ")", ";", "spirit", ".", "ondestruct", "(", ")", ";", "}" ]
Spirit destruct. @param {gui.Spirit} spirit
[ "Spirit", "destruct", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L10289-L10294
49,502
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(a) { gui.Spirit.prototype.onaction.call(this, a); this.action.$handleownaction = false; switch (a.type) { case gui.$ACTION_XFRAME_VISIBILITY: this._waiting = false; if (gui.hasModule("[email protected]")) { // TODO: - fix if (a.data === true) { this.visibility.on(); } else { this.visibility.off(); } } a.consume(); break; } }
javascript
function(a) { gui.Spirit.prototype.onaction.call(this, a); this.action.$handleownaction = false; switch (a.type) { case gui.$ACTION_XFRAME_VISIBILITY: this._waiting = false; if (gui.hasModule("[email protected]")) { // TODO: - fix if (a.data === true) { this.visibility.on(); } else { this.visibility.off(); } } a.consume(); break; } }
[ "function", "(", "a", ")", "{", "gui", ".", "Spirit", ".", "prototype", ".", "onaction", ".", "call", "(", "this", ",", "a", ")", ";", "this", ".", "action", ".", "$handleownaction", "=", "false", ";", "switch", "(", "a", ".", "type", ")", "{", "case", "gui", ".", "$ACTION_XFRAME_VISIBILITY", ":", "this", ".", "_waiting", "=", "false", ";", "if", "(", "gui", ".", "hasModule", "(", "\"[email protected]\"", ")", ")", "{", "// TODO: - fix", "if", "(", "a", ".", "data", "===", "true", ")", "{", "this", ".", "visibility", ".", "on", "(", ")", ";", "}", "else", "{", "this", ".", "visibility", ".", "off", "(", ")", ";", "}", "}", "a", ".", "consume", "(", ")", ";", "break", ";", "}", "}" ]
Handle action.s @param {gui.Action} a
[ "Handle", "action", ".", "s" ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L10346-L10362
49,503
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function() { gui.Spirit.prototype.onenter.call(this); this.event.add('load'); this.action.addGlobal([ // in order of appearance gui.ACTION_DOC_ONDOMCONTENT, gui.ACTION_DOC_ONLOAD, gui.ACTION_DOC_ONHASH, gui.ACTION_DOC_ONSPIRITUALIZED, gui.ACTION_DOC_UNLOAD ]); if (this.fit) { this.css.height = 0; } var src = this.element.src; if (src && src !== gui.IframeSpirit.SRC_DEFAULT) { if (!src.startsWith("blob:")) { // wrong... this._setupsrc(src); } } }
javascript
function() { gui.Spirit.prototype.onenter.call(this); this.event.add('load'); this.action.addGlobal([ // in order of appearance gui.ACTION_DOC_ONDOMCONTENT, gui.ACTION_DOC_ONLOAD, gui.ACTION_DOC_ONHASH, gui.ACTION_DOC_ONSPIRITUALIZED, gui.ACTION_DOC_UNLOAD ]); if (this.fit) { this.css.height = 0; } var src = this.element.src; if (src && src !== gui.IframeSpirit.SRC_DEFAULT) { if (!src.startsWith("blob:")) { // wrong... this._setupsrc(src); } } }
[ "function", "(", ")", "{", "gui", ".", "Spirit", ".", "prototype", ".", "onenter", ".", "call", "(", "this", ")", ";", "this", ".", "event", ".", "add", "(", "'load'", ")", ";", "this", ".", "action", ".", "addGlobal", "(", "[", "// in order of appearance", "gui", ".", "ACTION_DOC_ONDOMCONTENT", ",", "gui", ".", "ACTION_DOC_ONLOAD", ",", "gui", ".", "ACTION_DOC_ONHASH", ",", "gui", ".", "ACTION_DOC_ONSPIRITUALIZED", ",", "gui", ".", "ACTION_DOC_UNLOAD", "]", ")", ";", "if", "(", "this", ".", "fit", ")", "{", "this", ".", "css", ".", "height", "=", "0", ";", "}", "var", "src", "=", "this", ".", "element", ".", "src", ";", "if", "(", "src", "&&", "src", "!==", "gui", ".", "IframeSpirit", ".", "SRC_DEFAULT", ")", "{", "if", "(", "!", "src", ".", "startsWith", "(", "\"blob:\"", ")", ")", "{", "// wrong...", "this", ".", "_setupsrc", "(", "src", ")", ";", "}", "}", "}" ]
Stamp SRC on startup. Configure content document events in order of appearance and resolve current contentLocation.
[ "Stamp", "SRC", "on", "startup", ".", "Configure", "content", "document", "events", "in", "order", "of", "appearance", "and", "resolve", "current", "contentLocation", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L10490-L10509
49,504
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(a) { gui.Spirit.prototype.onaction.call(this, a); this.action.$handleownaction = false; var base; switch (a.type) { case gui.ACTION_DOC_ONDOMCONTENT: this.contentLocation = new gui.URL(document, a.data); this.life.dispatch(gui.LIFE_IFRAME_DOMCONTENT); this.action.remove(a.type); a.consume(); break; case gui.ACTION_DOC_ONLOAD: this.contentLocation = new gui.URL(document, a.data); this.life.dispatch(gui.LIFE_IFRAME_ONLOAD); this.action.remove(a.type); a.consume(); break; case gui.ACTION_DOC_ONHASH: base = this.contentLocation.href.split("#")[0]; this.contentLocation = new gui.URL(document, base + a.data); this.life.dispatch(gui.LIFE_IFRAME_ONHASH); a.consume(); break; case gui.ACTION_DOC_ONSPIRITUALIZED: this._onspiritualized(); this.life.dispatch(gui.LIFE_IFRAME_SPIRITUALIZED); this.action.remove(a.type); a.consume(); break; case gui.ACTION_DOC_UNLOAD: this._onunload(); this.life.dispatch(gui.LIFE_IFRAME_UNLOAD); this.action.add([ gui.ACTION_DOC_ONCONSTRUCT, gui.ACTION_DOC_ONDOMCONTENT, gui.ACTION_DOC_ONLOAD, gui.ACTION_DOC_ONSPIRITUALIZED ]); a.consume(); break; } }
javascript
function(a) { gui.Spirit.prototype.onaction.call(this, a); this.action.$handleownaction = false; var base; switch (a.type) { case gui.ACTION_DOC_ONDOMCONTENT: this.contentLocation = new gui.URL(document, a.data); this.life.dispatch(gui.LIFE_IFRAME_DOMCONTENT); this.action.remove(a.type); a.consume(); break; case gui.ACTION_DOC_ONLOAD: this.contentLocation = new gui.URL(document, a.data); this.life.dispatch(gui.LIFE_IFRAME_ONLOAD); this.action.remove(a.type); a.consume(); break; case gui.ACTION_DOC_ONHASH: base = this.contentLocation.href.split("#")[0]; this.contentLocation = new gui.URL(document, base + a.data); this.life.dispatch(gui.LIFE_IFRAME_ONHASH); a.consume(); break; case gui.ACTION_DOC_ONSPIRITUALIZED: this._onspiritualized(); this.life.dispatch(gui.LIFE_IFRAME_SPIRITUALIZED); this.action.remove(a.type); a.consume(); break; case gui.ACTION_DOC_UNLOAD: this._onunload(); this.life.dispatch(gui.LIFE_IFRAME_UNLOAD); this.action.add([ gui.ACTION_DOC_ONCONSTRUCT, gui.ACTION_DOC_ONDOMCONTENT, gui.ACTION_DOC_ONLOAD, gui.ACTION_DOC_ONSPIRITUALIZED ]); a.consume(); break; } }
[ "function", "(", "a", ")", "{", "gui", ".", "Spirit", ".", "prototype", ".", "onaction", ".", "call", "(", "this", ",", "a", ")", ";", "this", ".", "action", ".", "$handleownaction", "=", "false", ";", "var", "base", ";", "switch", "(", "a", ".", "type", ")", "{", "case", "gui", ".", "ACTION_DOC_ONDOMCONTENT", ":", "this", ".", "contentLocation", "=", "new", "gui", ".", "URL", "(", "document", ",", "a", ".", "data", ")", ";", "this", ".", "life", ".", "dispatch", "(", "gui", ".", "LIFE_IFRAME_DOMCONTENT", ")", ";", "this", ".", "action", ".", "remove", "(", "a", ".", "type", ")", ";", "a", ".", "consume", "(", ")", ";", "break", ";", "case", "gui", ".", "ACTION_DOC_ONLOAD", ":", "this", ".", "contentLocation", "=", "new", "gui", ".", "URL", "(", "document", ",", "a", ".", "data", ")", ";", "this", ".", "life", ".", "dispatch", "(", "gui", ".", "LIFE_IFRAME_ONLOAD", ")", ";", "this", ".", "action", ".", "remove", "(", "a", ".", "type", ")", ";", "a", ".", "consume", "(", ")", ";", "break", ";", "case", "gui", ".", "ACTION_DOC_ONHASH", ":", "base", "=", "this", ".", "contentLocation", ".", "href", ".", "split", "(", "\"#\"", ")", "[", "0", "]", ";", "this", ".", "contentLocation", "=", "new", "gui", ".", "URL", "(", "document", ",", "base", "+", "a", ".", "data", ")", ";", "this", ".", "life", ".", "dispatch", "(", "gui", ".", "LIFE_IFRAME_ONHASH", ")", ";", "a", ".", "consume", "(", ")", ";", "break", ";", "case", "gui", ".", "ACTION_DOC_ONSPIRITUALIZED", ":", "this", ".", "_onspiritualized", "(", ")", ";", "this", ".", "life", ".", "dispatch", "(", "gui", ".", "LIFE_IFRAME_SPIRITUALIZED", ")", ";", "this", ".", "action", ".", "remove", "(", "a", ".", "type", ")", ";", "a", ".", "consume", "(", ")", ";", "break", ";", "case", "gui", ".", "ACTION_DOC_UNLOAD", ":", "this", ".", "_onunload", "(", ")", ";", "this", ".", "life", ".", "dispatch", "(", "gui", ".", "LIFE_IFRAME_UNLOAD", ")", ";", "this", ".", "action", ".", "add", "(", "[", "gui", ".", "ACTION_DOC_ONCONSTRUCT", ",", "gui", ".", "ACTION_DOC_ONDOMCONTENT", ",", "gui", ".", "ACTION_DOC_ONLOAD", ",", "gui", ".", "ACTION_DOC_ONSPIRITUALIZED", "]", ")", ";", "a", ".", "consume", "(", ")", ";", "break", ";", "}", "}" ]
Handle action. @param {gui.Action} a
[ "Handle", "action", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L10516-L10557
49,505
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(url, src) { if (src) { this._setupsrc(src); } if (url) { this.element.src = url; } return this.contentLocation.href; }
javascript
function(url, src) { if (src) { this._setupsrc(src); } if (url) { this.element.src = url; } return this.contentLocation.href; }
[ "function", "(", "url", ",", "src", ")", "{", "if", "(", "src", ")", "{", "this", ".", "_setupsrc", "(", "src", ")", ";", "}", "if", "(", "url", ")", "{", "this", ".", "element", ".", "src", "=", "url", ";", "}", "return", "this", ".", "contentLocation", ".", "href", ";", "}" ]
Experimentally load some kind of blob. @param @optional {URL} url @param @optional {String} src
[ "Experimentally", "load", "some", "kind", "of", "blob", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L10614-L10622
49,506
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function() { var proto = Element.prototype; if (gui.Type.isDefined(proto.spirit)) { throw new Error("Spiritual loaded twice?"); } else { proto.spirit = null; // defineProperty fails in iOS5 } }
javascript
function() { var proto = Element.prototype; if (gui.Type.isDefined(proto.spirit)) { throw new Error("Spiritual loaded twice?"); } else { proto.spirit = null; // defineProperty fails in iOS5 } }
[ "function", "(", ")", "{", "var", "proto", "=", "Element", ".", "prototype", ";", "if", "(", "gui", ".", "Type", ".", "isDefined", "(", "proto", ".", "spirit", ")", ")", "{", "throw", "new", "Error", "(", "\"Spiritual loaded twice?\"", ")", ";", "}", "else", "{", "proto", ".", "spirit", "=", "null", ";", "// defineProperty fails in iOS5", "}", "}" ]
Declare `spirit` as a fundamental property of things. @param {Window} win
[ "Declare", "spirit", "as", "a", "fundamental", "property", "of", "things", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L10998-L11005
49,507
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function() { var Elm = gui.Client.isExplorer ? HTMLElement : Element; this._change(Elm.prototype, gui.DOMCombos); }
javascript
function() { var Elm = gui.Client.isExplorer ? HTMLElement : Element; this._change(Elm.prototype, gui.DOMCombos); }
[ "function", "(", ")", "{", "var", "Elm", "=", "gui", ".", "Client", ".", "isExplorer", "?", "HTMLElement", ":", "Element", ";", "this", ".", "_change", "(", "Elm", ".", "prototype", ",", "gui", ".", "DOMCombos", ")", ";", "}" ]
Extend native DOM methods in given window scope. Wonder what happens now with SVG in Explorer?
[ "Extend", "native", "DOM", "methods", "in", "given", "window", "scope", ".", "Wonder", "what", "happens", "now", "with", "SVG", "in", "Explorer?" ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11011-L11014
49,508
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(proto, name, combo, root) { var getter = root.__lookupGetter__(name); var setter = root.__lookupSetter__(name); if (getter) { // firefox 20 needs a getter for this to work proto.__defineGetter__(name, function() { return getter.apply(this, arguments); }); proto.__defineSetter__(name, combo(function() { setter.apply(this, arguments); })); } }
javascript
function(proto, name, combo, root) { var getter = root.__lookupGetter__(name); var setter = root.__lookupSetter__(name); if (getter) { // firefox 20 needs a getter for this to work proto.__defineGetter__(name, function() { return getter.apply(this, arguments); }); proto.__defineSetter__(name, combo(function() { setter.apply(this, arguments); })); } }
[ "function", "(", "proto", ",", "name", ",", "combo", ",", "root", ")", "{", "var", "getter", "=", "root", ".", "__lookupGetter__", "(", "name", ")", ";", "var", "setter", "=", "root", ".", "__lookupSetter__", "(", "name", ")", ";", "if", "(", "getter", ")", "{", "// firefox 20 needs a getter for this to work", "proto", ".", "__defineGetter__", "(", "name", ",", "function", "(", ")", "{", "return", "getter", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ")", ";", "proto", ".", "__defineSetter__", "(", "name", ",", "combo", "(", "function", "(", ")", "{", "setter", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ")", ")", ";", "}", "}" ]
Overload property setter for Firefox. @param {object} proto @param {String} name @param {function} combo @param {Element} root
[ "Overload", "property", "setter", "for", "Firefox", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11118-L11129
49,509
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function() { if (gui.Client.hasMutations) { if (!this._observer) { var Observer = this._mutationobserver(); this._observer = new Observer(function(mutations) { mutations.forEach(function(mutation) { gui.DOMObserver._handleMutation(mutation); }); }); } this._connect(true); this.observes = true; } else { throw new Error('MutationObserver no such thing'); } }
javascript
function() { if (gui.Client.hasMutations) { if (!this._observer) { var Observer = this._mutationobserver(); this._observer = new Observer(function(mutations) { mutations.forEach(function(mutation) { gui.DOMObserver._handleMutation(mutation); }); }); } this._connect(true); this.observes = true; } else { throw new Error('MutationObserver no such thing'); } }
[ "function", "(", ")", "{", "if", "(", "gui", ".", "Client", ".", "hasMutations", ")", "{", "if", "(", "!", "this", ".", "_observer", ")", "{", "var", "Observer", "=", "this", ".", "_mutationobserver", "(", ")", ";", "this", ".", "_observer", "=", "new", "Observer", "(", "function", "(", "mutations", ")", "{", "mutations", ".", "forEach", "(", "function", "(", "mutation", ")", "{", "gui", ".", "DOMObserver", ".", "_handleMutation", "(", "mutation", ")", ";", "}", ")", ";", "}", ")", ";", "}", "this", ".", "_connect", "(", "true", ")", ";", "this", ".", "observes", "=", "true", ";", "}", "else", "{", "throw", "new", "Error", "(", "'MutationObserver no such thing'", ")", ";", "}", "}" ]
Start observing.
[ "Start", "observing", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11441-L11456
49,510
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(action, thisp) { var res; if (this.observes) { if (++this._suspend === 1) { this._connect(false); } } if (gui.Type.isFunction(action)) { res = action.call(thisp); } if (this.observes) { this.resume(); } return res; }
javascript
function(action, thisp) { var res; if (this.observes) { if (++this._suspend === 1) { this._connect(false); } } if (gui.Type.isFunction(action)) { res = action.call(thisp); } if (this.observes) { this.resume(); } return res; }
[ "function", "(", "action", ",", "thisp", ")", "{", "var", "res", ";", "if", "(", "this", ".", "observes", ")", "{", "if", "(", "++", "this", ".", "_suspend", "===", "1", ")", "{", "this", ".", "_connect", "(", "false", ")", ";", "}", "}", "if", "(", "gui", ".", "Type", ".", "isFunction", "(", "action", ")", ")", "{", "res", "=", "action", ".", "call", "(", "thisp", ")", ";", "}", "if", "(", "this", ".", "observes", ")", "{", "this", ".", "resume", "(", ")", ";", "}", "return", "res", ";", "}" ]
Suspend mutation monitoring of document; enable monitoring again after executing provided function. @param {Node} node @param @optional {function} action @param @optional {object} thisp @returns {object} if action was defined, we might return something
[ "Suspend", "mutation", "monitoring", "of", "document", ";", "enable", "monitoring", "again", "after", "executing", "provided", "function", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11466-L11480
49,511
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(connect) { var obs = this._observer; if (obs) { if (connect) { obs.observe(document, { childList: true, subtree: true }); } else { obs.disconnect(); } } }
javascript
function(connect) { var obs = this._observer; if (obs) { if (connect) { obs.observe(document, { childList: true, subtree: true }); } else { obs.disconnect(); } } }
[ "function", "(", "connect", ")", "{", "var", "obs", "=", "this", ".", "_observer", ";", "if", "(", "obs", ")", "{", "if", "(", "connect", ")", "{", "obs", ".", "observe", "(", "document", ",", "{", "childList", ":", "true", ",", "subtree", ":", "true", "}", ")", ";", "}", "else", "{", "obs", ".", "disconnect", "(", ")", ";", "}", "}", "}" ]
Connect and disconnect observer. @param {boolean} connect
[ "Connect", "and", "disconnect", "observer", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11527-L11539
49,512
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(mutation) { Array.forEach(mutation.removedNodes, function(node) { if (node.nodeType === Node.ELEMENT_NODE) { gui.materialize(node); } }, this); Array.forEach(mutation.addedNodes, function(node) { if (node.nodeType === Node.ELEMENT_NODE) { gui.spiritualize(node); } }, this); }
javascript
function(mutation) { Array.forEach(mutation.removedNodes, function(node) { if (node.nodeType === Node.ELEMENT_NODE) { gui.materialize(node); } }, this); Array.forEach(mutation.addedNodes, function(node) { if (node.nodeType === Node.ELEMENT_NODE) { gui.spiritualize(node); } }, this); }
[ "function", "(", "mutation", ")", "{", "Array", ".", "forEach", "(", "mutation", ".", "removedNodes", ",", "function", "(", "node", ")", "{", "if", "(", "node", ".", "nodeType", "===", "Node", ".", "ELEMENT_NODE", ")", "{", "gui", ".", "materialize", "(", "node", ")", ";", "}", "}", ",", "this", ")", ";", "Array", ".", "forEach", "(", "mutation", ".", "addedNodes", ",", "function", "(", "node", ")", "{", "if", "(", "node", ".", "nodeType", "===", "Node", ".", "ELEMENT_NODE", ")", "{", "gui", ".", "spiritualize", "(", "node", ")", ";", "}", "}", ",", "this", ")", ";", "}" ]
Handle mutations. 1. Matarialize deleted nodes 2. Spiritualize added nodes @param {MutationRecord} mutation
[ "Handle", "mutations", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11548-L11559
49,513
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(elm, Spirit) { var doc = elm.ownerDocument; var win = doc.defaultView; var sig = win.gui.$contextid; if (elm.spirit) { throw new Error( "Cannot repossess element with spirit " + elm.spirit + " (exorcise first)" ); } else if (!gui.debug || gui.Type.isSpiritConstructor(Spirit)) { elm.spirit = new Spirit(elm, doc, win, sig); } else { throw new Error( "Not a spirit constructor (" + gui.Type.of(Spirit) + ")" ); } return elm.spirit; }
javascript
function(elm, Spirit) { var doc = elm.ownerDocument; var win = doc.defaultView; var sig = win.gui.$contextid; if (elm.spirit) { throw new Error( "Cannot repossess element with spirit " + elm.spirit + " (exorcise first)" ); } else if (!gui.debug || gui.Type.isSpiritConstructor(Spirit)) { elm.spirit = new Spirit(elm, doc, win, sig); } else { throw new Error( "Not a spirit constructor (" + gui.Type.of(Spirit) + ")" ); } return elm.spirit; }
[ "function", "(", "elm", ",", "Spirit", ")", "{", "var", "doc", "=", "elm", ".", "ownerDocument", ";", "var", "win", "=", "doc", ".", "defaultView", ";", "var", "sig", "=", "win", ".", "gui", ".", "$contextid", ";", "if", "(", "elm", ".", "spirit", ")", "{", "throw", "new", "Error", "(", "\"Cannot repossess element with spirit \"", "+", "elm", ".", "spirit", "+", "\" (exorcise first)\"", ")", ";", "}", "else", "if", "(", "!", "gui", ".", "debug", "||", "gui", ".", "Type", ".", "isSpiritConstructor", "(", "Spirit", ")", ")", "{", "elm", ".", "spirit", "=", "new", "Spirit", "(", "elm", ",", "doc", ",", "win", ",", "sig", ")", ";", "}", "else", "{", "throw", "new", "Error", "(", "\"Not a spirit constructor (\"", "+", "gui", ".", "Type", ".", "of", "(", "Spirit", ")", "+", "\")\"", ")", ";", "}", "return", "elm", ".", "spirit", ";", "}" ]
Associate DOM element to Spirit instance. @param {Element} elm @param {function} Spirit constructor @returns {Spirit}
[ "Associate", "DOM", "element", "to", "Spirit", "instance", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11594-L11611
49,514
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(operation, thisp) { this._suspended = true; var res = operation.call(thisp); this._suspended = false; return res; }
javascript
function(operation, thisp) { this._suspended = true; var res = operation.call(thisp); this._suspended = false; return res; }
[ "function", "(", "operation", ",", "thisp", ")", "{", "this", ".", "_suspended", "=", "true", ";", "var", "res", "=", "operation", ".", "call", "(", "thisp", ")", ";", "this", ".", "_suspended", "=", "false", ";", "return", "res", ";", "}" ]
Suspend spiritualization and materialization during operation. @param {function} operation @param @optional {object} thisp @returns {object}
[ "Suspend", "spiritualization", "and", "materialization", "during", "operation", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11619-L11624
49,515
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(node, skip, id) { var list = []; new gui.Crawler(id).descend(node, { handleSpirit: function(spirit) { if (skip && spirit.element === node) { // nothing } else if (!spirit.life.destructed) { list.push(spirit); } } }); return list; }
javascript
function(node, skip, id) { var list = []; new gui.Crawler(id).descend(node, { handleSpirit: function(spirit) { if (skip && spirit.element === node) { // nothing } else if (!spirit.life.destructed) { list.push(spirit); } } }); return list; }
[ "function", "(", "node", ",", "skip", ",", "id", ")", "{", "var", "list", "=", "[", "]", ";", "new", "gui", ".", "Crawler", "(", "id", ")", ".", "descend", "(", "node", ",", "{", "handleSpirit", ":", "function", "(", "spirit", ")", "{", "if", "(", "skip", "&&", "spirit", ".", "element", "===", "node", ")", "{", "// nothing", "}", "else", "if", "(", "!", "spirit", ".", "life", ".", "destructed", ")", "{", "list", ".", "push", "(", "spirit", ")", ";", "}", "}", "}", ")", ";", "return", "list", ";", "}" ]
Collect non-destructed spirits from element and descendants. @param {Node} node @param @optional {boolean} skip Skip start element @returns {Array<gui.Spirit>}
[ "Collect", "non", "-", "destructed", "spirits", "from", "element", "and", "descendants", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11740-L11752
49,516
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(node, skip, one) { node = node instanceof gui.Spirit ? node.element : node; node = node.nodeType === Node.DOCUMENT_NODE ? node.documentElement : node; if (this._handles(node)) { this._spiritualize(node, skip, one); } }
javascript
function(node, skip, one) { node = node instanceof gui.Spirit ? node.element : node; node = node.nodeType === Node.DOCUMENT_NODE ? node.documentElement : node; if (this._handles(node)) { this._spiritualize(node, skip, one); } }
[ "function", "(", "node", ",", "skip", ",", "one", ")", "{", "node", "=", "node", "instanceof", "gui", ".", "Spirit", "?", "node", ".", "element", ":", "node", ";", "node", "=", "node", ".", "nodeType", "===", "Node", ".", "DOCUMENT_NODE", "?", "node", ".", "documentElement", ":", "node", ";", "if", "(", "this", ".", "_handles", "(", "node", ")", ")", "{", "this", ".", "_spiritualize", "(", "node", ",", "skip", ",", "one", ")", ";", "}", "}" ]
Spiritualize node perhaps. @param {Node|gui.Spirit} node @param {boolean} skip Skip the element? @param {boolean} one Skip the subtree?
[ "Spiritualize", "node", "perhaps", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11760-L11766
49,517
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(element, skip, one) { skip = false; // until DOM setters can finally replace Mutation Observers... var att = 'gui-spiritualizing'; if (!element.hasAttribute(att)) { var spirit, spirits = []; // classname = gui.CLASS_NOSPIRITS element.setAttribute(att, 'true'); new gui.Crawler(gui.CRAWLER_SPIRITUALIZE).descend(element, { handleElement: function(elm) { if (elm !== element && elm.hasAttribute(att)) { return one ? gui.Crawler.STOP : gui.Crawler.SKIP_CHILDREN; } else { if (!skip || elm !== element) { spirit = elm.spirit; if (!spirit) { spirit = gui.Guide._evaluate(elm); } if (spirit) { if (!spirit.life.attached) { spirits.push(spirit); } } } if (one) { return gui.Crawler.STOP; } else if (!elm.childElementCount) { // || gui.CSSPlugin.contains(elm, classname) return gui.Crawler.SKIP_CHILDREN; } else { // TODO: interface for this kind of stuff! switch (elm.localName) { case "pre": case "code": return gui.Crawler.SKIP_CHILDREN; } } } return gui.Crawler.CONTINUE; } }); element.removeAttribute(att); this._sequence(spirits); } }
javascript
function(element, skip, one) { skip = false; // until DOM setters can finally replace Mutation Observers... var att = 'gui-spiritualizing'; if (!element.hasAttribute(att)) { var spirit, spirits = []; // classname = gui.CLASS_NOSPIRITS element.setAttribute(att, 'true'); new gui.Crawler(gui.CRAWLER_SPIRITUALIZE).descend(element, { handleElement: function(elm) { if (elm !== element && elm.hasAttribute(att)) { return one ? gui.Crawler.STOP : gui.Crawler.SKIP_CHILDREN; } else { if (!skip || elm !== element) { spirit = elm.spirit; if (!spirit) { spirit = gui.Guide._evaluate(elm); } if (spirit) { if (!spirit.life.attached) { spirits.push(spirit); } } } if (one) { return gui.Crawler.STOP; } else if (!elm.childElementCount) { // || gui.CSSPlugin.contains(elm, classname) return gui.Crawler.SKIP_CHILDREN; } else { // TODO: interface for this kind of stuff! switch (elm.localName) { case "pre": case "code": return gui.Crawler.SKIP_CHILDREN; } } } return gui.Crawler.CONTINUE; } }); element.removeAttribute(att); this._sequence(spirits); } }
[ "function", "(", "element", ",", "skip", ",", "one", ")", "{", "skip", "=", "false", ";", "// until DOM setters can finally replace Mutation Observers...", "var", "att", "=", "'gui-spiritualizing'", ";", "if", "(", "!", "element", ".", "hasAttribute", "(", "att", ")", ")", "{", "var", "spirit", ",", "spirits", "=", "[", "]", ";", "// classname = gui.CLASS_NOSPIRITS", "element", ".", "setAttribute", "(", "att", ",", "'true'", ")", ";", "new", "gui", ".", "Crawler", "(", "gui", ".", "CRAWLER_SPIRITUALIZE", ")", ".", "descend", "(", "element", ",", "{", "handleElement", ":", "function", "(", "elm", ")", "{", "if", "(", "elm", "!==", "element", "&&", "elm", ".", "hasAttribute", "(", "att", ")", ")", "{", "return", "one", "?", "gui", ".", "Crawler", ".", "STOP", ":", "gui", ".", "Crawler", ".", "SKIP_CHILDREN", ";", "}", "else", "{", "if", "(", "!", "skip", "||", "elm", "!==", "element", ")", "{", "spirit", "=", "elm", ".", "spirit", ";", "if", "(", "!", "spirit", ")", "{", "spirit", "=", "gui", ".", "Guide", ".", "_evaluate", "(", "elm", ")", ";", "}", "if", "(", "spirit", ")", "{", "if", "(", "!", "spirit", ".", "life", ".", "attached", ")", "{", "spirits", ".", "push", "(", "spirit", ")", ";", "}", "}", "}", "if", "(", "one", ")", "{", "return", "gui", ".", "Crawler", ".", "STOP", ";", "}", "else", "if", "(", "!", "elm", ".", "childElementCount", ")", "{", "// || gui.CSSPlugin.contains(elm, classname)", "return", "gui", ".", "Crawler", ".", "SKIP_CHILDREN", ";", "}", "else", "{", "// TODO: interface for this kind of stuff!", "switch", "(", "elm", ".", "localName", ")", "{", "case", "\"pre\"", ":", "case", "\"code\"", ":", "return", "gui", ".", "Crawler", ".", "SKIP_CHILDREN", ";", "}", "}", "}", "return", "gui", ".", "Crawler", ".", "CONTINUE", ";", "}", "}", ")", ";", "element", ".", "removeAttribute", "(", "att", ")", ";", "this", ".", "_sequence", "(", "spirits", ")", ";", "}", "}" ]
Evaluate spirits for element and subtree. - Construct spirits in document order - Fire life cycle events except `ready` in document order - Fire `ready` in reverse document order (innermost first) TODO: Create a dedicated crawler subclass for this purpose. @param {Element} element @param {boolean} skip Skip the element? @param {boolean} one Skip the subtree?
[ "Evaluate", "spirits", "for", "element", "and", "subtree", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11780-L11821
49,518
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(node, skip, one, force) { node = node instanceof gui.Spirit ? node.element : node; node = node.nodeType === Node.DOCUMENT_NODE ? node.documentElement : node; if (force || this._handles(node)) { node.setAttribute('gui-matarializing', 'true'); this._materialize(node, skip, one); node.removeAttribute('gui-matarializing'); } }
javascript
function(node, skip, one, force) { node = node instanceof gui.Spirit ? node.element : node; node = node.nodeType === Node.DOCUMENT_NODE ? node.documentElement : node; if (force || this._handles(node)) { node.setAttribute('gui-matarializing', 'true'); this._materialize(node, skip, one); node.removeAttribute('gui-matarializing'); } }
[ "function", "(", "node", ",", "skip", ",", "one", ",", "force", ")", "{", "node", "=", "node", "instanceof", "gui", ".", "Spirit", "?", "node", ".", "element", ":", "node", ";", "node", "=", "node", ".", "nodeType", "===", "Node", ".", "DOCUMENT_NODE", "?", "node", ".", "documentElement", ":", "node", ";", "if", "(", "force", "||", "this", ".", "_handles", "(", "node", ")", ")", "{", "node", ".", "setAttribute", "(", "'gui-matarializing'", ",", "'true'", ")", ";", "this", ".", "_materialize", "(", "node", ",", "skip", ",", "one", ")", ";", "node", ".", "removeAttribute", "(", "'gui-matarializing'", ")", ";", "}", "}" ]
Destruct spirits from element and subtree. Using a two-phased destruction sequence to minimize the risk of plugins invoking already destructed plugins during destruct. @param {Node|gui.Spirit} node @param {boolean} skip Skip the element? @param {boolean} one Skip the subtree? @param {boolean} force
[ "Destruct", "spirits", "from", "element", "and", "subtree", ".", "Using", "a", "two", "-", "phased", "destruction", "sequence", "to", "minimize", "the", "risk", "of", "plugins", "invoking", "already", "destructed", "plugins", "during", "destruct", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11863-L11871
49,519
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(spirits) { if (gui.hasModule("[email protected]")) { gui.DOMPlugin.group(spirits).forEach(function(spirit) { gui.VisibilityPlugin.$init(spirit); }, this); } }
javascript
function(spirits) { if (gui.hasModule("[email protected]")) { gui.DOMPlugin.group(spirits).forEach(function(spirit) { gui.VisibilityPlugin.$init(spirit); }, this); } }
[ "function", "(", "spirits", ")", "{", "if", "(", "gui", ".", "hasModule", "(", "\"[email protected]\"", ")", ")", "{", "gui", ".", "DOMPlugin", ".", "group", "(", "spirits", ")", ".", "forEach", "(", "function", "(", "spirit", ")", "{", "gui", ".", "VisibilityPlugin", ".", "$init", "(", "spirit", ")", ";", "}", ",", "this", ")", ";", "}", "}" ]
Evaluate spirits visibility. @todo: Off to plugin somehow. @todo: Test for this stuff. @param {Array<gui.Spirit>}
[ "Evaluate", "spirits", "visibility", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L11930-L11936
49,520
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(e) { /* * TODO: Move this code into {gui.EventPlugin} */ if (e.type === 'webkitTransitionEnd') { e = { type: 'transitionend', target: e.target, propertyName: e.propertyName, elapsedTime: e.elapsedTime, pseudoElement: e.pseudoElement }; } this.onevent(e); }
javascript
function(e) { /* * TODO: Move this code into {gui.EventPlugin} */ if (e.type === 'webkitTransitionEnd') { e = { type: 'transitionend', target: e.target, propertyName: e.propertyName, elapsedTime: e.elapsedTime, pseudoElement: e.pseudoElement }; } this.onevent(e); }
[ "function", "(", "e", ")", "{", "/*\n\t\t\t * TODO: Move this code into {gui.EventPlugin}\n\t\t\t */", "if", "(", "e", ".", "type", "===", "'webkitTransitionEnd'", ")", "{", "e", "=", "{", "type", ":", "'transitionend'", ",", "target", ":", "e", ".", "target", ",", "propertyName", ":", "e", ".", "propertyName", ",", "elapsedTime", ":", "e", ".", "elapsedTime", ",", "pseudoElement", ":", "e", ".", "pseudoElement", "}", ";", "}", "this", ".", "onevent", "(", "e", ")", ";", "}" ]
Native DOM interface. We'll forward the event to the method `onevent`. @see http://www.w3.org/TR/DOM-Level-3-Events/#interface-EventListener TODO: move to $protected area @param {Event} e
[ "Native", "DOM", "interface", ".", "We", "ll", "forward", "the", "event", "to", "the", "method", "onevent", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L12159-L12173
49,521
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(key) { gui.Spirit.prototype.onkey.call(this, key); console.log(key.type); var map = this._map; map[key.type] = key.down; if (Object.keys(map).every(function(type) { //console.log ( type + ": " + map [ type ]); return map[type] === true; })) { console.log("fis!"); } }
javascript
function(key) { gui.Spirit.prototype.onkey.call(this, key); console.log(key.type); var map = this._map; map[key.type] = key.down; if (Object.keys(map).every(function(type) { //console.log ( type + ": " + map [ type ]); return map[type] === true; })) { console.log("fis!"); } }
[ "function", "(", "key", ")", "{", "gui", ".", "Spirit", ".", "prototype", ".", "onkey", ".", "call", "(", "this", ",", "key", ")", ";", "console", ".", "log", "(", "key", ".", "type", ")", ";", "var", "map", "=", "this", ".", "_map", ";", "map", "[", "key", ".", "type", "]", "=", "key", ".", "down", ";", "if", "(", "Object", ".", "keys", "(", "map", ")", ".", "every", "(", "function", "(", "type", ")", "{", "//console.log ( type + \": \" + map [ type ]);", "return", "map", "[", "type", "]", "===", "true", ";", "}", ")", ")", "{", "console", ".", "log", "(", "\"fis!\"", ")", ";", "}", "}" ]
Handle key. @param {gui.Key} key
[ "Handle", "key", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L12527-L12539
49,522
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function() { var key = this.att.get("key"); if (key) { key.split(" ").forEach(function(token) { token = token.trim(); this.key.addGlobal(token); this._map[token] = false; }, this); } }
javascript
function() { var key = this.att.get("key"); if (key) { key.split(" ").forEach(function(token) { token = token.trim(); this.key.addGlobal(token); this._map[token] = false; }, this); } }
[ "function", "(", ")", "{", "var", "key", "=", "this", ".", "att", ".", "get", "(", "\"key\"", ")", ";", "if", "(", "key", ")", "{", "key", ".", "split", "(", "\" \"", ")", ".", "forEach", "(", "function", "(", "token", ")", "{", "token", "=", "token", ".", "trim", "(", ")", ";", "this", ".", "key", ".", "addGlobal", "(", "token", ")", ";", "this", ".", "_map", "[", "token", "]", "=", "false", ";", "}", ",", "this", ")", ";", "}", "}" ]
Parsing the 'key' attribute, setup key listeners.
[ "Parsing", "the", "key", "attribute", "setup", "key", "listeners", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L12554-L12563
49,523
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(context) { this._keymap = Object.create(null); ["keydown", "keypress", "keyup"].forEach(function(type) { context.document.addEventListener(type, this, false); }, this); }
javascript
function(context) { this._keymap = Object.create(null); ["keydown", "keypress", "keyup"].forEach(function(type) { context.document.addEventListener(type, this, false); }, this); }
[ "function", "(", "context", ")", "{", "this", ".", "_keymap", "=", "Object", ".", "create", "(", "null", ")", ";", "[", "\"keydown\"", ",", "\"keypress\"", ",", "\"keyup\"", "]", ".", "forEach", "(", "function", "(", "type", ")", "{", "context", ".", "document", ".", "addEventListener", "(", "type", ",", "this", ",", "false", ")", ";", "}", ",", "this", ")", ";", "}" ]
Context init. @param {Window} context
[ "Context", "init", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L12607-L12612
49,524
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(e) { var n = e.keyCode, c = this._keymap[n], b = gui.BROADCAST_KEYEVENT; var id = e.currentTarget.defaultView.gui.$contextid; /* // TODO: THIS! if ( e.ctrlKey && gui.Key.$key [ e.keyCode ] !== "Control" ) { e.preventDefault (); } */ switch (e.type) { case "keydown": if (c === undefined) { this._keycode = n; this._keymap[n] = null; this._keymap[n] = String.fromCharCode(e.which).toLowerCase(); gui.Tick.next(function() { c = this._keymap[n]; this._broadcast(true, null, c, n, id); this._keycode = null; }, this); } break; case "keypress": if (this._keycode) { c = this._keychar(e.keyCode, e.charCode, e.which); this._keymap[this._keycode] = c; } break; case "keyup": if (c !== undefined) { this._broadcast(false, null, c, n, id); delete this._keymap[n]; } break; } }
javascript
function(e) { var n = e.keyCode, c = this._keymap[n], b = gui.BROADCAST_KEYEVENT; var id = e.currentTarget.defaultView.gui.$contextid; /* // TODO: THIS! if ( e.ctrlKey && gui.Key.$key [ e.keyCode ] !== "Control" ) { e.preventDefault (); } */ switch (e.type) { case "keydown": if (c === undefined) { this._keycode = n; this._keymap[n] = null; this._keymap[n] = String.fromCharCode(e.which).toLowerCase(); gui.Tick.next(function() { c = this._keymap[n]; this._broadcast(true, null, c, n, id); this._keycode = null; }, this); } break; case "keypress": if (this._keycode) { c = this._keychar(e.keyCode, e.charCode, e.which); this._keymap[this._keycode] = c; } break; case "keyup": if (c !== undefined) { this._broadcast(false, null, c, n, id); delete this._keymap[n]; } break; } }
[ "function", "(", "e", ")", "{", "var", "n", "=", "e", ".", "keyCode", ",", "c", "=", "this", ".", "_keymap", "[", "n", "]", ",", "b", "=", "gui", ".", "BROADCAST_KEYEVENT", ";", "var", "id", "=", "e", ".", "currentTarget", ".", "defaultView", ".", "gui", ".", "$contextid", ";", "/*\n\t\t// TODO: THIS!\n\t\tif ( e.ctrlKey && gui.Key.$key [ e.keyCode ] !== \"Control\" ) {\n\t\t\te.preventDefault ();\n\t\t}\n\t\t*/", "switch", "(", "e", ".", "type", ")", "{", "case", "\"keydown\"", ":", "if", "(", "c", "===", "undefined", ")", "{", "this", ".", "_keycode", "=", "n", ";", "this", ".", "_keymap", "[", "n", "]", "=", "null", ";", "this", ".", "_keymap", "[", "n", "]", "=", "String", ".", "fromCharCode", "(", "e", ".", "which", ")", ".", "toLowerCase", "(", ")", ";", "gui", ".", "Tick", ".", "next", "(", "function", "(", ")", "{", "c", "=", "this", ".", "_keymap", "[", "n", "]", ";", "this", ".", "_broadcast", "(", "true", ",", "null", ",", "c", ",", "n", ",", "id", ")", ";", "this", ".", "_keycode", "=", "null", ";", "}", ",", "this", ")", ";", "}", "break", ";", "case", "\"keypress\"", ":", "if", "(", "this", ".", "_keycode", ")", "{", "c", "=", "this", ".", "_keychar", "(", "e", ".", "keyCode", ",", "e", ".", "charCode", ",", "e", ".", "which", ")", ";", "this", ".", "_keymap", "[", "this", ".", "_keycode", "]", "=", "c", ";", "}", "break", ";", "case", "\"keyup\"", ":", "if", "(", "c", "!==", "undefined", ")", "{", "this", ".", "_broadcast", "(", "false", ",", "null", ",", "c", ",", "n", ",", "id", ")", ";", "delete", "this", ".", "_keymap", "[", "n", "]", ";", "}", "break", ";", "}", "}" ]
Conan the Barbarian style events. At least they suck in a known way. @param {Event} e
[ "Conan", "the", "Barbarian", "style", "events", ".", "At", "least", "they", "suck", "in", "a", "known", "way", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L12660-L12699
49,525
wunderbyte/grunt-spiritual-dox
src/js/libs/spiritual-gui.js
function(e) { gui.Key.ctrlDown = e.ctrlKey; gui.Key.shiftDown = e.shiftKey; gui.Key.altDown = e.altKey; gui.Key.metaDown = e.metaKey; }
javascript
function(e) { gui.Key.ctrlDown = e.ctrlKey; gui.Key.shiftDown = e.shiftKey; gui.Key.altDown = e.altKey; gui.Key.metaDown = e.metaKey; }
[ "function", "(", "e", ")", "{", "gui", ".", "Key", ".", "ctrlDown", "=", "e", ".", "ctrlKey", ";", "gui", ".", "Key", ".", "shiftDown", "=", "e", ".", "shiftKey", ";", "gui", ".", "Key", ".", "altDown", "=", "e", ".", "altKey", ";", "gui", ".", "Key", ".", "metaDown", "=", "e", ".", "metaKey", ";", "}" ]
Update key modifiers state. @TODO Cross platform abstractions "accelDown" and "accessDown" @param {KeyEvent} e
[ "Update", "key", "modifiers", "state", "." ]
5afcfe31ddbf7d654166aa15b938553b61de5811
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/libs/spiritual-gui.js#L12738-L12743
49,526
bobtail-dev/bobtail-rx
dist/main.js
record
function record(f) { // TODO document why @refreshing exists // guards against recursively evaluating this recorded // function (@body or an async body) when calling `.get()` if (!_this10.refreshing) { var res = void 0; _this10.disconnect(); if (recorded) { throw new Error("this refresh has already recorded its dependencies"); } _this10.refreshing = true; recorded = true; try { res = recorder.record(_this10, function () { return f.call(env); }); } finally { _this10.refreshing = false; } if (isSynchronous) { realDone(syncResult); } return res; } }
javascript
function record(f) { // TODO document why @refreshing exists // guards against recursively evaluating this recorded // function (@body or an async body) when calling `.get()` if (!_this10.refreshing) { var res = void 0; _this10.disconnect(); if (recorded) { throw new Error("this refresh has already recorded its dependencies"); } _this10.refreshing = true; recorded = true; try { res = recorder.record(_this10, function () { return f.call(env); }); } finally { _this10.refreshing = false; } if (isSynchronous) { realDone(syncResult); } return res; } }
[ "function", "record", "(", "f", ")", "{", "// TODO document why @refreshing exists", "// guards against recursively evaluating this recorded", "// function (@body or an async body) when calling `.get()`", "if", "(", "!", "_this10", ".", "refreshing", ")", "{", "var", "res", "=", "void", "0", ";", "_this10", ".", "disconnect", "(", ")", ";", "if", "(", "recorded", ")", "{", "throw", "new", "Error", "(", "\"this refresh has already recorded its dependencies\"", ")", ";", "}", "_this10", ".", "refreshing", "=", "true", ";", "recorded", "=", "true", ";", "try", "{", "res", "=", "recorder", ".", "record", "(", "_this10", ",", "function", "(", ")", "{", "return", "f", ".", "call", "(", "env", ")", ";", "}", ")", ";", "}", "finally", "{", "_this10", ".", "refreshing", "=", "false", ";", "}", "if", "(", "isSynchronous", ")", "{", "realDone", "(", "syncResult", ")", ";", "}", "return", "res", ";", "}", "}" ]
next two are for tolerating env.done calls from within env.record
[ "next", "two", "are", "for", "tolerating", "env", ".", "done", "calls", "from", "within", "env", ".", "record" ]
b4b1491dac3bcae6cfeebcb07b42fa718833c126
https://github.com/bobtail-dev/bobtail-rx/blob/b4b1491dac3bcae6cfeebcb07b42fa718833c126/dist/main.js#L871-L895
49,527
dickhardt/node-a2p3
lib/a2p3.js
createAgentRequest
function createAgentRequest ( config, vault, params ) { if (!vault || !config || !params) throw new Error('"config", "vault", "params" are required) ') if (!params.returnURL && !params.callbackURL) throw new Error('params must have either "returnURL" or "callbackURL"') config = _init( config, vault ) var credentials = vault[ config.ix ].latest var details = { header: { typ: 'JWS' , alg: ALG_REQUEST } , payload: { 'iss': config.appID , 'aud': config.ix , 'iat': jwt.iat() , 'request.a2p3.org': { 'resources': params.resources || [] , 'auth': config.auth , 'ix': 'a2p3.net' } } , credentials: credentials } if ( params.returnURL ) details.payload['request.a2p3.org'].returnURL = params.returnURL else if ( params.callbackURL ) details.payload['request.a2p3.org'].callbackURL = params.callbackURL this.agentRequest = jwt.jws( details ) return this.agentRequest }
javascript
function createAgentRequest ( config, vault, params ) { if (!vault || !config || !params) throw new Error('"config", "vault", "params" are required) ') if (!params.returnURL && !params.callbackURL) throw new Error('params must have either "returnURL" or "callbackURL"') config = _init( config, vault ) var credentials = vault[ config.ix ].latest var details = { header: { typ: 'JWS' , alg: ALG_REQUEST } , payload: { 'iss': config.appID , 'aud': config.ix , 'iat': jwt.iat() , 'request.a2p3.org': { 'resources': params.resources || [] , 'auth': config.auth , 'ix': 'a2p3.net' } } , credentials: credentials } if ( params.returnURL ) details.payload['request.a2p3.org'].returnURL = params.returnURL else if ( params.callbackURL ) details.payload['request.a2p3.org'].callbackURL = params.callbackURL this.agentRequest = jwt.jws( details ) return this.agentRequest }
[ "function", "createAgentRequest", "(", "config", ",", "vault", ",", "params", ")", "{", "if", "(", "!", "vault", "||", "!", "config", "||", "!", "params", ")", "throw", "new", "Error", "(", "'\"config\", \"vault\", \"params\" are required) '", ")", "if", "(", "!", "params", ".", "returnURL", "&&", "!", "params", ".", "callbackURL", ")", "throw", "new", "Error", "(", "'params must have either \"returnURL\" or \"callbackURL\"'", ")", "config", "=", "_init", "(", "config", ",", "vault", ")", "var", "credentials", "=", "vault", "[", "config", ".", "ix", "]", ".", "latest", "var", "details", "=", "{", "header", ":", "{", "typ", ":", "'JWS'", ",", "alg", ":", "ALG_REQUEST", "}", ",", "payload", ":", "{", "'iss'", ":", "config", ".", "appID", ",", "'aud'", ":", "config", ".", "ix", ",", "'iat'", ":", "jwt", ".", "iat", "(", ")", ",", "'request.a2p3.org'", ":", "{", "'resources'", ":", "params", ".", "resources", "||", "[", "]", ",", "'auth'", ":", "config", ".", "auth", ",", "'ix'", ":", "'a2p3.net'", "}", "}", ",", "credentials", ":", "credentials", "}", "if", "(", "params", ".", "returnURL", ")", "details", ".", "payload", "[", "'request.a2p3.org'", "]", ".", "returnURL", "=", "params", ".", "returnURL", "else", "if", "(", "params", ".", "callbackURL", ")", "details", ".", "payload", "[", "'request.a2p3.org'", "]", ".", "callbackURL", "=", "params", ".", "callbackURL", "this", ".", "agentRequest", "=", "jwt", ".", "jws", "(", "details", ")", "return", "this", ".", "agentRequest", "}" ]
create an Agent Request
[ "create", "an", "Agent", "Request" ]
ca9dd8802d7ed2e90f6754bfced0ac9014c230a3
https://github.com/dickhardt/node-a2p3/blob/ca9dd8802d7ed2e90f6754bfced0ac9014c230a3/lib/a2p3.js#L63-L93
49,528
mcullenlewis/promise-maker
index.js
function(func, resolves = false){ if(typeof resolves !== 'boolean' && typeof resolves !== 'number' && resolves != 'all'){ throw new Error('Invalid value submitted for \'resolves\' argument.') } return function(){ return new Promise((resolve, reject)=>{ var params = [...arguments, function(...args){ //check for error hooks var error = false; for(let arg of args){ if(arg instanceof Error){ error = arg; break; } } if(error){ reject(error) }else{ switch(resolves){ case false: resolve(arguments.length == 1 ? arguments[0] : arguments[1]) break; case true: resolve(true) break; case 'all': resolve(args) break; default: resolve(args[resolve]) } } }] func.apply(null, params) }) } }
javascript
function(func, resolves = false){ if(typeof resolves !== 'boolean' && typeof resolves !== 'number' && resolves != 'all'){ throw new Error('Invalid value submitted for \'resolves\' argument.') } return function(){ return new Promise((resolve, reject)=>{ var params = [...arguments, function(...args){ //check for error hooks var error = false; for(let arg of args){ if(arg instanceof Error){ error = arg; break; } } if(error){ reject(error) }else{ switch(resolves){ case false: resolve(arguments.length == 1 ? arguments[0] : arguments[1]) break; case true: resolve(true) break; case 'all': resolve(args) break; default: resolve(args[resolve]) } } }] func.apply(null, params) }) } }
[ "function", "(", "func", ",", "resolves", "=", "false", ")", "{", "if", "(", "typeof", "resolves", "!==", "'boolean'", "&&", "typeof", "resolves", "!==", "'number'", "&&", "resolves", "!=", "'all'", ")", "{", "throw", "new", "Error", "(", "'Invalid value submitted for \\'resolves\\' argument.'", ")", "}", "return", "function", "(", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "var", "params", "=", "[", "...", "arguments", ",", "function", "(", "...", "args", ")", "{", "//check for error hooks", "var", "error", "=", "false", ";", "for", "(", "let", "arg", "of", "args", ")", "{", "if", "(", "arg", "instanceof", "Error", ")", "{", "error", "=", "arg", ";", "break", ";", "}", "}", "if", "(", "error", ")", "{", "reject", "(", "error", ")", "}", "else", "{", "switch", "(", "resolves", ")", "{", "case", "false", ":", "resolve", "(", "arguments", ".", "length", "==", "1", "?", "arguments", "[", "0", "]", ":", "arguments", "[", "1", "]", ")", "break", ";", "case", "true", ":", "resolve", "(", "true", ")", "break", ";", "case", "'all'", ":", "resolve", "(", "args", ")", "break", ";", "default", ":", "resolve", "(", "args", "[", "resolve", "]", ")", "}", "}", "}", "]", "func", ".", "apply", "(", "null", ",", "params", ")", "}", ")", "}", "}" ]
Return a promise-based version of a callback-based async method.
[ "Return", "a", "promise", "-", "based", "version", "of", "a", "callback", "-", "based", "async", "method", "." ]
ede012d28334cf79024d2b2d712b0b0d84ac7c81
https://github.com/mcullenlewis/promise-maker/blob/ede012d28334cf79024d2b2d712b0b0d84ac7c81/index.js#L4-L42
49,529
linyngfly/omelo-rpc
lib/rpc-client/client.js
function(opts) { opts = opts || {}; this._context = opts.context; this._routeContext = opts.routeContext; this.router = opts.router || router.df; this.routerType = opts.routerType; this.rpcDebugLog = opts.rpcDebugLog; if (this._context) { opts.clientId = this._context.serverId; } this.opts = opts; this.proxies = {}; this._station = createStation(opts); this.state = STATE_INITED; }
javascript
function(opts) { opts = opts || {}; this._context = opts.context; this._routeContext = opts.routeContext; this.router = opts.router || router.df; this.routerType = opts.routerType; this.rpcDebugLog = opts.rpcDebugLog; if (this._context) { opts.clientId = this._context.serverId; } this.opts = opts; this.proxies = {}; this._station = createStation(opts); this.state = STATE_INITED; }
[ "function", "(", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "this", ".", "_context", "=", "opts", ".", "context", ";", "this", ".", "_routeContext", "=", "opts", ".", "routeContext", ";", "this", ".", "router", "=", "opts", ".", "router", "||", "router", ".", "df", ";", "this", ".", "routerType", "=", "opts", ".", "routerType", ";", "this", ".", "rpcDebugLog", "=", "opts", ".", "rpcDebugLog", ";", "if", "(", "this", ".", "_context", ")", "{", "opts", ".", "clientId", "=", "this", ".", "_context", ".", "serverId", ";", "}", "this", ".", "opts", "=", "opts", ";", "this", ".", "proxies", "=", "{", "}", ";", "this", ".", "_station", "=", "createStation", "(", "opts", ")", ";", "this", ".", "state", "=", "STATE_INITED", ";", "}" ]
client has closed RPC Client Class
[ "client", "has", "closed", "RPC", "Client", "Class" ]
a8d64a4f098f1d174550f0f648d5ccc7716624b8
https://github.com/linyngfly/omelo-rpc/blob/a8d64a4f098f1d174550f0f648d5ccc7716624b8/lib/rpc-client/client.js#L22-L36
49,530
linyngfly/omelo-rpc
lib/rpc-client/client.js
function(client, serverType, msg, routeParam, cb) { if (!!client.routerType) { let method; switch (client.routerType) { case constants.SCHEDULE.ROUNDROBIN: method = router.rr; break; case constants.SCHEDULE.WEIGHT_ROUNDROBIN: method = router.wrr; break; case constants.SCHEDULE.LEAST_ACTIVE: method = router.la; break; case constants.SCHEDULE.CONSISTENT_HASH: method = router.ch; break; default: method = router.rd; break; } method.call(null, client, serverType, msg, function(err, serverId) { cb(err, serverId); }); } else { let route, target; if (typeof client.router === 'function') { route = client.router; target = null; } else if (typeof client.router.route === 'function') { route = client.router.route; target = client.router; } else { logger.error('[omelo-rpc] invalid route function.'); return; } route.call(target, routeParam, msg, client._routeContext, function(err, serverId) { cb(err, serverId); }); } }
javascript
function(client, serverType, msg, routeParam, cb) { if (!!client.routerType) { let method; switch (client.routerType) { case constants.SCHEDULE.ROUNDROBIN: method = router.rr; break; case constants.SCHEDULE.WEIGHT_ROUNDROBIN: method = router.wrr; break; case constants.SCHEDULE.LEAST_ACTIVE: method = router.la; break; case constants.SCHEDULE.CONSISTENT_HASH: method = router.ch; break; default: method = router.rd; break; } method.call(null, client, serverType, msg, function(err, serverId) { cb(err, serverId); }); } else { let route, target; if (typeof client.router === 'function') { route = client.router; target = null; } else if (typeof client.router.route === 'function') { route = client.router.route; target = client.router; } else { logger.error('[omelo-rpc] invalid route function.'); return; } route.call(target, routeParam, msg, client._routeContext, function(err, serverId) { cb(err, serverId); }); } }
[ "function", "(", "client", ",", "serverType", ",", "msg", ",", "routeParam", ",", "cb", ")", "{", "if", "(", "!", "!", "client", ".", "routerType", ")", "{", "let", "method", ";", "switch", "(", "client", ".", "routerType", ")", "{", "case", "constants", ".", "SCHEDULE", ".", "ROUNDROBIN", ":", "method", "=", "router", ".", "rr", ";", "break", ";", "case", "constants", ".", "SCHEDULE", ".", "WEIGHT_ROUNDROBIN", ":", "method", "=", "router", ".", "wrr", ";", "break", ";", "case", "constants", ".", "SCHEDULE", ".", "LEAST_ACTIVE", ":", "method", "=", "router", ".", "la", ";", "break", ";", "case", "constants", ".", "SCHEDULE", ".", "CONSISTENT_HASH", ":", "method", "=", "router", ".", "ch", ";", "break", ";", "default", ":", "method", "=", "router", ".", "rd", ";", "break", ";", "}", "method", ".", "call", "(", "null", ",", "client", ",", "serverType", ",", "msg", ",", "function", "(", "err", ",", "serverId", ")", "{", "cb", "(", "err", ",", "serverId", ")", ";", "}", ")", ";", "}", "else", "{", "let", "route", ",", "target", ";", "if", "(", "typeof", "client", ".", "router", "===", "'function'", ")", "{", "route", "=", "client", ".", "router", ";", "target", "=", "null", ";", "}", "else", "if", "(", "typeof", "client", ".", "router", ".", "route", "===", "'function'", ")", "{", "route", "=", "client", ".", "router", ".", "route", ";", "target", "=", "client", ".", "router", ";", "}", "else", "{", "logger", ".", "error", "(", "'[omelo-rpc] invalid route function.'", ")", ";", "return", ";", "}", "route", ".", "call", "(", "target", ",", "routeParam", ",", "msg", ",", "client", ".", "_routeContext", ",", "function", "(", "err", ",", "serverId", ")", "{", "cb", "(", "err", ",", "serverId", ")", ";", "}", ")", ";", "}", "}" ]
Calculate remote target server id for rpc client. @param client {Object} current client instance. @param serverType {String} remote server type. @param routeParam {Object} mailbox init context parameter. @param cb {Function} return rpc remote target server id. @api private
[ "Calculate", "remote", "target", "server", "id", "for", "rpc", "client", "." ]
a8d64a4f098f1d174550f0f648d5ccc7716624b8
https://github.com/linyngfly/omelo-rpc/blob/a8d64a4f098f1d174550f0f648d5ccc7716624b8/lib/rpc-client/client.js#L322-L361
49,531
linyngfly/omelo-rpc
lib/rpc-client/client.js
function(client, msg, serverType, serverId, cb) { if (typeof serverId !== 'string') { logger.error('[omelo-rpc] serverId is not a string : %s', serverId); return; } if (serverId === '*') { let servers = client._routeContext.getServersByType(serverType); if (!servers) { logger.error('[omelo-rpc] serverType %s servers not exist', serverType); return; } async.each(servers, function(server, next) { let serverId = server['id']; client.rpcInvoke(serverId, msg, function(err) { next(err); }); }, cb); } else { client.rpcInvoke(serverId, msg, cb); } }
javascript
function(client, msg, serverType, serverId, cb) { if (typeof serverId !== 'string') { logger.error('[omelo-rpc] serverId is not a string : %s', serverId); return; } if (serverId === '*') { let servers = client._routeContext.getServersByType(serverType); if (!servers) { logger.error('[omelo-rpc] serverType %s servers not exist', serverType); return; } async.each(servers, function(server, next) { let serverId = server['id']; client.rpcInvoke(serverId, msg, function(err) { next(err); }); }, cb); } else { client.rpcInvoke(serverId, msg, cb); } }
[ "function", "(", "client", ",", "msg", ",", "serverType", ",", "serverId", ",", "cb", ")", "{", "if", "(", "typeof", "serverId", "!==", "'string'", ")", "{", "logger", ".", "error", "(", "'[omelo-rpc] serverId is not a string : %s'", ",", "serverId", ")", ";", "return", ";", "}", "if", "(", "serverId", "===", "'*'", ")", "{", "let", "servers", "=", "client", ".", "_routeContext", ".", "getServersByType", "(", "serverType", ")", ";", "if", "(", "!", "servers", ")", "{", "logger", ".", "error", "(", "'[omelo-rpc] serverType %s servers not exist'", ",", "serverType", ")", ";", "return", ";", "}", "async", ".", "each", "(", "servers", ",", "function", "(", "server", ",", "next", ")", "{", "let", "serverId", "=", "server", "[", "'id'", "]", ";", "client", ".", "rpcInvoke", "(", "serverId", ",", "msg", ",", "function", "(", "err", ")", "{", "next", "(", "err", ")", ";", "}", ")", ";", "}", ",", "cb", ")", ";", "}", "else", "{", "client", ".", "rpcInvoke", "(", "serverId", ",", "msg", ",", "cb", ")", ";", "}", "}" ]
Rpc to specified server id or servers. @param client {Object} current client instance. @param msg {Object} rpc message. @param serverType {String} remote server type. @param serverId {Object} mailbox init context parameter. @api private
[ "Rpc", "to", "specified", "server", "id", "or", "servers", "." ]
a8d64a4f098f1d174550f0f648d5ccc7716624b8
https://github.com/linyngfly/omelo-rpc/blob/a8d64a4f098f1d174550f0f648d5ccc7716624b8/lib/rpc-client/client.js#L373-L394
49,532
ALDLife/outcome-graph
src/sessionsConverter.js
getValuesMapsFromOutcomes
function getValuesMapsFromOutcomes(outcomes) { var dataMap = {}; var noteMap = {}; // add each outcome to a set outcomes.forEach(function outcomeIterator(outcome) { var lowerCaseLabel = updateLabels(outcome.outcome); dataMap[lowerCaseLabel] = outcome.value; noteMap[lowerCaseLabel] = outcome.notes; }); return { data: dataMap, notes: noteMap }; }
javascript
function getValuesMapsFromOutcomes(outcomes) { var dataMap = {}; var noteMap = {}; // add each outcome to a set outcomes.forEach(function outcomeIterator(outcome) { var lowerCaseLabel = updateLabels(outcome.outcome); dataMap[lowerCaseLabel] = outcome.value; noteMap[lowerCaseLabel] = outcome.notes; }); return { data: dataMap, notes: noteMap }; }
[ "function", "getValuesMapsFromOutcomes", "(", "outcomes", ")", "{", "var", "dataMap", "=", "{", "}", ";", "var", "noteMap", "=", "{", "}", ";", "// add each outcome to a set", "outcomes", ".", "forEach", "(", "function", "outcomeIterator", "(", "outcome", ")", "{", "var", "lowerCaseLabel", "=", "updateLabels", "(", "outcome", ".", "outcome", ")", ";", "dataMap", "[", "lowerCaseLabel", "]", "=", "outcome", ".", "value", ";", "noteMap", "[", "lowerCaseLabel", "]", "=", "outcome", ".", "notes", ";", "}", ")", ";", "return", "{", "data", ":", "dataMap", ",", "notes", ":", "noteMap", "}", ";", "}" ]
this creates a mapping of the data value as well as notes for each label to be later used to create the ChartJS data array
[ "this", "creates", "a", "mapping", "of", "the", "data", "value", "as", "well", "as", "notes", "for", "each", "label", "to", "be", "later", "used", "to", "create", "the", "ChartJS", "data", "array" ]
5f96227208777b2a9d31a79f13dc4fc585583746
https://github.com/ALDLife/outcome-graph/blob/5f96227208777b2a9d31a79f13dc4fc585583746/src/sessionsConverter.js#L61-L74
49,533
ALDLife/outcome-graph
src/sessionsConverter.js
updateLabels
function updateLabels(potentialLabel) { var lowerCaseLabel = potentialLabel.toLowerCase(); if (!labelSet.hasOwnProperty(lowerCaseLabel)) { labels.push(potentialLabel); // now value is in our set labelSet[lowerCaseLabel] = true; } return lowerCaseLabel; }
javascript
function updateLabels(potentialLabel) { var lowerCaseLabel = potentialLabel.toLowerCase(); if (!labelSet.hasOwnProperty(lowerCaseLabel)) { labels.push(potentialLabel); // now value is in our set labelSet[lowerCaseLabel] = true; } return lowerCaseLabel; }
[ "function", "updateLabels", "(", "potentialLabel", ")", "{", "var", "lowerCaseLabel", "=", "potentialLabel", ".", "toLowerCase", "(", ")", ";", "if", "(", "!", "labelSet", ".", "hasOwnProperty", "(", "lowerCaseLabel", ")", ")", "{", "labels", ".", "push", "(", "potentialLabel", ")", ";", "// now value is in our set", "labelSet", "[", "lowerCaseLabel", "]", "=", "true", ";", "}", "return", "lowerCaseLabel", ";", "}" ]
check if our set has the value or not
[ "check", "if", "our", "set", "has", "the", "value", "or", "not" ]
5f96227208777b2a9d31a79f13dc4fc585583746
https://github.com/ALDLife/outcome-graph/blob/5f96227208777b2a9d31a79f13dc4fc585583746/src/sessionsConverter.js#L77-L85
49,534
ALDLife/outcome-graph
src/sessionsConverter.js
getExtractedDataAndTooltipNotes
function getExtractedDataAndTooltipNotes(valuesMap) { // go over currently added labels var data = []; var notes = []; labels.forEach(function labelIterator(label) { data.push(getExtractedDataValue(valuesMap.data[label.toLowerCase()])); notes.push(getExtractedNoteValue(valuesMap.notes[label.toLowerCase()])); }); return { data: data, notes: notes }; }
javascript
function getExtractedDataAndTooltipNotes(valuesMap) { // go over currently added labels var data = []; var notes = []; labels.forEach(function labelIterator(label) { data.push(getExtractedDataValue(valuesMap.data[label.toLowerCase()])); notes.push(getExtractedNoteValue(valuesMap.notes[label.toLowerCase()])); }); return { data: data, notes: notes }; }
[ "function", "getExtractedDataAndTooltipNotes", "(", "valuesMap", ")", "{", "// go over currently added labels", "var", "data", "=", "[", "]", ";", "var", "notes", "=", "[", "]", ";", "labels", ".", "forEach", "(", "function", "labelIterator", "(", "label", ")", "{", "data", ".", "push", "(", "getExtractedDataValue", "(", "valuesMap", ".", "data", "[", "label", ".", "toLowerCase", "(", ")", "]", ")", ")", ";", "notes", ".", "push", "(", "getExtractedNoteValue", "(", "valuesMap", ".", "notes", "[", "label", ".", "toLowerCase", "(", ")", "]", ")", ")", ";", "}", ")", ";", "return", "{", "data", ":", "data", ",", "notes", ":", "notes", "}", ";", "}" ]
Use values map to create the data and notes arrays confroming to ChartJS requirements.
[ "Use", "values", "map", "to", "create", "the", "data", "and", "notes", "arrays", "confroming", "to", "ChartJS", "requirements", "." ]
5f96227208777b2a9d31a79f13dc4fc585583746
https://github.com/ALDLife/outcome-graph/blob/5f96227208777b2a9d31a79f13dc4fc585583746/src/sessionsConverter.js#L89-L101
49,535
redisjs/jsr-server
lib/scanner.js
Scanner
function Scanner(target, cursor, pattern, count, map, stringify) { this.target = target; this.cursor = cursor; this.pattern = pattern; this.count = count || 10; this.map = map; this.stringify = stringify; // clamp the count this.count = Math.max(this.count, 10); this.count = Math.min(this.count, 1000); }
javascript
function Scanner(target, cursor, pattern, count, map, stringify) { this.target = target; this.cursor = cursor; this.pattern = pattern; this.count = count || 10; this.map = map; this.stringify = stringify; // clamp the count this.count = Math.max(this.count, 10); this.count = Math.min(this.count, 1000); }
[ "function", "Scanner", "(", "target", ",", "cursor", ",", "pattern", ",", "count", ",", "map", ",", "stringify", ")", "{", "this", ".", "target", "=", "target", ";", "this", ".", "cursor", "=", "cursor", ";", "this", ".", "pattern", "=", "pattern", ";", "this", ".", "count", "=", "count", "||", "10", ";", "this", ".", "map", "=", "map", ";", "this", ".", "stringify", "=", "stringify", ";", "// clamp the count", "this", ".", "count", "=", "Math", ".", "max", "(", "this", ".", "count", ",", "10", ")", ";", "this", ".", "count", "=", "Math", ".", "min", "(", "this", ".", "count", ",", "1000", ")", ";", "}" ]
Encapsulates the scan logic. @param target The target array of keys. @param cursor The user-supplied cursor position. @param pattern A regular expression pattern if match was specified. @param count A user-specified count option. @param map An object used to lookup values (hscan and zscan). @param stringify Convert map values to strings (zscan).
[ "Encapsulates", "the", "scan", "logic", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/scanner.js#L11-L22
49,536
redisjs/jsr-server
lib/scanner.js
scan
function scan(req, res) { var records = [] , position , i , key , inc , map = this.map , len = this.cursor + this.count; for(i = this.cursor; i < len;i++) { if(i === this.target.length) { position = 0; break; } key = '' + this.target[i]; inc = !this.pattern || (this.pattern && this.pattern.test(key)); if(inc) { records.push(key); if(map) records.push(this.stringify ? '' + map[key] : map[key]); } position = i + 1; } res.send(null, [position, records]); }
javascript
function scan(req, res) { var records = [] , position , i , key , inc , map = this.map , len = this.cursor + this.count; for(i = this.cursor; i < len;i++) { if(i === this.target.length) { position = 0; break; } key = '' + this.target[i]; inc = !this.pattern || (this.pattern && this.pattern.test(key)); if(inc) { records.push(key); if(map) records.push(this.stringify ? '' + map[key] : map[key]); } position = i + 1; } res.send(null, [position, records]); }
[ "function", "scan", "(", "req", ",", "res", ")", "{", "var", "records", "=", "[", "]", ",", "position", ",", "i", ",", "key", ",", "inc", ",", "map", "=", "this", ".", "map", ",", "len", "=", "this", ".", "cursor", "+", "this", ".", "count", ";", "for", "(", "i", "=", "this", ".", "cursor", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "i", "===", "this", ".", "target", ".", "length", ")", "{", "position", "=", "0", ";", "break", ";", "}", "key", "=", "''", "+", "this", ".", "target", "[", "i", "]", ";", "inc", "=", "!", "this", ".", "pattern", "||", "(", "this", ".", "pattern", "&&", "this", ".", "pattern", ".", "test", "(", "key", ")", ")", ";", "if", "(", "inc", ")", "{", "records", ".", "push", "(", "key", ")", ";", "if", "(", "map", ")", "records", ".", "push", "(", "this", ".", "stringify", "?", "''", "+", "map", "[", "key", "]", ":", "map", "[", "key", "]", ")", ";", "}", "position", "=", "i", "+", "1", ";", "}", "res", ".", "send", "(", "null", ",", "[", "position", ",", "records", "]", ")", ";", "}" ]
Perform the scan and send the response to the client.
[ "Perform", "the", "scan", "and", "send", "the", "response", "to", "the", "client", "." ]
49413052d3039524fbdd2ade0ef9bae26cb4d647
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/scanner.js#L27-L51
49,537
admoexperience/generator-admo
templates/scripts/libs/framework.js
function(message) { if (this.sendData % 200 == 0){ console.log("Kinect data being sent from kinect"); console.log(message); } this.sendData = this.sendData +1; if (true) { //Set the kinect data to the raw values from the kinect for(var key in message){ KinectState[key] = message[key]; } if (this.currentState == 1){ //We don't have any person data yet. }else if (this.currentState == 2){ var h = KinectState.head; User.updateObj(User.head,h.x,h.y,h.z, h.xmm, h.ymm); } else if (this.currentState == 3) { var h = KinectState.head; var l = KinectState.leftHand; var r = KinectState.rightHand; var el = KinectState.leftElbow; var er = KinectState.rightElbow; User.updateObj(User.head,h.x,h.y,h.z, h.xmm, h.ymm); User.updateObj(User.hands.left, l.x,l.y,l.z, l.xmm, l.ymm); User.updateObj(User.hands.right, r.x,r.y,r.z, r.xmm, r.ymm); User.updateObj(User.elbows.left, el.x, el.y, el.z, el.xmm, el.ymm); User.updateObj(User.elbows.right, er.x, er.y, er.z, er.xmm, er.ymm); } //Tell the app the state has changed this.setState(KinectState.phase); } }
javascript
function(message) { if (this.sendData % 200 == 0){ console.log("Kinect data being sent from kinect"); console.log(message); } this.sendData = this.sendData +1; if (true) { //Set the kinect data to the raw values from the kinect for(var key in message){ KinectState[key] = message[key]; } if (this.currentState == 1){ //We don't have any person data yet. }else if (this.currentState == 2){ var h = KinectState.head; User.updateObj(User.head,h.x,h.y,h.z, h.xmm, h.ymm); } else if (this.currentState == 3) { var h = KinectState.head; var l = KinectState.leftHand; var r = KinectState.rightHand; var el = KinectState.leftElbow; var er = KinectState.rightElbow; User.updateObj(User.head,h.x,h.y,h.z, h.xmm, h.ymm); User.updateObj(User.hands.left, l.x,l.y,l.z, l.xmm, l.ymm); User.updateObj(User.hands.right, r.x,r.y,r.z, r.xmm, r.ymm); User.updateObj(User.elbows.left, el.x, el.y, el.z, el.xmm, el.ymm); User.updateObj(User.elbows.right, er.x, er.y, er.z, er.xmm, er.ymm); } //Tell the app the state has changed this.setState(KinectState.phase); } }
[ "function", "(", "message", ")", "{", "if", "(", "this", ".", "sendData", "%", "200", "==", "0", ")", "{", "console", ".", "log", "(", "\"Kinect data being sent from kinect\"", ")", ";", "console", ".", "log", "(", "message", ")", ";", "}", "this", ".", "sendData", "=", "this", ".", "sendData", "+", "1", ";", "if", "(", "true", ")", "{", "//Set the kinect data to the raw values from the kinect", "for", "(", "var", "key", "in", "message", ")", "{", "KinectState", "[", "key", "]", "=", "message", "[", "key", "]", ";", "}", "if", "(", "this", ".", "currentState", "==", "1", ")", "{", "//We don't have any person data yet.", "}", "else", "if", "(", "this", ".", "currentState", "==", "2", ")", "{", "var", "h", "=", "KinectState", ".", "head", ";", "User", ".", "updateObj", "(", "User", ".", "head", ",", "h", ".", "x", ",", "h", ".", "y", ",", "h", ".", "z", ",", "h", ".", "xmm", ",", "h", ".", "ymm", ")", ";", "}", "else", "if", "(", "this", ".", "currentState", "==", "3", ")", "{", "var", "h", "=", "KinectState", ".", "head", ";", "var", "l", "=", "KinectState", ".", "leftHand", ";", "var", "r", "=", "KinectState", ".", "rightHand", ";", "var", "el", "=", "KinectState", ".", "leftElbow", ";", "var", "er", "=", "KinectState", ".", "rightElbow", ";", "User", ".", "updateObj", "(", "User", ".", "head", ",", "h", ".", "x", ",", "h", ".", "y", ",", "h", ".", "z", ",", "h", ".", "xmm", ",", "h", ".", "ymm", ")", ";", "User", ".", "updateObj", "(", "User", ".", "hands", ".", "left", ",", "l", ".", "x", ",", "l", ".", "y", ",", "l", ".", "z", ",", "l", ".", "xmm", ",", "l", ".", "ymm", ")", ";", "User", ".", "updateObj", "(", "User", ".", "hands", ".", "right", ",", "r", ".", "x", ",", "r", ".", "y", ",", "r", ".", "z", ",", "r", ".", "xmm", ",", "r", ".", "ymm", ")", ";", "User", ".", "updateObj", "(", "User", ".", "elbows", ".", "left", ",", "el", ".", "x", ",", "el", ".", "y", ",", "el", ".", "z", ",", "el", ".", "xmm", ",", "el", ".", "ymm", ")", ";", "User", ".", "updateObj", "(", "User", ".", "elbows", ".", "right", ",", "er", ".", "x", ",", "er", ".", "y", ",", "er", ".", "z", ",", "er", ".", "xmm", ",", "er", ".", "ymm", ")", ";", "}", "//Tell the app the state has changed", "this", ".", "setState", "(", "KinectState", ".", "phase", ")", ";", "}", "}" ]
handles WS message
[ "handles", "WS", "message" ]
f27e261990948860e14f735f3cd7c59bf1130feb
https://github.com/admoexperience/generator-admo/blob/f27e261990948860e14f735f3cd7c59bf1130feb/templates/scripts/libs/framework.js#L86-L122
49,538
hbouvier/node-tagger
lib/util/api.js
lex
function lex(phrase) { var words = phrase && typeof(phrase) === 'string' ? lexer.lex(phrase) : {status:"Invalid phrase parameter"}; logger.log('verbose', '%s|lex|phrase=%s|words=%j', meta.module, phrase, words, meta); return words; }
javascript
function lex(phrase) { var words = phrase && typeof(phrase) === 'string' ? lexer.lex(phrase) : {status:"Invalid phrase parameter"}; logger.log('verbose', '%s|lex|phrase=%s|words=%j', meta.module, phrase, words, meta); return words; }
[ "function", "lex", "(", "phrase", ")", "{", "var", "words", "=", "phrase", "&&", "typeof", "(", "phrase", ")", "===", "'string'", "?", "lexer", ".", "lex", "(", "phrase", ")", ":", "{", "status", ":", "\"Invalid phrase parameter\"", "}", ";", "logger", ".", "log", "(", "'verbose'", ",", "'%s|lex|phrase=%s|words=%j'", ",", "meta", ".", "module", ",", "phrase", ",", "words", ",", "meta", ")", ";", "return", "words", ";", "}" ]
Split a phrase into words @param phrase: A string @return an array of words
[ "Split", "a", "phrase", "into", "words" ]
51a6a9b6158e83cbbc4d3d4f10fde19ac796510b
https://github.com/hbouvier/node-tagger/blob/51a6a9b6158e83cbbc4d3d4f10fde19ac796510b/lib/util/api.js#L27-L31
49,539
hbouvier/node-tagger
lib/util/api.js
tag
function tag(words) { var taggedWords = (words && typeof(words) === 'string') ? tagger.tag(lexer.lex(words)) : (words && typeof(words) === 'object') ? tagger.tag(words) : {status:"Invalid words parameter"}; logger.log('verbose', '%s|tag|words=%j|tags=%j', meta.module, words, taggedWords, meta); return taggedWords; }
javascript
function tag(words) { var taggedWords = (words && typeof(words) === 'string') ? tagger.tag(lexer.lex(words)) : (words && typeof(words) === 'object') ? tagger.tag(words) : {status:"Invalid words parameter"}; logger.log('verbose', '%s|tag|words=%j|tags=%j', meta.module, words, taggedWords, meta); return taggedWords; }
[ "function", "tag", "(", "words", ")", "{", "var", "taggedWords", "=", "(", "words", "&&", "typeof", "(", "words", ")", "===", "'string'", ")", "?", "tagger", ".", "tag", "(", "lexer", ".", "lex", "(", "words", ")", ")", ":", "(", "words", "&&", "typeof", "(", "words", ")", "===", "'object'", ")", "?", "tagger", ".", "tag", "(", "words", ")", ":", "{", "status", ":", "\"Invalid words parameter\"", "}", ";", "logger", ".", "log", "(", "'verbose'", ",", "'%s|tag|words=%j|tags=%j'", ",", "meta", ".", "module", ",", "words", ",", "taggedWords", ",", "meta", ")", ";", "return", "taggedWords", ";", "}" ]
Tag each words in an array of words @param words: (string): run the lexer first, then the tagger. (array): run the tagger directly @return an array of array of words with their tags
[ "Tag", "each", "words", "in", "an", "array", "of", "words" ]
51a6a9b6158e83cbbc4d3d4f10fde19ac796510b
https://github.com/hbouvier/node-tagger/blob/51a6a9b6158e83cbbc4d3d4f10fde19ac796510b/lib/util/api.js#L40-L44
49,540
uupaa/Watch.js
lib/Watch.js
Sort_nat
function Sort_nat(source, // @arg StringArray - source. ["abc100", "abc1", "abc10"] ignoreCase) { // @arg Boolean = false - true is case-insensitive // @ret StringArray - sorted array. ["abc1", "abc10", "abc100"] // @desc nat sort //{@dev _if(!Array.isArray(source), "Sort.nat(source)"); _if(ignoreCase !== undefined && typeof ignoreCase !== "boolean", "Sort.nat(,ignoreCase)"); //}@dev function toNumberArray(str) { return str.split(/(\d+)/).reduce(function(prev, next) { if (next !== "") { if (isNaN(next)) { next.split("").forEach(function(v) { prev.push( v.charCodeAt(0) ); }); } else { prev.push(+next); } } return prev; }, []); } var cache = {}; // { keyword: [number, ...], ... } return source.sort(function(a, b) { var aa, bb; if (a in cache) { aa = cache[a]; } else { cache[a] = aa = toNumberArray( ignoreCase ? a.toLowerCase() : a ); } if (b in cache) { bb = cache[b]; } else { cache[b] = bb = toNumberArray( ignoreCase ? b.toLowerCase() : b ); } var x = 0, y = 0, i = 0, iz = aa.length; for (; i < iz; ++i) { x = aa[i] || 0; y = bb[i] || 0; if (x !== y) { return x - y; } } return a.length - b.length; }); }
javascript
function Sort_nat(source, // @arg StringArray - source. ["abc100", "abc1", "abc10"] ignoreCase) { // @arg Boolean = false - true is case-insensitive // @ret StringArray - sorted array. ["abc1", "abc10", "abc100"] // @desc nat sort //{@dev _if(!Array.isArray(source), "Sort.nat(source)"); _if(ignoreCase !== undefined && typeof ignoreCase !== "boolean", "Sort.nat(,ignoreCase)"); //}@dev function toNumberArray(str) { return str.split(/(\d+)/).reduce(function(prev, next) { if (next !== "") { if (isNaN(next)) { next.split("").forEach(function(v) { prev.push( v.charCodeAt(0) ); }); } else { prev.push(+next); } } return prev; }, []); } var cache = {}; // { keyword: [number, ...], ... } return source.sort(function(a, b) { var aa, bb; if (a in cache) { aa = cache[a]; } else { cache[a] = aa = toNumberArray( ignoreCase ? a.toLowerCase() : a ); } if (b in cache) { bb = cache[b]; } else { cache[b] = bb = toNumberArray( ignoreCase ? b.toLowerCase() : b ); } var x = 0, y = 0, i = 0, iz = aa.length; for (; i < iz; ++i) { x = aa[i] || 0; y = bb[i] || 0; if (x !== y) { return x - y; } } return a.length - b.length; }); }
[ "function", "Sort_nat", "(", "source", ",", "// @arg StringArray - source. [\"abc100\", \"abc1\", \"abc10\"]", "ignoreCase", ")", "{", "// @arg Boolean = false - true is case-insensitive", "// @ret StringArray - sorted array. [\"abc1\", \"abc10\", \"abc100\"]", "// @desc nat sort", "//{@dev", "_if", "(", "!", "Array", ".", "isArray", "(", "source", ")", ",", "\"Sort.nat(source)\"", ")", ";", "_if", "(", "ignoreCase", "!==", "undefined", "&&", "typeof", "ignoreCase", "!==", "\"boolean\"", ",", "\"Sort.nat(,ignoreCase)\"", ")", ";", "//}@dev", "function", "toNumberArray", "(", "str", ")", "{", "return", "str", ".", "split", "(", "/", "(\\d+)", "/", ")", ".", "reduce", "(", "function", "(", "prev", ",", "next", ")", "{", "if", "(", "next", "!==", "\"\"", ")", "{", "if", "(", "isNaN", "(", "next", ")", ")", "{", "next", ".", "split", "(", "\"\"", ")", ".", "forEach", "(", "function", "(", "v", ")", "{", "prev", ".", "push", "(", "v", ".", "charCodeAt", "(", "0", ")", ")", ";", "}", ")", ";", "}", "else", "{", "prev", ".", "push", "(", "+", "next", ")", ";", "}", "}", "return", "prev", ";", "}", ",", "[", "]", ")", ";", "}", "var", "cache", "=", "{", "}", ";", "// { keyword: [number, ...], ... }", "return", "source", ".", "sort", "(", "function", "(", "a", ",", "b", ")", "{", "var", "aa", ",", "bb", ";", "if", "(", "a", "in", "cache", ")", "{", "aa", "=", "cache", "[", "a", "]", ";", "}", "else", "{", "cache", "[", "a", "]", "=", "aa", "=", "toNumberArray", "(", "ignoreCase", "?", "a", ".", "toLowerCase", "(", ")", ":", "a", ")", ";", "}", "if", "(", "b", "in", "cache", ")", "{", "bb", "=", "cache", "[", "b", "]", ";", "}", "else", "{", "cache", "[", "b", "]", "=", "bb", "=", "toNumberArray", "(", "ignoreCase", "?", "b", ".", "toLowerCase", "(", ")", ":", "b", ")", ";", "}", "var", "x", "=", "0", ",", "y", "=", "0", ",", "i", "=", "0", ",", "iz", "=", "aa", ".", "length", ";", "for", "(", ";", "i", "<", "iz", ";", "++", "i", ")", "{", "x", "=", "aa", "[", "i", "]", "||", "0", ";", "y", "=", "bb", "[", "i", "]", "||", "0", ";", "if", "(", "x", "!==", "y", ")", "{", "return", "x", "-", "y", ";", "}", "}", "return", "a", ".", "length", "-", "b", ".", "length", ";", "}", ")", ";", "}" ]
copy from Sort.js
[ "copy", "from", "Sort", ".", "js" ]
5c8c4d30de6ae4feb20f091c8ccfaedb39bd9c12
https://github.com/uupaa/Watch.js/blob/5c8c4d30de6ae4feb20f091c8ccfaedb39bd9c12/lib/Watch.js#L232-L283
49,541
tolokoban/ToloFrameWork
lib/compiler-html2.js
lookForExternalDependenciesRES
function lookForExternalDependenciesRES( _def, resources, depFile ) { if ( !_def ) return; try { const def = convertExternalDependencyDefinition( _def ); for ( const dep of Object.keys( def ) ) { if ( def[ dep ] === "" ) { // `res: { "bob/foo.png": "" }` is equivalent to // `res: { "bob/foo.png": "bob/foo.png" }` def[ dep ] = dep; } const srcDep = Project.srcOrLibPath( `mod/${dep}` ) || Project.srcOrLibPath( dep ); if ( !srcDep ) { Fatal.fire( `Unable to find dependency file "${dep}" nor "mod/${dep}"!`, depFile.getAbsoluteFilePath() ); } resources[ srcDep ] = Project.wwwPath( def[ dep ] ); } } catch ( ex ) { Fatal.fire( `Unable to parse RES dependencies: ${JSON.stringify(_def)}!\n${ex}`, depFile ); } }
javascript
function lookForExternalDependenciesRES( _def, resources, depFile ) { if ( !_def ) return; try { const def = convertExternalDependencyDefinition( _def ); for ( const dep of Object.keys( def ) ) { if ( def[ dep ] === "" ) { // `res: { "bob/foo.png": "" }` is equivalent to // `res: { "bob/foo.png": "bob/foo.png" }` def[ dep ] = dep; } const srcDep = Project.srcOrLibPath( `mod/${dep}` ) || Project.srcOrLibPath( dep ); if ( !srcDep ) { Fatal.fire( `Unable to find dependency file "${dep}" nor "mod/${dep}"!`, depFile.getAbsoluteFilePath() ); } resources[ srcDep ] = Project.wwwPath( def[ dep ] ); } } catch ( ex ) { Fatal.fire( `Unable to parse RES dependencies: ${JSON.stringify(_def)}!\n${ex}`, depFile ); } }
[ "function", "lookForExternalDependenciesRES", "(", "_def", ",", "resources", ",", "depFile", ")", "{", "if", "(", "!", "_def", ")", "return", ";", "try", "{", "const", "def", "=", "convertExternalDependencyDefinition", "(", "_def", ")", ";", "for", "(", "const", "dep", "of", "Object", ".", "keys", "(", "def", ")", ")", "{", "if", "(", "def", "[", "dep", "]", "===", "\"\"", ")", "{", "// `res: { \"bob/foo.png\": \"\" }` is equivalent to", "// `res: { \"bob/foo.png\": \"bob/foo.png\" }`", "def", "[", "dep", "]", "=", "dep", ";", "}", "const", "srcDep", "=", "Project", ".", "srcOrLibPath", "(", "`", "${", "dep", "}", "`", ")", "||", "Project", ".", "srcOrLibPath", "(", "dep", ")", ";", "if", "(", "!", "srcDep", ")", "{", "Fatal", ".", "fire", "(", "`", "${", "dep", "}", "${", "dep", "}", "`", ",", "depFile", ".", "getAbsoluteFilePath", "(", ")", ")", ";", "}", "resources", "[", "srcDep", "]", "=", "Project", ".", "wwwPath", "(", "def", "[", "dep", "]", ")", ";", "}", "}", "catch", "(", "ex", ")", "{", "Fatal", ".", "fire", "(", "`", "${", "JSON", ".", "stringify", "(", "_def", ")", "}", "\\n", "${", "ex", "}", "`", ",", "depFile", ")", ";", "}", "}" ]
Section "res" in a dependency file. @param {objects} _def - `{ "bob/foo.png": "", "yo/man.kml": "maps/man.kml" }` @param {object} resources - @param {Source} depFile - Source of the dependency file. @returns {undefined}
[ "Section", "res", "in", "a", "dependency", "file", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/compiler-html2.js#L440-L467
49,542
tolokoban/ToloFrameWork
lib/compiler-html2.js
lookForExternalDependenciesJS
function lookForExternalDependenciesJS( _def, javascriptSources ) { if ( !_def ) return; try { const def = convertExternalDependencyDefinition( _def ); Object.keys( def ).forEach( function ( js ) { const filename = `mod/${js}`, src = new Source( Project, filename ), code = src.read(); pushUnique( javascriptSources, code ); } ); } catch ( ex ) { Fatal.fire( `Unable to parse JS dependencies: ${JSON.stringify(_def)}!\n${ex}`, javascriptSources ); } }
javascript
function lookForExternalDependenciesJS( _def, javascriptSources ) { if ( !_def ) return; try { const def = convertExternalDependencyDefinition( _def ); Object.keys( def ).forEach( function ( js ) { const filename = `mod/${js}`, src = new Source( Project, filename ), code = src.read(); pushUnique( javascriptSources, code ); } ); } catch ( ex ) { Fatal.fire( `Unable to parse JS dependencies: ${JSON.stringify(_def)}!\n${ex}`, javascriptSources ); } }
[ "function", "lookForExternalDependenciesJS", "(", "_def", ",", "javascriptSources", ")", "{", "if", "(", "!", "_def", ")", "return", ";", "try", "{", "const", "def", "=", "convertExternalDependencyDefinition", "(", "_def", ")", ";", "Object", ".", "keys", "(", "def", ")", ".", "forEach", "(", "function", "(", "js", ")", "{", "const", "filename", "=", "`", "${", "js", "}", "`", ",", "src", "=", "new", "Source", "(", "Project", ",", "filename", ")", ",", "code", "=", "src", ".", "read", "(", ")", ";", "pushUnique", "(", "javascriptSources", ",", "code", ")", ";", "}", ")", ";", "}", "catch", "(", "ex", ")", "{", "Fatal", ".", "fire", "(", "`", "${", "JSON", ".", "stringify", "(", "_def", ")", "}", "\\n", "${", "ex", "}", "`", ",", "javascriptSources", ")", ";", "}", "}" ]
Section "js" in a dependency file. @param {objects} _def - `{ "helper.js": "" }` or `"helper.js"`. @param {array} javascriptSources - Array of the Javascript code to include in current HTML page. @returns {undefined}
[ "Section", "js", "in", "a", "dependency", "file", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/compiler-html2.js#L476-L493
49,543
tolokoban/ToloFrameWork
lib/compiler-html2.js
pushUnique
function pushUnique( arr, item ) { if ( arr.indexOf( item ) > -1 ) return false; arr.push( item ); return true; }
javascript
function pushUnique( arr, item ) { if ( arr.indexOf( item ) > -1 ) return false; arr.push( item ); return true; }
[ "function", "pushUnique", "(", "arr", ",", "item", ")", "{", "if", "(", "arr", ".", "indexOf", "(", "item", ")", ">", "-", "1", ")", "return", "false", ";", "arr", ".", "push", "(", "item", ")", ";", "return", "true", ";", "}" ]
Push `item` into `arr` if it is not already in.
[ "Push", "item", "into", "arr", "if", "it", "is", "not", "already", "in", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/compiler-html2.js#L524-L528
49,544
tolokoban/ToloFrameWork
lib/compiler-html2.js
addFilePrefix
function addFilePrefix( path, prefix ) { if ( typeof prefix === 'undefined' ) prefix = '@'; var separatorPosition = path.lastIndexOf( '/' ); if ( separatorPosition < 0 ) { // Let's try with Windows separators. separatorPosition = path.lastIndexOf( '\\' ); } var filenameStart = separatorPosition > -1 ? separatorPosition + 1 : 0; var result = path.substr( 0, filenameStart ) + prefix + path.substr( filenameStart ); return result.replace( /\\/g, '/' ); }
javascript
function addFilePrefix( path, prefix ) { if ( typeof prefix === 'undefined' ) prefix = '@'; var separatorPosition = path.lastIndexOf( '/' ); if ( separatorPosition < 0 ) { // Let's try with Windows separators. separatorPosition = path.lastIndexOf( '\\' ); } var filenameStart = separatorPosition > -1 ? separatorPosition + 1 : 0; var result = path.substr( 0, filenameStart ) + prefix + path.substr( filenameStart ); return result.replace( /\\/g, '/' ); }
[ "function", "addFilePrefix", "(", "path", ",", "prefix", ")", "{", "if", "(", "typeof", "prefix", "===", "'undefined'", ")", "prefix", "=", "'@'", ";", "var", "separatorPosition", "=", "path", ".", "lastIndexOf", "(", "'/'", ")", ";", "if", "(", "separatorPosition", "<", "0", ")", "{", "// Let's try with Windows separators.", "separatorPosition", "=", "path", ".", "lastIndexOf", "(", "'\\\\'", ")", ";", "}", "var", "filenameStart", "=", "separatorPosition", ">", "-", "1", "?", "separatorPosition", "+", "1", ":", "0", ";", "var", "result", "=", "path", ".", "substr", "(", "0", ",", "filenameStart", ")", "+", "prefix", "+", "path", ".", "substr", "(", "filenameStart", ")", ";", "return", "result", ".", "replace", "(", "/", "\\\\", "/", "g", ",", "'/'", ")", ";", "}" ]
Add a prefix to a filename. This is not as simple as prepending the `prefix` to the string `path`, because `path` can contain folders' separators. The prefix must be prepended to the real file name and not to the whole path. Examples with `prefix` == "@": * `foobar.html`: `@foobar.html` * `myfolder/myfile.js`: `myfolder/@myfile.js`
[ "Add", "a", "prefix", "to", "a", "filename", ".", "This", "is", "not", "as", "simple", "as", "prepending", "the", "prefix", "to", "the", "string", "path", "because", "path", "can", "contain", "folders", "separators", ".", "The", "prefix", "must", "be", "prepended", "to", "the", "real", "file", "name", "and", "not", "to", "the", "whole", "path", ".", "Examples", "with", "prefix", "==" ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/compiler-html2.js#L866-L877
49,545
tolokoban/ToloFrameWork
lib/compiler-html2.js
addDescriptionToHead
function addDescriptionToHead( head, options ) { if ( !options || !options.config || typeof options.config.description !== 'string' ) { return false; } if ( !Array.isArray( head.children ) ) { head.children = []; } for ( let i = 0; i < head.children.length; i++ ) { const child = head.children[ i ]; if ( child.type !== Tree.ELEMENT ) continue; if ( child.name.toLowerCase() != 'meta' ) continue; if ( !child.attribs ) continue; if ( typeof child.attribs.name !== 'string' ) continue; if ( child.attribs.name.toLowerCase() === 'description' ) { // There is already a description. We don't add a new one. return false; } } head.children.push( { type: Tree.ELEMENT, name: 'meta', attribs: { name: 'description', content: options.config.description } } ); return true; }
javascript
function addDescriptionToHead( head, options ) { if ( !options || !options.config || typeof options.config.description !== 'string' ) { return false; } if ( !Array.isArray( head.children ) ) { head.children = []; } for ( let i = 0; i < head.children.length; i++ ) { const child = head.children[ i ]; if ( child.type !== Tree.ELEMENT ) continue; if ( child.name.toLowerCase() != 'meta' ) continue; if ( !child.attribs ) continue; if ( typeof child.attribs.name !== 'string' ) continue; if ( child.attribs.name.toLowerCase() === 'description' ) { // There is already a description. We don't add a new one. return false; } } head.children.push( { type: Tree.ELEMENT, name: 'meta', attribs: { name: 'description', content: options.config.description } } ); return true; }
[ "function", "addDescriptionToHead", "(", "head", ",", "options", ")", "{", "if", "(", "!", "options", "||", "!", "options", ".", "config", "||", "typeof", "options", ".", "config", ".", "description", "!==", "'string'", ")", "{", "return", "false", ";", "}", "if", "(", "!", "Array", ".", "isArray", "(", "head", ".", "children", ")", ")", "{", "head", ".", "children", "=", "[", "]", ";", "}", "for", "(", "let", "i", "=", "0", ";", "i", "<", "head", ".", "children", ".", "length", ";", "i", "++", ")", "{", "const", "child", "=", "head", ".", "children", "[", "i", "]", ";", "if", "(", "child", ".", "type", "!==", "Tree", ".", "ELEMENT", ")", "continue", ";", "if", "(", "child", ".", "name", ".", "toLowerCase", "(", ")", "!=", "'meta'", ")", "continue", ";", "if", "(", "!", "child", ".", "attribs", ")", "continue", ";", "if", "(", "typeof", "child", ".", "attribs", ".", "name", "!==", "'string'", ")", "continue", ";", "if", "(", "child", ".", "attribs", ".", "name", ".", "toLowerCase", "(", ")", "===", "'description'", ")", "{", "// There is already a description. We don't add a new one.", "return", "false", ";", "}", "}", "head", ".", "children", ".", "push", "(", "{", "type", ":", "Tree", ".", "ELEMENT", ",", "name", ":", "'meta'", ",", "attribs", ":", "{", "name", ":", "'description'", ",", "content", ":", "options", ".", "config", ".", "description", "}", "}", ")", ";", "return", "true", ";", "}" ]
Add a description in the header if no one was found. @param {string} options.config.description - The description to use.
[ "Add", "a", "description", "in", "the", "header", "if", "no", "one", "was", "found", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/compiler-html2.js#L919-L947
49,546
pzlr/build-core
lib/entries.js
getEntryImports
function getEntryImports(dir, content, arr = []) { $C(content.split(eol)).forEach((line) => { if (!hasImport.test(line)) { return; } const url = RegExp.$2, nodeModule = isNodeModule(url); if (nodeModule && entriesDir.test(url) || insideEntry.test(url)) { const d = nodeModule ? lib : dir; let f = path.join(d, `${url}.js`); if (!fs.existsSync(f)) { f = path.join(d, url, 'index.js'); } getEntryImports(path.dirname(f), fs.readFileSync(f, 'utf-8'), arr); } else { arr.push(nodeModule ? url : path.join(dir, url)); } }); return arr; }
javascript
function getEntryImports(dir, content, arr = []) { $C(content.split(eol)).forEach((line) => { if (!hasImport.test(line)) { return; } const url = RegExp.$2, nodeModule = isNodeModule(url); if (nodeModule && entriesDir.test(url) || insideEntry.test(url)) { const d = nodeModule ? lib : dir; let f = path.join(d, `${url}.js`); if (!fs.existsSync(f)) { f = path.join(d, url, 'index.js'); } getEntryImports(path.dirname(f), fs.readFileSync(f, 'utf-8'), arr); } else { arr.push(nodeModule ? url : path.join(dir, url)); } }); return arr; }
[ "function", "getEntryImports", "(", "dir", ",", "content", ",", "arr", "=", "[", "]", ")", "{", "$C", "(", "content", ".", "split", "(", "eol", ")", ")", ".", "forEach", "(", "(", "line", ")", "=>", "{", "if", "(", "!", "hasImport", ".", "test", "(", "line", ")", ")", "{", "return", ";", "}", "const", "url", "=", "RegExp", ".", "$2", ",", "nodeModule", "=", "isNodeModule", "(", "url", ")", ";", "if", "(", "nodeModule", "&&", "entriesDir", ".", "test", "(", "url", ")", "||", "insideEntry", ".", "test", "(", "url", ")", ")", "{", "const", "d", "=", "nodeModule", "?", "lib", ":", "dir", ";", "let", "f", "=", "path", ".", "join", "(", "d", ",", "`", "${", "url", "}", "`", ")", ";", "if", "(", "!", "fs", ".", "existsSync", "(", "f", ")", ")", "{", "f", "=", "path", ".", "join", "(", "d", ",", "url", ",", "'index.js'", ")", ";", "}", "getEntryImports", "(", "path", ".", "dirname", "(", "f", ")", ",", "fs", ".", "readFileSync", "(", "f", ",", "'utf-8'", ")", ",", "arr", ")", ";", "}", "else", "{", "arr", ".", "push", "(", "nodeModule", "?", "url", ":", "path", ".", "join", "(", "dir", ",", "url", ")", ")", ";", "}", "}", ")", ";", "return", "arr", ";", "}" ]
Returns a list of imports from the specified entry file @param {string} dir - entry directory @param {string} content - file content @param {!Array} [arr] @returns {!Array<string>}
[ "Returns", "a", "list", "of", "imports", "from", "the", "specified", "entry", "file" ]
11e20eda500682b9fa62c7804c66be1714df0df4
https://github.com/pzlr/build-core/blob/11e20eda500682b9fa62c7804c66be1714df0df4/lib/entries.js#L153-L182
49,547
pzlr/build-core
lib/entries.js
getEntryParents
function getEntryParents(content) { const parents = new Set(), clrfx = /\.\//; $C(content.split(eol)).forEach((line) => { if (!hasImport.test(line)) { return; } const url = RegExp.$2; if (isNodeModule(url) && entriesDir.test(url) || insideEntry.test(url)) { parents.add(url.replace(clrfx, '')); } }); return parents; }
javascript
function getEntryParents(content) { const parents = new Set(), clrfx = /\.\//; $C(content.split(eol)).forEach((line) => { if (!hasImport.test(line)) { return; } const url = RegExp.$2; if (isNodeModule(url) && entriesDir.test(url) || insideEntry.test(url)) { parents.add(url.replace(clrfx, '')); } }); return parents; }
[ "function", "getEntryParents", "(", "content", ")", "{", "const", "parents", "=", "new", "Set", "(", ")", ",", "clrfx", "=", "/", "\\.\\/", "/", ";", "$C", "(", "content", ".", "split", "(", "eol", ")", ")", ".", "forEach", "(", "(", "line", ")", "=>", "{", "if", "(", "!", "hasImport", ".", "test", "(", "line", ")", ")", "{", "return", ";", "}", "const", "url", "=", "RegExp", ".", "$2", ";", "if", "(", "isNodeModule", "(", "url", ")", "&&", "entriesDir", ".", "test", "(", "url", ")", "||", "insideEntry", ".", "test", "(", "url", ")", ")", "{", "parents", ".", "add", "(", "url", ".", "replace", "(", "clrfx", ",", "''", ")", ")", ";", "}", "}", ")", ";", "return", "parents", ";", "}" ]
Returns a set of parent entries for the specified entry @param {string} content - file content @returns {!Set<string>}
[ "Returns", "a", "set", "of", "parent", "entries", "for", "the", "specified", "entry" ]
11e20eda500682b9fa62c7804c66be1714df0df4
https://github.com/pzlr/build-core/blob/11e20eda500682b9fa62c7804c66be1714df0df4/lib/entries.js#L190-L209
49,548
pzlr/build-core
lib/entries.js
getEntryRuntimeDependencies
async function getEntryRuntimeDependencies(dir, content, {cache} = {}) { const deps = { runtime: new Map(), parents: new Map(), libs: new Set() }; const runtime = new Set(); await $C(getEntryImports(dir, content)).async.forEach(async (el) => { const name = path.basename(el, path.extname(el)), block = cache ? cache.get(name) : await Block.get(name); if (!blockName(name) || !block) { deps.runtime.set(el, el); return; } const blockDeps = await block.getRuntimeDependencies({cache}); $C(blockDeps.runtime).forEach((obj, block) => { if (!blockDeps.parents.has(block)) { runtime.add(block); } }); deps.runtime = new Map([...deps.runtime.entries(), ...blockDeps.runtime.entries()]); deps.parents = new Map( $C([...deps.parents.entries(), ...blockDeps.parents.entries()]) .filter(([block]) => !runtime.has(block)) .map() ); deps.libs = new Set([...deps.libs, ...blockDeps.libs]); }); return deps; }
javascript
async function getEntryRuntimeDependencies(dir, content, {cache} = {}) { const deps = { runtime: new Map(), parents: new Map(), libs: new Set() }; const runtime = new Set(); await $C(getEntryImports(dir, content)).async.forEach(async (el) => { const name = path.basename(el, path.extname(el)), block = cache ? cache.get(name) : await Block.get(name); if (!blockName(name) || !block) { deps.runtime.set(el, el); return; } const blockDeps = await block.getRuntimeDependencies({cache}); $C(blockDeps.runtime).forEach((obj, block) => { if (!blockDeps.parents.has(block)) { runtime.add(block); } }); deps.runtime = new Map([...deps.runtime.entries(), ...blockDeps.runtime.entries()]); deps.parents = new Map( $C([...deps.parents.entries(), ...blockDeps.parents.entries()]) .filter(([block]) => !runtime.has(block)) .map() ); deps.libs = new Set([...deps.libs, ...blockDeps.libs]); }); return deps; }
[ "async", "function", "getEntryRuntimeDependencies", "(", "dir", ",", "content", ",", "{", "cache", "}", "=", "{", "}", ")", "{", "const", "deps", "=", "{", "runtime", ":", "new", "Map", "(", ")", ",", "parents", ":", "new", "Map", "(", ")", ",", "libs", ":", "new", "Set", "(", ")", "}", ";", "const", "runtime", "=", "new", "Set", "(", ")", ";", "await", "$C", "(", "getEntryImports", "(", "dir", ",", "content", ")", ")", ".", "async", ".", "forEach", "(", "async", "(", "el", ")", "=>", "{", "const", "name", "=", "path", ".", "basename", "(", "el", ",", "path", ".", "extname", "(", "el", ")", ")", ",", "block", "=", "cache", "?", "cache", ".", "get", "(", "name", ")", ":", "await", "Block", ".", "get", "(", "name", ")", ";", "if", "(", "!", "blockName", "(", "name", ")", "||", "!", "block", ")", "{", "deps", ".", "runtime", ".", "set", "(", "el", ",", "el", ")", ";", "return", ";", "}", "const", "blockDeps", "=", "await", "block", ".", "getRuntimeDependencies", "(", "{", "cache", "}", ")", ";", "$C", "(", "blockDeps", ".", "runtime", ")", ".", "forEach", "(", "(", "obj", ",", "block", ")", "=>", "{", "if", "(", "!", "blockDeps", ".", "parents", ".", "has", "(", "block", ")", ")", "{", "runtime", ".", "add", "(", "block", ")", ";", "}", "}", ")", ";", "deps", ".", "runtime", "=", "new", "Map", "(", "[", "...", "deps", ".", "runtime", ".", "entries", "(", ")", ",", "...", "blockDeps", ".", "runtime", ".", "entries", "(", ")", "]", ")", ";", "deps", ".", "parents", "=", "new", "Map", "(", "$C", "(", "[", "...", "deps", ".", "parents", ".", "entries", "(", ")", ",", "...", "blockDeps", ".", "parents", ".", "entries", "(", ")", "]", ")", ".", "filter", "(", "(", "[", "block", "]", ")", "=>", "!", "runtime", ".", "has", "(", "block", ")", ")", ".", "map", "(", ")", ")", ";", "deps", ".", "libs", "=", "new", "Set", "(", "[", "...", "deps", ".", "libs", ",", "...", "blockDeps", ".", "libs", "]", ")", ";", "}", ")", ";", "return", "deps", ";", "}" ]
Returns a graph with dependencies for an entry file @param {string} dir - entry directory @param {string} content - file content @param {Map<string, !Block>=} [cache] - optional cache object with predefined blocks @returns {!Promise<{runtime: !Map<string, !Block>, parents: !Map<string, !Block>, libs: !Set<string>}>}
[ "Returns", "a", "graph", "with", "dependencies", "for", "an", "entry", "file" ]
11e20eda500682b9fa62c7804c66be1714df0df4
https://github.com/pzlr/build-core/blob/11e20eda500682b9fa62c7804c66be1714df0df4/lib/entries.js#L219-L259
49,549
pzlr/build-core
lib/entries.js
getBuildConfig
async function getBuildConfig() { const entries = await $C(vinyl.src(path.join(entry(), '*.js'), {read: false})) .async .to({}) .reduce((res, el) => { const src = el.path, name = path.basename(src, '.js'); let source; function getSource() { source = source || fs.readFileSync(src, 'utf-8'); return source; } res[name] = { path: src, get source() { return getSource(); }, get parent() { return $C(getEntryParents(getSource())).one.get(); }, get parents() { return getEntryParents(getSource()); }, getRuntimeDependencies({cache} = {}) { return getEntryRuntimeDependencies(path.dirname(src), getSource(), {cache}); } }; return res; }); function factory(entries) { function filter(cb) { return factory($C(entries).filter(cb).map()); } return { entries, filter, getUnionEntryPoints({cache} = {}) { return getUnionEntryPoints(entries, {cache}); } }; } return factory(entries); }
javascript
async function getBuildConfig() { const entries = await $C(vinyl.src(path.join(entry(), '*.js'), {read: false})) .async .to({}) .reduce((res, el) => { const src = el.path, name = path.basename(src, '.js'); let source; function getSource() { source = source || fs.readFileSync(src, 'utf-8'); return source; } res[name] = { path: src, get source() { return getSource(); }, get parent() { return $C(getEntryParents(getSource())).one.get(); }, get parents() { return getEntryParents(getSource()); }, getRuntimeDependencies({cache} = {}) { return getEntryRuntimeDependencies(path.dirname(src), getSource(), {cache}); } }; return res; }); function factory(entries) { function filter(cb) { return factory($C(entries).filter(cb).map()); } return { entries, filter, getUnionEntryPoints({cache} = {}) { return getUnionEntryPoints(entries, {cache}); } }; } return factory(entries); }
[ "async", "function", "getBuildConfig", "(", ")", "{", "const", "entries", "=", "await", "$C", "(", "vinyl", ".", "src", "(", "path", ".", "join", "(", "entry", "(", ")", ",", "'*.js'", ")", ",", "{", "read", ":", "false", "}", ")", ")", ".", "async", ".", "to", "(", "{", "}", ")", ".", "reduce", "(", "(", "res", ",", "el", ")", "=>", "{", "const", "src", "=", "el", ".", "path", ",", "name", "=", "path", ".", "basename", "(", "src", ",", "'.js'", ")", ";", "let", "source", ";", "function", "getSource", "(", ")", "{", "source", "=", "source", "||", "fs", ".", "readFileSync", "(", "src", ",", "'utf-8'", ")", ";", "return", "source", ";", "}", "res", "[", "name", "]", "=", "{", "path", ":", "src", ",", "get", "source", "(", ")", "{", "return", "getSource", "(", ")", ";", "}", ",", "get", "parent", "(", ")", "{", "return", "$C", "(", "getEntryParents", "(", "getSource", "(", ")", ")", ")", ".", "one", ".", "get", "(", ")", ";", "}", ",", "get", "parents", "(", ")", "{", "return", "getEntryParents", "(", "getSource", "(", ")", ")", ";", "}", ",", "getRuntimeDependencies", "(", "{", "cache", "}", "=", "{", "}", ")", "{", "return", "getEntryRuntimeDependencies", "(", "path", ".", "dirname", "(", "src", ")", ",", "getSource", "(", ")", ",", "{", "cache", "}", ")", ";", "}", "}", ";", "return", "res", ";", "}", ")", ";", "function", "factory", "(", "entries", ")", "{", "function", "filter", "(", "cb", ")", "{", "return", "factory", "(", "$C", "(", "entries", ")", ".", "filter", "(", "cb", ")", ".", "map", "(", ")", ")", ";", "}", "return", "{", "entries", ",", "filter", ",", "getUnionEntryPoints", "(", "{", "cache", "}", "=", "{", "}", ")", "{", "return", "getUnionEntryPoints", "(", "entries", ",", "{", "cache", "}", ")", ";", "}", "}", ";", "}", "return", "factory", "(", "entries", ")", ";", "}" ]
Returns build config for entries @returns {!Promise<!{entries, dependencies, commons}>}
[ "Returns", "build", "config", "for", "entries" ]
11e20eda500682b9fa62c7804c66be1714df0df4
https://github.com/pzlr/build-core/blob/11e20eda500682b9fa62c7804c66be1714df0df4/lib/entries.js#L265-L318
49,550
dalekjs/dalek-driver-sauce
lib/commands/window.js
function (name, hash) { this.actionQueue.push(this.webdriverClient.windowHandles.bind(this.webdriverClient)); this.actionQueue.push(function (result) { var deferred = Q.defer(); if (name === null) { deferred.resolve(JSON.parse(result).value[0]); } deferred.resolve(name); return deferred.promise; }); this.actionQueue.push(this.webdriverClient.changeWindow.bind(this.webdriverClient)); this.actionQueue.push(this._windowCb.bind(this, name, hash)); return this; }
javascript
function (name, hash) { this.actionQueue.push(this.webdriverClient.windowHandles.bind(this.webdriverClient)); this.actionQueue.push(function (result) { var deferred = Q.defer(); if (name === null) { deferred.resolve(JSON.parse(result).value[0]); } deferred.resolve(name); return deferred.promise; }); this.actionQueue.push(this.webdriverClient.changeWindow.bind(this.webdriverClient)); this.actionQueue.push(this._windowCb.bind(this, name, hash)); return this; }
[ "function", "(", "name", ",", "hash", ")", "{", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "webdriverClient", ".", "windowHandles", ".", "bind", "(", "this", ".", "webdriverClient", ")", ")", ";", "this", ".", "actionQueue", ".", "push", "(", "function", "(", "result", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "if", "(", "name", "===", "null", ")", "{", "deferred", ".", "resolve", "(", "JSON", ".", "parse", "(", "result", ")", ".", "value", "[", "0", "]", ")", ";", "}", "deferred", ".", "resolve", "(", "name", ")", ";", "return", "deferred", ".", "promise", ";", "}", ")", ";", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "webdriverClient", ".", "changeWindow", ".", "bind", "(", "this", ".", "webdriverClient", ")", ")", ";", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "_windowCb", ".", "bind", "(", "this", ",", "name", ",", "hash", ")", ")", ";", "return", "this", ";", "}" ]
Switches to another window context @method toFrame @param {string} name Name of the window to switch to @param {string} hash Unique hash of that fn call @chainable
[ "Switches", "to", "another", "window", "context" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/window.js#L49-L62
49,551
dalekjs/dalek-driver-sauce
lib/commands/window.js
function (dimensions, hash) { this.actionQueue.push(this.webdriverClient.setWindowSize.bind(this.webdriverClient, dimensions.width, dimensions.height)); this.actionQueue.push(this._resizeCb.bind(this, dimensions, hash)); return this; }
javascript
function (dimensions, hash) { this.actionQueue.push(this.webdriverClient.setWindowSize.bind(this.webdriverClient, dimensions.width, dimensions.height)); this.actionQueue.push(this._resizeCb.bind(this, dimensions, hash)); return this; }
[ "function", "(", "dimensions", ",", "hash", ")", "{", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "webdriverClient", ".", "setWindowSize", ".", "bind", "(", "this", ".", "webdriverClient", ",", "dimensions", ".", "width", ",", "dimensions", ".", "height", ")", ")", ";", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "_resizeCb", ".", "bind", "(", "this", ",", "dimensions", ",", "hash", ")", ")", ";", "return", "this", ";", "}" ]
Resizes the current window @method resize @param {object} dimensions New window width & height @param {string} hash Unique hash of that fn call @chainable
[ "Resizes", "the", "current", "window" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/window.js#L91-L95
49,552
dalekjs/dalek-driver-sauce
lib/commands/window.js
function (hash) { this.actionQueue.push(this.webdriverClient.maximize.bind(this.webdriverClient)); this.actionQueue.push(this._maximizeCb.bind(this, hash)); return this; }
javascript
function (hash) { this.actionQueue.push(this.webdriverClient.maximize.bind(this.webdriverClient)); this.actionQueue.push(this._maximizeCb.bind(this, hash)); return this; }
[ "function", "(", "hash", ")", "{", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "webdriverClient", ".", "maximize", ".", "bind", "(", "this", ".", "webdriverClient", ")", ")", ";", "this", ".", "actionQueue", ".", "push", "(", "this", ".", "_maximizeCb", ".", "bind", "(", "this", ",", "hash", ")", ")", ";", "return", "this", ";", "}" ]
Maximizes the current window @method maximize @param {string} hash Unique hash of that fn call @chainable
[ "Maximizes", "the", "current", "window" ]
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/window.js#L123-L127
49,553
berkeleybop/bbopx-js
npm/bbopx/bbopx.js
_set_url_from_token
function _set_url_from_token(in_token){ var url = null; if( in_token ){ url = barista_location + '/api/' + namespace + '/m3BatchPrivileged'; }else{ url = barista_location + '/api/' + namespace + '/m3Batch'; } anchor._url = url; return url; }
javascript
function _set_url_from_token(in_token){ var url = null; if( in_token ){ url = barista_location + '/api/' + namespace + '/m3BatchPrivileged'; }else{ url = barista_location + '/api/' + namespace + '/m3Batch'; } anchor._url = url; return url; }
[ "function", "_set_url_from_token", "(", "in_token", ")", "{", "var", "url", "=", "null", ";", "if", "(", "in_token", ")", "{", "url", "=", "barista_location", "+", "'/api/'", "+", "namespace", "+", "'/m3BatchPrivileged'", ";", "}", "else", "{", "url", "=", "barista_location", "+", "'/api/'", "+", "namespace", "+", "'/m3Batch'", ";", "}", "anchor", ".", "_url", "=", "url", ";", "return", "url", ";", "}" ]
Will use this one other spot, where the user can change the token.
[ "Will", "use", "this", "one", "other", "spot", "where", "the", "user", "can", "change", "the", "token", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/npm/bbopx/bbopx.js#L643-L652
49,554
berkeleybop/bbopx-js
npm/bbopx/bbopx.js
_on_fail
function _on_fail(resp, man){ // See if we got any traction. if( ! resp || ! resp.message_type() || ! resp.message() ){ // Something dark has happened, try to put something // together. // console.log('bad resp!?: ', resp); var resp_seed = { 'message_type': 'error', 'message': 'deep manager error' }; resp = new bbopx.barista.response(resp_seed); } anchor.apply_callbacks('manager_error', [resp, anchor]); }
javascript
function _on_fail(resp, man){ // See if we got any traction. if( ! resp || ! resp.message_type() || ! resp.message() ){ // Something dark has happened, try to put something // together. // console.log('bad resp!?: ', resp); var resp_seed = { 'message_type': 'error', 'message': 'deep manager error' }; resp = new bbopx.barista.response(resp_seed); } anchor.apply_callbacks('manager_error', [resp, anchor]); }
[ "function", "_on_fail", "(", "resp", ",", "man", ")", "{", "// See if we got any traction.", "if", "(", "!", "resp", "||", "!", "resp", ".", "message_type", "(", ")", "||", "!", "resp", ".", "message", "(", ")", ")", "{", "// Something dark has happened, try to put something", "// together.", "// console.log('bad resp!?: ', resp);", "var", "resp_seed", "=", "{", "'message_type'", ":", "'error'", ",", "'message'", ":", "'deep manager error'", "}", ";", "resp", "=", "new", "bbopx", ".", "barista", ".", "response", "(", "resp_seed", ")", ";", "}", "anchor", ".", "apply_callbacks", "(", "'manager_error'", ",", "[", "resp", ",", "anchor", "]", ")", ";", "}" ]
How to deal with failure.
[ "How", "to", "deal", "with", "failure", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/npm/bbopx/bbopx.js#L689-L702
49,555
berkeleybop/bbopx-js
npm/bbopx/bbopx.js
_on_nominal_success
function _on_nominal_success(resp, man){ // Switch on message type when there isn't a complete failure. var m = resp.message_type(); if( m == 'error' ){ // Errors trump everything. anchor.apply_callbacks('error', [resp, anchor]); }else if( m == 'warning' ){ // Don't really have anything for warning yet...remove? anchor.apply_callbacks('warning', [resp, anchor]); }else if( m == 'success' ){ var sig = resp.signal(); if( sig == 'merge' || sig == 'rebuild' || sig == 'meta' ){ //console.log('run on signal: ' + sig); anchor.apply_callbacks(sig, [resp, anchor]); }else{ alert('unknown signal: very bad'); } }else{ alert('unimplemented message_type'); } // Postrun goes no matter what. anchor.apply_callbacks('postrun', [resp, anchor]); }
javascript
function _on_nominal_success(resp, man){ // Switch on message type when there isn't a complete failure. var m = resp.message_type(); if( m == 'error' ){ // Errors trump everything. anchor.apply_callbacks('error', [resp, anchor]); }else if( m == 'warning' ){ // Don't really have anything for warning yet...remove? anchor.apply_callbacks('warning', [resp, anchor]); }else if( m == 'success' ){ var sig = resp.signal(); if( sig == 'merge' || sig == 'rebuild' || sig == 'meta' ){ //console.log('run on signal: ' + sig); anchor.apply_callbacks(sig, [resp, anchor]); }else{ alert('unknown signal: very bad'); } }else{ alert('unimplemented message_type'); } // Postrun goes no matter what. anchor.apply_callbacks('postrun', [resp, anchor]); }
[ "function", "_on_nominal_success", "(", "resp", ",", "man", ")", "{", "// Switch on message type when there isn't a complete failure.", "var", "m", "=", "resp", ".", "message_type", "(", ")", ";", "if", "(", "m", "==", "'error'", ")", "{", "// Errors trump everything.", "anchor", ".", "apply_callbacks", "(", "'error'", ",", "[", "resp", ",", "anchor", "]", ")", ";", "}", "else", "if", "(", "m", "==", "'warning'", ")", "{", "// Don't really have anything for warning yet...remove?", "anchor", ".", "apply_callbacks", "(", "'warning'", ",", "[", "resp", ",", "anchor", "]", ")", ";", "}", "else", "if", "(", "m", "==", "'success'", ")", "{", "var", "sig", "=", "resp", ".", "signal", "(", ")", ";", "if", "(", "sig", "==", "'merge'", "||", "sig", "==", "'rebuild'", "||", "sig", "==", "'meta'", ")", "{", "//console.log('run on signal: ' + sig);", "anchor", ".", "apply_callbacks", "(", "sig", ",", "[", "resp", ",", "anchor", "]", ")", ";", "}", "else", "{", "alert", "(", "'unknown signal: very bad'", ")", ";", "}", "}", "else", "{", "alert", "(", "'unimplemented message_type'", ")", ";", "}", "// Postrun goes no matter what.", "anchor", ".", "apply_callbacks", "(", "'postrun'", ",", "[", "resp", ",", "anchor", "]", ")", ";", "}" ]
When we have nominal success, we still need to do some kind of dispatch to the proper functionality.
[ "When", "we", "have", "nominal", "success", "we", "still", "need", "to", "do", "some", "kind", "of", "dispatch", "to", "the", "proper", "functionality", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/npm/bbopx/bbopx.js#L707-L731
49,556
berkeleybop/bbopx-js
npm/bbopx/bbopx.js
_applys_to_us_p
function _applys_to_us_p(data){ var ret = false; var mid = data['model_id'] || null; if( ! mid || mid != anchor.model_id ){ ll('skip packet--not for us'); }else{ ret = true; } return ret; }
javascript
function _applys_to_us_p(data){ var ret = false; var mid = data['model_id'] || null; if( ! mid || mid != anchor.model_id ){ ll('skip packet--not for us'); }else{ ret = true; } return ret; }
[ "function", "_applys_to_us_p", "(", "data", ")", "{", "var", "ret", "=", "false", ";", "var", "mid", "=", "data", "[", "'model_id'", "]", "||", "null", ";", "if", "(", "!", "mid", "||", "mid", "!=", "anchor", ".", "model_id", ")", "{", "ll", "(", "'skip packet--not for us'", ")", ";", "}", "else", "{", "ret", "=", "true", ";", "}", "return", "ret", ";", "}" ]
Check whether ot not we should ignore the incoming data.
[ "Check", "whether", "ot", "not", "we", "should", "ignore", "the", "incoming", "data", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/npm/bbopx/bbopx.js#L3936-L3947
49,557
berkeleybop/bbopx-js
npm/bbopx/bbopx.js
function(e){ // Check if we are talking about self or parent. if( this === e.target || container_id === jQuery(e.target).parent().attr('id') || container_id === jQuery(e.target).attr('id') ){ _update_start_pos(e); // Bind to moving. jQuery(container_div).bind('mousemove', _scroller); } }
javascript
function(e){ // Check if we are talking about self or parent. if( this === e.target || container_id === jQuery(e.target).parent().attr('id') || container_id === jQuery(e.target).attr('id') ){ _update_start_pos(e); // Bind to moving. jQuery(container_div).bind('mousemove', _scroller); } }
[ "function", "(", "e", ")", "{", "// Check if we are talking about self or parent.", "if", "(", "this", "===", "e", ".", "target", "||", "container_id", "===", "jQuery", "(", "e", ".", "target", ")", ".", "parent", "(", ")", ".", "attr", "(", "'id'", ")", "||", "container_id", "===", "jQuery", "(", "e", ".", "target", ")", ".", "attr", "(", "'id'", ")", ")", "{", "_update_start_pos", "(", "e", ")", ";", "// Bind to moving.", "jQuery", "(", "container_div", ")", ".", "bind", "(", "'mousemove'", ",", "_scroller", ")", ";", "}", "}" ]
Only start if actual, not child.
[ "Only", "start", "if", "actual", "not", "child", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/npm/bbopx/bbopx.js#L4262-L4271
49,558
berkeleybop/bbopx-js
npm/bbopx/bbopx.js
_sorter
function _sorter(a, b){ // Use aid property priority. var bpri = aid.priority(b.property_id()); var apri = aid.priority(a.property_id()); return apri - bpri; }
javascript
function _sorter(a, b){ // Use aid property priority. var bpri = aid.priority(b.property_id()); var apri = aid.priority(a.property_id()); return apri - bpri; }
[ "function", "_sorter", "(", "a", ",", "b", ")", "{", "// Use aid property priority.", "var", "bpri", "=", "aid", ".", "priority", "(", "b", ".", "property_id", "(", ")", ")", ";", "var", "apri", "=", "aid", ".", "priority", "(", "a", ".", "property_id", "(", ")", ")", ";", "return", "apri", "-", "bpri", ";", "}" ]
Sort the types within the stack according to the known type priorities.
[ "Sort", "the", "types", "within", "the", "stack", "according", "to", "the", "known", "type", "priorities", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/npm/bbopx/bbopx.js#L5340-L5345
49,559
berkeleybop/bbopx-js
npm/bbopx/bbopx.js
_add_table_row
function _add_table_row(item, color, prefix, suffix){ //var rep_color = aid.color(item.category()); var out_rep = bbopx.noctua.type_to_span(item, color); if( prefix ){ out_rep = prefix + out_rep; } if( suffix ){ out_rep = out_rep + suffix; } var trstr = null; if( color ){ trstr = '<tr class="bbop-mme-stack-tr" ' + 'style="background-color: ' + color + ';"><td class="bbop-mme-stack-td">' + out_rep + '</td></tr>'; }else{ trstr = '<tr class="bbop-mme-stack-tr">' + '<td class="bbop-mme-stack-td">' + out_rep + '</td></tr>'; } enode_stack_table.add_to(trstr); }
javascript
function _add_table_row(item, color, prefix, suffix){ //var rep_color = aid.color(item.category()); var out_rep = bbopx.noctua.type_to_span(item, color); if( prefix ){ out_rep = prefix + out_rep; } if( suffix ){ out_rep = out_rep + suffix; } var trstr = null; if( color ){ trstr = '<tr class="bbop-mme-stack-tr" ' + 'style="background-color: ' + color + ';"><td class="bbop-mme-stack-td">' + out_rep + '</td></tr>'; }else{ trstr = '<tr class="bbop-mme-stack-tr">' + '<td class="bbop-mme-stack-td">' + out_rep + '</td></tr>'; } enode_stack_table.add_to(trstr); }
[ "function", "_add_table_row", "(", "item", ",", "color", ",", "prefix", ",", "suffix", ")", "{", "//var rep_color = aid.color(item.category());", "var", "out_rep", "=", "bbopx", ".", "noctua", ".", "type_to_span", "(", "item", ",", "color", ")", ";", "if", "(", "prefix", ")", "{", "out_rep", "=", "prefix", "+", "out_rep", ";", "}", "if", "(", "suffix", ")", "{", "out_rep", "=", "out_rep", "+", "suffix", ";", "}", "var", "trstr", "=", "null", ";", "if", "(", "color", ")", "{", "trstr", "=", "'<tr class=\"bbop-mme-stack-tr\" '", "+", "'style=\"background-color: '", "+", "color", "+", "';\"><td class=\"bbop-mme-stack-td\">'", "+", "out_rep", "+", "'</td></tr>'", ";", "}", "else", "{", "trstr", "=", "'<tr class=\"bbop-mme-stack-tr\">'", "+", "'<td class=\"bbop-mme-stack-td\">'", "+", "out_rep", "+", "'</td></tr>'", ";", "}", "enode_stack_table", ".", "add_to", "(", "trstr", ")", ";", "}" ]
General function for adding type information to stack.
[ "General", "function", "for", "adding", "type", "information", "to", "stack", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/npm/bbopx/bbopx.js#L5366-L5381
49,560
berkeleybop/bbopx-js
npm/bbopx/bbopx.js
_rel_save_button_start
function _rel_save_button_start(){ // //ll('looks like edge (in cb): ' + eeid); var qstr ='input:radio[name=' + radio_name + ']:checked'; var rval = jQuery(qstr).val(); // ll('rval: ' + rval); // // TODO: Should I report this too? Smells a // // bit like the missing properties with // // setParameter/s(), // // Change label. // //conn.setLabel(rval); // does not work!? // conn.removeOverlay("label"); // conn.addOverlay(["Label", {'label': rval, // 'location': 0.5, // 'cssClass': "aLabel", // 'id': 'label' } ]); // Kick off callback. manager.add_fact(ecore.get_id(), source_id, target_id, rval); // Close modal. mdl.destroy(); }
javascript
function _rel_save_button_start(){ // //ll('looks like edge (in cb): ' + eeid); var qstr ='input:radio[name=' + radio_name + ']:checked'; var rval = jQuery(qstr).val(); // ll('rval: ' + rval); // // TODO: Should I report this too? Smells a // // bit like the missing properties with // // setParameter/s(), // // Change label. // //conn.setLabel(rval); // does not work!? // conn.removeOverlay("label"); // conn.addOverlay(["Label", {'label': rval, // 'location': 0.5, // 'cssClass': "aLabel", // 'id': 'label' } ]); // Kick off callback. manager.add_fact(ecore.get_id(), source_id, target_id, rval); // Close modal. mdl.destroy(); }
[ "function", "_rel_save_button_start", "(", ")", "{", "//", "//ll('looks like edge (in cb): ' + eeid);", "var", "qstr", "=", "'input:radio[name='", "+", "radio_name", "+", "']:checked'", ";", "var", "rval", "=", "jQuery", "(", "qstr", ")", ".", "val", "(", ")", ";", "// ll('rval: ' + rval);", "// // TODO: Should I report this too? Smells a", "// // bit like the missing properties with", "// // setParameter/s(),", "// // Change label.", "// //conn.setLabel(rval); // does not work!?", "// conn.removeOverlay(\"label\");", "// conn.addOverlay([\"Label\", {'label': rval,", "// \t\t\t 'location': 0.5,", "// \t\t\t 'cssClass': \"aLabel\",", "// \t\t\t 'id': 'label' } ]);", "// Kick off callback.\t", "manager", ".", "add_fact", "(", "ecore", ".", "get_id", "(", ")", ",", "source_id", ",", "target_id", ",", "rval", ")", ";", "// Close modal.", "mdl", ".", "destroy", "(", ")", ";", "}" ]
Add action listener to the save button.
[ "Add", "action", "listener", "to", "the", "save", "button", "." ]
847d87f5980f144c19c4caef3786044930fe51db
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/npm/bbopx/bbopx.js#L5824-L5849
49,561
skerit/hawkejs
lib/client/is_visible.js
isChild
function isChild(child, parent) { while (child = child.parentNode) { if (child == parent) { return true; } } return false; }
javascript
function isChild(child, parent) { while (child = child.parentNode) { if (child == parent) { return true; } } return false; }
[ "function", "isChild", "(", "child", ",", "parent", ")", "{", "while", "(", "child", "=", "child", ".", "parentNode", ")", "{", "if", "(", "child", "==", "parent", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if one element is a child of the other @author Jelle De Loecker <[email protected]> @since 1.2.2 @version 1.2.2 @param {HTMLElement} element @return {Boolean}
[ "Returns", "true", "if", "one", "element", "is", "a", "child", "of", "the", "other" ]
15ed7205183ac2c425362deb8c0796c0d16b898a
https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L61-L69
49,562
skerit/hawkejs
lib/client/is_visible.js
isHidden
function isHidden(element) { var parent_styles, overflow_x, overflow_y, overflow, parent = element.parentNode, styles; if (!parent) { return true; } // Always return false for the document element if (isDocumentElement(parent)) { return false; } // Get the computed styles of the element styles = getStyle(element); // Return true if the element is invisible if ( styles.opacity === '0' || styles.display === 'none' || styles.visibility === 'hidden') { return true; } return isHidden(parent); }
javascript
function isHidden(element) { var parent_styles, overflow_x, overflow_y, overflow, parent = element.parentNode, styles; if (!parent) { return true; } // Always return false for the document element if (isDocumentElement(parent)) { return false; } // Get the computed styles of the element styles = getStyle(element); // Return true if the element is invisible if ( styles.opacity === '0' || styles.display === 'none' || styles.visibility === 'hidden') { return true; } return isHidden(parent); }
[ "function", "isHidden", "(", "element", ")", "{", "var", "parent_styles", ",", "overflow_x", ",", "overflow_y", ",", "overflow", ",", "parent", "=", "element", ".", "parentNode", ",", "styles", ";", "if", "(", "!", "parent", ")", "{", "return", "true", ";", "}", "// Always return false for the document element", "if", "(", "isDocumentElement", "(", "parent", ")", ")", "{", "return", "false", ";", "}", "// Get the computed styles of the element", "styles", "=", "getStyle", "(", "element", ")", ";", "// Return true if the element is invisible", "if", "(", "styles", ".", "opacity", "===", "'0'", "||", "styles", ".", "display", "===", "'none'", "||", "styles", ".", "visibility", "===", "'hidden'", ")", "{", "return", "true", ";", "}", "return", "isHidden", "(", "parent", ")", ";", "}" ]
Returns true if the element or its parents has no opacity, visibility or display @author Jelle De Loecker <[email protected]> @since 1.2.2 @version 1.2.2 @param {HTMLElement} element @return {Boolean}
[ "Returns", "true", "if", "the", "element", "or", "its", "parents", "has", "no", "opacity", "visibility", "or", "display" ]
15ed7205183ac2c425362deb8c0796c0d16b898a
https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L83-L112
49,563
skerit/hawkejs
lib/client/is_visible.js
isDocumentElement
function isDocumentElement(element) { if ( element == document.body || element.nodeType === 9 || (element.nodeType == 1 && element.nodeName == 'HTML')) { return true; } return false; }
javascript
function isDocumentElement(element) { if ( element == document.body || element.nodeType === 9 || (element.nodeType == 1 && element.nodeName == 'HTML')) { return true; } return false; }
[ "function", "isDocumentElement", "(", "element", ")", "{", "if", "(", "element", "==", "document", ".", "body", "||", "element", ".", "nodeType", "===", "9", "||", "(", "element", ".", "nodeType", "==", "1", "&&", "element", ".", "nodeName", "==", "'HTML'", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if the element is the body or document or html element @author Jelle De Loecker <[email protected]> @since 1.2.2 @version 1.2.2 @param {HTMLElement} element @return {Boolean}
[ "Returns", "true", "if", "the", "element", "is", "the", "body", "or", "document", "or", "html", "element" ]
15ed7205183ac2c425362deb8c0796c0d16b898a
https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L125-L133
49,564
skerit/hawkejs
lib/client/is_visible.js
collides
function collides(element_one, element_two) { var result, rect1, rect2; if (element_one.nodeName) { rect1 = element_one.getBoundingClientRect(); } else { rect1 = element_one; } if (element_two.nodeName) { rect2 = element_two.getBoundingClientRect(); } else { rect2 = element_two; } result = !( rect1.top > rect2.bottom || rect1.right < rect2.left || rect1.bottom < rect2.top || rect1.left > rect2.right ); return result; }
javascript
function collides(element_one, element_two) { var result, rect1, rect2; if (element_one.nodeName) { rect1 = element_one.getBoundingClientRect(); } else { rect1 = element_one; } if (element_two.nodeName) { rect2 = element_two.getBoundingClientRect(); } else { rect2 = element_two; } result = !( rect1.top > rect2.bottom || rect1.right < rect2.left || rect1.bottom < rect2.top || rect1.left > rect2.right ); return result; }
[ "function", "collides", "(", "element_one", ",", "element_two", ")", "{", "var", "result", ",", "rect1", ",", "rect2", ";", "if", "(", "element_one", ".", "nodeName", ")", "{", "rect1", "=", "element_one", ".", "getBoundingClientRect", "(", ")", ";", "}", "else", "{", "rect1", "=", "element_one", ";", "}", "if", "(", "element_two", ".", "nodeName", ")", "{", "rect2", "=", "element_two", ".", "getBoundingClientRect", "(", ")", ";", "}", "else", "{", "rect2", "=", "element_two", ";", "}", "result", "=", "!", "(", "rect1", ".", "top", ">", "rect2", ".", "bottom", "||", "rect1", ".", "right", "<", "rect2", ".", "left", "||", "rect1", ".", "bottom", "<", "rect2", ".", "top", "||", "rect1", ".", "left", ">", "rect2", ".", "right", ")", ";", "return", "result", ";", "}" ]
Returns true if the two elements or rectangles collide @author Jelle De Loecker <[email protected]> @since 1.2.2 @version 1.2.2 @param {HTMLElement} element_one @param {HTMLElement} element_two @return {Boolean}
[ "Returns", "true", "if", "the", "two", "elements", "or", "rectangles", "collide" ]
15ed7205183ac2c425362deb8c0796c0d16b898a
https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L147-L173
49,565
skerit/hawkejs
lib/client/is_visible.js
elementAtRectPoints
function elementAtRectPoints(element, rect) { var sample; // Get the first sample sample = document.elementFromPoint(rect.left, ~~rect.top); if (sample == element || isChild(element, sample)) { return true; } // Get the second sample sample = document.elementFromPoint(rect.left, ~~rect.bottom); if (sample == element || isChild(element, sample)) { return true; } // Get the third sample sample = document.elementFromPoint(rect.right, ~~rect.bottom); if (sample == element || isChild(element, sample)) { return true; } // Get the fourth sample sample = document.elementFromPoint(rect.right, ~~rect.top); if (sample == element || isChild(element, sample)) { return true; } return false; }
javascript
function elementAtRectPoints(element, rect) { var sample; // Get the first sample sample = document.elementFromPoint(rect.left, ~~rect.top); if (sample == element || isChild(element, sample)) { return true; } // Get the second sample sample = document.elementFromPoint(rect.left, ~~rect.bottom); if (sample == element || isChild(element, sample)) { return true; } // Get the third sample sample = document.elementFromPoint(rect.right, ~~rect.bottom); if (sample == element || isChild(element, sample)) { return true; } // Get the fourth sample sample = document.elementFromPoint(rect.right, ~~rect.top); if (sample == element || isChild(element, sample)) { return true; } return false; }
[ "function", "elementAtRectPoints", "(", "element", ",", "rect", ")", "{", "var", "sample", ";", "// Get the first sample", "sample", "=", "document", ".", "elementFromPoint", "(", "rect", ".", "left", ",", "~", "~", "rect", ".", "top", ")", ";", "if", "(", "sample", "==", "element", "||", "isChild", "(", "element", ",", "sample", ")", ")", "{", "return", "true", ";", "}", "// Get the second sample", "sample", "=", "document", ".", "elementFromPoint", "(", "rect", ".", "left", ",", "~", "~", "rect", ".", "bottom", ")", ";", "if", "(", "sample", "==", "element", "||", "isChild", "(", "element", ",", "sample", ")", ")", "{", "return", "true", ";", "}", "// Get the third sample", "sample", "=", "document", ".", "elementFromPoint", "(", "rect", ".", "right", ",", "~", "~", "rect", ".", "bottom", ")", ";", "if", "(", "sample", "==", "element", "||", "isChild", "(", "element", ",", "sample", ")", ")", "{", "return", "true", ";", "}", "// Get the fourth sample", "sample", "=", "document", ".", "elementFromPoint", "(", "rect", ".", "right", ",", "~", "~", "rect", ".", "top", ")", ";", "if", "(", "sample", "==", "element", "||", "isChild", "(", "element", ",", "sample", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
See if the element can be found at any of the rect's points @author Jelle De Loecker <[email protected]> @since 1.2.2 @version 1.2.2 @param {HTMLElement} element @param {Object} rect @return {Boolean}
[ "See", "if", "the", "element", "can", "be", "found", "at", "any", "of", "the", "rect", "s", "points" ]
15ed7205183ac2c425362deb8c0796c0d16b898a
https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L233-L266
49,566
skerit/hawkejs
lib/client/is_visible.js
_isVisible
function _isVisible(start_element, padding) { var real_rect, sample, result, rect; // Check if the start element is in the document if (!elementInDocument(start_element)) { return false; } // Check if the element is explicitly hidden if (isHidden(start_element)) { return false; } if (padding == null) { padding = 2; } // Make sure the start element is somewhere on the screen real_rect = start_element.getBoundingClientRect(); rect = { bottom : real_rect.bottom + padding, right : real_rect.right + padding, left : real_rect.left - padding, top : real_rect.top - padding }; // Totally underneath the viewport if (rect.top > document.documentElement.clientHeight) { return false; } // Totally above the viewport if (rect.bottom < 0) { return false; } // Totally left of the viewport if (rect.right < 0) { return false; } // Totally right of the viewport if (rect.left > document.documentElement.clientWidth) { return false; } result = isElementVisible(start_element); if (result) { // If no padding is given, we can also check for occlusions if (!padding) { return elementAtRectPoints(start_element, rect); } return true; } else { return false; } function isElementVisible(element) { var context = getViewContext(element), ctx_rect; if (!context) { return false; } // Get the context rectangle ctx_rect = context.getBoundingClientRect(); // The current element and the start element // both have to collide with the current context rectangle // (if the current element equals the start_element we only need // to check the modified rect to the ctx_rect) if ( (element == start_element || collides(element, ctx_rect)) && collides(rect, ctx_rect)) { // If the context element is the document element, // no further checks are needed if (isDocumentElement(context)) { return true; } // Recursively see if the current context is visible return isElementVisible(context); } return false; } }
javascript
function _isVisible(start_element, padding) { var real_rect, sample, result, rect; // Check if the start element is in the document if (!elementInDocument(start_element)) { return false; } // Check if the element is explicitly hidden if (isHidden(start_element)) { return false; } if (padding == null) { padding = 2; } // Make sure the start element is somewhere on the screen real_rect = start_element.getBoundingClientRect(); rect = { bottom : real_rect.bottom + padding, right : real_rect.right + padding, left : real_rect.left - padding, top : real_rect.top - padding }; // Totally underneath the viewport if (rect.top > document.documentElement.clientHeight) { return false; } // Totally above the viewport if (rect.bottom < 0) { return false; } // Totally left of the viewport if (rect.right < 0) { return false; } // Totally right of the viewport if (rect.left > document.documentElement.clientWidth) { return false; } result = isElementVisible(start_element); if (result) { // If no padding is given, we can also check for occlusions if (!padding) { return elementAtRectPoints(start_element, rect); } return true; } else { return false; } function isElementVisible(element) { var context = getViewContext(element), ctx_rect; if (!context) { return false; } // Get the context rectangle ctx_rect = context.getBoundingClientRect(); // The current element and the start element // both have to collide with the current context rectangle // (if the current element equals the start_element we only need // to check the modified rect to the ctx_rect) if ( (element == start_element || collides(element, ctx_rect)) && collides(rect, ctx_rect)) { // If the context element is the document element, // no further checks are needed if (isDocumentElement(context)) { return true; } // Recursively see if the current context is visible return isElementVisible(context); } return false; } }
[ "function", "_isVisible", "(", "start_element", ",", "padding", ")", "{", "var", "real_rect", ",", "sample", ",", "result", ",", "rect", ";", "// Check if the start element is in the document", "if", "(", "!", "elementInDocument", "(", "start_element", ")", ")", "{", "return", "false", ";", "}", "// Check if the element is explicitly hidden", "if", "(", "isHidden", "(", "start_element", ")", ")", "{", "return", "false", ";", "}", "if", "(", "padding", "==", "null", ")", "{", "padding", "=", "2", ";", "}", "// Make sure the start element is somewhere on the screen", "real_rect", "=", "start_element", ".", "getBoundingClientRect", "(", ")", ";", "rect", "=", "{", "bottom", ":", "real_rect", ".", "bottom", "+", "padding", ",", "right", ":", "real_rect", ".", "right", "+", "padding", ",", "left", ":", "real_rect", ".", "left", "-", "padding", ",", "top", ":", "real_rect", ".", "top", "-", "padding", "}", ";", "// Totally underneath the viewport", "if", "(", "rect", ".", "top", ">", "document", ".", "documentElement", ".", "clientHeight", ")", "{", "return", "false", ";", "}", "// Totally above the viewport", "if", "(", "rect", ".", "bottom", "<", "0", ")", "{", "return", "false", ";", "}", "// Totally left of the viewport", "if", "(", "rect", ".", "right", "<", "0", ")", "{", "return", "false", ";", "}", "// Totally right of the viewport", "if", "(", "rect", ".", "left", ">", "document", ".", "documentElement", ".", "clientWidth", ")", "{", "return", "false", ";", "}", "result", "=", "isElementVisible", "(", "start_element", ")", ";", "if", "(", "result", ")", "{", "// If no padding is given, we can also check for occlusions", "if", "(", "!", "padding", ")", "{", "return", "elementAtRectPoints", "(", "start_element", ",", "rect", ")", ";", "}", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "function", "isElementVisible", "(", "element", ")", "{", "var", "context", "=", "getViewContext", "(", "element", ")", ",", "ctx_rect", ";", "if", "(", "!", "context", ")", "{", "return", "false", ";", "}", "// Get the context rectangle", "ctx_rect", "=", "context", ".", "getBoundingClientRect", "(", ")", ";", "// The current element and the start element", "// both have to collide with the current context rectangle", "// (if the current element equals the start_element we only need", "// to check the modified rect to the ctx_rect)", "if", "(", "(", "element", "==", "start_element", "||", "collides", "(", "element", ",", "ctx_rect", ")", ")", "&&", "collides", "(", "rect", ",", "ctx_rect", ")", ")", "{", "// If the context element is the document element,", "// no further checks are needed", "if", "(", "isDocumentElement", "(", "context", ")", ")", "{", "return", "true", ";", "}", "// Recursively see if the current context is visible", "return", "isElementVisible", "(", "context", ")", ";", "}", "return", "false", ";", "}", "}" ]
The actual visibility checking @author Jelle De Loecker <[email protected]> @since 1.2.2 @version 1.2.2 @param {HTMLElement} element @param {Number} padding @return {Boolean}
[ "The", "actual", "visibility", "checking" ]
15ed7205183ac2c425362deb8c0796c0d16b898a
https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L280-L375
49,567
pixelsandbytes/h2o
examples/basic/server.js
defineApp
function defineApp(app) { app.use('/foo', function appFoo(req, res) { if (req.xhr) { var body = { foo: 'bar' }; responseSender.sendJSON(res, body); } else { responseSender.sendPage(res, 'Foo', '<h1>Bar!</h1>', 200); } }); app.use('/fail', function appFail(req, res) { /* jshint unused: false, quotmark: false */ throw new Error("Don't worry, the error handler will take care of this"); }); app.use('/fail-async', function appFailAsync(req, res) { /* jshint unused: false, quotmark: false */ setTimeout(function() { throw new Error("I may be async, but the error handler will still catch me!"); }, 100); }); app.use('/', express.static(__dirname)); }
javascript
function defineApp(app) { app.use('/foo', function appFoo(req, res) { if (req.xhr) { var body = { foo: 'bar' }; responseSender.sendJSON(res, body); } else { responseSender.sendPage(res, 'Foo', '<h1>Bar!</h1>', 200); } }); app.use('/fail', function appFail(req, res) { /* jshint unused: false, quotmark: false */ throw new Error("Don't worry, the error handler will take care of this"); }); app.use('/fail-async', function appFailAsync(req, res) { /* jshint unused: false, quotmark: false */ setTimeout(function() { throw new Error("I may be async, but the error handler will still catch me!"); }, 100); }); app.use('/', express.static(__dirname)); }
[ "function", "defineApp", "(", "app", ")", "{", "app", ".", "use", "(", "'/foo'", ",", "function", "appFoo", "(", "req", ",", "res", ")", "{", "if", "(", "req", ".", "xhr", ")", "{", "var", "body", "=", "{", "foo", ":", "'bar'", "}", ";", "responseSender", ".", "sendJSON", "(", "res", ",", "body", ")", ";", "}", "else", "{", "responseSender", ".", "sendPage", "(", "res", ",", "'Foo'", ",", "'<h1>Bar!</h1>'", ",", "200", ")", ";", "}", "}", ")", ";", "app", ".", "use", "(", "'/fail'", ",", "function", "appFail", "(", "req", ",", "res", ")", "{", "/* jshint unused: false, quotmark: false */", "throw", "new", "Error", "(", "\"Don't worry, the error handler will take care of this\"", ")", ";", "}", ")", ";", "app", ".", "use", "(", "'/fail-async'", ",", "function", "appFailAsync", "(", "req", ",", "res", ")", "{", "/* jshint unused: false, quotmark: false */", "setTimeout", "(", "function", "(", ")", "{", "throw", "new", "Error", "(", "\"I may be async, but the error handler will still catch me!\"", ")", ";", "}", ",", "100", ")", ";", "}", ")", ";", "app", ".", "use", "(", "'/'", ",", "express", ".", "static", "(", "__dirname", ")", ")", ";", "}" ]
Defines the express application that your server will run a.k.a. the routes, logic, etc. of your web application. Simply setup the application exactly as you would when using express directly. @param an express application, which this function will manipulate and augment
[ "Defines", "the", "express", "application", "that", "your", "server", "will", "run", "a", ".", "k", ".", "a", ".", "the", "routes", "logic", "etc", ".", "of", "your", "web", "application", ".", "Simply", "setup", "the", "application", "exactly", "as", "you", "would", "when", "using", "express", "directly", "." ]
496e81d68f7765c53c4f24c73e8eeab74a4f532a
https://github.com/pixelsandbytes/h2o/blob/496e81d68f7765c53c4f24c73e8eeab74a4f532a/examples/basic/server.js#L20-L48
49,568
wavesoft/jbb-profile-three
profile-loader.js
function( cb ) { // If we are running in node.js replace the THREE.js XHRLoader // with an offline version. var isBrowser=new Function("try {return this===window;}catch(e){ return false;}"); // browser exclude if (!isBrowser()) { // Expose 'THREE' for non-compatible scripts global.THREE = THREE; // Override XHR Loader global.THREE.XHRLoader = require('./lib/FileXHRLoader'); } // Trigger callback if (cb) cb(); }
javascript
function( cb ) { // If we are running in node.js replace the THREE.js XHRLoader // with an offline version. var isBrowser=new Function("try {return this===window;}catch(e){ return false;}"); // browser exclude if (!isBrowser()) { // Expose 'THREE' for non-compatible scripts global.THREE = THREE; // Override XHR Loader global.THREE.XHRLoader = require('./lib/FileXHRLoader'); } // Trigger callback if (cb) cb(); }
[ "function", "(", "cb", ")", "{", "// If we are running in node.js replace the THREE.js XHRLoader", "// with an offline version.", "var", "isBrowser", "=", "new", "Function", "(", "\"try {return this===window;}catch(e){ return false;}\"", ")", ";", "// browser exclude", "if", "(", "!", "isBrowser", "(", ")", ")", "{", "// Expose 'THREE' for non-compatible scripts", "global", ".", "THREE", "=", "THREE", ";", "// Override XHR Loader", "global", ".", "THREE", ".", "XHRLoader", "=", "require", "(", "'./lib/FileXHRLoader'", ")", ";", "}", "// Trigger callback", "if", "(", "cb", ")", "cb", "(", ")", ";", "}" ]
Initialize profile loader
[ "Initialize", "profile", "loader" ]
8539cfbb2d04b67999eee6e530fcaf03083e0e04
https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-loader.js#L40-L58
49,569
LINKIWI/react-loading-hoc
src/hoc.js
hoc
function hoc(Component) { return class HOC extends React.Component { /** * Create a new instance of the HOC with state defaults. * * @param {Object} props Props passed from other HOCs. */ constructor(props) { super(props); this.state = {isLoading: false}; } /** * Set the current isLoading state. * * @param {Boolean} isLoading Whether the component is currently loading. */ setIsLoading(isLoading) { this.setState({isLoading}); } /** * Execute a function that sets the current loading state while it is executing. * * @param {Function} func Function to execute. Expect a callback as its first parameter, which, * when called, resets the current loading state. */ loading(func) { this.setIsLoading(true); func(this.setIsLoading.bind(this, false)); } /** * Render the wrapped component, passing along props from this HOC's internal state. * * @returns {XML} The wrapped component with additional props. */ render() { return ( <Component ref={(elem) => { this.component = elem; }} loading={this.loading.bind(this)} {...this.props} {...this.state} /> ); } }; }
javascript
function hoc(Component) { return class HOC extends React.Component { /** * Create a new instance of the HOC with state defaults. * * @param {Object} props Props passed from other HOCs. */ constructor(props) { super(props); this.state = {isLoading: false}; } /** * Set the current isLoading state. * * @param {Boolean} isLoading Whether the component is currently loading. */ setIsLoading(isLoading) { this.setState({isLoading}); } /** * Execute a function that sets the current loading state while it is executing. * * @param {Function} func Function to execute. Expect a callback as its first parameter, which, * when called, resets the current loading state. */ loading(func) { this.setIsLoading(true); func(this.setIsLoading.bind(this, false)); } /** * Render the wrapped component, passing along props from this HOC's internal state. * * @returns {XML} The wrapped component with additional props. */ render() { return ( <Component ref={(elem) => { this.component = elem; }} loading={this.loading.bind(this)} {...this.props} {...this.state} /> ); } }; }
[ "function", "hoc", "(", "Component", ")", "{", "return", "class", "HOC", "extends", "React", ".", "Component", "{", "/**\n * Create a new instance of the HOC with state defaults.\n *\n * @param {Object} props Props passed from other HOCs.\n */", "constructor", "(", "props", ")", "{", "super", "(", "props", ")", ";", "this", ".", "state", "=", "{", "isLoading", ":", "false", "}", ";", "}", "/**\n * Set the current isLoading state.\n *\n * @param {Boolean} isLoading Whether the component is currently loading.\n */", "setIsLoading", "(", "isLoading", ")", "{", "this", ".", "setState", "(", "{", "isLoading", "}", ")", ";", "}", "/**\n * Execute a function that sets the current loading state while it is executing.\n *\n * @param {Function} func Function to execute. Expect a callback as its first parameter, which,\n * when called, resets the current loading state.\n */", "loading", "(", "func", ")", "{", "this", ".", "setIsLoading", "(", "true", ")", ";", "func", "(", "this", ".", "setIsLoading", ".", "bind", "(", "this", ",", "false", ")", ")", ";", "}", "/**\n * Render the wrapped component, passing along props from this HOC's internal state.\n *\n * @returns {XML} The wrapped component with additional props.\n */", "render", "(", ")", "{", "return", "(", "<", "Component", "ref", "=", "{", "(", "elem", ")", "=>", "{", "this", ".", "component", "=", "elem", ";", "}", "}", "loading", "=", "{", "this", ".", "loading", ".", "bind", "(", "this", ")", "}", "{", "...", "this", ".", "props", "}", "{", "...", "this", ".", "state", "}", "/", ">", ")", ";", "}", "}", ";", "}" ]
Create a higher-order component wrapping a child component, passing along all props as a proxy. @param {XML} Component The React component to wrap. @returns {HOC} A wrapper component that exposes additional component props accessible via the child component.
[ "Create", "a", "higher", "-", "order", "component", "wrapping", "a", "child", "component", "passing", "along", "all", "props", "as", "a", "proxy", "." ]
3f521ec7897813df54935e9cfd6336f97c9bec80
https://github.com/LINKIWI/react-loading-hoc/blob/3f521ec7897813df54935e9cfd6336f97c9bec80/src/hoc.js#L10-L61
49,570
redisjs/jsr-format
lib/format.js
repeat
function repeat(str, amount) { var s = '' , i; for(i = 0;i < amount;i++) { s += str; } return s; }
javascript
function repeat(str, amount) { var s = '' , i; for(i = 0;i < amount;i++) { s += str; } return s; }
[ "function", "repeat", "(", "str", ",", "amount", ")", "{", "var", "s", "=", "''", ",", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "amount", ";", "i", "++", ")", "{", "s", "+=", "str", ";", "}", "return", "s", ";", "}" ]
Repeat a string by amount.
[ "Repeat", "a", "string", "by", "amount", "." ]
375142a4c0b177cd1a69947a4d4880839f964d73
https://github.com/redisjs/jsr-format/blob/375142a4c0b177cd1a69947a4d4880839f964d73/lib/format.js#L10-L17
49,571
antoniobrandao/mongoose3-bsonfix-bson
lib/bson/bson.js
function(string, start, end) { var crc = 0 var x = 0; var y = 0; crc = crc ^ (-1); for(var i = start, iTop = end; i < iTop;i++) { y = (crc ^ string[i]) & 0xFF; x = table[y]; crc = (crc >>> 8) ^ x; } return crc ^ (-1); }
javascript
function(string, start, end) { var crc = 0 var x = 0; var y = 0; crc = crc ^ (-1); for(var i = start, iTop = end; i < iTop;i++) { y = (crc ^ string[i]) & 0xFF; x = table[y]; crc = (crc >>> 8) ^ x; } return crc ^ (-1); }
[ "function", "(", "string", ",", "start", ",", "end", ")", "{", "var", "crc", "=", "0", "var", "x", "=", "0", ";", "var", "y", "=", "0", ";", "crc", "=", "crc", "^", "(", "-", "1", ")", ";", "for", "(", "var", "i", "=", "start", ",", "iTop", "=", "end", ";", "i", "<", "iTop", ";", "i", "++", ")", "{", "y", "=", "(", "crc", "^", "string", "[", "i", "]", ")", "&", "0xFF", ";", "x", "=", "table", "[", "y", "]", ";", "crc", "=", "(", "crc", ">>>", "8", ")", "^", "x", ";", "}", "return", "crc", "^", "(", "-", "1", ")", ";", "}" ]
CRC32 hash method, Fast and enough versitility for our usage @ignore @api private
[ "CRC32", "hash", "method", "Fast", "and", "enough", "versitility", "for", "our", "usage" ]
b0eae261710704de70f6f282669cf020dbd6a490
https://github.com/antoniobrandao/mongoose3-bsonfix-bson/blob/b0eae261710704de70f6f282669cf020dbd6a490/lib/bson/bson.js#L1063-L1076
49,572
antoniobrandao/mongoose3-bsonfix-bson
lib/bson/bson.js
function(functionCache, hash, functionString, object) { // Contains the value we are going to set var value = null; // Check for cache hit, eval if missing and return cached function if(functionCache[hash] == null) { eval("value = " + functionString); functionCache[hash] = value; } // Set the object return functionCache[hash].bind(object); }
javascript
function(functionCache, hash, functionString, object) { // Contains the value we are going to set var value = null; // Check for cache hit, eval if missing and return cached function if(functionCache[hash] == null) { eval("value = " + functionString); functionCache[hash] = value; } // Set the object return functionCache[hash].bind(object); }
[ "function", "(", "functionCache", ",", "hash", ",", "functionString", ",", "object", ")", "{", "// Contains the value we are going to set", "var", "value", "=", "null", ";", "// Check for cache hit, eval if missing and return cached function", "if", "(", "functionCache", "[", "hash", "]", "==", "null", ")", "{", "eval", "(", "\"value = \"", "+", "functionString", ")", ";", "functionCache", "[", "hash", "]", "=", "value", ";", "}", "// Set the object", "return", "functionCache", "[", "hash", "]", ".", "bind", "(", "object", ")", ";", "}" ]
Ensure eval is isolated. @ignore @api private
[ "Ensure", "eval", "is", "isolated", "." ]
b0eae261710704de70f6f282669cf020dbd6a490
https://github.com/antoniobrandao/mongoose3-bsonfix-bson/blob/b0eae261710704de70f6f282669cf020dbd6a490/lib/bson/bson.js#L1122-L1133
49,573
antoniobrandao/mongoose3-bsonfix-bson
lib/bson/bson.js
function() { // Get the start search index var i = index; // Locate the end of the c string while(buffer[i] !== 0x00 && i < buffer.length) { i++ } // If are at the end of the buffer there is a problem with the document if(i >= buffer.length) throw new Error("Bad BSON Document: illegal CString") // Grab utf8 encoded string var string = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, i) : convertUint8ArrayToUtf8String(buffer, index, i); // Update index position index = i + 1; // Return string return string; }
javascript
function() { // Get the start search index var i = index; // Locate the end of the c string while(buffer[i] !== 0x00 && i < buffer.length) { i++ } // If are at the end of the buffer there is a problem with the document if(i >= buffer.length) throw new Error("Bad BSON Document: illegal CString") // Grab utf8 encoded string var string = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, i) : convertUint8ArrayToUtf8String(buffer, index, i); // Update index position index = i + 1; // Return string return string; }
[ "function", "(", ")", "{", "// Get the start search index", "var", "i", "=", "index", ";", "// Locate the end of the c string", "while", "(", "buffer", "[", "i", "]", "!==", "0x00", "&&", "i", "<", "buffer", ".", "length", ")", "{", "i", "++", "}", "// If are at the end of the buffer there is a problem with the document", "if", "(", "i", ">=", "buffer", ".", "length", ")", "throw", "new", "Error", "(", "\"Bad BSON Document: illegal CString\"", ")", "// Grab utf8 encoded string", "var", "string", "=", "supportsBuffer", "&&", "Buffer", ".", "isBuffer", "(", "buffer", ")", "?", "buffer", ".", "toString", "(", "'utf8'", ",", "index", ",", "i", ")", ":", "convertUint8ArrayToUtf8String", "(", "buffer", ",", "index", ",", "i", ")", ";", "// Update index position", "index", "=", "i", "+", "1", ";", "// Return string", "return", "string", ";", "}" ]
Reads in a C style string
[ "Reads", "in", "a", "C", "style", "string" ]
b0eae261710704de70f6f282669cf020dbd6a490
https://github.com/antoniobrandao/mongoose3-bsonfix-bson/blob/b0eae261710704de70f6f282669cf020dbd6a490/lib/bson/bson.js#L1197-L1212
49,574
0of/grunt-env-config
index.js
enableEnvConfig
function enableEnvConfig (grunt, opts) { var options = opts || {}; var cacheConfig = options.cache; var getRaw = grunt.config.getRaw; grunt.config.getRaw = function getRawWrapper (prop) { if (prop) { prop = grunt.config.getPropString(prop); var required = propRequire(prop, /^\$require\.([a-z0-9_$]+(?:\.[a-z0-9_$]+)*)$/i); if (required) { return required; } else { return preprocessForEach(prop.replace(/([^\\])\./g, '$1\u000E').split('\u000E'), function preprocessEach (obj) { // when not match the `$require` pattern, behave as `grunt.config.getRaw` if (typeof obj === 'string' || obj instanceof String) { var required = propRequire(obj, /^<%=\s*\$require\.([a-z0-9_$]+(?:\.[a-z0-9_$]+)*)\s*%>$/i); // recursively template requiring is not supported obj = required ? required : obj; } return obj; }); } } return getRaw.apply(this, arguments); }; function preprocessForEach (props, fn) { var parent = grunt.config.data , obj , eachProp; while ((eachProp = props.shift()) !== undefined && eachProp.length) { obj = parent[eachProp]; if (eachProp in parent) { obj = fn.call(this, obj, parent); if (cacheConfig) { parent[eachProp] = obj; } parent = obj; } if (typeof obj !== 'object') { break; } } return obj; } grunt.template.env = function (env) { if (typeof env !== 'string' && !(env instanceof String)) throw new TypeError('template.env expects string formated property'); var obj = process.env; env.replace(/([^\\])\./g, '$1\u000E').split('\u000E').forEach(function (prop) { obj = obj[prop]; }); return obj; }; grunt.template.through = function (obj) { if (typeof obj === 'object') { return JSON.stringify(obj); } return obj; }; function propRequire (prop, regExpr) { var matched = prop.match(regExpr); if (matched) { var path = grunt.config.get(matched[1]); grunt.verbose.writeln('$require:' + path); return require(path); } } }
javascript
function enableEnvConfig (grunt, opts) { var options = opts || {}; var cacheConfig = options.cache; var getRaw = grunt.config.getRaw; grunt.config.getRaw = function getRawWrapper (prop) { if (prop) { prop = grunt.config.getPropString(prop); var required = propRequire(prop, /^\$require\.([a-z0-9_$]+(?:\.[a-z0-9_$]+)*)$/i); if (required) { return required; } else { return preprocessForEach(prop.replace(/([^\\])\./g, '$1\u000E').split('\u000E'), function preprocessEach (obj) { // when not match the `$require` pattern, behave as `grunt.config.getRaw` if (typeof obj === 'string' || obj instanceof String) { var required = propRequire(obj, /^<%=\s*\$require\.([a-z0-9_$]+(?:\.[a-z0-9_$]+)*)\s*%>$/i); // recursively template requiring is not supported obj = required ? required : obj; } return obj; }); } } return getRaw.apply(this, arguments); }; function preprocessForEach (props, fn) { var parent = grunt.config.data , obj , eachProp; while ((eachProp = props.shift()) !== undefined && eachProp.length) { obj = parent[eachProp]; if (eachProp in parent) { obj = fn.call(this, obj, parent); if (cacheConfig) { parent[eachProp] = obj; } parent = obj; } if (typeof obj !== 'object') { break; } } return obj; } grunt.template.env = function (env) { if (typeof env !== 'string' && !(env instanceof String)) throw new TypeError('template.env expects string formated property'); var obj = process.env; env.replace(/([^\\])\./g, '$1\u000E').split('\u000E').forEach(function (prop) { obj = obj[prop]; }); return obj; }; grunt.template.through = function (obj) { if (typeof obj === 'object') { return JSON.stringify(obj); } return obj; }; function propRequire (prop, regExpr) { var matched = prop.match(regExpr); if (matched) { var path = grunt.config.get(matched[1]); grunt.verbose.writeln('$require:' + path); return require(path); } } }
[ "function", "enableEnvConfig", "(", "grunt", ",", "opts", ")", "{", "var", "options", "=", "opts", "||", "{", "}", ";", "var", "cacheConfig", "=", "options", ".", "cache", ";", "var", "getRaw", "=", "grunt", ".", "config", ".", "getRaw", ";", "grunt", ".", "config", ".", "getRaw", "=", "function", "getRawWrapper", "(", "prop", ")", "{", "if", "(", "prop", ")", "{", "prop", "=", "grunt", ".", "config", ".", "getPropString", "(", "prop", ")", ";", "var", "required", "=", "propRequire", "(", "prop", ",", "/", "^\\$require\\.([a-z0-9_$]+(?:\\.[a-z0-9_$]+)*)$", "/", "i", ")", ";", "if", "(", "required", ")", "{", "return", "required", ";", "}", "else", "{", "return", "preprocessForEach", "(", "prop", ".", "replace", "(", "/", "([^\\\\])\\.", "/", "g", ",", "'$1\\u000E'", ")", ".", "split", "(", "'\\u000E'", ")", ",", "function", "preprocessEach", "(", "obj", ")", "{", "// when not match the `$require` pattern, behave as `grunt.config.getRaw`", "if", "(", "typeof", "obj", "===", "'string'", "||", "obj", "instanceof", "String", ")", "{", "var", "required", "=", "propRequire", "(", "obj", ",", "/", "^<%=\\s*\\$require\\.([a-z0-9_$]+(?:\\.[a-z0-9_$]+)*)\\s*%>$", "/", "i", ")", ";", "// recursively template requiring is not supported", "obj", "=", "required", "?", "required", ":", "obj", ";", "}", "return", "obj", ";", "}", ")", ";", "}", "}", "return", "getRaw", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "function", "preprocessForEach", "(", "props", ",", "fn", ")", "{", "var", "parent", "=", "grunt", ".", "config", ".", "data", ",", "obj", ",", "eachProp", ";", "while", "(", "(", "eachProp", "=", "props", ".", "shift", "(", ")", ")", "!==", "undefined", "&&", "eachProp", ".", "length", ")", "{", "obj", "=", "parent", "[", "eachProp", "]", ";", "if", "(", "eachProp", "in", "parent", ")", "{", "obj", "=", "fn", ".", "call", "(", "this", ",", "obj", ",", "parent", ")", ";", "if", "(", "cacheConfig", ")", "{", "parent", "[", "eachProp", "]", "=", "obj", ";", "}", "parent", "=", "obj", ";", "}", "if", "(", "typeof", "obj", "!==", "'object'", ")", "{", "break", ";", "}", "}", "return", "obj", ";", "}", "grunt", ".", "template", ".", "env", "=", "function", "(", "env", ")", "{", "if", "(", "typeof", "env", "!==", "'string'", "&&", "!", "(", "env", "instanceof", "String", ")", ")", "throw", "new", "TypeError", "(", "'template.env expects string formated property'", ")", ";", "var", "obj", "=", "process", ".", "env", ";", "env", ".", "replace", "(", "/", "([^\\\\])\\.", "/", "g", ",", "'$1\\u000E'", ")", ".", "split", "(", "'\\u000E'", ")", ".", "forEach", "(", "function", "(", "prop", ")", "{", "obj", "=", "obj", "[", "prop", "]", ";", "}", ")", ";", "return", "obj", ";", "}", ";", "grunt", ".", "template", ".", "through", "=", "function", "(", "obj", ")", "{", "if", "(", "typeof", "obj", "===", "'object'", ")", "{", "return", "JSON", ".", "stringify", "(", "obj", ")", ";", "}", "return", "obj", ";", "}", ";", "function", "propRequire", "(", "prop", ",", "regExpr", ")", "{", "var", "matched", "=", "prop", ".", "match", "(", "regExpr", ")", ";", "if", "(", "matched", ")", "{", "var", "path", "=", "grunt", ".", "config", ".", "get", "(", "matched", "[", "1", "]", ")", ";", "grunt", ".", "verbose", ".", "writeln", "(", "'$require:'", "+", "path", ")", ";", "return", "require", "(", "path", ")", ";", "}", "}", "}" ]
enable env config @param {Object}[grunt] grunt object @param {Object} [opts] @param {Boolean} [options.cache] replace $require template string by required result @public
[ "enable", "env", "config" ]
d2d7d3499ac9136c85e8e72ca008721e3821acf7
https://github.com/0of/grunt-env-config/blob/d2d7d3499ac9136c85e8e72ca008721e3821acf7/index.js#L11-L92
49,575
ryanramage/schema-couch-boilerplate
jam/json.edit/addons/adsafe/lib/jslint.js
one_space
function one_space(left, right) { left = left || token; right = right || next_token; if (right.id !== '(end)' && !option.white && (token.line !== right.line || token.thru + 1 !== right.from)) { warn('expected_space_a_b', right, artifact(token), artifact(right)); } }
javascript
function one_space(left, right) { left = left || token; right = right || next_token; if (right.id !== '(end)' && !option.white && (token.line !== right.line || token.thru + 1 !== right.from)) { warn('expected_space_a_b', right, artifact(token), artifact(right)); } }
[ "function", "one_space", "(", "left", ",", "right", ")", "{", "left", "=", "left", "||", "token", ";", "right", "=", "right", "||", "next_token", ";", "if", "(", "right", ".", "id", "!==", "'(end)'", "&&", "!", "option", ".", "white", "&&", "(", "token", ".", "line", "!==", "right", ".", "line", "||", "token", ".", "thru", "+", "1", "!==", "right", ".", "from", ")", ")", "{", "warn", "(", "'expected_space_a_b'", ",", "right", ",", "artifact", "(", "token", ")", ",", "artifact", "(", "right", ")", ")", ";", "}", "}" ]
Functions for conformance of whitespace.
[ "Functions", "for", "conformance", "of", "whitespace", "." ]
c323516f02c90101aa6b21592bfdd2a6f2e47680
https://github.com/ryanramage/schema-couch-boilerplate/blob/c323516f02c90101aa6b21592bfdd2a6f2e47680/jam/json.edit/addons/adsafe/lib/jslint.js#L2026-L2034
49,576
ryanramage/schema-couch-boilerplate
jam/json.edit/addons/adsafe/lib/jslint.js
symbol
function symbol(s, p) { var x = syntax[s]; if (!x || typeof x !== 'object') { syntax[s] = x = { id: s, lbp: p || 0, string: s }; } return x; }
javascript
function symbol(s, p) { var x = syntax[s]; if (!x || typeof x !== 'object') { syntax[s] = x = { id: s, lbp: p || 0, string: s }; } return x; }
[ "function", "symbol", "(", "s", ",", "p", ")", "{", "var", "x", "=", "syntax", "[", "s", "]", ";", "if", "(", "!", "x", "||", "typeof", "x", "!==", "'object'", ")", "{", "syntax", "[", "s", "]", "=", "x", "=", "{", "id", ":", "s", ",", "lbp", ":", "p", "||", "0", ",", "string", ":", "s", "}", ";", "}", "return", "x", ";", "}" ]
Functional constructors for making the symbols that will be inherited by tokens.
[ "Functional", "constructors", "for", "making", "the", "symbols", "that", "will", "be", "inherited", "by", "tokens", "." ]
c323516f02c90101aa6b21592bfdd2a6f2e47680
https://github.com/ryanramage/schema-couch-boilerplate/blob/c323516f02c90101aa6b21592bfdd2a6f2e47680/jam/json.edit/addons/adsafe/lib/jslint.js#L2232-L2242
49,577
lokijs/fenrir-core
client/entityTracker.js
onEntityDraw
function onEntityDraw(entity, context) { context.save(); if (selectionService.isSelected(entity)) { context.strokeStyle = '#f33'; } else { context.strokeStyle = '#666'; } context.strokeRect( entity.pos.x, entity.pos.y, entity.size.x, entity.size.y); context.restore(); }
javascript
function onEntityDraw(entity, context) { context.save(); if (selectionService.isSelected(entity)) { context.strokeStyle = '#f33'; } else { context.strokeStyle = '#666'; } context.strokeRect( entity.pos.x, entity.pos.y, entity.size.x, entity.size.y); context.restore(); }
[ "function", "onEntityDraw", "(", "entity", ",", "context", ")", "{", "context", ".", "save", "(", ")", ";", "if", "(", "selectionService", ".", "isSelected", "(", "entity", ")", ")", "{", "context", ".", "strokeStyle", "=", "'#f33'", ";", "}", "else", "{", "context", ".", "strokeStyle", "=", "'#666'", ";", "}", "context", ".", "strokeRect", "(", "entity", ".", "pos", ".", "x", ",", "entity", ".", "pos", ".", "y", ",", "entity", ".", "size", ".", "x", ",", "entity", ".", "size", ".", "y", ")", ";", "context", ".", "restore", "(", ")", ";", "}" ]
Subscribed to entity draw event.
[ "Subscribed", "to", "entity", "draw", "event", "." ]
15aea869eb74b5bb998e07328aee6b1c6fe21d80
https://github.com/lokijs/fenrir-core/blob/15aea869eb74b5bb998e07328aee6b1c6fe21d80/client/entityTracker.js#L22-L32
49,578
duniter/duniter-common
lib/crypto/keyring.js
verify
function verify(rawMsg, rawSig, rawPub) { const msg = nacl.util.decodeUTF8(rawMsg); const sig = nacl.util.decodeBase64(rawSig); const pub = base58.decode(rawPub); const m = new Uint8Array(crypto_sign_BYTES + msg.length); const sm = new Uint8Array(crypto_sign_BYTES + msg.length); let i; for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i]; for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i]; // Call to verification lib... return naclBinding.verify(m, sm, pub); }
javascript
function verify(rawMsg, rawSig, rawPub) { const msg = nacl.util.decodeUTF8(rawMsg); const sig = nacl.util.decodeBase64(rawSig); const pub = base58.decode(rawPub); const m = new Uint8Array(crypto_sign_BYTES + msg.length); const sm = new Uint8Array(crypto_sign_BYTES + msg.length); let i; for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i]; for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i]; // Call to verification lib... return naclBinding.verify(m, sm, pub); }
[ "function", "verify", "(", "rawMsg", ",", "rawSig", ",", "rawPub", ")", "{", "const", "msg", "=", "nacl", ".", "util", ".", "decodeUTF8", "(", "rawMsg", ")", ";", "const", "sig", "=", "nacl", ".", "util", ".", "decodeBase64", "(", "rawSig", ")", ";", "const", "pub", "=", "base58", ".", "decode", "(", "rawPub", ")", ";", "const", "m", "=", "new", "Uint8Array", "(", "crypto_sign_BYTES", "+", "msg", ".", "length", ")", ";", "const", "sm", "=", "new", "Uint8Array", "(", "crypto_sign_BYTES", "+", "msg", ".", "length", ")", ";", "let", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "crypto_sign_BYTES", ";", "i", "++", ")", "sm", "[", "i", "]", "=", "sig", "[", "i", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "msg", ".", "length", ";", "i", "++", ")", "sm", "[", "i", "+", "crypto_sign_BYTES", "]", "=", "msg", "[", "i", "]", ";", "// Call to verification lib...", "return", "naclBinding", ".", "verify", "(", "m", ",", "sm", ",", "pub", ")", ";", "}" ]
Verify a signature against data & public key. Return true of false as callback argument.
[ "Verify", "a", "signature", "against", "data", "&", "public", "key", ".", "Return", "true", "of", "false", "as", "callback", "argument", "." ]
4f5b64150379c81f9175c37fa4f043835213b0d9
https://github.com/duniter/duniter-common/blob/4f5b64150379c81f9175c37fa4f043835213b0d9/lib/crypto/keyring.js#L15-L27
49,579
hypergroup/hyper-path
build/build.js
require
function require(name) { var module = require.modules[name]; if (!module) throw new Error('failed to require "' + name + '"'); if (!('exports' in module) && typeof module.definition === 'function') { module.client = module.component = true; module.definition.call(this, module.exports = {}, module); delete module.definition; } return module.exports; }
javascript
function require(name) { var module = require.modules[name]; if (!module) throw new Error('failed to require "' + name + '"'); if (!('exports' in module) && typeof module.definition === 'function') { module.client = module.component = true; module.definition.call(this, module.exports = {}, module); delete module.definition; } return module.exports; }
[ "function", "require", "(", "name", ")", "{", "var", "module", "=", "require", ".", "modules", "[", "name", "]", ";", "if", "(", "!", "module", ")", "throw", "new", "Error", "(", "'failed to require \"'", "+", "name", "+", "'\"'", ")", ";", "if", "(", "!", "(", "'exports'", "in", "module", ")", "&&", "typeof", "module", ".", "definition", "===", "'function'", ")", "{", "module", ".", "client", "=", "module", ".", "component", "=", "true", ";", "module", ".", "definition", ".", "call", "(", "this", ",", "module", ".", "exports", "=", "{", "}", ",", "module", ")", ";", "delete", "module", ".", "definition", ";", "}", "return", "module", ".", "exports", ";", "}" ]
Require the module at `name`. @param {String} name @return {Object} exports @api public
[ "Require", "the", "module", "at", "name", "." ]
937490d22316d00fae60be0562e690d338c27b35
https://github.com/hypergroup/hyper-path/blob/937490d22316d00fae60be0562e690d338c27b35/build/build.js#L12-L23
49,580
hypergroup/hyper-path
build/build.js
Request
function Request(path, client, delim) { if (!(this instanceof Request)) return new Request(path, client); // init client this.client = client; if (!this.client) throw new Error('hyper-path requires a client to be passed as the second argument'); this.delim = delim || '.'; this.parse(path); this._listeners = {}; this._scope = {}; this._warnings = {}; }
javascript
function Request(path, client, delim) { if (!(this instanceof Request)) return new Request(path, client); // init client this.client = client; if (!this.client) throw new Error('hyper-path requires a client to be passed as the second argument'); this.delim = delim || '.'; this.parse(path); this._listeners = {}; this._scope = {}; this._warnings = {}; }
[ "function", "Request", "(", "path", ",", "client", ",", "delim", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Request", ")", ")", "return", "new", "Request", "(", "path", ",", "client", ")", ";", "// init client", "this", ".", "client", "=", "client", ";", "if", "(", "!", "this", ".", "client", ")", "throw", "new", "Error", "(", "'hyper-path requires a client to be passed as the second argument'", ")", ";", "this", ".", "delim", "=", "delim", "||", "'.'", ";", "this", ".", "parse", "(", "path", ")", ";", "this", ".", "_listeners", "=", "{", "}", ";", "this", ".", "_scope", "=", "{", "}", ";", "this", ".", "_warnings", "=", "{", "}", ";", "}" ]
Create a hyper-path request @param {String} path @param {Client} client
[ "Create", "a", "hyper", "-", "path", "request" ]
937490d22316d00fae60be0562e690d338c27b35
https://github.com/hypergroup/hyper-path/blob/937490d22316d00fae60be0562e690d338c27b35/build/build.js#L163-L176
49,581
hypergroup/hyper-path
build/build.js
firstDefined
function firstDefined() { for (var i = 0, l = arguments.length, v; i < l; i++) { v = arguments[i]; if (typeof v !== 'undefined') return v; } return v; }
javascript
function firstDefined() { for (var i = 0, l = arguments.length, v; i < l; i++) { v = arguments[i]; if (typeof v !== 'undefined') return v; } return v; }
[ "function", "firstDefined", "(", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "arguments", ".", "length", ",", "v", ";", "i", "<", "l", ";", "i", "++", ")", "{", "v", "=", "arguments", "[", "i", "]", ";", "if", "(", "typeof", "v", "!==", "'undefined'", ")", "return", "v", ";", "}", "return", "v", ";", "}" ]
Choose the first defined value @api private
[ "Choose", "the", "first", "defined", "value" ]
937490d22316d00fae60be0562e690d338c27b35
https://github.com/hypergroup/hyper-path/blob/937490d22316d00fae60be0562e690d338c27b35/build/build.js#L536-L542
49,582
klesh/bblib
textlines.js
process
async function process({inputStream, skip, lineHandler, quiet, throttle}) { skip = skip || 0; throttle = throttle || Number.MAX_VALUE; return await new P((resolve, reject) => { let cursor = 0; let concurrency = 0; const errors = []; const reader = readline.createInterface({input: inputStream}); reader.on('line', async line => { if (cursor++ < skip || (!quiet && errors.length)) { return; } const lineNo = cursor; if (++concurrency > throttle) { reader.pause(); } try { await lineHandler(line, cursor); } catch (e) { if (!quiet) { e.line = lineNo; errors.push(e); reader.close(); } } finally { skip++; if (--concurrency < throttle) { reader.resume(); } } }).on('close', async () => { while (skip < cursor) await P.delay(100); if (errors.length) { const e = _.minBy(errors, 'line'); e.errors = errors; reject(e); } else { resolve(skip); } }); }); }
javascript
async function process({inputStream, skip, lineHandler, quiet, throttle}) { skip = skip || 0; throttle = throttle || Number.MAX_VALUE; return await new P((resolve, reject) => { let cursor = 0; let concurrency = 0; const errors = []; const reader = readline.createInterface({input: inputStream}); reader.on('line', async line => { if (cursor++ < skip || (!quiet && errors.length)) { return; } const lineNo = cursor; if (++concurrency > throttle) { reader.pause(); } try { await lineHandler(line, cursor); } catch (e) { if (!quiet) { e.line = lineNo; errors.push(e); reader.close(); } } finally { skip++; if (--concurrency < throttle) { reader.resume(); } } }).on('close', async () => { while (skip < cursor) await P.delay(100); if (errors.length) { const e = _.minBy(errors, 'line'); e.errors = errors; reject(e); } else { resolve(skip); } }); }); }
[ "async", "function", "process", "(", "{", "inputStream", ",", "skip", ",", "lineHandler", ",", "quiet", ",", "throttle", "}", ")", "{", "skip", "=", "skip", "||", "0", ";", "throttle", "=", "throttle", "||", "Number", ".", "MAX_VALUE", ";", "return", "await", "new", "P", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "let", "cursor", "=", "0", ";", "let", "concurrency", "=", "0", ";", "const", "errors", "=", "[", "]", ";", "const", "reader", "=", "readline", ".", "createInterface", "(", "{", "input", ":", "inputStream", "}", ")", ";", "reader", ".", "on", "(", "'line'", ",", "async", "line", "=>", "{", "if", "(", "cursor", "++", "<", "skip", "||", "(", "!", "quiet", "&&", "errors", ".", "length", ")", ")", "{", "return", ";", "}", "const", "lineNo", "=", "cursor", ";", "if", "(", "++", "concurrency", ">", "throttle", ")", "{", "reader", ".", "pause", "(", ")", ";", "}", "try", "{", "await", "lineHandler", "(", "line", ",", "cursor", ")", ";", "}", "catch", "(", "e", ")", "{", "if", "(", "!", "quiet", ")", "{", "e", ".", "line", "=", "lineNo", ";", "errors", ".", "push", "(", "e", ")", ";", "reader", ".", "close", "(", ")", ";", "}", "}", "finally", "{", "skip", "++", ";", "if", "(", "--", "concurrency", "<", "throttle", ")", "{", "reader", ".", "resume", "(", ")", ";", "}", "}", "}", ")", ".", "on", "(", "'close'", ",", "async", "(", ")", "=>", "{", "while", "(", "skip", "<", "cursor", ")", "await", "P", ".", "delay", "(", "100", ")", ";", "if", "(", "errors", ".", "length", ")", "{", "const", "e", "=", "_", ".", "minBy", "(", "errors", ",", "'line'", ")", ";", "e", ".", "errors", "=", "errors", ";", "reject", "(", "e", ")", ";", "}", "else", "{", "resolve", "(", "skip", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}" ]
process lines concurrently @param {object} opts @param {ReadableStream} opts.inputStream - stream to be read from @param {function(line:string, cursor:number)} opts.lineHandler @param {number} [opts.skip=0] - number of lines to be skipped @param {boolean} [opts.quiet=false] - suppress all errors threw by lineHandler @param {boolean} [opts.throttle=Number.MAX_VALUE] - close inputStream automatically
[ "process", "lines", "concurrently" ]
5059964fc41b45c1ab87dd9ae9863b3fac1ee470
https://github.com/klesh/bblib/blob/5059964fc41b45c1ab87dd9ae9863b3fac1ee470/textlines.js#L15-L59
49,583
kerryhatcher/AdminJS-core-navigation
hawtio-core-navigation.js
itemIsValid
function itemIsValid(item) { if (!('isValid' in item)) { return true; } if (_.isFunction(item.isValid)) { return item.isValid(); } return false; }
javascript
function itemIsValid(item) { if (!('isValid' in item)) { return true; } if (_.isFunction(item.isValid)) { return item.isValid(); } return false; }
[ "function", "itemIsValid", "(", "item", ")", "{", "if", "(", "!", "(", "'isValid'", "in", "item", ")", ")", "{", "return", "true", ";", "}", "if", "(", "_", ".", "isFunction", "(", "item", ".", "isValid", ")", ")", "{", "return", "item", ".", "isValid", "(", ")", ";", "}", "return", "false", ";", "}" ]
helper function for testing nav items
[ "helper", "function", "for", "testing", "nav", "items" ]
8911560391491ff425c5c323b727401510a38b7d
https://github.com/kerryhatcher/AdminJS-core-navigation/blob/8911560391491ff425c5c323b727401510a38b7d/hawtio-core-navigation.js#L650-L658
49,584
OffByNone/Omniscience-UPnP
Chrome_module.js
mine
function mine(js) { var names = []; var state = 0; var ident; var quote; var name; var isIdent = /[a-z0-9_.]/i; var isWhitespace = /[ \r\n\t]/; function $start(char) { if (char === "/") { return $slash; } if (char === "'" || char === '"') { quote = char; return $string; } if (isIdent.test(char)) { ident = char; return $ident; } return $start; } function $ident(char) { if (isIdent.test(char)) { ident += char; return $ident; } if (char === "(" && ident === "require") { ident = undefined; return $call; } return $start(char); } function $call(char) { if (isWhitespace.test(char)) return $call; if (char === "'" || char === '"') { quote = char; name = ""; return $name; } return $start(char); } function $name(char) { if (char === quote) { return $close; } name += char; return $name; } function $close(char) { if (isWhitespace.test(char)) return $close; if (char === ")" || char === ',') { names.push(name); } name = undefined; return $start(char); } function $string(char) { if (char === "\\") { return $escape; } if (char === quote) { return $start; } return $string; } function $escape(char) { return $string; } function $slash(char) { if (char === "/") return $lineComment; if (char === "*") return $multilineComment; return $start(char); } function $lineComment(char) { if (char === "\r" || char === "\n") return $start; return $lineComment; } function $multilineComment(char) { if (char === "*") return $multilineEnding; return $multilineComment; } function $multilineEnding(char) { if (char === "/") return $start; if (char === "*") return $multilineEnding; return $multilineComment; } var state = $start; for (var i = 0, l = js.length; i < l; i++) { state = state(js[i]); } return names; }
javascript
function mine(js) { var names = []; var state = 0; var ident; var quote; var name; var isIdent = /[a-z0-9_.]/i; var isWhitespace = /[ \r\n\t]/; function $start(char) { if (char === "/") { return $slash; } if (char === "'" || char === '"') { quote = char; return $string; } if (isIdent.test(char)) { ident = char; return $ident; } return $start; } function $ident(char) { if (isIdent.test(char)) { ident += char; return $ident; } if (char === "(" && ident === "require") { ident = undefined; return $call; } return $start(char); } function $call(char) { if (isWhitespace.test(char)) return $call; if (char === "'" || char === '"') { quote = char; name = ""; return $name; } return $start(char); } function $name(char) { if (char === quote) { return $close; } name += char; return $name; } function $close(char) { if (isWhitespace.test(char)) return $close; if (char === ")" || char === ',') { names.push(name); } name = undefined; return $start(char); } function $string(char) { if (char === "\\") { return $escape; } if (char === quote) { return $start; } return $string; } function $escape(char) { return $string; } function $slash(char) { if (char === "/") return $lineComment; if (char === "*") return $multilineComment; return $start(char); } function $lineComment(char) { if (char === "\r" || char === "\n") return $start; return $lineComment; } function $multilineComment(char) { if (char === "*") return $multilineEnding; return $multilineComment; } function $multilineEnding(char) { if (char === "/") return $start; if (char === "*") return $multilineEnding; return $multilineComment; } var state = $start; for (var i = 0, l = js.length; i < l; i++) { state = state(js[i]); } return names; }
[ "function", "mine", "(", "js", ")", "{", "var", "names", "=", "[", "]", ";", "var", "state", "=", "0", ";", "var", "ident", ";", "var", "quote", ";", "var", "name", ";", "var", "isIdent", "=", "/", "[a-z0-9_.]", "/", "i", ";", "var", "isWhitespace", "=", "/", "[ \\r\\n\\t]", "/", ";", "function", "$start", "(", "char", ")", "{", "if", "(", "char", "===", "\"/\"", ")", "{", "return", "$slash", ";", "}", "if", "(", "char", "===", "\"'\"", "||", "char", "===", "'\"'", ")", "{", "quote", "=", "char", ";", "return", "$string", ";", "}", "if", "(", "isIdent", ".", "test", "(", "char", ")", ")", "{", "ident", "=", "char", ";", "return", "$ident", ";", "}", "return", "$start", ";", "}", "function", "$ident", "(", "char", ")", "{", "if", "(", "isIdent", ".", "test", "(", "char", ")", ")", "{", "ident", "+=", "char", ";", "return", "$ident", ";", "}", "if", "(", "char", "===", "\"(\"", "&&", "ident", "===", "\"require\"", ")", "{", "ident", "=", "undefined", ";", "return", "$call", ";", "}", "return", "$start", "(", "char", ")", ";", "}", "function", "$call", "(", "char", ")", "{", "if", "(", "isWhitespace", ".", "test", "(", "char", ")", ")", "return", "$call", ";", "if", "(", "char", "===", "\"'\"", "||", "char", "===", "'\"'", ")", "{", "quote", "=", "char", ";", "name", "=", "\"\"", ";", "return", "$name", ";", "}", "return", "$start", "(", "char", ")", ";", "}", "function", "$name", "(", "char", ")", "{", "if", "(", "char", "===", "quote", ")", "{", "return", "$close", ";", "}", "name", "+=", "char", ";", "return", "$name", ";", "}", "function", "$close", "(", "char", ")", "{", "if", "(", "isWhitespace", ".", "test", "(", "char", ")", ")", "return", "$close", ";", "if", "(", "char", "===", "\")\"", "||", "char", "===", "','", ")", "{", "names", ".", "push", "(", "name", ")", ";", "}", "name", "=", "undefined", ";", "return", "$start", "(", "char", ")", ";", "}", "function", "$string", "(", "char", ")", "{", "if", "(", "char", "===", "\"\\\\\"", ")", "{", "return", "$escape", ";", "}", "if", "(", "char", "===", "quote", ")", "{", "return", "$start", ";", "}", "return", "$string", ";", "}", "function", "$escape", "(", "char", ")", "{", "return", "$string", ";", "}", "function", "$slash", "(", "char", ")", "{", "if", "(", "char", "===", "\"/\"", ")", "return", "$lineComment", ";", "if", "(", "char", "===", "\"*\"", ")", "return", "$multilineComment", ";", "return", "$start", "(", "char", ")", ";", "}", "function", "$lineComment", "(", "char", ")", "{", "if", "(", "char", "===", "\"\\r\"", "||", "char", "===", "\"\\n\"", ")", "return", "$start", ";", "return", "$lineComment", ";", "}", "function", "$multilineComment", "(", "char", ")", "{", "if", "(", "char", "===", "\"*\"", ")", "return", "$multilineEnding", ";", "return", "$multilineComment", ";", "}", "function", "$multilineEnding", "(", "char", ")", "{", "if", "(", "char", "===", "\"/\"", ")", "return", "$start", ";", "if", "(", "char", "===", "\"*\"", ")", "return", "$multilineEnding", ";", "return", "$multilineComment", ";", "}", "var", "state", "=", "$start", ";", "for", "(", "var", "i", "=", "0", ",", "l", "=", "js", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "state", "=", "state", "(", "js", "[", "i", "]", ")", ";", "}", "return", "names", ";", "}" ]
Mine a string for require calls and export the module names Extract all require calls using a proper state-machine parser.
[ "Mine", "a", "string", "for", "require", "calls", "and", "export", "the", "module", "names", "Extract", "all", "require", "calls", "using", "a", "proper", "state", "-", "machine", "parser", "." ]
4a6da31f5898bd32d44e8fbad312444cc30809bf
https://github.com/OffByNone/Omniscience-UPnP/blob/4a6da31f5898bd32d44e8fbad312444cc30809bf/Chrome_module.js#L281-L386
49,585
wshager/js-rrb-vector
src/concat.js
allocate
function allocate(height, length) { var node = new Array(length); node.height = height; if (height > 0) { node.sizes = new Array(length); } return node; }
javascript
function allocate(height, length) { var node = new Array(length); node.height = height; if (height > 0) { node.sizes = new Array(length); } return node; }
[ "function", "allocate", "(", "height", ",", "length", ")", "{", "var", "node", "=", "new", "Array", "(", "length", ")", ";", "node", ".", "height", "=", "height", ";", "if", "(", "height", ">", "0", ")", "{", "node", ".", "sizes", "=", "new", "Array", "(", "length", ")", ";", "}", "return", "node", ";", "}" ]
Creates a node or leaf with a given length at their arrays for performance. Is only used by shuffle.
[ "Creates", "a", "node", "or", "leaf", "with", "a", "given", "length", "at", "their", "arrays", "for", "performance", ".", "Is", "only", "used", "by", "shuffle", "." ]
766c3c12f658cc251dce028460c4eca4e33d5254
https://github.com/wshager/js-rrb-vector/blob/766c3c12f658cc251dce028460c4eca4e33d5254/src/concat.js#L225-L232
49,586
wshager/js-rrb-vector
src/concat.js
saveSlot
function saveSlot(aList, bList, index, slot) { setEither(aList, bList, index, slot); var isInFirst = (index === 0 || index === aList.sizes.length); var len = isInFirst ? 0 : getEither(aList.sizes, bList.sizes, index - 1); setEither(aList.sizes, bList.sizes, index, len + length(slot)); }
javascript
function saveSlot(aList, bList, index, slot) { setEither(aList, bList, index, slot); var isInFirst = (index === 0 || index === aList.sizes.length); var len = isInFirst ? 0 : getEither(aList.sizes, bList.sizes, index - 1); setEither(aList.sizes, bList.sizes, index, len + length(slot)); }
[ "function", "saveSlot", "(", "aList", ",", "bList", ",", "index", ",", "slot", ")", "{", "setEither", "(", "aList", ",", "bList", ",", "index", ",", "slot", ")", ";", "var", "isInFirst", "=", "(", "index", "===", "0", "||", "index", "===", "aList", ".", "sizes", ".", "length", ")", ";", "var", "len", "=", "isInFirst", "?", "0", ":", "getEither", "(", "aList", ".", "sizes", ",", "bList", ".", "sizes", ",", "index", "-", "1", ")", ";", "setEither", "(", "aList", ".", "sizes", ",", "bList", ".", "sizes", ",", "index", ",", "len", "+", "length", "(", "slot", ")", ")", ";", "}" ]
helper for setting picking a slot between to nodes @param {Node} aList - a non-leaf node @param {Node} bList - a non-leaf node @param {number} index @param {Node} slot
[ "helper", "for", "setting", "picking", "a", "slot", "between", "to", "nodes" ]
766c3c12f658cc251dce028460c4eca4e33d5254
https://github.com/wshager/js-rrb-vector/blob/766c3c12f658cc251dce028460c4eca4e33d5254/src/concat.js#L241-L248
49,587
raincatcher-beta/raincatcher-result
lib/client/result-client/index.js
start
function start() { var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START, CONSTANTS.DONE_PREFIX)); var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START, CONSTANTS.ERROR_PREFIX)); mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START)); return getTopicPromises(donePromise, errorPromise); }
javascript
function start() { var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START, CONSTANTS.DONE_PREFIX)); var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START, CONSTANTS.ERROR_PREFIX)); mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START)); return getTopicPromises(donePromise, errorPromise); }
[ "function", "start", "(", ")", "{", "var", "donePromise", "=", "mediator", ".", "promise", "(", "resultSyncSubscribers", ".", "getTopic", "(", "CONSTANTS", ".", "TOPICS", ".", "START", ",", "CONSTANTS", ".", "DONE_PREFIX", ")", ")", ";", "var", "errorPromise", "=", "mediator", ".", "promise", "(", "resultSyncSubscribers", ".", "getTopic", "(", "CONSTANTS", ".", "TOPICS", ".", "START", ",", "CONSTANTS", ".", "ERROR_PREFIX", ")", ")", ";", "mediator", ".", "publish", "(", "resultSyncSubscribers", ".", "getTopic", "(", "CONSTANTS", ".", "TOPICS", ".", "START", ")", ")", ";", "return", "getTopicPromises", "(", "donePromise", ",", "errorPromise", ")", ";", "}" ]
Starting the synchronisation process for results.
[ "Starting", "the", "synchronisation", "process", "for", "results", "." ]
8ed874f22aecb8105998635b2cee6b13abe01647
https://github.com/raincatcher-beta/raincatcher-result/blob/8ed874f22aecb8105998635b2cee6b13abe01647/lib/client/result-client/index.js#L123-L132
49,588
raincatcher-beta/raincatcher-result
lib/client/result-client/index.js
stop
function stop() { var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP, CONSTANTS.DONE_PREFIX)); var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP, CONSTANTS.ERROR_PREFIX)); mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP)); return getTopicPromises(donePromise, errorPromise); }
javascript
function stop() { var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP, CONSTANTS.DONE_PREFIX)); var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP, CONSTANTS.ERROR_PREFIX)); mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP)); return getTopicPromises(donePromise, errorPromise); }
[ "function", "stop", "(", ")", "{", "var", "donePromise", "=", "mediator", ".", "promise", "(", "resultSyncSubscribers", ".", "getTopic", "(", "CONSTANTS", ".", "TOPICS", ".", "STOP", ",", "CONSTANTS", ".", "DONE_PREFIX", ")", ")", ";", "var", "errorPromise", "=", "mediator", ".", "promise", "(", "resultSyncSubscribers", ".", "getTopic", "(", "CONSTANTS", ".", "TOPICS", ".", "STOP", ",", "CONSTANTS", ".", "ERROR_PREFIX", ")", ")", ";", "mediator", ".", "publish", "(", "resultSyncSubscribers", ".", "getTopic", "(", "CONSTANTS", ".", "TOPICS", ".", "STOP", ")", ")", ";", "return", "getTopicPromises", "(", "donePromise", ",", "errorPromise", ")", ";", "}" ]
Stopping the synchronisation process for results.
[ "Stopping", "the", "synchronisation", "process", "for", "results", "." ]
8ed874f22aecb8105998635b2cee6b13abe01647
https://github.com/raincatcher-beta/raincatcher-result/blob/8ed874f22aecb8105998635b2cee6b13abe01647/lib/client/result-client/index.js#L137-L145
49,589
raincatcher-beta/raincatcher-result
lib/client/result-client/index.js
forceSync
function forceSync() { var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.DONE_PREFIX)); var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.ERROR_PREFIX)); mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC)); return getTopicPromises(donePromise, errorPromise); }
javascript
function forceSync() { var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.DONE_PREFIX)); var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.ERROR_PREFIX)); mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC)); return getTopicPromises(donePromise, errorPromise); }
[ "function", "forceSync", "(", ")", "{", "var", "donePromise", "=", "mediator", ".", "promise", "(", "resultSyncSubscribers", ".", "getTopic", "(", "CONSTANTS", ".", "TOPICS", ".", "FORCE_SYNC", ",", "CONSTANTS", ".", "DONE_PREFIX", ")", ")", ";", "var", "errorPromise", "=", "mediator", ".", "promise", "(", "resultSyncSubscribers", ".", "getTopic", "(", "CONSTANTS", ".", "TOPICS", ".", "FORCE_SYNC", ",", "CONSTANTS", ".", "ERROR_PREFIX", ")", ")", ";", "mediator", ".", "publish", "(", "resultSyncSubscribers", ".", "getTopic", "(", "CONSTANTS", ".", "TOPICS", ".", "FORCE_SYNC", ")", ")", ";", "return", "getTopicPromises", "(", "donePromise", ",", "errorPromise", ")", ";", "}" ]
Forcing the results to sync to the remote store.
[ "Forcing", "the", "results", "to", "sync", "to", "the", "remote", "store", "." ]
8ed874f22aecb8105998635b2cee6b13abe01647
https://github.com/raincatcher-beta/raincatcher-result/blob/8ed874f22aecb8105998635b2cee6b13abe01647/lib/client/result-client/index.js#L150-L158
49,590
cli-kit/cli-help
lib/doc/markdown.js
function() { this.colon = false; HelpDocument.apply(this, arguments); this.format = fmt.MARKDOWN_FORMAT; this.vanilla = true; this.useCustom = true; // disable columns this.use = false; var format = '* `%s`: %s'; var overrides = { synopsis: '```synopsis\n%s\n```' } this.markdown = {}; var conf = this.conf.markdown || {}, i, key; var formats = conf.formats || {}; for(i = 0;i < this.sections.length;i++) { key = this.sections[i]; this.markdown[key] = formats[key] || overrides[key] || format; } }
javascript
function() { this.colon = false; HelpDocument.apply(this, arguments); this.format = fmt.MARKDOWN_FORMAT; this.vanilla = true; this.useCustom = true; // disable columns this.use = false; var format = '* `%s`: %s'; var overrides = { synopsis: '```synopsis\n%s\n```' } this.markdown = {}; var conf = this.conf.markdown || {}, i, key; var formats = conf.formats || {}; for(i = 0;i < this.sections.length;i++) { key = this.sections[i]; this.markdown[key] = formats[key] || overrides[key] || format; } }
[ "function", "(", ")", "{", "this", ".", "colon", "=", "false", ";", "HelpDocument", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "format", "=", "fmt", ".", "MARKDOWN_FORMAT", ";", "this", ".", "vanilla", "=", "true", ";", "this", ".", "useCustom", "=", "true", ";", "// disable columns", "this", ".", "use", "=", "false", ";", "var", "format", "=", "'* `%s`: %s'", ";", "var", "overrides", "=", "{", "synopsis", ":", "'```synopsis\\n%s\\n```'", "}", "this", ".", "markdown", "=", "{", "}", ";", "var", "conf", "=", "this", ".", "conf", ".", "markdown", "||", "{", "}", ",", "i", ",", "key", ";", "var", "formats", "=", "conf", ".", "formats", "||", "{", "}", ";", "for", "(", "i", "=", "0", ";", "i", "<", "this", ".", "sections", ".", "length", ";", "i", "++", ")", "{", "key", "=", "this", ".", "sections", "[", "i", "]", ";", "this", ".", "markdown", "[", "key", "]", "=", "formats", "[", "key", "]", "||", "overrides", "[", "key", "]", "||", "format", ";", "}", "}" ]
Help document that outputs as markdown.
[ "Help", "document", "that", "outputs", "as", "markdown", "." ]
09613efdd753452b466d4deb7c5391c4926e3f04
https://github.com/cli-kit/cli-help/blob/09613efdd753452b466d4deb7c5391c4926e3f04/lib/doc/markdown.js#L13-L32
49,591
yefremov/aggregatejs
average.js
average
function average(array) { var length = array.length; if (length === 0) { throw new RangeError("Error"); } var index = -1; var result = 0; while (++index < length) { result += array[index]; } return result / length; }
javascript
function average(array) { var length = array.length; if (length === 0) { throw new RangeError("Error"); } var index = -1; var result = 0; while (++index < length) { result += array[index]; } return result / length; }
[ "function", "average", "(", "array", ")", "{", "var", "length", "=", "array", ".", "length", ";", "if", "(", "length", "===", "0", ")", "{", "throw", "new", "RangeError", "(", "\"Error\"", ")", ";", "}", "var", "index", "=", "-", "1", ";", "var", "result", "=", "0", ";", "while", "(", "++", "index", "<", "length", ")", "{", "result", "+=", "array", "[", "index", "]", ";", "}", "return", "result", "/", "length", ";", "}" ]
Returns the average of the numbers in `array`. @param {Array} array Range of numbers to get the average. @return {number} @example average([100, -100, 150, -50, 100, 250]); // => 75
[ "Returns", "the", "average", "of", "the", "numbers", "in", "array", "." ]
932b28a15a5707135e7095950000a838db409511
https://github.com/yefremov/aggregatejs/blob/932b28a15a5707135e7095950000a838db409511/average.js#L19-L34
49,592
tolokoban/ToloFrameWork
lib/configuration-loader.js
checkCompilationType
function checkCompilationType( config ) { if ( config.tfw.compile.type === 'firefoxos' ) { config.tfw.compile.type = 'web'; } else { config.tfw.compile.type = 'desktop'; } }
javascript
function checkCompilationType( config ) { if ( config.tfw.compile.type === 'firefoxos' ) { config.tfw.compile.type = 'web'; } else { config.tfw.compile.type = 'desktop'; } }
[ "function", "checkCompilationType", "(", "config", ")", "{", "if", "(", "config", ".", "tfw", ".", "compile", ".", "type", "===", "'firefoxos'", ")", "{", "config", ".", "tfw", ".", "compile", ".", "type", "=", "'web'", ";", "}", "else", "{", "config", ".", "tfw", ".", "compile", ".", "type", "=", "'desktop'", ";", "}", "}" ]
Prior to version 0.46, compilation types were `firefoxos` and `nodewebkit`. Now, we use `web` and `desktop`. @param {object} config - Configuration as object. @returns {undefined}
[ "Prior", "to", "version", "0", ".", "46", "compilation", "types", "were", "firefoxos", "and", "nodewebkit", ".", "Now", "we", "use", "web", "and", "desktop", "." ]
730845a833a9660ebfdb60ad027ebaab5ac871b6
https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/configuration-loader.js#L151-L157
49,593
darkoverlordofdata/liquid.coffee
example/scrumptious/public/js/main.js
handleStatusChange
function handleStatusChange(response) { if (response.authResponse) { logResponse(response); window.location.hash = '#menu'; updateUserInfo(response); } else { window.location.hash = '#login'; } }
javascript
function handleStatusChange(response) { if (response.authResponse) { logResponse(response); window.location.hash = '#menu'; updateUserInfo(response); } else { window.location.hash = '#login'; } }
[ "function", "handleStatusChange", "(", "response", ")", "{", "if", "(", "response", ".", "authResponse", ")", "{", "logResponse", "(", "response", ")", ";", "window", ".", "location", ".", "hash", "=", "'#menu'", ";", "updateUserInfo", "(", "response", ")", ";", "}", "else", "{", "window", ".", "location", ".", "hash", "=", "'#login'", ";", "}", "}" ]
AUTHENTICATION Handle status changes
[ "AUTHENTICATION", "Handle", "status", "changes" ]
7480f98580f3b9e6358e564e6d9d1a7ecd562bb8
https://github.com/darkoverlordofdata/liquid.coffee/blob/7480f98580f3b9e6358e564e6d9d1a7ecd562bb8/example/scrumptious/public/js/main.js#L182-L190
49,594
darkoverlordofdata/liquid.coffee
example/scrumptious/public/js/main.js
displayMealList
function displayMealList() { // Meal list logResponse("[displayMealList] displaying meal list."); var tmpl = $("#meal_list_tmpl").html(); var output = Mustache.to_html(tmpl, meals); $("#meal-list").html(output).listview('refresh'); }
javascript
function displayMealList() { // Meal list logResponse("[displayMealList] displaying meal list."); var tmpl = $("#meal_list_tmpl").html(); var output = Mustache.to_html(tmpl, meals); $("#meal-list").html(output).listview('refresh'); }
[ "function", "displayMealList", "(", ")", "{", "// Meal list", "logResponse", "(", "\"[displayMealList] displaying meal list.\"", ")", ";", "var", "tmpl", "=", "$", "(", "\"#meal_list_tmpl\"", ")", ".", "html", "(", ")", ";", "var", "output", "=", "Mustache", ".", "to_html", "(", "tmpl", ",", "meals", ")", ";", "$", "(", "\"#meal-list\"", ")", ".", "html", "(", "output", ")", ".", "listview", "(", "'refresh'", ")", ";", "}" ]
DATA FETCH AND DISPLAY Meals
[ "DATA", "FETCH", "AND", "DISPLAY", "Meals" ]
7480f98580f3b9e6358e564e6d9d1a7ecd562bb8
https://github.com/darkoverlordofdata/liquid.coffee/blob/7480f98580f3b9e6358e564e6d9d1a7ecd562bb8/example/scrumptious/public/js/main.js#L324-L330
49,595
buzzin0609/tagbuildr
src/appendChildren.js
appendChildren
function appendChildren(children, el) { ensureArray(children) .forEach(append.bind(el)); return el; }
javascript
function appendChildren(children, el) { ensureArray(children) .forEach(append.bind(el)); return el; }
[ "function", "appendChildren", "(", "children", ",", "el", ")", "{", "ensureArray", "(", "children", ")", ".", "forEach", "(", "append", ".", "bind", "(", "el", ")", ")", ";", "return", "el", ";", "}" ]
Convenience function to add multiple children nodes to the element @param {Array} children a mixed array of strings|elements|html to add to the element @param {Element} el the dom element
[ "Convenience", "function", "to", "add", "multiple", "children", "nodes", "to", "the", "element" ]
9d6a52ad51c0fc3230de2da1e8e3f63f95a6e542
https://github.com/buzzin0609/tagbuildr/blob/9d6a52ad51c0fc3230de2da1e8e3f63f95a6e542/src/appendChildren.js#L8-L12
49,596
vindm/procss
example/plugin.js
function(scope) { console.log( 'Before start to process input files:', scope.files.map(function(file) { var rulesCount = file.parsed.rules.length; rulesCount += ' rule' + (rulesCount > 1 ? 's' : ''); return '\n' + rulesCount + ' in ' + file.config.input; }).join(',') ); }
javascript
function(scope) { console.log( 'Before start to process input files:', scope.files.map(function(file) { var rulesCount = file.parsed.rules.length; rulesCount += ' rule' + (rulesCount > 1 ? 's' : ''); return '\n' + rulesCount + ' in ' + file.config.input; }).join(',') ); }
[ "function", "(", "scope", ")", "{", "console", ".", "log", "(", "'Before start to process input files:'", ",", "scope", ".", "files", ".", "map", "(", "function", "(", "file", ")", "{", "var", "rulesCount", "=", "file", ".", "parsed", ".", "rules", ".", "length", ";", "rulesCount", "+=", "' rule'", "+", "(", "rulesCount", ">", "1", "?", "'s'", ":", "''", ")", ";", "return", "'\\n'", "+", "rulesCount", "+", "' in '", "+", "file", ".", "config", ".", "input", ";", "}", ")", ".", "join", "(", "','", ")", ")", ";", "}" ]
Will be called before start to process input files @param {Object} scope @param {File[]} scope.files Parsed input files
[ "Will", "be", "called", "before", "start", "to", "process", "input", "files" ]
b08e2169f23a9648a9c10fe800e077d1392bbfe5
https://github.com/vindm/procss/blob/b08e2169f23a9648a9c10fe800e077d1392bbfe5/example/plugin.js#L35-L46
49,597
vindm/procss
example/plugin.js
function(scope, config) { var isAngry = config.mood === 'angry', isColorExist; console.log( '\nProcessing command: ' + scope.command.name ); if (scope.decl.prop === 'content') { scope.decl.value = isAngry ? '"BAD BAD NOT GOOD"' : '"GOOD GOOD NOT BAD"'; } isColorExist = scope.rule.decls.some(function(decl) { if (decl.prop === 'color') { decl.value = isAngry ? 'red' : 'pink'; return true; } if ( ! isAngry && decl.prop === 'font-size') { decl.value = '48px'; } }); if ( ! isColorExist) { scope.rule.append({ prop : 'color', value : isAngry ? 'red' : 'pink' }); } (scope.angrifiedCount || (scope.angrifiedCount = 0)); scope.angrifiedCount++; }
javascript
function(scope, config) { var isAngry = config.mood === 'angry', isColorExist; console.log( '\nProcessing command: ' + scope.command.name ); if (scope.decl.prop === 'content') { scope.decl.value = isAngry ? '"BAD BAD NOT GOOD"' : '"GOOD GOOD NOT BAD"'; } isColorExist = scope.rule.decls.some(function(decl) { if (decl.prop === 'color') { decl.value = isAngry ? 'red' : 'pink'; return true; } if ( ! isAngry && decl.prop === 'font-size') { decl.value = '48px'; } }); if ( ! isColorExist) { scope.rule.append({ prop : 'color', value : isAngry ? 'red' : 'pink' }); } (scope.angrifiedCount || (scope.angrifiedCount = 0)); scope.angrifiedCount++; }
[ "function", "(", "scope", ",", "config", ")", "{", "var", "isAngry", "=", "config", ".", "mood", "===", "'angry'", ",", "isColorExist", ";", "console", ".", "log", "(", "'\\nProcessing command: '", "+", "scope", ".", "command", ".", "name", ")", ";", "if", "(", "scope", ".", "decl", ".", "prop", "===", "'content'", ")", "{", "scope", ".", "decl", ".", "value", "=", "isAngry", "?", "'\"BAD BAD NOT GOOD\"'", ":", "'\"GOOD GOOD NOT BAD\"'", ";", "}", "isColorExist", "=", "scope", ".", "rule", ".", "decls", ".", "some", "(", "function", "(", "decl", ")", "{", "if", "(", "decl", ".", "prop", "===", "'color'", ")", "{", "decl", ".", "value", "=", "isAngry", "?", "'red'", ":", "'pink'", ";", "return", "true", ";", "}", "if", "(", "!", "isAngry", "&&", "decl", ".", "prop", "===", "'font-size'", ")", "{", "decl", ".", "value", "=", "'48px'", ";", "}", "}", ")", ";", "if", "(", "!", "isColorExist", ")", "{", "scope", ".", "rule", ".", "append", "(", "{", "prop", ":", "'color'", ",", "value", ":", "isAngry", "?", "'red'", ":", "'pink'", "}", ")", ";", "}", "(", "scope", ".", "angrifiedCount", "||", "(", "scope", ".", "angrifiedCount", "=", "0", ")", ")", ";", "scope", ".", "angrifiedCount", "++", ";", "}" ]
Will be called on each parsed command @param {Object} scope @param {File[]} scope.files Parsed input files @param {File} scope.file Current processing file node @param {Rule} scope.rule Current processing rule node @param {Decl} scope.decl Current processing declaration node @param {Command} scope.command Current processing command @param {Object} config Plugin config for processing file
[ "Will", "be", "called", "on", "each", "parsed", "command" ]
b08e2169f23a9648a9c10fe800e077d1392bbfe5
https://github.com/vindm/procss/blob/b08e2169f23a9648a9c10fe800e077d1392bbfe5/example/plugin.js#L72-L107
49,598
GerHobbelt/jison-helpers-lib
dist/helpers-lib-umd.js
dquote
function dquote(s) { var sq = (s.indexOf('\'') >= 0); var dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; } else { s = '"' + s + '"'; } return s; }
javascript
function dquote(s) { var sq = (s.indexOf('\'') >= 0); var dq = (s.indexOf('"') >= 0); if (sq && dq) { s = s.replace(/"/g, '\\"'); dq = false; } if (dq) { s = '\'' + s + '\''; } else { s = '"' + s + '"'; } return s; }
[ "function", "dquote", "(", "s", ")", "{", "var", "sq", "=", "(", "s", ".", "indexOf", "(", "'\\''", ")", ">=", "0", ")", ";", "var", "dq", "=", "(", "s", ".", "indexOf", "(", "'\"'", ")", ">=", "0", ")", ";", "if", "(", "sq", "&&", "dq", ")", "{", "s", "=", "s", ".", "replace", "(", "/", "\"", "/", "g", ",", "'\\\\\"'", ")", ";", "dq", "=", "false", ";", "}", "if", "(", "dq", ")", "{", "s", "=", "'\\''", "+", "s", "+", "'\\''", ";", "}", "else", "{", "s", "=", "'\"'", "+", "s", "+", "'\"'", ";", "}", "return", "s", ";", "}" ]
properly quote and escape the given input string
[ "properly", "quote", "and", "escape", "the", "given", "input", "string" ]
cbde7b780c2f6613027730403ed1b3908daf1007
https://github.com/GerHobbelt/jison-helpers-lib/blob/cbde7b780c2f6613027730403ed1b3908daf1007/dist/helpers-lib-umd.js#L112-L126
49,599
steveesamson/slicks-bee
libs/server.js
function (i) { workers[i] = cluster.fork(); console.log('Creating Worker: ', workers[i].process.pid); workers[i].on('message', m => { switch (m.type) { case 'STARTED': !startedWorkers && startWatches(); break; } }); // Optional: Restart worker on exit workers[i].on('exit', function (code, signal) { console.log('Respawning worker', i); spawn(i); }); }
javascript
function (i) { workers[i] = cluster.fork(); console.log('Creating Worker: ', workers[i].process.pid); workers[i].on('message', m => { switch (m.type) { case 'STARTED': !startedWorkers && startWatches(); break; } }); // Optional: Restart worker on exit workers[i].on('exit', function (code, signal) { console.log('Respawning worker', i); spawn(i); }); }
[ "function", "(", "i", ")", "{", "workers", "[", "i", "]", "=", "cluster", ".", "fork", "(", ")", ";", "console", ".", "log", "(", "'Creating Worker: '", ",", "workers", "[", "i", "]", ".", "process", ".", "pid", ")", ";", "workers", "[", "i", "]", ".", "on", "(", "'message'", ",", "m", "=>", "{", "switch", "(", "m", ".", "type", ")", "{", "case", "'STARTED'", ":", "!", "startedWorkers", "&&", "startWatches", "(", ")", ";", "break", ";", "}", "}", ")", ";", "// Optional: Restart worker on exit", "workers", "[", "i", "]", ".", "on", "(", "'exit'", ",", "function", "(", "code", ",", "signal", ")", "{", "console", ".", "log", "(", "'Respawning worker'", ",", "i", ")", ";", "spawn", "(", "i", ")", ";", "}", ")", ";", "}" ]
This stores our workers. We need to keep them to be able to reference them based on source IP address. It's also useful for auto-restart, for example.
[ "This", "stores", "our", "workers", ".", "We", "need", "to", "keep", "them", "to", "be", "able", "to", "reference", "them", "based", "on", "source", "IP", "address", ".", "It", "s", "also", "useful", "for", "auto", "-", "restart", "for", "example", "." ]
ebec403c21fa37ffec727aed1a92567679853e40
https://github.com/steveesamson/slicks-bee/blob/ebec403c21fa37ffec727aed1a92567679853e40/libs/server.js#L61-L77