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
43,200
neyric/webhookit
public/javascripts/yui/storage/storage.js
function(key) { Y.log("Fetching item at " + key); var item = this._getItem(key); return YL.isValue(item) ? this._getValue(item) : null; // required by HTML 5 spec }
javascript
function(key) { Y.log("Fetching item at " + key); var item = this._getItem(key); return YL.isValue(item) ? this._getValue(item) : null; // required by HTML 5 spec }
[ "function", "(", "key", ")", "{", "Y", ".", "log", "(", "\"Fetching item at \"", "+", "key", ")", ";", "var", "item", "=", "this", ".", "_getItem", "(", "key", ")", ";", "return", "YL", ".", "isValue", "(", "item", ")", "?", "this", ".", "_getValue", "(", "item", ")", ":", "null", ";", "// required by HTML 5 spec", "}" ]
Fetches the data stored and the provided key. @method getItem @param key {String} Required. The key used to reference this value (DOMString in HTML 5 spec). @return {String|NULL} The value stored at the provided key (DOMString in HTML 5 spec). @public
[ "Fetches", "the", "data", "stored", "and", "the", "provided", "key", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/storage/storage.js#L136-L140
43,201
neyric/webhookit
public/javascripts/yui/storage/storage.js
function(index) { Y.log("Fetching key at " + index); if (YL.isNumber(index) && -1 < index && this.length > index) { var value = this._key(index); if (value) {return value;} } // this is thrown according to the HTML5 spec throw('INDEX_SIZE_ERR - Storage.setItem - The provided index (' + index + ') is not available'); }
javascript
function(index) { Y.log("Fetching key at " + index); if (YL.isNumber(index) && -1 < index && this.length > index) { var value = this._key(index); if (value) {return value;} } // this is thrown according to the HTML5 spec throw('INDEX_SIZE_ERR - Storage.setItem - The provided index (' + index + ') is not available'); }
[ "function", "(", "index", ")", "{", "Y", ".", "log", "(", "\"Fetching key at \"", "+", "index", ")", ";", "if", "(", "YL", ".", "isNumber", "(", "index", ")", "&&", "-", "1", "<", "index", "&&", "this", ".", "length", ">", "index", ")", "{", "var", "value", "=", "this", ".", "_key", "(", "index", ")", ";", "if", "(", "value", ")", "{", "return", "value", ";", "}", "}", "// this is thrown according to the HTML5 spec", "throw", "(", "'INDEX_SIZE_ERR - Storage.setItem - The provided index ('", "+", "index", "+", "') is not available'", ")", ";", "}" ]
Retrieve the key stored at the provided index; should be overwritten by storage engine. @method key @param index {Number} Required. The index to retrieve (unsigned long in HTML 5 spec). @return {String} Required. The key at the provided index (DOMString in HTML 5 spec). @public
[ "Retrieve", "the", "key", "stored", "at", "the", "provided", "index", ";", "should", "be", "overwritten", "by", "storage", "engine", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/storage/storage.js#L168-L178
43,202
neyric/webhookit
public/javascripts/yui/storage/storage.js
function(key) { Y.log("removing " + key); if (this.hasKey(key)) { var oldValue = this._getItem(key); if (! oldValue) {oldValue = null;} this._removeItem(key); this.fireEvent(this.CE_CHANGE, new YU.StorageEvent(this, key, oldValue, null, YU.StorageEvent.TYPE_REMOVE_ITEM)); } else { // HTML 5 spec says to do nothing } }
javascript
function(key) { Y.log("removing " + key); if (this.hasKey(key)) { var oldValue = this._getItem(key); if (! oldValue) {oldValue = null;} this._removeItem(key); this.fireEvent(this.CE_CHANGE, new YU.StorageEvent(this, key, oldValue, null, YU.StorageEvent.TYPE_REMOVE_ITEM)); } else { // HTML 5 spec says to do nothing } }
[ "function", "(", "key", ")", "{", "Y", ".", "log", "(", "\"removing \"", "+", "key", ")", ";", "if", "(", "this", ".", "hasKey", "(", "key", ")", ")", "{", "var", "oldValue", "=", "this", ".", "_getItem", "(", "key", ")", ";", "if", "(", "!", "oldValue", ")", "{", "oldValue", "=", "null", ";", "}", "this", ".", "_removeItem", "(", "key", ")", ";", "this", ".", "fireEvent", "(", "this", ".", "CE_CHANGE", ",", "new", "YU", ".", "StorageEvent", "(", "this", ",", "key", ",", "oldValue", ",", "null", ",", "YU", ".", "StorageEvent", ".", "TYPE_REMOVE_ITEM", ")", ")", ";", "}", "else", "{", "// HTML 5 spec says to do nothing", "}", "}" ]
Remove an item from the data storage. @method setItem @param key {String} Required. The key to remove (DOMString in HTML 5 spec). @public
[ "Remove", "an", "item", "from", "the", "data", "storage", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/storage/storage.js#L186-L198
43,203
neyric/webhookit
public/javascripts/yui/storage/storage.js
function(key, data) { Y.log("SETTING " + data + " to " + key); if (YL.isString(key)) { var eventType = this.hasKey(key) ? YU.StorageEvent.TYPE_UPDATE_ITEM : YU.StorageEvent.TYPE_ADD_ITEM, oldValue = this._getItem(key); if (! oldValue) {oldValue = null;} if (this._setItem(key, this._createValue(data))) { this.fireEvent(this.CE_CHANGE, new YU.StorageEvent(this, key, oldValue, data, eventType)); } else { // this is thrown according to the HTML5 spec throw('QUOTA_EXCEEDED_ERROR - Storage.setItem - The choosen storage method (' + this.getName() + ') has exceeded capacity'); } } else { // HTML 5 spec says to do nothing } }
javascript
function(key, data) { Y.log("SETTING " + data + " to " + key); if (YL.isString(key)) { var eventType = this.hasKey(key) ? YU.StorageEvent.TYPE_UPDATE_ITEM : YU.StorageEvent.TYPE_ADD_ITEM, oldValue = this._getItem(key); if (! oldValue) {oldValue = null;} if (this._setItem(key, this._createValue(data))) { this.fireEvent(this.CE_CHANGE, new YU.StorageEvent(this, key, oldValue, data, eventType)); } else { // this is thrown according to the HTML5 spec throw('QUOTA_EXCEEDED_ERROR - Storage.setItem - The choosen storage method (' + this.getName() + ') has exceeded capacity'); } } else { // HTML 5 spec says to do nothing } }
[ "function", "(", "key", ",", "data", ")", "{", "Y", ".", "log", "(", "\"SETTING \"", "+", "data", "+", "\" to \"", "+", "key", ")", ";", "if", "(", "YL", ".", "isString", "(", "key", ")", ")", "{", "var", "eventType", "=", "this", ".", "hasKey", "(", "key", ")", "?", "YU", ".", "StorageEvent", ".", "TYPE_UPDATE_ITEM", ":", "YU", ".", "StorageEvent", ".", "TYPE_ADD_ITEM", ",", "oldValue", "=", "this", ".", "_getItem", "(", "key", ")", ";", "if", "(", "!", "oldValue", ")", "{", "oldValue", "=", "null", ";", "}", "if", "(", "this", ".", "_setItem", "(", "key", ",", "this", ".", "_createValue", "(", "data", ")", ")", ")", "{", "this", ".", "fireEvent", "(", "this", ".", "CE_CHANGE", ",", "new", "YU", ".", "StorageEvent", "(", "this", ",", "key", ",", "oldValue", ",", "data", ",", "eventType", ")", ")", ";", "}", "else", "{", "// this is thrown according to the HTML5 spec", "throw", "(", "'QUOTA_EXCEEDED_ERROR - Storage.setItem - The choosen storage method ('", "+", "this", ".", "getName", "(", ")", "+", "') has exceeded capacity'", ")", ";", "}", "}", "else", "{", "// HTML 5 spec says to do nothing", "}", "}" ]
Adds an item to the data storage. @method setItem @param key {String} Required. The key used to reference this value (DOMString in HTML 5 spec). @param data {Object} Required. The data to store at key (DOMString in HTML 5 spec). @public @throws QUOTA_EXCEEDED_ERROR
[ "Adds", "an", "item", "to", "the", "data", "storage", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/storage/storage.js#L208-L228
43,204
neyric/webhookit
public/javascripts/yui/storage/storage.js
function(s) { var a = s ? s.split(this.DELIMITER) : []; if (1 == a.length) {return s;} switch (a[0]) { case 'boolean': return 'true' === a[1]; case 'number': return parseFloat(a[1]); case 'null': return null; default: return a[1]; } }
javascript
function(s) { var a = s ? s.split(this.DELIMITER) : []; if (1 == a.length) {return s;} switch (a[0]) { case 'boolean': return 'true' === a[1]; case 'number': return parseFloat(a[1]); case 'null': return null; default: return a[1]; } }
[ "function", "(", "s", ")", "{", "var", "a", "=", "s", "?", "s", ".", "split", "(", "this", ".", "DELIMITER", ")", ":", "[", "]", ";", "if", "(", "1", "==", "a", ".", "length", ")", "{", "return", "s", ";", "}", "switch", "(", "a", "[", "0", "]", ")", "{", "case", "'boolean'", ":", "return", "'true'", "===", "a", "[", "1", "]", ";", "case", "'number'", ":", "return", "parseFloat", "(", "a", "[", "1", "]", ")", ";", "case", "'null'", ":", "return", "null", ";", "default", ":", "return", "a", "[", "1", "]", ";", "}", "}" ]
Converts the stored value into its appropriate type. @method _getValue @param s {String} Required. The stored value. @protected
[ "Converts", "the", "stored", "value", "into", "its", "appropriate", "type", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/storage/storage.js#L269-L279
43,205
neyric/webhookit
public/javascripts/yui/storage/storage.js
function(engineType, location, conf) { var _cfg = YL.isObject(conf) ? conf : {}, klass = _getClass(_registeredEngineMap[engineType]); if (! klass && ! _cfg.force) { var i, j; if (_cfg.order) { j = _cfg.order.length; for (i = 0; i < j && ! klass; i += 1) { klass = _getClass(_cfg.order[i]); } } if (! klass) { j = _registeredEngineSet.length; for (i = 0; i < j && ! klass; i += 1) { klass = _getClass(_registeredEngineSet[i]); } } } if (klass) { return _getStorageEngine(_getValidLocation(location), klass, _cfg.engine); } throw('YAHOO.util.StorageManager.get - No engine available, please include an engine before calling this function.'); }
javascript
function(engineType, location, conf) { var _cfg = YL.isObject(conf) ? conf : {}, klass = _getClass(_registeredEngineMap[engineType]); if (! klass && ! _cfg.force) { var i, j; if (_cfg.order) { j = _cfg.order.length; for (i = 0; i < j && ! klass; i += 1) { klass = _getClass(_cfg.order[i]); } } if (! klass) { j = _registeredEngineSet.length; for (i = 0; i < j && ! klass; i += 1) { klass = _getClass(_registeredEngineSet[i]); } } } if (klass) { return _getStorageEngine(_getValidLocation(location), klass, _cfg.engine); } throw('YAHOO.util.StorageManager.get - No engine available, please include an engine before calling this function.'); }
[ "function", "(", "engineType", ",", "location", ",", "conf", ")", "{", "var", "_cfg", "=", "YL", ".", "isObject", "(", "conf", ")", "?", "conf", ":", "{", "}", ",", "klass", "=", "_getClass", "(", "_registeredEngineMap", "[", "engineType", "]", ")", ";", "if", "(", "!", "klass", "&&", "!", "_cfg", ".", "force", ")", "{", "var", "i", ",", "j", ";", "if", "(", "_cfg", ".", "order", ")", "{", "j", "=", "_cfg", ".", "order", ".", "length", ";", "for", "(", "i", "=", "0", ";", "i", "<", "j", "&&", "!", "klass", ";", "i", "+=", "1", ")", "{", "klass", "=", "_getClass", "(", "_cfg", ".", "order", "[", "i", "]", ")", ";", "}", "}", "if", "(", "!", "klass", ")", "{", "j", "=", "_registeredEngineSet", ".", "length", ";", "for", "(", "i", "=", "0", ";", "i", "<", "j", "&&", "!", "klass", ";", "i", "+=", "1", ")", "{", "klass", "=", "_getClass", "(", "_registeredEngineSet", "[", "i", "]", ")", ";", "}", "}", "}", "if", "(", "klass", ")", "{", "return", "_getStorageEngine", "(", "_getValidLocation", "(", "location", ")", ",", "klass", ",", "_cfg", ".", "engine", ")", ";", "}", "throw", "(", "'YAHOO.util.StorageManager.get - No engine available, please include an engine before calling this function.'", ")", ";", "}" ]
Fetches the desired engine type or first available engine type. @method get @param engineType {String} Optional. The engine type, see engines. @param location {String} Optional. The storage location - LOCATION_SESSION & LOCATION_LOCAL; default is LOCAL. @param conf {Object} Optional. Additional configuration for the getting the storage engine. { engine: {Object} configuration parameters for the desired engine order: {Array} an array of storage engine names; the desired order to try engines} } @static
[ "Fetches", "the", "desired", "engine", "type", "or", "first", "available", "engine", "type", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/storage/storage.js#L423-L452
43,206
neyric/webhookit
public/javascripts/yui/storage/storage.js
function(engineConstructor) { if (YL.isFunction(engineConstructor) && YL.isFunction(engineConstructor.isAvailable) && YL.isString(engineConstructor.ENGINE_NAME)) { _registeredEngineMap[engineConstructor.ENGINE_NAME] = engineConstructor; _registeredEngineSet.push(engineConstructor); return true; } return false; }
javascript
function(engineConstructor) { if (YL.isFunction(engineConstructor) && YL.isFunction(engineConstructor.isAvailable) && YL.isString(engineConstructor.ENGINE_NAME)) { _registeredEngineMap[engineConstructor.ENGINE_NAME] = engineConstructor; _registeredEngineSet.push(engineConstructor); return true; } return false; }
[ "function", "(", "engineConstructor", ")", "{", "if", "(", "YL", ".", "isFunction", "(", "engineConstructor", ")", "&&", "YL", ".", "isFunction", "(", "engineConstructor", ".", "isAvailable", ")", "&&", "YL", ".", "isString", "(", "engineConstructor", ".", "ENGINE_NAME", ")", ")", "{", "_registeredEngineMap", "[", "engineConstructor", ".", "ENGINE_NAME", "]", "=", "engineConstructor", ";", "_registeredEngineSet", ".", "push", "(", "engineConstructor", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Registers a engineType Class with the StorageManager singleton; first in is the first out. @method register @param engineConstructor {Function} Required. The engine constructor function, see engines. @return {Boolean} When successfully registered. @static
[ "Registers", "a", "engineType", "Class", "with", "the", "StorageManager", "singleton", ";", "first", "in", "is", "the", "first", "out", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/storage/storage.js#L472-L480
43,207
neyric/webhookit
public/javascripts/yui/storage/storage.js
function(key) { this._keyMap[key] = this.length; this._keys.push(key); this.length = this._keys.length; }
javascript
function(key) { this._keyMap[key] = this.length; this._keys.push(key); this.length = this._keys.length; }
[ "function", "(", "key", ")", "{", "this", ".", "_keyMap", "[", "key", "]", "=", "this", ".", "length", ";", "this", ".", "_keys", ".", "push", "(", "key", ")", ";", "this", ".", "length", "=", "this", ".", "_keys", ".", "length", ";", "}" ]
Adds the key to the set. @method _addKey @param key {String} Required. The key to evaluate. @protected
[ "Adds", "the", "key", "to", "the", "set", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/storage/storage.js#L622-L626
43,208
neyric/webhookit
public/javascripts/yui/storage/storage.js
function(key) { var j = this._indexOfKey(key), rest = this._keys.slice(j + 1); delete this._keyMap[key]; for (var k in this._keyMap) { if (j < this._keyMap[k]) { this._keyMap[k] -= 1; } } this._keys.length = j; this._keys = this._keys.concat(rest); this.length = this._keys.length; }
javascript
function(key) { var j = this._indexOfKey(key), rest = this._keys.slice(j + 1); delete this._keyMap[key]; for (var k in this._keyMap) { if (j < this._keyMap[k]) { this._keyMap[k] -= 1; } } this._keys.length = j; this._keys = this._keys.concat(rest); this.length = this._keys.length; }
[ "function", "(", "key", ")", "{", "var", "j", "=", "this", ".", "_indexOfKey", "(", "key", ")", ",", "rest", "=", "this", ".", "_keys", ".", "slice", "(", "j", "+", "1", ")", ";", "delete", "this", ".", "_keyMap", "[", "key", "]", ";", "for", "(", "var", "k", "in", "this", ".", "_keyMap", ")", "{", "if", "(", "j", "<", "this", ".", "_keyMap", "[", "k", "]", ")", "{", "this", ".", "_keyMap", "[", "k", "]", "-=", "1", ";", "}", "}", "this", ".", "_keys", ".", "length", "=", "j", ";", "this", ".", "_keys", "=", "this", ".", "_keys", ".", "concat", "(", "rest", ")", ";", "this", ".", "length", "=", "this", ".", "_keys", ".", "length", ";", "}" ]
Removes a key from the keys array. @method _removeKey @param key {String} Required. The key to remove. @protected
[ "Removes", "a", "key", "from", "the", "keys", "array", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/storage/storage.js#L645-L660
43,209
neyric/webhookit
public/javascripts/yui/slider/slider-debug.js
function() { this.logger.log("focus"); this.valueChangeSource = Slider.SOURCE_UI_EVENT; // Focus the background element if possible var el = this.getEl(); if (el.focus) { try { el.focus(); } catch(e) { // Prevent permission denied unhandled exception in FF that can // happen when setting focus while another element is handling // the blur. @TODO this is still writing to the error log // (unhandled error) in FF1.5 with strict error checking on. } } this.verifyOffset(); return !this.isLocked(); }
javascript
function() { this.logger.log("focus"); this.valueChangeSource = Slider.SOURCE_UI_EVENT; // Focus the background element if possible var el = this.getEl(); if (el.focus) { try { el.focus(); } catch(e) { // Prevent permission denied unhandled exception in FF that can // happen when setting focus while another element is handling // the blur. @TODO this is still writing to the error log // (unhandled error) in FF1.5 with strict error checking on. } } this.verifyOffset(); return !this.isLocked(); }
[ "function", "(", ")", "{", "this", ".", "logger", ".", "log", "(", "\"focus\"", ")", ";", "this", ".", "valueChangeSource", "=", "Slider", ".", "SOURCE_UI_EVENT", ";", "// Focus the background element if possible", "var", "el", "=", "this", ".", "getEl", "(", ")", ";", "if", "(", "el", ".", "focus", ")", "{", "try", "{", "el", ".", "focus", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "// Prevent permission denied unhandled exception in FF that can", "// happen when setting focus while another element is handling", "// the blur. @TODO this is still writing to the error log ", "// (unhandled error) in FF1.5 with strict error checking on.", "}", "}", "this", ".", "verifyOffset", "(", ")", ";", "return", "!", "this", ".", "isLocked", "(", ")", ";", "}" ]
Try to focus the element when clicked so we can add accessibility features @method focus @private
[ "Try", "to", "focus", "the", "element", "when", "clicked", "so", "we", "can", "add", "accessibility", "features" ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/slider/slider-debug.js#L603-L624
43,210
neyric/webhookit
public/javascripts/yui/slider/slider-debug.js
function(source, newOffset, skipAnim, force, silent) { var t = this.thumb, newX, newY; if (!t.available) { this.logger.log("defer setValue until after onAvailble"); this.deferredSetValue = arguments; return false; } if (this.isLocked() && !force) { this.logger.log("Can't set the value, the control is locked"); return false; } if ( isNaN(newOffset) ) { this.logger.log("setValue, Illegal argument: " + newOffset); return false; } if (t._isRegion) { this.logger.log("Call to setValue for region Slider ignored. Use setRegionValue","warn"); return false; } this.logger.log("setValue " + newOffset); this._silent = silent; this.valueChangeSource = source || Slider.SOURCE_SET_VALUE; t.lastOffset = [newOffset, newOffset]; this.verifyOffset(); this._slideStart(); if (t._isHoriz) { newX = t.initPageX + newOffset + this.thumbCenterPoint.x; this.moveThumb(newX, t.initPageY, skipAnim); } else { newY = t.initPageY + newOffset + this.thumbCenterPoint.y; this.moveThumb(t.initPageX, newY, skipAnim); } return true; }
javascript
function(source, newOffset, skipAnim, force, silent) { var t = this.thumb, newX, newY; if (!t.available) { this.logger.log("defer setValue until after onAvailble"); this.deferredSetValue = arguments; return false; } if (this.isLocked() && !force) { this.logger.log("Can't set the value, the control is locked"); return false; } if ( isNaN(newOffset) ) { this.logger.log("setValue, Illegal argument: " + newOffset); return false; } if (t._isRegion) { this.logger.log("Call to setValue for region Slider ignored. Use setRegionValue","warn"); return false; } this.logger.log("setValue " + newOffset); this._silent = silent; this.valueChangeSource = source || Slider.SOURCE_SET_VALUE; t.lastOffset = [newOffset, newOffset]; this.verifyOffset(); this._slideStart(); if (t._isHoriz) { newX = t.initPageX + newOffset + this.thumbCenterPoint.x; this.moveThumb(newX, t.initPageY, skipAnim); } else { newY = t.initPageY + newOffset + this.thumbCenterPoint.y; this.moveThumb(t.initPageX, newY, skipAnim); } return true; }
[ "function", "(", "source", ",", "newOffset", ",", "skipAnim", ",", "force", ",", "silent", ")", "{", "var", "t", "=", "this", ".", "thumb", ",", "newX", ",", "newY", ";", "if", "(", "!", "t", ".", "available", ")", "{", "this", ".", "logger", ".", "log", "(", "\"defer setValue until after onAvailble\"", ")", ";", "this", ".", "deferredSetValue", "=", "arguments", ";", "return", "false", ";", "}", "if", "(", "this", ".", "isLocked", "(", ")", "&&", "!", "force", ")", "{", "this", ".", "logger", ".", "log", "(", "\"Can't set the value, the control is locked\"", ")", ";", "return", "false", ";", "}", "if", "(", "isNaN", "(", "newOffset", ")", ")", "{", "this", ".", "logger", ".", "log", "(", "\"setValue, Illegal argument: \"", "+", "newOffset", ")", ";", "return", "false", ";", "}", "if", "(", "t", ".", "_isRegion", ")", "{", "this", ".", "logger", ".", "log", "(", "\"Call to setValue for region Slider ignored. Use setRegionValue\"", ",", "\"warn\"", ")", ";", "return", "false", ";", "}", "this", ".", "logger", ".", "log", "(", "\"setValue \"", "+", "newOffset", ")", ";", "this", ".", "_silent", "=", "silent", ";", "this", ".", "valueChangeSource", "=", "source", "||", "Slider", ".", "SOURCE_SET_VALUE", ";", "t", ".", "lastOffset", "=", "[", "newOffset", ",", "newOffset", "]", ";", "this", ".", "verifyOffset", "(", ")", ";", "this", ".", "_slideStart", "(", ")", ";", "if", "(", "t", ".", "_isHoriz", ")", "{", "newX", "=", "t", ".", "initPageX", "+", "newOffset", "+", "this", ".", "thumbCenterPoint", ".", "x", ";", "this", ".", "moveThumb", "(", "newX", ",", "t", ".", "initPageY", ",", "skipAnim", ")", ";", "}", "else", "{", "newY", "=", "t", ".", "initPageY", "+", "newOffset", "+", "this", ".", "thumbCenterPoint", ".", "y", ";", "this", ".", "moveThumb", "(", "t", ".", "initPageX", ",", "newY", ",", "skipAnim", ")", ";", "}", "return", "true", ";", "}" ]
Worker function to execute the value set operation. Accepts type of set operation in addition to the usual setValue params. @method _setValue @param source {int} what triggered the set (e.g. Slider.SOURCE_SET_VALUE) @param {int} newOffset the number of pixels the thumb should be positioned away from the initial start point @param {boolean} skipAnim set to true to disable the animation for this move action (but not others). @param {boolean} force ignore the locked setting and set value anyway @param {boolean} silent when true, do not fire events @return {boolean} true if the move was performed, false if it failed @protected
[ "Worker", "function", "to", "execute", "the", "value", "set", "operation", ".", "Accepts", "type", "of", "set", "operation", "in", "addition", "to", "the", "usual", "setValue", "params", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/slider/slider-debug.js#L721-L764
43,211
neyric/webhookit
public/javascripts/yui/slider/slider-debug.js
function() { var xy = getXY(this.getEl()), t = this.thumb; if (!this.thumbCenterPoint || !this.thumbCenterPoint.x) { this.setThumbCenterPoint(); } if (xy) { this.logger.log("newPos: " + xy); if (xy[0] != this.baselinePos[0] || xy[1] != this.baselinePos[1]) { this.logger.log("background moved, resetting constraints"); // Reset background this.setInitPosition(); this.baselinePos = xy; // Reset thumb t.initPageX = this.initPageX + t.startOffset[0]; t.initPageY = this.initPageY + t.startOffset[1]; t.deltaSetXY = null; this.resetThumbConstraints(); return false; } } return true; }
javascript
function() { var xy = getXY(this.getEl()), t = this.thumb; if (!this.thumbCenterPoint || !this.thumbCenterPoint.x) { this.setThumbCenterPoint(); } if (xy) { this.logger.log("newPos: " + xy); if (xy[0] != this.baselinePos[0] || xy[1] != this.baselinePos[1]) { this.logger.log("background moved, resetting constraints"); // Reset background this.setInitPosition(); this.baselinePos = xy; // Reset thumb t.initPageX = this.initPageX + t.startOffset[0]; t.initPageY = this.initPageY + t.startOffset[1]; t.deltaSetXY = null; this.resetThumbConstraints(); return false; } } return true; }
[ "function", "(", ")", "{", "var", "xy", "=", "getXY", "(", "this", ".", "getEl", "(", ")", ")", ",", "t", "=", "this", ".", "thumb", ";", "if", "(", "!", "this", ".", "thumbCenterPoint", "||", "!", "this", ".", "thumbCenterPoint", ".", "x", ")", "{", "this", ".", "setThumbCenterPoint", "(", ")", ";", "}", "if", "(", "xy", ")", "{", "this", ".", "logger", ".", "log", "(", "\"newPos: \"", "+", "xy", ")", ";", "if", "(", "xy", "[", "0", "]", "!=", "this", ".", "baselinePos", "[", "0", "]", "||", "xy", "[", "1", "]", "!=", "this", ".", "baselinePos", "[", "1", "]", ")", "{", "this", ".", "logger", ".", "log", "(", "\"background moved, resetting constraints\"", ")", ";", "// Reset background", "this", ".", "setInitPosition", "(", ")", ";", "this", ".", "baselinePos", "=", "xy", ";", "// Reset thumb", "t", ".", "initPageX", "=", "this", ".", "initPageX", "+", "t", ".", "startOffset", "[", "0", "]", ";", "t", ".", "initPageY", "=", "this", ".", "initPageY", "+", "t", ".", "startOffset", "[", "1", "]", ";", "t", ".", "deltaSetXY", "=", "null", ";", "this", ".", "resetThumbConstraints", "(", ")", ";", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks the background position element position. If it has moved from the baseline position, the constraints for the thumb are reset @method verifyOffset @return {boolean} True if the offset is the same as the baseline.
[ "Checks", "the", "background", "position", "element", "position", ".", "If", "it", "has", "moved", "from", "the", "baseline", "position", "the", "constraints", "for", "the", "thumb", "are", "reset" ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/slider/slider-debug.js#L848-L879
43,212
neyric/webhookit
public/javascripts/yui/slider/slider-debug.js
function(x, y, skipAnim, midMove) { var t = this.thumb, self = this, p,_p,anim; if (!t.available) { this.logger.log("thumb is not available yet, aborting move"); return; } this.logger.log("move thumb, x: " + x + ", y: " + y); t.setDelta(this.thumbCenterPoint.x, this.thumbCenterPoint.y); _p = t.getTargetCoord(x, y); p = [Math.round(_p.x), Math.round(_p.y)]; if (this.animate && t._graduated && !skipAnim) { this.logger.log("graduated"); this.lock(); // cache the current thumb pos this.curCoord = getXY(this.thumb.getEl()); this.curCoord = [Math.round(this.curCoord[0]), Math.round(this.curCoord[1])]; setTimeout( function() { self.moveOneTick(p); }, this.tickPause ); } else if (this.animate && Slider.ANIM_AVAIL && !skipAnim) { this.logger.log("animating to " + p); this.lock(); anim = new YAHOO.util.Motion( t.id, { points: { to: p } }, this.animationDuration, YAHOO.util.Easing.easeOut ); anim.onComplete.subscribe( function() { self.logger.log("Animation completed _mouseDown:" + self._mouseDown); self.unlock(); if (!self._mouseDown) { self.endMove(); } }); anim.animate(); } else { t.setDragElPos(x, y); if (!midMove && !this._mouseDown) { this.endMove(); } } }
javascript
function(x, y, skipAnim, midMove) { var t = this.thumb, self = this, p,_p,anim; if (!t.available) { this.logger.log("thumb is not available yet, aborting move"); return; } this.logger.log("move thumb, x: " + x + ", y: " + y); t.setDelta(this.thumbCenterPoint.x, this.thumbCenterPoint.y); _p = t.getTargetCoord(x, y); p = [Math.round(_p.x), Math.round(_p.y)]; if (this.animate && t._graduated && !skipAnim) { this.logger.log("graduated"); this.lock(); // cache the current thumb pos this.curCoord = getXY(this.thumb.getEl()); this.curCoord = [Math.round(this.curCoord[0]), Math.round(this.curCoord[1])]; setTimeout( function() { self.moveOneTick(p); }, this.tickPause ); } else if (this.animate && Slider.ANIM_AVAIL && !skipAnim) { this.logger.log("animating to " + p); this.lock(); anim = new YAHOO.util.Motion( t.id, { points: { to: p } }, this.animationDuration, YAHOO.util.Easing.easeOut ); anim.onComplete.subscribe( function() { self.logger.log("Animation completed _mouseDown:" + self._mouseDown); self.unlock(); if (!self._mouseDown) { self.endMove(); } }); anim.animate(); } else { t.setDragElPos(x, y); if (!midMove && !this._mouseDown) { this.endMove(); } } }
[ "function", "(", "x", ",", "y", ",", "skipAnim", ",", "midMove", ")", "{", "var", "t", "=", "this", ".", "thumb", ",", "self", "=", "this", ",", "p", ",", "_p", ",", "anim", ";", "if", "(", "!", "t", ".", "available", ")", "{", "this", ".", "logger", ".", "log", "(", "\"thumb is not available yet, aborting move\"", ")", ";", "return", ";", "}", "this", ".", "logger", ".", "log", "(", "\"move thumb, x: \"", "+", "x", "+", "\", y: \"", "+", "y", ")", ";", "t", ".", "setDelta", "(", "this", ".", "thumbCenterPoint", ".", "x", ",", "this", ".", "thumbCenterPoint", ".", "y", ")", ";", "_p", "=", "t", ".", "getTargetCoord", "(", "x", ",", "y", ")", ";", "p", "=", "[", "Math", ".", "round", "(", "_p", ".", "x", ")", ",", "Math", ".", "round", "(", "_p", ".", "y", ")", "]", ";", "if", "(", "this", ".", "animate", "&&", "t", ".", "_graduated", "&&", "!", "skipAnim", ")", "{", "this", ".", "logger", ".", "log", "(", "\"graduated\"", ")", ";", "this", ".", "lock", "(", ")", ";", "// cache the current thumb pos", "this", ".", "curCoord", "=", "getXY", "(", "this", ".", "thumb", ".", "getEl", "(", ")", ")", ";", "this", ".", "curCoord", "=", "[", "Math", ".", "round", "(", "this", ".", "curCoord", "[", "0", "]", ")", ",", "Math", ".", "round", "(", "this", ".", "curCoord", "[", "1", "]", ")", "]", ";", "setTimeout", "(", "function", "(", ")", "{", "self", ".", "moveOneTick", "(", "p", ")", ";", "}", ",", "this", ".", "tickPause", ")", ";", "}", "else", "if", "(", "this", ".", "animate", "&&", "Slider", ".", "ANIM_AVAIL", "&&", "!", "skipAnim", ")", "{", "this", ".", "logger", ".", "log", "(", "\"animating to \"", "+", "p", ")", ";", "this", ".", "lock", "(", ")", ";", "anim", "=", "new", "YAHOO", ".", "util", ".", "Motion", "(", "t", ".", "id", ",", "{", "points", ":", "{", "to", ":", "p", "}", "}", ",", "this", ".", "animationDuration", ",", "YAHOO", ".", "util", ".", "Easing", ".", "easeOut", ")", ";", "anim", ".", "onComplete", ".", "subscribe", "(", "function", "(", ")", "{", "self", ".", "logger", ".", "log", "(", "\"Animation completed _mouseDown:\"", "+", "self", ".", "_mouseDown", ")", ";", "self", ".", "unlock", "(", ")", ";", "if", "(", "!", "self", ".", "_mouseDown", ")", "{", "self", ".", "endMove", "(", ")", ";", "}", "}", ")", ";", "anim", ".", "animate", "(", ")", ";", "}", "else", "{", "t", ".", "setDragElPos", "(", "x", ",", "y", ")", ";", "if", "(", "!", "midMove", "&&", "!", "this", ".", "_mouseDown", ")", "{", "this", ".", "endMove", "(", ")", ";", "}", "}", "}" ]
Move the associated slider moved to a timeout to try to get around the mousedown stealing moz does when I move the slider element between the cursor and the background during the mouseup event @method moveThumb @param {int} x the X coordinate of the click @param {int} y the Y coordinate of the click @param {boolean} skipAnim don't animate if the move happend onDrag @param {boolean} midMove set to true if this is not terminating the slider movement @private
[ "Move", "the", "associated", "slider", "moved", "to", "a", "timeout", "to", "try", "to", "get", "around", "the", "mousedown", "stealing", "moz", "does", "when", "I", "move", "the", "slider", "element", "between", "the", "cursor", "and", "the", "background", "during", "the", "mouseup", "event" ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/slider/slider-debug.js#L893-L946
43,213
neyric/webhookit
public/javascripts/yui/slider/slider-debug.js
function(curCoord, finalCoord) { this.logger.log("getNextX: " + curCoord + ", " + finalCoord); var t = this.thumb, thresh, tmp = [], nextCoord = null; if (curCoord[0] > finalCoord[0]) { thresh = t.tickSize - this.thumbCenterPoint.x; tmp = t.getTargetCoord( curCoord[0] - thresh, curCoord[1] ); nextCoord = [tmp.x, tmp.y]; } else if (curCoord[0] < finalCoord[0]) { thresh = t.tickSize + this.thumbCenterPoint.x; tmp = t.getTargetCoord( curCoord[0] + thresh, curCoord[1] ); nextCoord = [tmp.x, tmp.y]; } else { // equal, do nothing } return nextCoord; }
javascript
function(curCoord, finalCoord) { this.logger.log("getNextX: " + curCoord + ", " + finalCoord); var t = this.thumb, thresh, tmp = [], nextCoord = null; if (curCoord[0] > finalCoord[0]) { thresh = t.tickSize - this.thumbCenterPoint.x; tmp = t.getTargetCoord( curCoord[0] - thresh, curCoord[1] ); nextCoord = [tmp.x, tmp.y]; } else if (curCoord[0] < finalCoord[0]) { thresh = t.tickSize + this.thumbCenterPoint.x; tmp = t.getTargetCoord( curCoord[0] + thresh, curCoord[1] ); nextCoord = [tmp.x, tmp.y]; } else { // equal, do nothing } return nextCoord; }
[ "function", "(", "curCoord", ",", "finalCoord", ")", "{", "this", ".", "logger", ".", "log", "(", "\"getNextX: \"", "+", "curCoord", "+", "\", \"", "+", "finalCoord", ")", ";", "var", "t", "=", "this", ".", "thumb", ",", "thresh", ",", "tmp", "=", "[", "]", ",", "nextCoord", "=", "null", ";", "if", "(", "curCoord", "[", "0", "]", ">", "finalCoord", "[", "0", "]", ")", "{", "thresh", "=", "t", ".", "tickSize", "-", "this", ".", "thumbCenterPoint", ".", "x", ";", "tmp", "=", "t", ".", "getTargetCoord", "(", "curCoord", "[", "0", "]", "-", "thresh", ",", "curCoord", "[", "1", "]", ")", ";", "nextCoord", "=", "[", "tmp", ".", "x", ",", "tmp", ".", "y", "]", ";", "}", "else", "if", "(", "curCoord", "[", "0", "]", "<", "finalCoord", "[", "0", "]", ")", "{", "thresh", "=", "t", ".", "tickSize", "+", "this", ".", "thumbCenterPoint", ".", "x", ";", "tmp", "=", "t", ".", "getTargetCoord", "(", "curCoord", "[", "0", "]", "+", "thresh", ",", "curCoord", "[", "1", "]", ")", ";", "nextCoord", "=", "[", "tmp", ".", "x", ",", "tmp", ".", "y", "]", ";", "}", "else", "{", "// equal, do nothing", "}", "return", "nextCoord", ";", "}" ]
Returns the next X tick value based on the current coord and the target coord. @method _getNextX @private
[ "Returns", "the", "next", "X", "tick", "value", "based", "on", "the", "current", "coord", "and", "the", "target", "coord", "." ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/slider/slider-debug.js#L1037-L1057
43,214
neyric/webhookit
public/javascripts/yui/slider/slider-debug.js
function(e) { this.logger.log("background drag"); if (this.backgroundEnabled && !this.isLocked()) { var x = Event.getPageX(e), y = Event.getPageY(e); this.moveThumb(x, y, true, true); this.fireEvents(); } }
javascript
function(e) { this.logger.log("background drag"); if (this.backgroundEnabled && !this.isLocked()) { var x = Event.getPageX(e), y = Event.getPageY(e); this.moveThumb(x, y, true, true); this.fireEvents(); } }
[ "function", "(", "e", ")", "{", "this", ".", "logger", ".", "log", "(", "\"background drag\"", ")", ";", "if", "(", "this", ".", "backgroundEnabled", "&&", "!", "this", ".", "isLocked", "(", ")", ")", "{", "var", "x", "=", "Event", ".", "getPageX", "(", "e", ")", ",", "y", "=", "Event", ".", "getPageY", "(", "e", ")", ";", "this", ".", "moveThumb", "(", "x", ",", "y", ",", "true", ",", "true", ")", ";", "this", ".", "fireEvents", "(", ")", ";", "}", "}" ]
Handles the onDrag event for the slider background @method onDrag @private
[ "Handles", "the", "onDrag", "event", "for", "the", "slider", "background" ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/slider/slider-debug.js#L1126-L1134
43,215
neyric/webhookit
public/javascripts/yui/slider/slider-debug.js
function (thumbEvent) { var t = this.thumb, newX, newY, newVal; if (!thumbEvent) { t.cachePosition(); } if (! this.isLocked()) { if (t._isRegion) { newX = t.getXValue(); newY = t.getYValue(); if (newX != this.previousX || newY != this.previousY) { if (!this._silent) { this.onChange(newX, newY); this.fireEvent("change", { x: newX, y: newY }); } } this.previousX = newX; this.previousY = newY; } else { newVal = t.getValue(); if (newVal != this.previousVal) { this.logger.log("Firing onchange: " + newVal); if (!this._silent) { this.onChange( newVal ); this.fireEvent("change", newVal); } } this.previousVal = newVal; } } }
javascript
function (thumbEvent) { var t = this.thumb, newX, newY, newVal; if (!thumbEvent) { t.cachePosition(); } if (! this.isLocked()) { if (t._isRegion) { newX = t.getXValue(); newY = t.getYValue(); if (newX != this.previousX || newY != this.previousY) { if (!this._silent) { this.onChange(newX, newY); this.fireEvent("change", { x: newX, y: newY }); } } this.previousX = newX; this.previousY = newY; } else { newVal = t.getValue(); if (newVal != this.previousVal) { this.logger.log("Firing onchange: " + newVal); if (!this._silent) { this.onChange( newVal ); this.fireEvent("change", newVal); } } this.previousVal = newVal; } } }
[ "function", "(", "thumbEvent", ")", "{", "var", "t", "=", "this", ".", "thumb", ",", "newX", ",", "newY", ",", "newVal", ";", "if", "(", "!", "thumbEvent", ")", "{", "t", ".", "cachePosition", "(", ")", ";", "}", "if", "(", "!", "this", ".", "isLocked", "(", ")", ")", "{", "if", "(", "t", ".", "_isRegion", ")", "{", "newX", "=", "t", ".", "getXValue", "(", ")", ";", "newY", "=", "t", ".", "getYValue", "(", ")", ";", "if", "(", "newX", "!=", "this", ".", "previousX", "||", "newY", "!=", "this", ".", "previousY", ")", "{", "if", "(", "!", "this", ".", "_silent", ")", "{", "this", ".", "onChange", "(", "newX", ",", "newY", ")", ";", "this", ".", "fireEvent", "(", "\"change\"", ",", "{", "x", ":", "newX", ",", "y", ":", "newY", "}", ")", ";", "}", "}", "this", ".", "previousX", "=", "newX", ";", "this", ".", "previousY", "=", "newY", ";", "}", "else", "{", "newVal", "=", "t", ".", "getValue", "(", ")", ";", "if", "(", "newVal", "!=", "this", ".", "previousVal", ")", "{", "this", ".", "logger", ".", "log", "(", "\"Firing onchange: \"", "+", "newVal", ")", ";", "if", "(", "!", "this", ".", "_silent", ")", "{", "this", ".", "onChange", "(", "newVal", ")", ";", "this", ".", "fireEvent", "(", "\"change\"", ",", "newVal", ")", ";", "}", "}", "this", ".", "previousVal", "=", "newVal", ";", "}", "}", "}" ]
Fires the change event if the value has been changed. Ignored if we are in the middle of an animation as the event will fire when the animation is complete @method fireEvents @param {boolean} thumbEvent set to true if this event is fired from an event that occurred on the thumb. If it is, the state of the thumb dd object should be correct. Otherwise, the event originated on the background, so the thumb state needs to be refreshed before proceeding. @private
[ "Fires", "the", "change", "event", "if", "the", "value", "has", "been", "changed", ".", "Ignored", "if", "we", "are", "in", "the", "middle", "of", "an", "animation", "as", "the", "event", "will", "fire", "when", "the", "animation", "is", "complete" ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/yui/slider/slider-debug.js#L1174-L1210
43,216
neyric/webhookit
public/javascripts/inputex/js/fields/ColorPickerField.js
function(options) { inputEx.ColorPickerField.superclass.setOptions.call(this, options); // Overwrite options this.options.className = options.className ? options.className : 'inputEx-Field inputEx-ColorPickerField'; // Color Picker options object this.options.colorPickerOptions = YAHOO.lang.isUndefined(options.colorPickerOptions) ? {} : options.colorPickerOptions; // showcontrols this.options.colorPickerOptions.showcontrols = YAHOO.lang.isUndefined(this.options.colorPickerOptions.showcontrols) ? true : this.options.colorPickerOptions.showcontrols; // default images (color selection images) this.options.colorPickerOptions.images = YAHOO.lang.isUndefined(this.options.colorPickerOptions.images) ? { PICKER_THUMB: "../lib/yui/colorpicker/assets/picker_thumb.png", HUE_THUMB: "../lib/yui/colorpicker/assets/hue_thumb.png" } : this.options.colorPickerOptions.images; }
javascript
function(options) { inputEx.ColorPickerField.superclass.setOptions.call(this, options); // Overwrite options this.options.className = options.className ? options.className : 'inputEx-Field inputEx-ColorPickerField'; // Color Picker options object this.options.colorPickerOptions = YAHOO.lang.isUndefined(options.colorPickerOptions) ? {} : options.colorPickerOptions; // showcontrols this.options.colorPickerOptions.showcontrols = YAHOO.lang.isUndefined(this.options.colorPickerOptions.showcontrols) ? true : this.options.colorPickerOptions.showcontrols; // default images (color selection images) this.options.colorPickerOptions.images = YAHOO.lang.isUndefined(this.options.colorPickerOptions.images) ? { PICKER_THUMB: "../lib/yui/colorpicker/assets/picker_thumb.png", HUE_THUMB: "../lib/yui/colorpicker/assets/hue_thumb.png" } : this.options.colorPickerOptions.images; }
[ "function", "(", "options", ")", "{", "inputEx", ".", "ColorPickerField", ".", "superclass", ".", "setOptions", ".", "call", "(", "this", ",", "options", ")", ";", "// Overwrite options", "this", ".", "options", ".", "className", "=", "options", ".", "className", "?", "options", ".", "className", ":", "'inputEx-Field inputEx-ColorPickerField'", ";", "// Color Picker options object", "this", ".", "options", ".", "colorPickerOptions", "=", "YAHOO", ".", "lang", ".", "isUndefined", "(", "options", ".", "colorPickerOptions", ")", "?", "{", "}", ":", "options", ".", "colorPickerOptions", ";", "// showcontrols", "this", ".", "options", ".", "colorPickerOptions", ".", "showcontrols", "=", "YAHOO", ".", "lang", ".", "isUndefined", "(", "this", ".", "options", ".", "colorPickerOptions", ".", "showcontrols", ")", "?", "true", ":", "this", ".", "options", ".", "colorPickerOptions", ".", "showcontrols", ";", "// default images (color selection images)", "this", ".", "options", ".", "colorPickerOptions", ".", "images", "=", "YAHOO", ".", "lang", ".", "isUndefined", "(", "this", ".", "options", ".", "colorPickerOptions", ".", "images", ")", "?", "{", "PICKER_THUMB", ":", "\"../lib/yui/colorpicker/assets/picker_thumb.png\"", ",", "HUE_THUMB", ":", "\"../lib/yui/colorpicker/assets/hue_thumb.png\"", "}", ":", "this", ".", "options", ".", "colorPickerOptions", ".", "images", ";", "}" ]
Adds the 'inputEx-ColorPickerField' default className @param {Object} options Options object as passed to the constructor
[ "Adds", "the", "inputEx", "-", "ColorPickerField", "default", "className" ]
13abf6f072e23d536432235da78fd3e4e5d742b6
https://github.com/neyric/webhookit/blob/13abf6f072e23d536432235da78fd3e4e5d742b6/public/javascripts/inputex/js/fields/ColorPickerField.js#L24-L39
43,217
perak/meteor-user-roles
src/index.js
function (userId, doc, fieldNames, modifier) { // only admins can update user roles via the client return Users.isAdmin(userId) || (doc._id === userId && fieldNames.indexOf("roles") < 0); }
javascript
function (userId, doc, fieldNames, modifier) { // only admins can update user roles via the client return Users.isAdmin(userId) || (doc._id === userId && fieldNames.indexOf("roles") < 0); }
[ "function", "(", "userId", ",", "doc", ",", "fieldNames", ",", "modifier", ")", "{", "// only admins can update user roles via the client", "return", "Users", ".", "isAdmin", "(", "userId", ")", "||", "(", "doc", ".", "_id", "===", "userId", "&&", "fieldNames", ".", "indexOf", "(", "\"roles\"", ")", "<", "0", ")", ";", "}" ]
doesn't allow insert or removal of users from untrusted code
[ "doesn", "t", "allow", "insert", "or", "removal", "of", "users", "from", "untrusted", "code" ]
7aa840db6656613f15e4c30dab27257675dc4313
https://github.com/perak/meteor-user-roles/blob/7aa840db6656613f15e4c30dab27257675dc4313/src/index.js#L152-L155
43,218
reelyactive/raddec
lib/events.js
encode
function encode(events) { if(!Array.isArray(events)) { return '00'; } let bitmask = 0; for(event in events) { let index = events[event]; bitmask += (1 << index); } return ('00' + bitmask.toString(16)).substr(-2); }
javascript
function encode(events) { if(!Array.isArray(events)) { return '00'; } let bitmask = 0; for(event in events) { let index = events[event]; bitmask += (1 << index); } return ('00' + bitmask.toString(16)).substr(-2); }
[ "function", "encode", "(", "events", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "events", ")", ")", "{", "return", "'00'", ";", "}", "let", "bitmask", "=", "0", ";", "for", "(", "event", "in", "events", ")", "{", "let", "index", "=", "events", "[", "event", "]", ";", "bitmask", "+=", "(", "1", "<<", "index", ")", ";", "}", "return", "(", "'00'", "+", "bitmask", ".", "toString", "(", "16", ")", ")", ".", "substr", "(", "-", "2", ")", ";", "}" ]
Encode the given events index list as a hexadecimal string byte. @param {Array} events The given events as an index list. @return {String} The resulting hexadecimal string.
[ "Encode", "the", "given", "events", "index", "list", "as", "a", "hexadecimal", "string", "byte", "." ]
6bd2c73ce63c5e45fb9e77c245491939a690a76a
https://github.com/reelyactive/raddec/blob/6bd2c73ce63c5e45fb9e77c245491939a690a76a/lib/events.js#L25-L35
43,219
reelyactive/raddec
lib/events.js
decode
function decode(events) { let indexList = []; let eventsByte = parseInt(events, 16); if(eventsByte & APPEARANCE_MASK) { indexList.push(APPEARANCE); } if(eventsByte & DISPLACEMENT_MASK) { indexList.push(DISPLACEMENT); } if(eventsByte & PACKETS_MASK) { indexList.push(PACKETS); } if(eventsByte & KEEPALIVE_MASK) { indexList.push(KEEPALIVE); } if(eventsByte & DISAPPEARANCE_MASK) { indexList.push(DISAPPEARANCE); } return indexList; }
javascript
function decode(events) { let indexList = []; let eventsByte = parseInt(events, 16); if(eventsByte & APPEARANCE_MASK) { indexList.push(APPEARANCE); } if(eventsByte & DISPLACEMENT_MASK) { indexList.push(DISPLACEMENT); } if(eventsByte & PACKETS_MASK) { indexList.push(PACKETS); } if(eventsByte & KEEPALIVE_MASK) { indexList.push(KEEPALIVE); } if(eventsByte & DISAPPEARANCE_MASK) { indexList.push(DISAPPEARANCE); } return indexList; }
[ "function", "decode", "(", "events", ")", "{", "let", "indexList", "=", "[", "]", ";", "let", "eventsByte", "=", "parseInt", "(", "events", ",", "16", ")", ";", "if", "(", "eventsByte", "&", "APPEARANCE_MASK", ")", "{", "indexList", ".", "push", "(", "APPEARANCE", ")", ";", "}", "if", "(", "eventsByte", "&", "DISPLACEMENT_MASK", ")", "{", "indexList", ".", "push", "(", "DISPLACEMENT", ")", ";", "}", "if", "(", "eventsByte", "&", "PACKETS_MASK", ")", "{", "indexList", ".", "push", "(", "PACKETS", ")", ";", "}", "if", "(", "eventsByte", "&", "KEEPALIVE_MASK", ")", "{", "indexList", ".", "push", "(", "KEEPALIVE", ")", ";", "}", "if", "(", "eventsByte", "&", "DISAPPEARANCE_MASK", ")", "{", "indexList", ".", "push", "(", "DISAPPEARANCE", ")", ";", "}", "return", "indexList", ";", "}" ]
Decode the given hexadecimal string byte as an index list of events. @param {String} rssi The given events as a bitmask hexadecimal string. @return {Array} The corresponding index list of events.
[ "Decode", "the", "given", "hexadecimal", "string", "byte", "as", "an", "index", "list", "of", "events", "." ]
6bd2c73ce63c5e45fb9e77c245491939a690a76a
https://github.com/reelyactive/raddec/blob/6bd2c73ce63c5e45fb9e77c245491939a690a76a/lib/events.js#L43-L64
43,220
danigb/scorejs
lib/measures.js
measures
function measures (meter, measures, builder) { var list var mLen = measureLength(meter) if (!mLen) throw Error('Not valid meter: ' + meter) var seq = [] builder = builder || score.note splitMeasures(measures).forEach(function (measure) { measure = measure.trim() if (measure.length > 0) { list = parenthesize(tokenize(measure), []) processList(seq, list, measureLength(meter), builder) } }) return score.seq(seq) }
javascript
function measures (meter, measures, builder) { var list var mLen = measureLength(meter) if (!mLen) throw Error('Not valid meter: ' + meter) var seq = [] builder = builder || score.note splitMeasures(measures).forEach(function (measure) { measure = measure.trim() if (measure.length > 0) { list = parenthesize(tokenize(measure), []) processList(seq, list, measureLength(meter), builder) } }) return score.seq(seq) }
[ "function", "measures", "(", "meter", ",", "measures", ",", "builder", ")", "{", "var", "list", "var", "mLen", "=", "measureLength", "(", "meter", ")", "if", "(", "!", "mLen", ")", "throw", "Error", "(", "'Not valid meter: '", "+", "meter", ")", "var", "seq", "=", "[", "]", "builder", "=", "builder", "||", "score", ".", "note", "splitMeasures", "(", "measures", ")", ".", "forEach", "(", "function", "(", "measure", ")", "{", "measure", "=", "measure", ".", "trim", "(", ")", "if", "(", "measure", ".", "length", ">", "0", ")", "{", "list", "=", "parenthesize", "(", "tokenize", "(", "measure", ")", ",", "[", "]", ")", "processList", "(", "seq", ",", "list", ",", "measureLength", "(", "meter", ")", ",", "builder", ")", "}", "}", ")", "return", "score", ".", "seq", "(", "seq", ")", "}" ]
Parse masures using a time meter to get a sequence @param {String} meter - the time meter @param {String} measures - the measures string @param {Function} builder - (Optional) the function used to build the notes @return {Score} the score object @example measures('4/4', 'c d (e f) | g | (a b c) d')
[ "Parse", "masures", "using", "a", "time", "meter", "to", "get", "a", "sequence" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/lib/measures.js#L16-L31
43,221
danigb/scorejs
lib/measures.js
chords
function chords (meter, data) { return measures(meter, data, function (dur, el) { return score.el({ duration: dur, chord: el }) }) }
javascript
function chords (meter, data) { return measures(meter, data, function (dur, el) { return score.el({ duration: dur, chord: el }) }) }
[ "function", "chords", "(", "meter", ",", "data", ")", "{", "return", "measures", "(", "meter", ",", "data", ",", "function", "(", "dur", ",", "el", ")", "{", "return", "score", ".", "el", "(", "{", "duration", ":", "dur", ",", "chord", ":", "el", "}", ")", "}", ")", "}" ]
Create a chord names sequence @param {String} meter - the meter used in the measures @param {String} measures - the chords @param {Sequence} a sequence of chords @example score.chords('4/4', 'C6 | Dm7 G7 | Cmaj7') @example score(['chords', '4/4', 'Cmaj7 | Dm7 G7'])
[ "Create", "a", "chord", "names", "sequence" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/lib/measures.js#L52-L56
43,222
danigb/scorejs
lib/measures.js
measureLength
function measureLength (meter) { var m = meter.split('/').map(function (n) { return +n.trim() }) return m[0] * (4 / m[1]) }
javascript
function measureLength (meter) { var m = meter.split('/').map(function (n) { return +n.trim() }) return m[0] * (4 / m[1]) }
[ "function", "measureLength", "(", "meter", ")", "{", "var", "m", "=", "meter", ".", "split", "(", "'/'", ")", ".", "map", "(", "function", "(", "n", ")", "{", "return", "+", "n", ".", "trim", "(", ")", "}", ")", "return", "m", "[", "0", "]", "*", "(", "4", "/", "m", "[", "1", "]", ")", "}" ]
get the length of one measure
[ "get", "the", "length", "of", "one", "measure" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/lib/measures.js#L59-L64
43,223
niksy/fetch-google-maps
index.js
internalResolve
function internalResolve ( resolve ) { resolve(window.google && window.google.maps ? window.google.maps : false); }
javascript
function internalResolve ( resolve ) { resolve(window.google && window.google.maps ? window.google.maps : false); }
[ "function", "internalResolve", "(", "resolve", ")", "{", "resolve", "(", "window", ".", "google", "&&", "window", ".", "google", ".", "maps", "?", "window", ".", "google", ".", "maps", ":", "false", ")", ";", "}" ]
Declare internal resolve function, pass google.maps for the Promise resolve @param {Function} resolve
[ "Declare", "internal", "resolve", "function", "pass", "google", ".", "maps", "for", "the", "Promise", "resolve" ]
db0d402206aa7fd592a46ee32e728b89c4801696
https://github.com/niksy/fetch-google-maps/blob/db0d402206aa7fd592a46ee32e728b89c4801696/index.js#L15-L17
43,224
reelyactive/raddec
lib/raddec.js
constructFromObject
function constructFromObject(instance, source) { instance.transmitterId = identifiers.format(source.transmitterId); instance.transmitterIdType = source.transmitterIdType; instance.rssiSignature = source.rssiSignature || []; instance.rssiSignature.forEach(function(entry) { entry.receiverIdType = entry.receiverIdType || identifiers.TYPE_UNKNOWN; entry.rssi = entry.rssi || -Number.MAX_SAFE_INTEGER; entry.numberOfDecodings = entry.numberOfDecodings || 1; entry.rssiSum = entry.rssiSum || entry.rssi; }); if(source.hasOwnProperty('packets')) { instance.packets = source.packets; } if(source.hasOwnProperty('timestamp')) { instance.timestamp = source.timestamp; } if(source.hasOwnProperty('events')) { instance.events = source.events; } if(source.hasOwnProperty('earliestDecodingTime')) { instance.earliestDecodingTime = source.earliestDecodingTime; } instance.creationTime = new Date().getTime(); }
javascript
function constructFromObject(instance, source) { instance.transmitterId = identifiers.format(source.transmitterId); instance.transmitterIdType = source.transmitterIdType; instance.rssiSignature = source.rssiSignature || []; instance.rssiSignature.forEach(function(entry) { entry.receiverIdType = entry.receiverIdType || identifiers.TYPE_UNKNOWN; entry.rssi = entry.rssi || -Number.MAX_SAFE_INTEGER; entry.numberOfDecodings = entry.numberOfDecodings || 1; entry.rssiSum = entry.rssiSum || entry.rssi; }); if(source.hasOwnProperty('packets')) { instance.packets = source.packets; } if(source.hasOwnProperty('timestamp')) { instance.timestamp = source.timestamp; } if(source.hasOwnProperty('events')) { instance.events = source.events; } if(source.hasOwnProperty('earliestDecodingTime')) { instance.earliestDecodingTime = source.earliestDecodingTime; } instance.creationTime = new Date().getTime(); }
[ "function", "constructFromObject", "(", "instance", ",", "source", ")", "{", "instance", ".", "transmitterId", "=", "identifiers", ".", "format", "(", "source", ".", "transmitterId", ")", ";", "instance", ".", "transmitterIdType", "=", "source", ".", "transmitterIdType", ";", "instance", ".", "rssiSignature", "=", "source", ".", "rssiSignature", "||", "[", "]", ";", "instance", ".", "rssiSignature", ".", "forEach", "(", "function", "(", "entry", ")", "{", "entry", ".", "receiverIdType", "=", "entry", ".", "receiverIdType", "||", "identifiers", ".", "TYPE_UNKNOWN", ";", "entry", ".", "rssi", "=", "entry", ".", "rssi", "||", "-", "Number", ".", "MAX_SAFE_INTEGER", ";", "entry", ".", "numberOfDecodings", "=", "entry", ".", "numberOfDecodings", "||", "1", ";", "entry", ".", "rssiSum", "=", "entry", ".", "rssiSum", "||", "entry", ".", "rssi", ";", "}", ")", ";", "if", "(", "source", ".", "hasOwnProperty", "(", "'packets'", ")", ")", "{", "instance", ".", "packets", "=", "source", ".", "packets", ";", "}", "if", "(", "source", ".", "hasOwnProperty", "(", "'timestamp'", ")", ")", "{", "instance", ".", "timestamp", "=", "source", ".", "timestamp", ";", "}", "if", "(", "source", ".", "hasOwnProperty", "(", "'events'", ")", ")", "{", "instance", ".", "events", "=", "source", ".", "events", ";", "}", "if", "(", "source", ".", "hasOwnProperty", "(", "'earliestDecodingTime'", ")", ")", "{", "instance", ".", "earliestDecodingTime", "=", "source", ".", "earliestDecodingTime", ";", "}", "instance", ".", "creationTime", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "}" ]
Construct the Raddec from an Object. @param {Raddec} instance The given Raddec instance. @param {Object} source The source as an Object.
[ "Construct", "the", "Raddec", "from", "an", "Object", "." ]
6bd2c73ce63c5e45fb9e77c245491939a690a76a
https://github.com/reelyactive/raddec/blob/6bd2c73ce63c5e45fb9e77c245491939a690a76a/lib/raddec.js#L446-L471
43,225
reelyactive/raddec
lib/raddec.js
mergeTimes
function mergeTimes(source, destination) { if(source.hasOwnProperty('earliestDecodingTime')) { if(destination.hasOwnProperty('earliestDecodingTime')) { let isSourceEarlier = (source.earliestDecodingTime < destination.earliestDecodingTime); if(isSourceEarlier) { destination.earliestDecodingTime = source.earliestDecodingTime; } } else { destination.earliestDecodingTime = source.earliestDecodingTime; } } }
javascript
function mergeTimes(source, destination) { if(source.hasOwnProperty('earliestDecodingTime')) { if(destination.hasOwnProperty('earliestDecodingTime')) { let isSourceEarlier = (source.earliestDecodingTime < destination.earliestDecodingTime); if(isSourceEarlier) { destination.earliestDecodingTime = source.earliestDecodingTime; } } else { destination.earliestDecodingTime = source.earliestDecodingTime; } } }
[ "function", "mergeTimes", "(", "source", ",", "destination", ")", "{", "if", "(", "source", ".", "hasOwnProperty", "(", "'earliestDecodingTime'", ")", ")", "{", "if", "(", "destination", ".", "hasOwnProperty", "(", "'earliestDecodingTime'", ")", ")", "{", "let", "isSourceEarlier", "=", "(", "source", ".", "earliestDecodingTime", "<", "destination", ".", "earliestDecodingTime", ")", ";", "if", "(", "isSourceEarlier", ")", "{", "destination", ".", "earliestDecodingTime", "=", "source", ".", "earliestDecodingTime", ";", "}", "}", "else", "{", "destination", ".", "earliestDecodingTime", "=", "source", ".", "earliestDecodingTime", ";", "}", "}", "}" ]
Merge the times of the source Raddec into those of the destination Raddec. @param {Raddec} source The source Raddec instance. @param {Raddec} destination The destination Raddec instance.
[ "Merge", "the", "times", "of", "the", "source", "Raddec", "into", "those", "of", "the", "destination", "Raddec", "." ]
6bd2c73ce63c5e45fb9e77c245491939a690a76a
https://github.com/reelyactive/raddec/blob/6bd2c73ce63c5e45fb9e77c245491939a690a76a/lib/raddec.js#L479-L492
43,226
reelyactive/raddec
lib/raddec.js
toHexString
function toHexString(number, numberOfBytes) { numberOfBytes = numberOfBytes || 1; let hexString = '00'.repeat(numberOfBytes) + number.toString(16); return hexString.substr(-2 * numberOfBytes); }
javascript
function toHexString(number, numberOfBytes) { numberOfBytes = numberOfBytes || 1; let hexString = '00'.repeat(numberOfBytes) + number.toString(16); return hexString.substr(-2 * numberOfBytes); }
[ "function", "toHexString", "(", "number", ",", "numberOfBytes", ")", "{", "numberOfBytes", "=", "numberOfBytes", "||", "1", ";", "let", "hexString", "=", "'00'", ".", "repeat", "(", "numberOfBytes", ")", "+", "number", ".", "toString", "(", "16", ")", ";", "return", "hexString", ".", "substr", "(", "-", "2", "*", "numberOfBytes", ")", ";", "}" ]
Convert the given number to a hexadecimal string of the given length. @param {Number} number The given number. @param {Number} numberOfBytes The number of bytes of hex string. @return {String} The resulting hexadecimal string.
[ "Convert", "the", "given", "number", "to", "a", "hexadecimal", "string", "of", "the", "given", "length", "." ]
6bd2c73ce63c5e45fb9e77c245491939a690a76a
https://github.com/reelyactive/raddec/blob/6bd2c73ce63c5e45fb9e77c245491939a690a76a/lib/raddec.js#L501-L506
43,227
MingweiSamuel/TeemoJS
index.js
Region
function Region(config) { this.config = config; this.appLimit = new RateLimit(this.config.rateLimitTypeApplication, 1, this.config); this.methodLimits = {}; this.liveRequests = 0; }
javascript
function Region(config) { this.config = config; this.appLimit = new RateLimit(this.config.rateLimitTypeApplication, 1, this.config); this.methodLimits = {}; this.liveRequests = 0; }
[ "function", "Region", "(", "config", ")", "{", "this", ".", "config", "=", "config", ";", "this", ".", "appLimit", "=", "new", "RateLimit", "(", "this", ".", "config", ".", "rateLimitTypeApplication", ",", "1", ",", "this", ".", "config", ")", ";", "this", ".", "methodLimits", "=", "{", "}", ";", "this", ".", "liveRequests", "=", "0", ";", "}" ]
RateLimits for a region. One app limit and any number of method limits.
[ "RateLimits", "for", "a", "region", ".", "One", "app", "limit", "and", "any", "number", "of", "method", "limits", "." ]
cc0bb94ceaa232c11e573111b375df44920e2b33
https://github.com/MingweiSamuel/TeemoJS/blob/cc0bb94ceaa232c11e573111b375df44920e2b33/index.js#L50-L55
43,228
MingweiSamuel/TeemoJS
index.js
RateLimit
function RateLimit(type, distFactor, config) { this.config = config; this.type = type; this.buckets = this.config.defaultBuckets.map(b => new TokenBucket(b.timespan, b.limit, b)); this.retryAfter = 0; this.distFactor = distFactor; }
javascript
function RateLimit(type, distFactor, config) { this.config = config; this.type = type; this.buckets = this.config.defaultBuckets.map(b => new TokenBucket(b.timespan, b.limit, b)); this.retryAfter = 0; this.distFactor = distFactor; }
[ "function", "RateLimit", "(", "type", ",", "distFactor", ",", "config", ")", "{", "this", ".", "config", "=", "config", ";", "this", ".", "type", "=", "type", ";", "this", ".", "buckets", "=", "this", ".", "config", ".", "defaultBuckets", ".", "map", "(", "b", "=>", "new", "TokenBucket", "(", "b", ".", "timespan", ",", "b", ".", "limit", ",", "b", ")", ")", ";", "this", ".", "retryAfter", "=", "0", ";", "this", ".", "distFactor", "=", "distFactor", ";", "}" ]
Rate limit. A collection of token buckets, updated when needed.
[ "Rate", "limit", ".", "A", "collection", "of", "token", "buckets", "updated", "when", "needed", "." ]
cc0bb94ceaa232c11e573111b375df44920e2b33
https://github.com/MingweiSamuel/TeemoJS/blob/cc0bb94ceaa232c11e573111b375df44920e2b33/index.js#L128-L134
43,229
JamieMason/grunt-rewrite
tasks/lib/rewrite.js
dependency
function dependency(deps, name) { if (name in deps && typeof deps[name] !== 'undefined') { return deps[name]; } throw new Error('grunt-rewrite.registerTask requires dependency "' + name + '"'); }
javascript
function dependency(deps, name) { if (name in deps && typeof deps[name] !== 'undefined') { return deps[name]; } throw new Error('grunt-rewrite.registerTask requires dependency "' + name + '"'); }
[ "function", "dependency", "(", "deps", ",", "name", ")", "{", "if", "(", "name", "in", "deps", "&&", "typeof", "deps", "[", "name", "]", "!==", "'undefined'", ")", "{", "return", "deps", "[", "name", "]", ";", "}", "throw", "new", "Error", "(", "'grunt-rewrite.registerTask requires dependency \"'", "+", "name", "+", "'\"'", ")", ";", "}" ]
Return the named dependency or throw an error that it is absent. @param {Object} deps @param {String} name @throws {Error} @return {Mixed}
[ "Return", "the", "named", "dependency", "or", "throw", "an", "error", "that", "it", "is", "absent", "." ]
e27c8d4b78da18087c012f87b458dff8e6088376
https://github.com/JamieMason/grunt-rewrite/blob/e27c8d4b78da18087c012f87b458dff8e6088376/tasks/lib/rewrite.js#L11-L16
43,230
JamieMason/grunt-rewrite
tasks/lib/rewrite.js
function(deps) { deps = deps || {}; var grunt = dependency(deps, 'grunt'); var task = dependency(deps, 'task'); var done = task.async(); task.files.forEach(function(subTask) { // make sure an editing function has been provided if (typeof subTask.editor !== 'function') { return grunt.fatal(task.current.nameArgs + ' needs a ".editor" method'); } // replace contents of each file with the return value // of the editor when given the file's contents and path. subTask.src.forEach(function(filePath) { if (!grunt.file.isFile(filePath)) { return grunt.log.write('skipped "' + filePath + '" as is not a file'); } var original = grunt.file.read(filePath); var rewritten = subTask.editor(original, filePath); if (typeof rewritten === 'undefined') { return grunt.fatal(task.current.nameArgs + ' ".editor" method did not return a value'); } grunt.file.write(filePath, rewritten); }); }); done(); }
javascript
function(deps) { deps = deps || {}; var grunt = dependency(deps, 'grunt'); var task = dependency(deps, 'task'); var done = task.async(); task.files.forEach(function(subTask) { // make sure an editing function has been provided if (typeof subTask.editor !== 'function') { return grunt.fatal(task.current.nameArgs + ' needs a ".editor" method'); } // replace contents of each file with the return value // of the editor when given the file's contents and path. subTask.src.forEach(function(filePath) { if (!grunt.file.isFile(filePath)) { return grunt.log.write('skipped "' + filePath + '" as is not a file'); } var original = grunt.file.read(filePath); var rewritten = subTask.editor(original, filePath); if (typeof rewritten === 'undefined') { return grunt.fatal(task.current.nameArgs + ' ".editor" method did not return a value'); } grunt.file.write(filePath, rewritten); }); }); done(); }
[ "function", "(", "deps", ")", "{", "deps", "=", "deps", "||", "{", "}", ";", "var", "grunt", "=", "dependency", "(", "deps", ",", "'grunt'", ")", ";", "var", "task", "=", "dependency", "(", "deps", ",", "'task'", ")", ";", "var", "done", "=", "task", ".", "async", "(", ")", ";", "task", ".", "files", ".", "forEach", "(", "function", "(", "subTask", ")", "{", "// make sure an editing function has been provided", "if", "(", "typeof", "subTask", ".", "editor", "!==", "'function'", ")", "{", "return", "grunt", ".", "fatal", "(", "task", ".", "current", ".", "nameArgs", "+", "' needs a \".editor\" method'", ")", ";", "}", "// replace contents of each file with the return value", "// of the editor when given the file's contents and path.", "subTask", ".", "src", ".", "forEach", "(", "function", "(", "filePath", ")", "{", "if", "(", "!", "grunt", ".", "file", ".", "isFile", "(", "filePath", ")", ")", "{", "return", "grunt", ".", "log", ".", "write", "(", "'skipped \"'", "+", "filePath", "+", "'\" as is not a file'", ")", ";", "}", "var", "original", "=", "grunt", ".", "file", ".", "read", "(", "filePath", ")", ";", "var", "rewritten", "=", "subTask", ".", "editor", "(", "original", ",", "filePath", ")", ";", "if", "(", "typeof", "rewritten", "===", "'undefined'", ")", "{", "return", "grunt", ".", "fatal", "(", "task", ".", "current", ".", "nameArgs", "+", "' \".editor\" method did not return a value'", ")", ";", "}", "grunt", ".", "file", ".", "write", "(", "filePath", ",", "rewritten", ")", ";", "}", ")", ";", "}", ")", ";", "done", "(", ")", ";", "}" ]
Improve testability by allowing mock dependencies to be passed into the task. @param {Object} deps.grunt @param {Object} deps.task
[ "Improve", "testability", "by", "allowing", "mock", "dependencies", "to", "be", "passed", "into", "the", "task", "." ]
e27c8d4b78da18087c012f87b458dff8e6088376
https://github.com/JamieMason/grunt-rewrite/blob/e27c8d4b78da18087c012f87b458dff8e6088376/tasks/lib/rewrite.js#L26-L66
43,231
giapnguyen74/gstate
src/apply.js
create_node
function create_node(length) { const node = {}; Object.defineProperty(node, "_", { value: { length: length, //record array length watchers: {}, watcher_key: new Set(), watcher_props: new Set(), on_watch_callback: undefined }, writable: true, enumerable: false }); return node; }
javascript
function create_node(length) { const node = {}; Object.defineProperty(node, "_", { value: { length: length, //record array length watchers: {}, watcher_key: new Set(), watcher_props: new Set(), on_watch_callback: undefined }, writable: true, enumerable: false }); return node; }
[ "function", "create_node", "(", "length", ")", "{", "const", "node", "=", "{", "}", ";", "Object", ".", "defineProperty", "(", "node", ",", "\"_\"", ",", "{", "value", ":", "{", "length", ":", "length", ",", "//record array length", "watchers", ":", "{", "}", ",", "watcher_key", ":", "new", "Set", "(", ")", ",", "watcher_props", ":", "new", "Set", "(", ")", ",", "on_watch_callback", ":", "undefined", "}", ",", "writable", ":", "true", ",", "enumerable", ":", "false", "}", ")", ";", "return", "node", ";", "}" ]
Create a node @param {*} [length]
[ "Create", "a", "node" ]
3a4f426ce95162518974eb10309afd342ec80006
https://github.com/giapnguyen74/gstate/blob/3a4f426ce95162518974eb10309afd342ec80006/src/apply.js#L7-L22
43,232
giapnguyen74/gstate
src/apply.js
create_node_by_path
function create_node_by_path(context, path, len, tracker) { let node = context.state.rootNode; for (let i = 0; i < len; i++) { const k = path[i]; if (k == "_") continue; if (k == "#") { node = context.state.rootNode; continue; } if (node_type(node[k]) != NodeTypes.NODE) { commit_node_prop(context, node, k, create_node(), tracker); } node = node[k]; } return node; }
javascript
function create_node_by_path(context, path, len, tracker) { let node = context.state.rootNode; for (let i = 0; i < len; i++) { const k = path[i]; if (k == "_") continue; if (k == "#") { node = context.state.rootNode; continue; } if (node_type(node[k]) != NodeTypes.NODE) { commit_node_prop(context, node, k, create_node(), tracker); } node = node[k]; } return node; }
[ "function", "create_node_by_path", "(", "context", ",", "path", ",", "len", ",", "tracker", ")", "{", "let", "node", "=", "context", ".", "state", ".", "rootNode", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "const", "k", "=", "path", "[", "i", "]", ";", "if", "(", "k", "==", "\"_\"", ")", "continue", ";", "if", "(", "k", "==", "\"#\"", ")", "{", "node", "=", "context", ".", "state", ".", "rootNode", ";", "continue", ";", "}", "if", "(", "node_type", "(", "node", "[", "k", "]", ")", "!=", "NodeTypes", ".", "NODE", ")", "{", "commit_node_prop", "(", "context", ",", "node", ",", "k", ",", "create_node", "(", ")", ",", "tracker", ")", ";", "}", "node", "=", "node", "[", "k", "]", ";", "}", "return", "node", ";", "}" ]
Follow path create node if not existed @param {*} context @param {*} node @param {*} keys @param {*} len @param {*} tracker
[ "Follow", "path", "create", "node", "if", "not", "existed" ]
3a4f426ce95162518974eb10309afd342ec80006
https://github.com/giapnguyen74/gstate/blob/3a4f426ce95162518974eb10309afd342ec80006/src/apply.js#L89-L104
43,233
giapnguyen74/gstate
src/apply.js
apply_patch
function apply_patch(context, patch, tracker) { const path = patch[0]; if (path.length == 0) return; //ignore replace root node const value = patch[1]; const len = path.length - 1; const prop = path[len]; if (!Array.isArray(value)) { const node = create_node_by_path(context, path, len, tracker); commit_node_prop(context, node, prop, value, tracker); return; } else { const patchType = value[0]; if (patchType == PatchTypes.DEL) { return apply_delete_patch(context, path, tracker); } const node = create_node_by_path(context, path, len, tracker); if (patchType == PatchTypes.REFERENCE) { const refNode = create_node_by_path( context, value[1], value[1].length, tracker ); commit_node_prop(context, node, prop, refNode, tracker); return; } if (patchType == PatchTypes.NODE) { if ( value[1] == undefined && node_type(node[prop]) == NodeTypes.NODE //&& node[prop]._.length == undefined ) { return; } const childNode = create_node(value[1]); commit_node_prop(context, node, prop, childNode, tracker); return; } } }
javascript
function apply_patch(context, patch, tracker) { const path = patch[0]; if (path.length == 0) return; //ignore replace root node const value = patch[1]; const len = path.length - 1; const prop = path[len]; if (!Array.isArray(value)) { const node = create_node_by_path(context, path, len, tracker); commit_node_prop(context, node, prop, value, tracker); return; } else { const patchType = value[0]; if (patchType == PatchTypes.DEL) { return apply_delete_patch(context, path, tracker); } const node = create_node_by_path(context, path, len, tracker); if (patchType == PatchTypes.REFERENCE) { const refNode = create_node_by_path( context, value[1], value[1].length, tracker ); commit_node_prop(context, node, prop, refNode, tracker); return; } if (patchType == PatchTypes.NODE) { if ( value[1] == undefined && node_type(node[prop]) == NodeTypes.NODE //&& node[prop]._.length == undefined ) { return; } const childNode = create_node(value[1]); commit_node_prop(context, node, prop, childNode, tracker); return; } } }
[ "function", "apply_patch", "(", "context", ",", "patch", ",", "tracker", ")", "{", "const", "path", "=", "patch", "[", "0", "]", ";", "if", "(", "path", ".", "length", "==", "0", ")", "return", ";", "//ignore replace root node", "const", "value", "=", "patch", "[", "1", "]", ";", "const", "len", "=", "path", ".", "length", "-", "1", ";", "const", "prop", "=", "path", "[", "len", "]", ";", "if", "(", "!", "Array", ".", "isArray", "(", "value", ")", ")", "{", "const", "node", "=", "create_node_by_path", "(", "context", ",", "path", ",", "len", ",", "tracker", ")", ";", "commit_node_prop", "(", "context", ",", "node", ",", "prop", ",", "value", ",", "tracker", ")", ";", "return", ";", "}", "else", "{", "const", "patchType", "=", "value", "[", "0", "]", ";", "if", "(", "patchType", "==", "PatchTypes", ".", "DEL", ")", "{", "return", "apply_delete_patch", "(", "context", ",", "path", ",", "tracker", ")", ";", "}", "const", "node", "=", "create_node_by_path", "(", "context", ",", "path", ",", "len", ",", "tracker", ")", ";", "if", "(", "patchType", "==", "PatchTypes", ".", "REFERENCE", ")", "{", "const", "refNode", "=", "create_node_by_path", "(", "context", ",", "value", "[", "1", "]", ",", "value", "[", "1", "]", ".", "length", ",", "tracker", ")", ";", "commit_node_prop", "(", "context", ",", "node", ",", "prop", ",", "refNode", ",", "tracker", ")", ";", "return", ";", "}", "if", "(", "patchType", "==", "PatchTypes", ".", "NODE", ")", "{", "if", "(", "value", "[", "1", "]", "==", "undefined", "&&", "node_type", "(", "node", "[", "prop", "]", ")", "==", "NodeTypes", ".", "NODE", "//&& node[prop]._.length == undefined", ")", "{", "return", ";", "}", "const", "childNode", "=", "create_node", "(", "value", "[", "1", "]", ")", ";", "commit_node_prop", "(", "context", ",", "node", ",", "prop", ",", "childNode", ",", "tracker", ")", ";", "return", ";", "}", "}", "}" ]
Apply single patch @param {*} context @param {*} patch @param {*} [tracker]
[ "Apply", "single", "patch" ]
3a4f426ce95162518974eb10309afd342ec80006
https://github.com/giapnguyen74/gstate/blob/3a4f426ce95162518974eb10309afd342ec80006/src/apply.js#L145-L188
43,234
giapnguyen74/gstate
src/patch.js
calc_patches_any
function calc_patches_any(context, patches, path, value, tracker) { const valueType = value_type(value); if (valueType == ValueTypes.OBJECT) { if (value.propertyIsEnumerable("_")) { if (value["_"] == "$ref") { return patches.push([path, [PatchTypes.REFERENCE, value.path]]); } throw new Error("Underscore property is reserved"); } calc_patches_object(context, patches, path, value, tracker); } else if (valueType == ValueTypes.ARRAY) { calc_patches_array(context, patches, path, value, tracker); } else { patches.push([path, value]); } }
javascript
function calc_patches_any(context, patches, path, value, tracker) { const valueType = value_type(value); if (valueType == ValueTypes.OBJECT) { if (value.propertyIsEnumerable("_")) { if (value["_"] == "$ref") { return patches.push([path, [PatchTypes.REFERENCE, value.path]]); } throw new Error("Underscore property is reserved"); } calc_patches_object(context, patches, path, value, tracker); } else if (valueType == ValueTypes.ARRAY) { calc_patches_array(context, patches, path, value, tracker); } else { patches.push([path, value]); } }
[ "function", "calc_patches_any", "(", "context", ",", "patches", ",", "path", ",", "value", ",", "tracker", ")", "{", "const", "valueType", "=", "value_type", "(", "value", ")", ";", "if", "(", "valueType", "==", "ValueTypes", ".", "OBJECT", ")", "{", "if", "(", "value", ".", "propertyIsEnumerable", "(", "\"_\"", ")", ")", "{", "if", "(", "value", "[", "\"_\"", "]", "==", "\"$ref\"", ")", "{", "return", "patches", ".", "push", "(", "[", "path", ",", "[", "PatchTypes", ".", "REFERENCE", ",", "value", ".", "path", "]", "]", ")", ";", "}", "throw", "new", "Error", "(", "\"Underscore property is reserved\"", ")", ";", "}", "calc_patches_object", "(", "context", ",", "patches", ",", "path", ",", "value", ",", "tracker", ")", ";", "}", "else", "if", "(", "valueType", "==", "ValueTypes", ".", "ARRAY", ")", "{", "calc_patches_array", "(", "context", ",", "patches", ",", "path", ",", "value", ",", "tracker", ")", ";", "}", "else", "{", "patches", ".", "push", "(", "[", "path", ",", "value", "]", ")", ";", "}", "}" ]
Given path and value , calculate patches @param {*} context @param {*} patches @param {*} path @param {*} value @param {*} tracker
[ "Given", "path", "and", "value", "calculate", "patches" ]
3a4f426ce95162518974eb10309afd342ec80006
https://github.com/giapnguyen74/gstate/blob/3a4f426ce95162518974eb10309afd342ec80006/src/patch.js#L66-L82
43,235
danigb/scorejs
ext/pianoroll.js
draw
function draw (ctx, score) { console.log(score) drawStripes(box, ctx) forEachTime(function (time, note) { var midi = toMidi(note.pitch) console.log(time, note, midi) ctx.fillRect(box.x(time), box.y(midi), box.nw(note.duration), box.nh()) }, null, score) }
javascript
function draw (ctx, score) { console.log(score) drawStripes(box, ctx) forEachTime(function (time, note) { var midi = toMidi(note.pitch) console.log(time, note, midi) ctx.fillRect(box.x(time), box.y(midi), box.nw(note.duration), box.nh()) }, null, score) }
[ "function", "draw", "(", "ctx", ",", "score", ")", "{", "console", ".", "log", "(", "score", ")", "drawStripes", "(", "box", ",", "ctx", ")", "forEachTime", "(", "function", "(", "time", ",", "note", ")", "{", "var", "midi", "=", "toMidi", "(", "note", ".", "pitch", ")", "console", ".", "log", "(", "time", ",", "note", ",", "midi", ")", "ctx", ".", "fillRect", "(", "box", ".", "x", "(", "time", ")", ",", "box", ".", "y", "(", "midi", ")", ",", "box", ".", "nw", "(", "note", ".", "duration", ")", ",", "box", ".", "nh", "(", ")", ")", "}", ",", "null", ",", "score", ")", "}" ]
Draw a piano roll
[ "Draw", "a", "piano", "roll" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/ext/pianoroll.js#L30-L38
43,236
danigb/scorejs
lib/build.js
exec
function exec (ctx, scope, data) { console.log('exec', ctx, scope, data) var fn = getFunction(ctx, scope, data[0]) var elements = data.slice(1) var params = elements.map(function (p) { return Array.isArray(p) ? exec(ctx, scope, p) : (p[0] === '$') ? ctx[p] : p }).filter(function (p) { return p !== VAR }) return fn.apply(null, params) }
javascript
function exec (ctx, scope, data) { console.log('exec', ctx, scope, data) var fn = getFunction(ctx, scope, data[0]) var elements = data.slice(1) var params = elements.map(function (p) { return Array.isArray(p) ? exec(ctx, scope, p) : (p[0] === '$') ? ctx[p] : p }).filter(function (p) { return p !== VAR }) return fn.apply(null, params) }
[ "function", "exec", "(", "ctx", ",", "scope", ",", "data", ")", "{", "console", ".", "log", "(", "'exec'", ",", "ctx", ",", "scope", ",", "data", ")", "var", "fn", "=", "getFunction", "(", "ctx", ",", "scope", ",", "data", "[", "0", "]", ")", "var", "elements", "=", "data", ".", "slice", "(", "1", ")", "var", "params", "=", "elements", ".", "map", "(", "function", "(", "p", ")", "{", "return", "Array", ".", "isArray", "(", "p", ")", "?", "exec", "(", "ctx", ",", "scope", ",", "p", ")", ":", "(", "p", "[", "0", "]", "===", "'$'", ")", "?", "ctx", "[", "p", "]", ":", "p", "}", ")", ".", "filter", "(", "function", "(", "p", ")", "{", "return", "p", "!==", "VAR", "}", ")", "return", "fn", ".", "apply", "(", "null", ",", "params", ")", "}" ]
exec a data array
[ "exec", "a", "data", "array" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/lib/build.js#L14-L23
43,237
reelyactive/raddec
lib/identifiers.js
format
function format(identifier) { if(typeof identifier === 'string') { var hexIdentifier = identifier.replace(/[^A-Fa-f0-9]/g, ''); return hexIdentifier.toLowerCase(); } return null; }
javascript
function format(identifier) { if(typeof identifier === 'string') { var hexIdentifier = identifier.replace(/[^A-Fa-f0-9]/g, ''); return hexIdentifier.toLowerCase(); } return null; }
[ "function", "format", "(", "identifier", ")", "{", "if", "(", "typeof", "identifier", "===", "'string'", ")", "{", "var", "hexIdentifier", "=", "identifier", ".", "replace", "(", "/", "[^A-Fa-f0-9]", "/", "g", ",", "''", ")", ";", "return", "hexIdentifier", ".", "toLowerCase", "(", ")", ";", "}", "return", "null", ";", "}" ]
Convert the given identifier to a valid identifier string, if possible. @param {String} identifier The given identifier. @return {String} Valid identifier string, or null if invalid input.
[ "Convert", "the", "given", "identifier", "to", "a", "valid", "identifier", "string", "if", "possible", "." ]
6bd2c73ce63c5e45fb9e77c245491939a690a76a
https://github.com/reelyactive/raddec/blob/6bd2c73ce63c5e45fb9e77c245491939a690a76a/lib/identifiers.js#L25-L31
43,238
reelyactive/raddec
lib/identifiers.js
lengthInBytes
function lengthInBytes(type) { switch(type) { case TYPE_UNKNOWN: return LENGTH_UNKNOWN; case TYPE_EUI64: return LENGTH_EUI64; case TYPE_EUI48: return LENGTH_EUI48; case TYPE_RND48: return LENGTH_RND48; default: return null; } }
javascript
function lengthInBytes(type) { switch(type) { case TYPE_UNKNOWN: return LENGTH_UNKNOWN; case TYPE_EUI64: return LENGTH_EUI64; case TYPE_EUI48: return LENGTH_EUI48; case TYPE_RND48: return LENGTH_RND48; default: return null; } }
[ "function", "lengthInBytes", "(", "type", ")", "{", "switch", "(", "type", ")", "{", "case", "TYPE_UNKNOWN", ":", "return", "LENGTH_UNKNOWN", ";", "case", "TYPE_EUI64", ":", "return", "LENGTH_EUI64", ";", "case", "TYPE_EUI48", ":", "return", "LENGTH_EUI48", ";", "case", "TYPE_RND48", ":", "return", "LENGTH_RND48", ";", "default", ":", "return", "null", ";", "}", "}" ]
Return the length in bytes of the given identifier type. @param {Number} identifier The given identifier type. @return {Number} The length of the identifier in bytes.
[ "Return", "the", "length", "in", "bytes", "of", "the", "given", "identifier", "type", "." ]
6bd2c73ce63c5e45fb9e77c245491939a690a76a
https://github.com/reelyactive/raddec/blob/6bd2c73ce63c5e45fb9e77c245491939a690a76a/lib/identifiers.js#L39-L52
43,239
netproteus/protobuf2flowtype
build/generate.js
buildType
function buildType(t, typeClassification) { let typeDef; switch (typeClassification) { case 'primative': typeDef = { interface: t, builder: t }; break; case 'message': typeDef = { interface: '$Subtype<' + t + 'Interface>', builder: t + 'Builder' }; break; case 'enum': typeDef = { interface: t + 'Values', builder: t + 'Values' }; break; default: throw new Error('Unhandled classification case :: ' + typeClassification); } if (repeated) { for (const key in typeDef) { typeDef[key] = 'Array<' + typeDef[key] + '>'; } } return typeDef; }
javascript
function buildType(t, typeClassification) { let typeDef; switch (typeClassification) { case 'primative': typeDef = { interface: t, builder: t }; break; case 'message': typeDef = { interface: '$Subtype<' + t + 'Interface>', builder: t + 'Builder' }; break; case 'enum': typeDef = { interface: t + 'Values', builder: t + 'Values' }; break; default: throw new Error('Unhandled classification case :: ' + typeClassification); } if (repeated) { for (const key in typeDef) { typeDef[key] = 'Array<' + typeDef[key] + '>'; } } return typeDef; }
[ "function", "buildType", "(", "t", ",", "typeClassification", ")", "{", "let", "typeDef", ";", "switch", "(", "typeClassification", ")", "{", "case", "'primative'", ":", "typeDef", "=", "{", "interface", ":", "t", ",", "builder", ":", "t", "}", ";", "break", ";", "case", "'message'", ":", "typeDef", "=", "{", "interface", ":", "'$Subtype<'", "+", "t", "+", "'Interface>'", ",", "builder", ":", "t", "+", "'Builder'", "}", ";", "break", ";", "case", "'enum'", ":", "typeDef", "=", "{", "interface", ":", "t", "+", "'Values'", ",", "builder", ":", "t", "+", "'Values'", "}", ";", "break", ";", "default", ":", "throw", "new", "Error", "(", "'Unhandled classification case :: '", "+", "typeClassification", ")", ";", "}", "if", "(", "repeated", ")", "{", "for", "(", "const", "key", "in", "typeDef", ")", "{", "typeDef", "[", "key", "]", "=", "'Array<'", "+", "typeDef", "[", "key", "]", "+", "'>'", ";", "}", "}", "return", "typeDef", ";", "}" ]
Builds the typedef needed for the template @param t - base type name @param primative - is it a built in type - i.e. leave it alone @returns {{interface: string, builder: string}}
[ "Builds", "the", "typedef", "needed", "for", "the", "template" ]
105fa5dea8769ef71267e01e25d32a39baf31176
https://github.com/netproteus/protobuf2flowtype/blob/105fa5dea8769ef71267e01e25d32a39baf31176/build/generate.js#L233-L263
43,240
netproteus/protobuf2flowtype
build/generate.js
strip
function strip(obj) { if (!obj || ! obj instanceof Object || typeof obj === 'string') { return undefined; } if (obj instanceof Array) { for (const value of obj) { strip(value); } } else { delete obj['loc']; delete obj['start']; delete obj['end']; Object.keys(obj).forEach(key => strip(obj[key])); } return obj; }
javascript
function strip(obj) { if (!obj || ! obj instanceof Object || typeof obj === 'string') { return undefined; } if (obj instanceof Array) { for (const value of obj) { strip(value); } } else { delete obj['loc']; delete obj['start']; delete obj['end']; Object.keys(obj).forEach(key => strip(obj[key])); } return obj; }
[ "function", "strip", "(", "obj", ")", "{", "if", "(", "!", "obj", "||", "!", "obj", "instanceof", "Object", "||", "typeof", "obj", "===", "'string'", ")", "{", "return", "undefined", ";", "}", "if", "(", "obj", "instanceof", "Array", ")", "{", "for", "(", "const", "value", "of", "obj", ")", "{", "strip", "(", "value", ")", ";", "}", "}", "else", "{", "delete", "obj", "[", "'loc'", "]", ";", "delete", "obj", "[", "'start'", "]", ";", "delete", "obj", "[", "'end'", "]", ";", "Object", ".", "keys", "(", "obj", ")", ".", "forEach", "(", "key", "=>", "strip", "(", "obj", "[", "key", "]", ")", ")", ";", "}", "return", "obj", ";", "}" ]
Strips location information out of babel ast, so we can regen clean code from the ast @param obj - babylon ast @returns ast
[ "Strips", "location", "information", "out", "of", "babel", "ast", "so", "we", "can", "regen", "clean", "code", "from", "the", "ast" ]
105fa5dea8769ef71267e01e25d32a39baf31176
https://github.com/netproteus/protobuf2flowtype/blob/105fa5dea8769ef71267e01e25d32a39baf31176/build/generate.js#L385-L405
43,241
netproteus/protobuf2flowtype
build/generate.js
clean
function clean(code) { try { const ast = babylon.parse(code, { // parse in strict mode and allow module declarations sourceType: 'module', plugins: [ // enable jsx and flow syntax 'jsx', 'flow' ] }); const cleanAst = strip(ast).program; const resultCode = generate(cleanAst, {}).code; return resultCode.replace(/(\/\*\$ | \#\*\/)/g, ''); } catch (e) { console.log(code); throw e; } }
javascript
function clean(code) { try { const ast = babylon.parse(code, { // parse in strict mode and allow module declarations sourceType: 'module', plugins: [ // enable jsx and flow syntax 'jsx', 'flow' ] }); const cleanAst = strip(ast).program; const resultCode = generate(cleanAst, {}).code; return resultCode.replace(/(\/\*\$ | \#\*\/)/g, ''); } catch (e) { console.log(code); throw e; } }
[ "function", "clean", "(", "code", ")", "{", "try", "{", "const", "ast", "=", "babylon", ".", "parse", "(", "code", ",", "{", "// parse in strict mode and allow module declarations", "sourceType", ":", "'module'", ",", "plugins", ":", "[", "// enable jsx and flow syntax", "'jsx'", ",", "'flow'", "]", "}", ")", ";", "const", "cleanAst", "=", "strip", "(", "ast", ")", ".", "program", ";", "const", "resultCode", "=", "generate", "(", "cleanAst", ",", "{", "}", ")", ".", "code", ";", "return", "resultCode", ".", "replace", "(", "/", "(\\/\\*\\$ | \\#\\*\\/)", "/", "g", ",", "''", ")", ";", "}", "catch", "(", "e", ")", "{", "console", ".", "log", "(", "code", ")", ";", "throw", "e", ";", "}", "}" ]
Takes JS code as string, parses it to AST, strips out formating information And regenerates clean code as a result @param code @returns code
[ "Takes", "JS", "code", "as", "string", "parses", "it", "to", "AST", "strips", "out", "formating", "information", "And", "regenerates", "clean", "code", "as", "a", "result" ]
105fa5dea8769ef71267e01e25d32a39baf31176
https://github.com/netproteus/protobuf2flowtype/blob/105fa5dea8769ef71267e01e25d32a39baf31176/build/generate.js#L414-L437
43,242
netproteus/protobuf2flowtype
build/generate.js
camelCase
function camelCase(str, next) { let output = ''; for (const c of str) { if (c === '_') { next = true; continue; } output += next ? c.toUpperCase() : c; next = false; } return output; }
javascript
function camelCase(str, next) { let output = ''; for (const c of str) { if (c === '_') { next = true; continue; } output += next ? c.toUpperCase() : c; next = false; } return output; }
[ "function", "camelCase", "(", "str", ",", "next", ")", "{", "let", "output", "=", "''", ";", "for", "(", "const", "c", "of", "str", ")", "{", "if", "(", "c", "===", "'_'", ")", "{", "next", "=", "true", ";", "continue", ";", "}", "output", "+=", "next", "?", "c", ".", "toUpperCase", "(", ")", ":", "c", ";", "next", "=", "false", ";", "}", "return", "output", ";", "}" ]
Converts foo_bar -> fooBar @param str @param next @returns {string}
[ "Converts", "foo_bar", "-", ">", "fooBar" ]
105fa5dea8769ef71267e01e25d32a39baf31176
https://github.com/netproteus/protobuf2flowtype/blob/105fa5dea8769ef71267e01e25d32a39baf31176/build/generate.js#L445-L456
43,243
netproteus/protobuf2flowtype
build/generate.js
processProto
function processProto(protoFile, root, imported = []) { const protPath = path.format({ dir: root, base: protoFile }); const parser = new ProtoBuf.DotProto.Parser(fs.readFileSync(protPath)); const protoAst = parser.parse(); imported.push(protoFile); protoAst.imports.forEach(file => { if (imported.indexOf(file) === -1) { processProto(file, root, imported); } }); return Namespace.getNamespace(protoAst.package).update(protoAst); }
javascript
function processProto(protoFile, root, imported = []) { const protPath = path.format({ dir: root, base: protoFile }); const parser = new ProtoBuf.DotProto.Parser(fs.readFileSync(protPath)); const protoAst = parser.parse(); imported.push(protoFile); protoAst.imports.forEach(file => { if (imported.indexOf(file) === -1) { processProto(file, root, imported); } }); return Namespace.getNamespace(protoAst.package).update(protoAst); }
[ "function", "processProto", "(", "protoFile", ",", "root", ",", "imported", "=", "[", "]", ")", "{", "const", "protPath", "=", "path", ".", "format", "(", "{", "dir", ":", "root", ",", "base", ":", "protoFile", "}", ")", ";", "const", "parser", "=", "new", "ProtoBuf", ".", "DotProto", ".", "Parser", "(", "fs", ".", "readFileSync", "(", "protPath", ")", ")", ";", "const", "protoAst", "=", "parser", ".", "parse", "(", ")", ";", "imported", ".", "push", "(", "protoFile", ")", ";", "protoAst", ".", "imports", ".", "forEach", "(", "file", "=>", "{", "if", "(", "imported", ".", "indexOf", "(", "file", ")", "===", "-", "1", ")", "{", "processProto", "(", "file", ",", "root", ",", "imported", ")", ";", "}", "}", ")", ";", "return", "Namespace", ".", "getNamespace", "(", "protoAst", ".", "package", ")", ".", "update", "(", "protoAst", ")", ";", "}" ]
Parses protofile recursively, resolving all imports To create Nampespace that can be used for generation @param protoFile @returns {Namespace}
[ "Parses", "protofile", "recursively", "resolving", "all", "imports" ]
105fa5dea8769ef71267e01e25d32a39baf31176
https://github.com/netproteus/protobuf2flowtype/blob/105fa5dea8769ef71267e01e25d32a39baf31176/build/generate.js#L467-L483
43,244
netproteus/protobuf2flowtype
build/generate.js
generateFromProto
function generateFromProto(outputDir, inputProto, protoDir) { try { fs.accessSync(path.format({ dir: protoDir, base: inputProto })); if (!protoDir) { const absolutePath = fs.realpathSync(inputProto); protoDir = path.dirname(absolutePath); inputProto = path.basename(absolutePath); } } catch (e) { throw new Error('Can not locate proto file - ' + inputProto, e); } let jsonDescriptor; try { class ImportBuilder extends ProtoBuf.Builder { import(json, filename) { this._imported = this._imported || []; this._imported.push({ filename: filename, json: json }); super['import'](json, filename); } } const importBuilder = new ImportBuilder(); // This validates that proto is parsable const builder = ProtoBuf.loadProtoFile({ root: protoDir, file: inputProto }, importBuilder); jsonDescriptor = JSON.stringify(builder._imported, undefined, 2); } catch (e) { console.error('Proto Parsing Failed', e); throw new Error('Generation Failed'); } Namespace.reset(); const namespace = processProto(inputProto, protoDir); const code = namespace.generate( jsonDescriptor, { render: data => mustache.render(fs.readFileSync(path.format({ dir: templateDir, base: 'module.js.mt' }), 'utf8'), data) }, { render: data => mustache.render(fs.readFileSync(path.format({ dir: templateDir, base: 'root.js.mt' }), 'utf8'), data) } ); for (const key of Object.keys(code)) { const dir = path.format({ dir: outputDir, base: key }); fs.ensureDirSync(dir); const file = path.format({ dir: dir, base: 'index.js' }); fs.writeFileSync(file, code[key], {encoding: 'utf8'}); } }
javascript
function generateFromProto(outputDir, inputProto, protoDir) { try { fs.accessSync(path.format({ dir: protoDir, base: inputProto })); if (!protoDir) { const absolutePath = fs.realpathSync(inputProto); protoDir = path.dirname(absolutePath); inputProto = path.basename(absolutePath); } } catch (e) { throw new Error('Can not locate proto file - ' + inputProto, e); } let jsonDescriptor; try { class ImportBuilder extends ProtoBuf.Builder { import(json, filename) { this._imported = this._imported || []; this._imported.push({ filename: filename, json: json }); super['import'](json, filename); } } const importBuilder = new ImportBuilder(); // This validates that proto is parsable const builder = ProtoBuf.loadProtoFile({ root: protoDir, file: inputProto }, importBuilder); jsonDescriptor = JSON.stringify(builder._imported, undefined, 2); } catch (e) { console.error('Proto Parsing Failed', e); throw new Error('Generation Failed'); } Namespace.reset(); const namespace = processProto(inputProto, protoDir); const code = namespace.generate( jsonDescriptor, { render: data => mustache.render(fs.readFileSync(path.format({ dir: templateDir, base: 'module.js.mt' }), 'utf8'), data) }, { render: data => mustache.render(fs.readFileSync(path.format({ dir: templateDir, base: 'root.js.mt' }), 'utf8'), data) } ); for (const key of Object.keys(code)) { const dir = path.format({ dir: outputDir, base: key }); fs.ensureDirSync(dir); const file = path.format({ dir: dir, base: 'index.js' }); fs.writeFileSync(file, code[key], {encoding: 'utf8'}); } }
[ "function", "generateFromProto", "(", "outputDir", ",", "inputProto", ",", "protoDir", ")", "{", "try", "{", "fs", ".", "accessSync", "(", "path", ".", "format", "(", "{", "dir", ":", "protoDir", ",", "base", ":", "inputProto", "}", ")", ")", ";", "if", "(", "!", "protoDir", ")", "{", "const", "absolutePath", "=", "fs", ".", "realpathSync", "(", "inputProto", ")", ";", "protoDir", "=", "path", ".", "dirname", "(", "absolutePath", ")", ";", "inputProto", "=", "path", ".", "basename", "(", "absolutePath", ")", ";", "}", "}", "catch", "(", "e", ")", "{", "throw", "new", "Error", "(", "'Can not locate proto file - '", "+", "inputProto", ",", "e", ")", ";", "}", "let", "jsonDescriptor", ";", "try", "{", "class", "ImportBuilder", "extends", "ProtoBuf", ".", "Builder", "{", "import", "(", "json", ",", "filename", ")", "{", "this", ".", "_imported", "=", "this", ".", "_imported", "||", "[", "]", ";", "this", ".", "_imported", ".", "push", "(", "{", "filename", ":", "filename", ",", "json", ":", "json", "}", ")", ";", "super", "[", "'import'", "]", "(", "json", ",", "filename", ")", ";", "}", "}", "const", "importBuilder", "=", "new", "ImportBuilder", "(", ")", ";", "// This validates that proto is parsable", "const", "builder", "=", "ProtoBuf", ".", "loadProtoFile", "(", "{", "root", ":", "protoDir", ",", "file", ":", "inputProto", "}", ",", "importBuilder", ")", ";", "jsonDescriptor", "=", "JSON", ".", "stringify", "(", "builder", ".", "_imported", ",", "undefined", ",", "2", ")", ";", "}", "catch", "(", "e", ")", "{", "console", ".", "error", "(", "'Proto Parsing Failed'", ",", "e", ")", ";", "throw", "new", "Error", "(", "'Generation Failed'", ")", ";", "}", "Namespace", ".", "reset", "(", ")", ";", "const", "namespace", "=", "processProto", "(", "inputProto", ",", "protoDir", ")", ";", "const", "code", "=", "namespace", ".", "generate", "(", "jsonDescriptor", ",", "{", "render", ":", "data", "=>", "mustache", ".", "render", "(", "fs", ".", "readFileSync", "(", "path", ".", "format", "(", "{", "dir", ":", "templateDir", ",", "base", ":", "'module.js.mt'", "}", ")", ",", "'utf8'", ")", ",", "data", ")", "}", ",", "{", "render", ":", "data", "=>", "mustache", ".", "render", "(", "fs", ".", "readFileSync", "(", "path", ".", "format", "(", "{", "dir", ":", "templateDir", ",", "base", ":", "'root.js.mt'", "}", ")", ",", "'utf8'", ")", ",", "data", ")", "}", ")", ";", "for", "(", "const", "key", "of", "Object", ".", "keys", "(", "code", ")", ")", "{", "const", "dir", "=", "path", ".", "format", "(", "{", "dir", ":", "outputDir", ",", "base", ":", "key", "}", ")", ";", "fs", ".", "ensureDirSync", "(", "dir", ")", ";", "const", "file", "=", "path", ".", "format", "(", "{", "dir", ":", "dir", ",", "base", ":", "'index.js'", "}", ")", ";", "fs", ".", "writeFileSync", "(", "file", ",", "code", "[", "key", "]", ",", "{", "encoding", ":", "'utf8'", "}", ")", ";", "}", "}" ]
Exported function from this module Given the proto input will generate the modules with flowtype bindings in outputDir @param outputDir - Directory to output files @param inputProto - Root proto file @param protoDir - directory to load proto files from - can be ommited and absolute path used in inputProto if imports are relative to the directory of inputProto
[ "Exported", "function", "from", "this", "module" ]
105fa5dea8769ef71267e01e25d32a39baf31176
https://github.com/netproteus/protobuf2flowtype/blob/105fa5dea8769ef71267e01e25d32a39baf31176/build/generate.js#L496-L569
43,245
danigb/scorejs
lib/score.js
note
function note (dur, pitch, data) { if (arguments.length === 1) return function (p, d) { return note(dur, p, d) } return assign({ pitch: pitch, duration: dur || 1 }, data) }
javascript
function note (dur, pitch, data) { if (arguments.length === 1) return function (p, d) { return note(dur, p, d) } return assign({ pitch: pitch, duration: dur || 1 }, data) }
[ "function", "note", "(", "dur", ",", "pitch", ",", "data", ")", "{", "if", "(", "arguments", ".", "length", "===", "1", ")", "return", "function", "(", "p", ",", "d", ")", "{", "return", "note", "(", "dur", ",", "p", ",", "d", ")", "}", "return", "assign", "(", "{", "pitch", ":", "pitch", ",", "duration", ":", "dur", "||", "1", "}", ",", "data", ")", "}" ]
Create a note from duration and pitch. It's a helper function to create score elements easely. A note is any object with duration and pitch attributes. The duration must be a number and the pitch can be any value (but usually expressed by integers, floats or strings) If only duration is provided, a partially applied function is returned. @param {Integer} duration - the note duration @param {String|Integer} pitch - the note pitch @param {Hash} data - (Optional) arbitraty note data @return {Hash} a note @example score.note(1, 'A') // => { duration: 1, pitch: 'A' } score.note(0.5, 'anything') // => { duration: 0.5, pitch: 'anything' } score.note(2, 'A', 2, { inst: 'piano' }) // => { duration: 2, pitch: 'A', inst: 'piano' } @example // partially applied ['C', 'D', 'E'].map(score.note(1)) // => [{ duration: 1, pitch: 'C'}, { duration: 1, pitch: 'D'}, { duration: 1, pitch: 'E'}]
[ "Create", "a", "note", "from", "duration", "and", "pitch", ".", "It", "s", "a", "helper", "function", "to", "create", "score", "elements", "easely", "." ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/lib/score.js#L61-L64
43,246
danigb/scorejs
lib/score.js
transform
function transform (nt, st, pt, ctx, obj) { switch (arguments.length) { case 0: return transform case 1: case 2: case 3: return transformer(nt, st, pt) case 4: return function (o) { return transformer(nt, st, pt)(ctx, o) } default: return transformer(nt, st, pt)(ctx, obj) } }
javascript
function transform (nt, st, pt, ctx, obj) { switch (arguments.length) { case 0: return transform case 1: case 2: case 3: return transformer(nt, st, pt) case 4: return function (o) { return transformer(nt, st, pt)(ctx, o) } default: return transformer(nt, st, pt)(ctx, obj) } }
[ "function", "transform", "(", "nt", ",", "st", ",", "pt", ",", "ctx", ",", "obj", ")", "{", "switch", "(", "arguments", ".", "length", ")", "{", "case", "0", ":", "return", "transform", "case", "1", ":", "case", "2", ":", "case", "3", ":", "return", "transformer", "(", "nt", ",", "st", ",", "pt", ")", "case", "4", ":", "return", "function", "(", "o", ")", "{", "return", "transformer", "(", "nt", ",", "st", ",", "pt", ")", "(", "ctx", ",", "o", ")", "}", "default", ":", "return", "transformer", "(", "nt", ",", "st", ",", "pt", ")", "(", "ctx", ",", "obj", ")", "}", "}" ]
Transform a musical structure This is probably the most important function. It allows complex transformations of musical structures using three functions @param {Function} elTransform - element transform function @param {Function} seqTransform - sequential structure transform function @param {Function} parTransform - simultaneous structure transform function @param {*} ctx - an additional object passed to transform functions @param {Object} score - the score to transform @return {*} the result of the transformation
[ "Transform", "a", "musical", "structure" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/lib/score.js#L100-L109
43,247
danigb/scorejs
lib/score.js
map
function map (fn, ctx, obj) { switch (arguments.length) { case 0: return map case 1: return transform(fn, buildSeq, buildSim) case 2: return function (obj) { return map(fn)(ctx, obj) } case 3: return map(fn)(ctx, obj) } }
javascript
function map (fn, ctx, obj) { switch (arguments.length) { case 0: return map case 1: return transform(fn, buildSeq, buildSim) case 2: return function (obj) { return map(fn)(ctx, obj) } case 3: return map(fn)(ctx, obj) } }
[ "function", "map", "(", "fn", ",", "ctx", ",", "obj", ")", "{", "switch", "(", "arguments", ".", "length", ")", "{", "case", "0", ":", "return", "map", "case", "1", ":", "return", "transform", "(", "fn", ",", "buildSeq", ",", "buildSim", ")", "case", "2", ":", "return", "function", "(", "obj", ")", "{", "return", "map", "(", "fn", ")", "(", "ctx", ",", "obj", ")", "}", "case", "3", ":", "return", "map", "(", "fn", ")", "(", "ctx", ",", "obj", ")", "}", "}" ]
Map the notes of a musical structure using a function @param {Function} fn - the function used to map the notes @param {Object} ctx - a context object passed to the function @param {Score} score - the score to transform @return {Score} the transformed score
[ "Map", "the", "notes", "of", "a", "musical", "structure", "using", "a", "function" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/lib/score.js#L132-L139
43,248
avinoamr/blueprint.js
lib/blueprint.js
extend
function extend( obj, var_args ) { for ( var i = 1; i < arguments.length ; i += 1 ) { var other = arguments[ i ]; for ( var p in other ) { var v = Object.getOwnPropertyDescriptor( other, p ); if ( typeof v == "undefined" || typeof v.value == "undefined" ) { delete obj[ p ]; } else { Object.defineProperty( obj, p, v ); } } } return obj; }
javascript
function extend( obj, var_args ) { for ( var i = 1; i < arguments.length ; i += 1 ) { var other = arguments[ i ]; for ( var p in other ) { var v = Object.getOwnPropertyDescriptor( other, p ); if ( typeof v == "undefined" || typeof v.value == "undefined" ) { delete obj[ p ]; } else { Object.defineProperty( obj, p, v ); } } } return obj; }
[ "function", "extend", "(", "obj", ",", "var_args", ")", "{", "for", "(", "var", "i", "=", "1", ";", "i", "<", "arguments", ".", "length", ";", "i", "+=", "1", ")", "{", "var", "other", "=", "arguments", "[", "i", "]", ";", "for", "(", "var", "p", "in", "other", ")", "{", "var", "v", "=", "Object", ".", "getOwnPropertyDescriptor", "(", "other", ",", "p", ")", ";", "if", "(", "typeof", "v", "==", "\"undefined\"", "||", "typeof", "v", ".", "value", "==", "\"undefined\"", ")", "{", "delete", "obj", "[", "p", "]", ";", "}", "else", "{", "Object", ".", "defineProperty", "(", "obj", ",", "p", ",", "v", ")", ";", "}", "}", "}", "return", "obj", ";", "}" ]
helper function for extending objects
[ "helper", "function", "for", "extending", "objects" ]
f6bef30e759bff91be564c071afe3556d2ac82ef
https://github.com/avinoamr/blueprint.js/blob/f6bef30e759bff91be564c071afe3556d2ac82ef/lib/blueprint.js#L700-L713
43,249
sperka/node-sshclient
lib/ssh.js
SSH
function SSH(options) { this.options = options || {}; console.assert(this.options.hostname, "Hostname required!"); this.debug = !!options.debug; this.listener = new Listener({ debug: options.debug }); }
javascript
function SSH(options) { this.options = options || {}; console.assert(this.options.hostname, "Hostname required!"); this.debug = !!options.debug; this.listener = new Listener({ debug: options.debug }); }
[ "function", "SSH", "(", "options", ")", "{", "this", ".", "options", "=", "options", "||", "{", "}", ";", "console", ".", "assert", "(", "this", ".", "options", ".", "hostname", ",", "\"Hostname required!\"", ")", ";", "this", ".", "debug", "=", "!", "!", "options", ".", "debug", ";", "this", ".", "listener", "=", "new", "Listener", "(", "{", "debug", ":", "options", ".", "debug", "}", ")", ";", "}" ]
SSH manager. @param options The options to use when sending the command to the remote server. @constructor
[ "SSH", "manager", "." ]
83212209fee784f4474b8135b0f6d39a39077cd4
https://github.com/sperka/node-sshclient/blob/83212209fee784f4474b8135b0f6d39a39077cd4/lib/ssh.js#L28-L36
43,250
danigb/scorejs
lib/timed.js
forEachTime
function forEachTime (fn, ctx, obj) { if (arguments.length > 1) return forEachTime(fn)(ctx, obj) return function (ctx, obj) { return score.transform( function (note) { return function (time, ctx) { fn(time, note, ctx) return note.duration } }, function (seq) { return function (time, ctx) { return seq.reduce(function (dur, fn) { return dur + fn(time + dur, ctx) }, 0) } }, function (par) { return function (time, ctx) { return par.reduce(function (max, fn) { return Math.max(max, fn(time, ctx)) }, 0) } } )(null, obj)(0, ctx) } }
javascript
function forEachTime (fn, ctx, obj) { if (arguments.length > 1) return forEachTime(fn)(ctx, obj) return function (ctx, obj) { return score.transform( function (note) { return function (time, ctx) { fn(time, note, ctx) return note.duration } }, function (seq) { return function (time, ctx) { return seq.reduce(function (dur, fn) { return dur + fn(time + dur, ctx) }, 0) } }, function (par) { return function (time, ctx) { return par.reduce(function (max, fn) { return Math.max(max, fn(time, ctx)) }, 0) } } )(null, obj)(0, ctx) } }
[ "function", "forEachTime", "(", "fn", ",", "ctx", ",", "obj", ")", "{", "if", "(", "arguments", ".", "length", ">", "1", ")", "return", "forEachTime", "(", "fn", ")", "(", "ctx", ",", "obj", ")", "return", "function", "(", "ctx", ",", "obj", ")", "{", "return", "score", ".", "transform", "(", "function", "(", "note", ")", "{", "return", "function", "(", "time", ",", "ctx", ")", "{", "fn", "(", "time", ",", "note", ",", "ctx", ")", "return", "note", ".", "duration", "}", "}", ",", "function", "(", "seq", ")", "{", "return", "function", "(", "time", ",", "ctx", ")", "{", "return", "seq", ".", "reduce", "(", "function", "(", "dur", ",", "fn", ")", "{", "return", "dur", "+", "fn", "(", "time", "+", "dur", ",", "ctx", ")", "}", ",", "0", ")", "}", "}", ",", "function", "(", "par", ")", "{", "return", "function", "(", "time", ",", "ctx", ")", "{", "return", "par", ".", "reduce", "(", "function", "(", "max", ",", "fn", ")", "{", "return", "Math", ".", "max", "(", "max", ",", "fn", "(", "time", ",", "ctx", ")", ")", "}", ",", "0", ")", "}", "}", ")", "(", "null", ",", "obj", ")", "(", "0", ",", "ctx", ")", "}", "}" ]
Get all notes for side-effects __Important:__ ascending time ordered is not guaranteed @param {Function} fn - the function @param {Object} ctx - (Optional) a context object passed to the function @param {Score} score - the score object
[ "Get", "all", "notes", "for", "side", "-", "effects" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/lib/timed.js#L21-L48
43,251
danigb/scorejs
lib/timed.js
events
function events (obj, build, compare) { var e = [] forEachTime(function (time, obj) { e.push(build ? build(time, obj) : [time, obj]) }, null, obj) return e.sort(compare || function (a, b) { return a[0] - b[0] }) }
javascript
function events (obj, build, compare) { var e = [] forEachTime(function (time, obj) { e.push(build ? build(time, obj) : [time, obj]) }, null, obj) return e.sort(compare || function (a, b) { return a[0] - b[0] }) }
[ "function", "events", "(", "obj", ",", "build", ",", "compare", ")", "{", "var", "e", "=", "[", "]", "forEachTime", "(", "function", "(", "time", ",", "obj", ")", "{", "e", ".", "push", "(", "build", "?", "build", "(", "time", ",", "obj", ")", ":", "[", "time", ",", "obj", "]", ")", "}", ",", "null", ",", "obj", ")", "return", "e", ".", "sort", "(", "compare", "||", "function", "(", "a", ",", "b", ")", "{", "return", "a", "[", "0", "]", "-", "b", "[", "0", "]", "}", ")", "}" ]
Get a sorted events array from a score
[ "Get", "a", "sorted", "events", "array", "from", "a", "score" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/lib/timed.js#L54-L60
43,252
sperka/node-sshclient
lib/scp.js
SCP
function SCP(options) { this.options = options || {}; console.assert(this.options.hostname, "Hostname required!"); this.debug = !!options.debug; this.listener = new Listener({ debug: options.debug }); }
javascript
function SCP(options) { this.options = options || {}; console.assert(this.options.hostname, "Hostname required!"); this.debug = !!options.debug; this.listener = new Listener({ debug: options.debug }); }
[ "function", "SCP", "(", "options", ")", "{", "this", ".", "options", "=", "options", "||", "{", "}", ";", "console", ".", "assert", "(", "this", ".", "options", ".", "hostname", ",", "\"Hostname required!\"", ")", ";", "this", ".", "debug", "=", "!", "!", "options", ".", "debug", ";", "this", ".", "listener", "=", "new", "Listener", "(", "{", "debug", ":", "options", ".", "debug", "}", ")", ";", "}" ]
SCP manager. @param options The options to use when sending the command to the remote server. @constructor
[ "SCP", "manager", "." ]
83212209fee784f4474b8135b0f6d39a39077cd4
https://github.com/sperka/node-sshclient/blob/83212209fee784f4474b8135b0f6d39a39077cd4/lib/scp.js#L23-L32
43,253
reelyactive/raddec
lib/rssiSignature.js
merge
function merge(source, destination) { source.forEach(function(current) { let matchFound = false; destination.forEach(function(target) { let isSameReceiver = identifiers.areMatch(current.receiverId, current.receiverIdType, target.receiverId, target.receiverIdType); if(isSameReceiver) { target.rssiSum = target.rssiSum || (target.rssi * target.numberOfDecodings); target.numberOfDecodings += current.numberOfDecodings || 1; target.rssiSum += current.rssiSum || (current.rssi * current.numberOfDecodings); target.rssi = Math.round(target.rssiSum / target.numberOfDecodings); matchFound = true; } }); if(!matchFound) { destination.push(current); } }); destination.sort(compareRssi); }
javascript
function merge(source, destination) { source.forEach(function(current) { let matchFound = false; destination.forEach(function(target) { let isSameReceiver = identifiers.areMatch(current.receiverId, current.receiverIdType, target.receiverId, target.receiverIdType); if(isSameReceiver) { target.rssiSum = target.rssiSum || (target.rssi * target.numberOfDecodings); target.numberOfDecodings += current.numberOfDecodings || 1; target.rssiSum += current.rssiSum || (current.rssi * current.numberOfDecodings); target.rssi = Math.round(target.rssiSum / target.numberOfDecodings); matchFound = true; } }); if(!matchFound) { destination.push(current); } }); destination.sort(compareRssi); }
[ "function", "merge", "(", "source", ",", "destination", ")", "{", "source", ".", "forEach", "(", "function", "(", "current", ")", "{", "let", "matchFound", "=", "false", ";", "destination", ".", "forEach", "(", "function", "(", "target", ")", "{", "let", "isSameReceiver", "=", "identifiers", ".", "areMatch", "(", "current", ".", "receiverId", ",", "current", ".", "receiverIdType", ",", "target", ".", "receiverId", ",", "target", ".", "receiverIdType", ")", ";", "if", "(", "isSameReceiver", ")", "{", "target", ".", "rssiSum", "=", "target", ".", "rssiSum", "||", "(", "target", ".", "rssi", "*", "target", ".", "numberOfDecodings", ")", ";", "target", ".", "numberOfDecodings", "+=", "current", ".", "numberOfDecodings", "||", "1", ";", "target", ".", "rssiSum", "+=", "current", ".", "rssiSum", "||", "(", "current", ".", "rssi", "*", "current", ".", "numberOfDecodings", ")", ";", "target", ".", "rssi", "=", "Math", ".", "round", "(", "target", ".", "rssiSum", "/", "target", ".", "numberOfDecodings", ")", ";", "matchFound", "=", "true", ";", "}", "}", ")", ";", "if", "(", "!", "matchFound", ")", "{", "destination", ".", "push", "(", "current", ")", ";", "}", "}", ")", ";", "destination", ".", "sort", "(", "compareRssi", ")", ";", "}" ]
Merge the source rssiSignature into the destination rssiSignature. @param {Array} source The source rssiSignature. @param {Array} destination The destination rssiSignature.
[ "Merge", "the", "source", "rssiSignature", "into", "the", "destination", "rssiSignature", "." ]
6bd2c73ce63c5e45fb9e77c245491939a690a76a
https://github.com/reelyactive/raddec/blob/6bd2c73ce63c5e45fb9e77c245491939a690a76a/lib/rssiSignature.js#L15-L38
43,254
reelyactive/raddec
lib/rssiSignature.js
compareRssi
function compareRssi(a,b) { if(a.rssi < b.rssi) return 1; if(a.rssi > b.rssi) return -1; return 0; }
javascript
function compareRssi(a,b) { if(a.rssi < b.rssi) return 1; if(a.rssi > b.rssi) return -1; return 0; }
[ "function", "compareRssi", "(", "a", ",", "b", ")", "{", "if", "(", "a", ".", "rssi", "<", "b", ".", "rssi", ")", "return", "1", ";", "if", "(", "a", ".", "rssi", ">", "b", ".", "rssi", ")", "return", "-", "1", ";", "return", "0", ";", "}" ]
Compare rssi values for array sorting. @param {Object} a An rssiSignature entry. @param {Object} b Another rssiSignature entry.
[ "Compare", "rssi", "values", "for", "array", "sorting", "." ]
6bd2c73ce63c5e45fb9e77c245491939a690a76a
https://github.com/reelyactive/raddec/blob/6bd2c73ce63c5e45fb9e77c245491939a690a76a/lib/rssiSignature.js#L46-L52
43,255
reelyactive/raddec
lib/rssi.js
encode
function encode(rssi) { if(rssi < MIN_RSSI_DBM) { rssi = MIN_RSSI_DBM; } else if(rssi > MAX_RSSI_DBM) { rssi = MAX_RSSI_DBM; } else { rssi = Math.round(rssi); } return ('00' + (rssi - MIN_RSSI_DBM).toString(16)).substr(-2); }
javascript
function encode(rssi) { if(rssi < MIN_RSSI_DBM) { rssi = MIN_RSSI_DBM; } else if(rssi > MAX_RSSI_DBM) { rssi = MAX_RSSI_DBM; } else { rssi = Math.round(rssi); } return ('00' + (rssi - MIN_RSSI_DBM).toString(16)).substr(-2); }
[ "function", "encode", "(", "rssi", ")", "{", "if", "(", "rssi", "<", "MIN_RSSI_DBM", ")", "{", "rssi", "=", "MIN_RSSI_DBM", ";", "}", "else", "if", "(", "rssi", ">", "MAX_RSSI_DBM", ")", "{", "rssi", "=", "MAX_RSSI_DBM", ";", "}", "else", "{", "rssi", "=", "Math", ".", "round", "(", "rssi", ")", ";", "}", "return", "(", "'00'", "+", "(", "rssi", "-", "MIN_RSSI_DBM", ")", ".", "toString", "(", "16", ")", ")", ".", "substr", "(", "-", "2", ")", ";", "}" ]
Encode the given RSSI value as a hexadecimal string byte. @param {Number} rssi The given RSSI in dBm. @return {String} The resulting hexadecimal string.
[ "Encode", "the", "given", "RSSI", "value", "as", "a", "hexadecimal", "string", "byte", "." ]
6bd2c73ce63c5e45fb9e77c245491939a690a76a
https://github.com/reelyactive/raddec/blob/6bd2c73ce63c5e45fb9e77c245491939a690a76a/lib/rssi.js#L16-L28
43,256
danigb/scorejs
examples/twelveTone.js
ttone1
function ttone1 (reps, row, key, beat, amp) { var tr = row.split(' ').map(function (n) { return +n + key }) var r = score.repeat(reps, score.phrase(tr, beat, amp)) return score.map(function (e) { return randDur(randOct(e), beat) }, null, r) }
javascript
function ttone1 (reps, row, key, beat, amp) { var tr = row.split(' ').map(function (n) { return +n + key }) var r = score.repeat(reps, score.phrase(tr, beat, amp)) return score.map(function (e) { return randDur(randOct(e), beat) }, null, r) }
[ "function", "ttone1", "(", "reps", ",", "row", ",", "key", ",", "beat", ",", "amp", ")", "{", "var", "tr", "=", "row", ".", "split", "(", "' '", ")", ".", "map", "(", "function", "(", "n", ")", "{", "return", "+", "n", "+", "key", "}", ")", "var", "r", "=", "score", ".", "repeat", "(", "reps", ",", "score", ".", "phrase", "(", "tr", ",", "beat", ",", "amp", ")", ")", "return", "score", ".", "map", "(", "function", "(", "e", ")", "{", "return", "randDur", "(", "randOct", "(", "e", ")", ",", "beat", ")", "}", ",", "null", ",", "r", ")", "}" ]
Metalevel, pg 124
[ "Metalevel", "pg", "124" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/examples/twelveTone.js#L20-L28
43,257
danigb/scorejs
core/score.js
structureAs
function structureAs (name) { return function () { return [name].concat(isCollection(arguments[0]) ? arguments[0] : slice.call(arguments)) } }
javascript
function structureAs (name) { return function () { return [name].concat(isCollection(arguments[0]) ? arguments[0] : slice.call(arguments)) } }
[ "function", "structureAs", "(", "name", ")", "{", "return", "function", "(", ")", "{", "return", "[", "name", "]", ".", "concat", "(", "isCollection", "(", "arguments", "[", "0", "]", ")", "?", "arguments", "[", "0", "]", ":", "slice", ".", "call", "(", "arguments", ")", ")", "}", "}" ]
Create musical structures from function arguments
[ "Create", "musical", "structures", "from", "function", "arguments" ]
fc95215d7efef72aeaa22cf375b7839091ba35ff
https://github.com/danigb/scorejs/blob/fc95215d7efef72aeaa22cf375b7839091ba35ff/core/score.js#L95-L99
43,258
hhromic/e131-node
lib/client.js
Client
function Client(arg, port) { if (this instanceof Client === false) { return new Client(arg, port); } if (arg === undefined) { throw new TypeError('arg should be a host address, name or universe'); } this.host = Number.isInteger(arg) ? e131.getMulticastGroup(arg) : arg; this.port = port || e131.DEFAULT_PORT; this._socket = dgram.createSocket('udp4'); }
javascript
function Client(arg, port) { if (this instanceof Client === false) { return new Client(arg, port); } if (arg === undefined) { throw new TypeError('arg should be a host address, name or universe'); } this.host = Number.isInteger(arg) ? e131.getMulticastGroup(arg) : arg; this.port = port || e131.DEFAULT_PORT; this._socket = dgram.createSocket('udp4'); }
[ "function", "Client", "(", "arg", ",", "port", ")", "{", "if", "(", "this", "instanceof", "Client", "===", "false", ")", "{", "return", "new", "Client", "(", "arg", ",", "port", ")", ";", "}", "if", "(", "arg", "===", "undefined", ")", "{", "throw", "new", "TypeError", "(", "'arg should be a host address, name or universe'", ")", ";", "}", "this", ".", "host", "=", "Number", ".", "isInteger", "(", "arg", ")", "?", "e131", ".", "getMulticastGroup", "(", "arg", ")", ":", "arg", ";", "this", ".", "port", "=", "port", "||", "e131", ".", "DEFAULT_PORT", ";", "this", ".", "_socket", "=", "dgram", ".", "createSocket", "(", "'udp4'", ")", ";", "}" ]
E1.31 client object constructor
[ "E1", ".", "31", "client", "object", "constructor" ]
3a33b9219d917f46c52d1cb02bf36447f5fa6172
https://github.com/hhromic/e131-node/blob/3a33b9219d917f46c52d1cb02bf36447f5fa6172/lib/client.js#L27-L39
43,259
nakardo/node-gameboy
lib/cpu/opcodes.js
add_sp_n
function add_sp_n (cpu, mmu) { const n = mmu.readByte(cpu.pc + 1).signed(); const r = cpu.sp + n; const op = cpu.sp ^ n ^ r; cpu.f = 0; if ((op & 0x10) != 0) cpu.f |= FLAG_H; if ((op & 0x100) != 0) cpu.f |= FLAG_C; return r; }
javascript
function add_sp_n (cpu, mmu) { const n = mmu.readByte(cpu.pc + 1).signed(); const r = cpu.sp + n; const op = cpu.sp ^ n ^ r; cpu.f = 0; if ((op & 0x10) != 0) cpu.f |= FLAG_H; if ((op & 0x100) != 0) cpu.f |= FLAG_C; return r; }
[ "function", "add_sp_n", "(", "cpu", ",", "mmu", ")", "{", "const", "n", "=", "mmu", ".", "readByte", "(", "cpu", ".", "pc", "+", "1", ")", ".", "signed", "(", ")", ";", "const", "r", "=", "cpu", ".", "sp", "+", "n", ";", "const", "op", "=", "cpu", ".", "sp", "^", "n", "^", "r", ";", "cpu", ".", "f", "=", "0", ";", "if", "(", "(", "op", "&", "0x10", ")", "!=", "0", ")", "cpu", ".", "f", "|=", "FLAG_H", ";", "if", "(", "(", "op", "&", "0x100", ")", "!=", "0", ")", "cpu", ".", "f", "|=", "FLAG_C", ";", "return", "r", ";", "}" ]
LD HL,SP+n LDHL SP,n Description Put SP + n effective address into HL. Use with: n = one byte signed immediate value. Flags affected: Z - Reset. N - Reset. H - Set or reset according to operation. C - Set or reset according to operation. Opcodes: Instruction Parameters Opcode Cycles LDHL SP,n F8 12
[ "LD", "HL", "SP", "+", "n", "LDHL", "SP", "n" ]
93d112cddf7c9fd914f597be4d110b922d7cb59f
https://github.com/nakardo/node-gameboy/blob/93d112cddf7c9fd914f597be4d110b922d7cb59f/lib/cpu/opcodes.js#L600-L611
43,260
nakardo/node-gameboy
lib/cpu/opcodes.js
add
function add (cpu, n) { const r = cpu.a + n; cpu.f = 0; if ((r & 0xff) == 0) cpu.f |= FLAG_Z; if (((cpu.a ^ n ^ r) & 0x10) != 0) cpu.f |= FLAG_H; if ((r & 0x100) != 0) cpu.f |= FLAG_C; return r; }
javascript
function add (cpu, n) { const r = cpu.a + n; cpu.f = 0; if ((r & 0xff) == 0) cpu.f |= FLAG_Z; if (((cpu.a ^ n ^ r) & 0x10) != 0) cpu.f |= FLAG_H; if ((r & 0x100) != 0) cpu.f |= FLAG_C; return r; }
[ "function", "add", "(", "cpu", ",", "n", ")", "{", "const", "r", "=", "cpu", ".", "a", "+", "n", ";", "cpu", ".", "f", "=", "0", ";", "if", "(", "(", "r", "&", "0xff", ")", "==", "0", ")", "cpu", ".", "f", "|=", "FLAG_Z", ";", "if", "(", "(", "(", "cpu", ".", "a", "^", "n", "^", "r", ")", "&", "0x10", ")", "!=", "0", ")", "cpu", ".", "f", "|=", "FLAG_H", ";", "if", "(", "(", "r", "&", "0x100", ")", "!=", "0", ")", "cpu", ".", "f", "|=", "FLAG_C", ";", "return", "r", ";", "}" ]
8-Bit ALU ADD A,n Description: Add n to A. Use with: n = A, B, C, D, E, H, L, (HL), # Flags affected: Z - Set if result is zero. N - Reset. H - Set if carry from bit 3. C - Set if carry from bit 7. Opcodes: Instruction Parameters Opcode Cycles ADD A,A 87 4 ADD A,B 80 4 ADD A,C 81 4 ADD A,D 82 4 ADD A,E 83 4 ADD A,H 84 4 ADD A,L 85 4 ADD A,(HL) 86 8 ADD A,# C6 8
[ "8", "-", "Bit", "ALU", "ADD", "A", "n" ]
93d112cddf7c9fd914f597be4d110b922d7cb59f
https://github.com/nakardo/node-gameboy/blob/93d112cddf7c9fd914f597be4d110b922d7cb59f/lib/cpu/opcodes.js#L731-L740
43,261
nakardo/node-gameboy
lib/cpu/opcodes.js
adc
function adc (cpu, n) { const cy = cpu.f >> 4 & 1; const r = cpu.a + n + cy; cpu.f = 0; if ((r & 0xff) == 0) cpu.f |= FLAG_Z; if (((cpu.a ^ n ^ r) & 0x10) != 0) cpu.f |= FLAG_H; if ((r & 0x100) != 0) cpu.f |= FLAG_C; return r; }
javascript
function adc (cpu, n) { const cy = cpu.f >> 4 & 1; const r = cpu.a + n + cy; cpu.f = 0; if ((r & 0xff) == 0) cpu.f |= FLAG_Z; if (((cpu.a ^ n ^ r) & 0x10) != 0) cpu.f |= FLAG_H; if ((r & 0x100) != 0) cpu.f |= FLAG_C; return r; }
[ "function", "adc", "(", "cpu", ",", "n", ")", "{", "const", "cy", "=", "cpu", ".", "f", ">>", "4", "&", "1", ";", "const", "r", "=", "cpu", ".", "a", "+", "n", "+", "cy", ";", "cpu", ".", "f", "=", "0", ";", "if", "(", "(", "r", "&", "0xff", ")", "==", "0", ")", "cpu", ".", "f", "|=", "FLAG_Z", ";", "if", "(", "(", "(", "cpu", ".", "a", "^", "n", "^", "r", ")", "&", "0x10", ")", "!=", "0", ")", "cpu", ".", "f", "|=", "FLAG_H", ";", "if", "(", "(", "r", "&", "0x100", ")", "!=", "0", ")", "cpu", ".", "f", "|=", "FLAG_C", ";", "return", "r", ";", "}" ]
ADC A,n Description: Add n + Carry flag to A. Use with: n = A, B, C, D, E, H, L, (HL), # Flags affected: Z - Set if result is zero. N - Reset. H - Set if carry from bit 3. C - Set if carry from bit 7. Opcodes: Instruction Parameters Opcode Cycles ADC A,A 8F 4 ADC A,B 88 4 ADC A,C 89 4 ADC A,D 8A 4 ADC A,E 8B 4 ADC A,H 8C 4 ADC A,L 8D 4 ADC A,(HL) 8E 8 ADC A,# CE 8
[ "ADC", "A", "n" ]
93d112cddf7c9fd914f597be4d110b922d7cb59f
https://github.com/nakardo/node-gameboy/blob/93d112cddf7c9fd914f597be4d110b922d7cb59f/lib/cpu/opcodes.js#L801-L811
43,262
nakardo/node-gameboy
lib/cpu/opcodes.js
sbc
function sbc (cpu, n) { const cy = cpu.f >> 4 & 1; const r = cpu.a - n - cy; cpu.f = FLAG_N; if ((r & 0xff) == 0) cpu.f |= FLAG_Z; if (((cpu.a ^ n ^ r) & 0x10) != 0) cpu.f |= FLAG_H; if ((r & 0x100) != 0) cpu.f |= FLAG_C; return r; }
javascript
function sbc (cpu, n) { const cy = cpu.f >> 4 & 1; const r = cpu.a - n - cy; cpu.f = FLAG_N; if ((r & 0xff) == 0) cpu.f |= FLAG_Z; if (((cpu.a ^ n ^ r) & 0x10) != 0) cpu.f |= FLAG_H; if ((r & 0x100) != 0) cpu.f |= FLAG_C; return r; }
[ "function", "sbc", "(", "cpu", ",", "n", ")", "{", "const", "cy", "=", "cpu", ".", "f", ">>", "4", "&", "1", ";", "const", "r", "=", "cpu", ".", "a", "-", "n", "-", "cy", ";", "cpu", ".", "f", "=", "FLAG_N", ";", "if", "(", "(", "r", "&", "0xff", ")", "==", "0", ")", "cpu", ".", "f", "|=", "FLAG_Z", ";", "if", "(", "(", "(", "cpu", ".", "a", "^", "n", "^", "r", ")", "&", "0x10", ")", "!=", "0", ")", "cpu", ".", "f", "|=", "FLAG_H", ";", "if", "(", "(", "r", "&", "0x100", ")", "!=", "0", ")", "cpu", ".", "f", "|=", "FLAG_C", ";", "return", "r", ";", "}" ]
SBC A,n Description: Subtract n + Carry flag from A. Use with: n = A, B, C, D, E, H, L, (HL), # Flags affected: Z - Set if result is zero. N - Set. H - Set if no borrow from bit 4. C - Set if no borrow. Opcodes: Instruction Parameters Opcode Cycles SBC A,A 9F 4 SBC A,B 98 4 SBC A,C 99 4 SBC A,D 9A 4 SBC A,E 9B 4 SBC A,H 9C 4 SBC A,L 9D 4 SBC A,(HL) 9E 8 SBC A,# DE 8
[ "SBC", "A", "n" ]
93d112cddf7c9fd914f597be4d110b922d7cb59f
https://github.com/nakardo/node-gameboy/blob/93d112cddf7c9fd914f597be4d110b922d7cb59f/lib/cpu/opcodes.js#L938-L948
43,263
nakardo/node-gameboy
lib/cpu/opcodes.js
swap
function swap (cpu, n) { const r = n << 4 | n >> 4; cpu.f = 0; if ((r & 0xff) == 0) cpu.f |= FLAG_Z; return r; }
javascript
function swap (cpu, n) { const r = n << 4 | n >> 4; cpu.f = 0; if ((r & 0xff) == 0) cpu.f |= FLAG_Z; return r; }
[ "function", "swap", "(", "cpu", ",", "n", ")", "{", "const", "r", "=", "n", "<<", "4", "|", "n", ">>", "4", ";", "cpu", ".", "f", "=", "0", ";", "if", "(", "(", "r", "&", "0xff", ")", "==", "0", ")", "cpu", ".", "f", "|=", "FLAG_Z", ";", "return", "r", ";", "}" ]
Miscellaneous SWAP n Description: Swap upper & lower nibles of n. Use with: n = A, B, C, D, E, H, L, (HL) Flags affected: Z - Set if result is zero. N - Reset. H - Reset. C - Reset. Opcodes: Instruction Parameters Opcode Cycles SWAP A CB 37 8 SWAP B CB 30 8 SWAP C CB 31 8 SWAP D CB 32 8 SWAP E CB 33 8 SWAP H CB 34 8 SWAP L CB 35 8 SWAP (HL) CB 36 16
[ "Miscellaneous", "SWAP", "n" ]
93d112cddf7c9fd914f597be4d110b922d7cb59f
https://github.com/nakardo/node-gameboy/blob/93d112cddf7c9fd914f597be4d110b922d7cb59f/lib/cpu/opcodes.js#L1513-L1520
43,264
nakardo/node-gameboy
lib/cpu/opcodes.js
bit
function bit (cpu, b, n) { const r = n & (1 << b); cpu.f &= ~0xe0; if (r == 0) cpu.f |= FLAG_Z; cpu.f |= FLAG_H; return r; }
javascript
function bit (cpu, b, n) { const r = n & (1 << b); cpu.f &= ~0xe0; if (r == 0) cpu.f |= FLAG_Z; cpu.f |= FLAG_H; return r; }
[ "function", "bit", "(", "cpu", ",", "b", ",", "n", ")", "{", "const", "r", "=", "n", "&", "(", "1", "<<", "b", ")", ";", "cpu", ".", "f", "&=", "~", "0xe0", ";", "if", "(", "r", "==", "0", ")", "cpu", ".", "f", "|=", "FLAG_Z", ";", "cpu", ".", "f", "|=", "FLAG_H", ";", "return", "r", ";", "}" ]
Bit Opcodes BIT b,r Description: Test bit b in register r. Use with: b = 0 - 7, r = A, B, C, D, E, H, L, (HL) Flags affected: Z - Set if bit b of register r is 0. N - Reset. H - Set. C - Not affected. Opcodes: Instruction Parameters Opcode Cycles BIT b,A CB 47 8 BIT b,B CB 40 8 BIT b,C CB 41 8 BIT b,D CB 42 8 BIT b,E CB 43 8 BIT b,H CB 44 8 BIT b,L CB 45 8 BIT b,(HL) CB 46 16
[ "Bit", "Opcodes", "BIT", "b", "r" ]
93d112cddf7c9fd914f597be4d110b922d7cb59f
https://github.com/nakardo/node-gameboy/blob/93d112cddf7c9fd914f597be4d110b922d7cb59f/lib/cpu/opcodes.js#L2329-L2337
43,265
nakardo/node-gameboy
lib/cpu/opcodes.js
function (cpu, mmu, cc) { if (cc) { cpu.pc += 2 + mmu.readByte(cpu.pc + 1).signed(); return 12; } cpu.pc += 2; return 8; }
javascript
function (cpu, mmu, cc) { if (cc) { cpu.pc += 2 + mmu.readByte(cpu.pc + 1).signed(); return 12; } cpu.pc += 2; return 8; }
[ "function", "(", "cpu", ",", "mmu", ",", "cc", ")", "{", "if", "(", "cc", ")", "{", "cpu", ".", "pc", "+=", "2", "+", "mmu", ".", "readByte", "(", "cpu", ".", "pc", "+", "1", ")", ".", "signed", "(", ")", ";", "return", "12", ";", "}", "cpu", ".", "pc", "+=", "2", ";", "return", "8", ";", "}" ]
JR cc,n Description: If following condition is true then add n address and jump to it: Use with: n = one byte signed immediate value cc = NZ, Jump if Z flag is reset. cc = Z, Jump if Z flag is set. cc = NC, Jump if C flag is reset. cc = C, Jump if C flag is set. Opcodes: Instruction Parameters Opcode Cycles JR NZ,* 20 8 JR Z,* 28 8 JR NC,* 30 8 JR C,* 38 8
[ "JR", "cc", "n" ]
93d112cddf7c9fd914f597be4d110b922d7cb59f
https://github.com/nakardo/node-gameboy/blob/93d112cddf7c9fd914f597be4d110b922d7cb59f/lib/cpu/opcodes.js#L2759-L2767
43,266
nakardo/node-gameboy
lib/cpu/opcodes.js
function (cpu, mmu, cc) { if (cc) { mmu.writeWord(cpu.sp -= 2, cpu.pc + 3); cpu.pc = mmu.readWord(cpu.pc + 1); return 24; } cpu.pc += 3; return 12; }
javascript
function (cpu, mmu, cc) { if (cc) { mmu.writeWord(cpu.sp -= 2, cpu.pc + 3); cpu.pc = mmu.readWord(cpu.pc + 1); return 24; } cpu.pc += 3; return 12; }
[ "function", "(", "cpu", ",", "mmu", ",", "cc", ")", "{", "if", "(", "cc", ")", "{", "mmu", ".", "writeWord", "(", "cpu", ".", "sp", "-=", "2", ",", "cpu", ".", "pc", "+", "3", ")", ";", "cpu", ".", "pc", "=", "mmu", ".", "readWord", "(", "cpu", ".", "pc", "+", "1", ")", ";", "return", "24", ";", "}", "cpu", ".", "pc", "+=", "3", ";", "return", "12", ";", "}" ]
CALL cc,nn Description: Call address n if following condition is true: cc = NZ, Call if Z flag is reset. cc = Z, Call if Z flag is set. cc = NC, Call if C flag is reset. cc = C, Call if C flag is set. Use with: nn = two byte immediate value. (LS byte first.) Opcodes: Instruction Parameters Opcode Cycles CALL NZ,nn C4 12 CALL Z,nn CC 12 CALL NC,nn D4 12 CALL C,nn DC 12
[ "CALL", "cc", "nn" ]
93d112cddf7c9fd914f597be4d110b922d7cb59f
https://github.com/nakardo/node-gameboy/blob/93d112cddf7c9fd914f597be4d110b922d7cb59f/lib/cpu/opcodes.js#L2820-L2830
43,267
bevacqua/indexeddb-mock
indexeddb.js
function (data) { if (mockIndexedDBTestFlags.canSave === true) { mockIndexedDBItems.push(data); mockIndexedDB_storeAddTimer = setTimeout(function () { mockIndexedDBTransaction.callCompleteHandler(); mockIndexedDB_saveSuccess = true; }, 20); } else { mockIndexedDB_storeAddTimer = setTimeout(function () { mockIndexedDBTransaction.callErrorHandler(); mockIndexedDB_saveFail = true; }, 20); } return mockIndexedDBTransaction; }
javascript
function (data) { if (mockIndexedDBTestFlags.canSave === true) { mockIndexedDBItems.push(data); mockIndexedDB_storeAddTimer = setTimeout(function () { mockIndexedDBTransaction.callCompleteHandler(); mockIndexedDB_saveSuccess = true; }, 20); } else { mockIndexedDB_storeAddTimer = setTimeout(function () { mockIndexedDBTransaction.callErrorHandler(); mockIndexedDB_saveFail = true; }, 20); } return mockIndexedDBTransaction; }
[ "function", "(", "data", ")", "{", "if", "(", "mockIndexedDBTestFlags", ".", "canSave", "===", "true", ")", "{", "mockIndexedDBItems", ".", "push", "(", "data", ")", ";", "mockIndexedDB_storeAddTimer", "=", "setTimeout", "(", "function", "(", ")", "{", "mockIndexedDBTransaction", ".", "callCompleteHandler", "(", ")", ";", "mockIndexedDB_saveSuccess", "=", "true", ";", "}", ",", "20", ")", ";", "}", "else", "{", "mockIndexedDB_storeAddTimer", "=", "setTimeout", "(", "function", "(", ")", "{", "mockIndexedDBTransaction", ".", "callErrorHandler", "(", ")", ";", "mockIndexedDB_saveFail", "=", "true", ";", "}", ",", "20", ")", ";", "}", "return", "mockIndexedDBTransaction", ";", "}" ]
add returns a different txn than delete does. in indexedDB, the listeners are attached to the txn that returned the store.
[ "add", "returns", "a", "different", "txn", "than", "delete", "does", ".", "in", "indexedDB", "the", "listeners", "are", "attached", "to", "the", "txn", "that", "returned", "the", "store", "." ]
ad62dfa699d0fd6933f1d4d897f4c099c56d734d
https://github.com/bevacqua/indexeddb-mock/blob/ad62dfa699d0fd6933f1d4d897f4c099c56d734d/indexeddb.js#L239-L255
43,268
bevacqua/indexeddb-mock
indexeddb.js
function (data_id) { if (mockIndexedDBTestFlags.canDelete === true) { mockIndexedDB_storeDeleteTimer = setTimeout(function () { mockIndexedDBStoreTransaction.callSuccessHandler(); mockIndexedDB_deleteSuccess = true; }, 20); } else { mockIndexedDB_storeDeleteTimer = setTimeout(function () { mockIndexedDBStoreTransaction.callErrorHandler(); mockIndexedDB_deleteFail = true; }, 20); } return mockIndexedDBStoreTransaction; }
javascript
function (data_id) { if (mockIndexedDBTestFlags.canDelete === true) { mockIndexedDB_storeDeleteTimer = setTimeout(function () { mockIndexedDBStoreTransaction.callSuccessHandler(); mockIndexedDB_deleteSuccess = true; }, 20); } else { mockIndexedDB_storeDeleteTimer = setTimeout(function () { mockIndexedDBStoreTransaction.callErrorHandler(); mockIndexedDB_deleteFail = true; }, 20); } return mockIndexedDBStoreTransaction; }
[ "function", "(", "data_id", ")", "{", "if", "(", "mockIndexedDBTestFlags", ".", "canDelete", "===", "true", ")", "{", "mockIndexedDB_storeDeleteTimer", "=", "setTimeout", "(", "function", "(", ")", "{", "mockIndexedDBStoreTransaction", ".", "callSuccessHandler", "(", ")", ";", "mockIndexedDB_deleteSuccess", "=", "true", ";", "}", ",", "20", ")", ";", "}", "else", "{", "mockIndexedDB_storeDeleteTimer", "=", "setTimeout", "(", "function", "(", ")", "{", "mockIndexedDBStoreTransaction", ".", "callErrorHandler", "(", ")", ";", "mockIndexedDB_deleteFail", "=", "true", ";", "}", ",", "20", ")", ";", "}", "return", "mockIndexedDBStoreTransaction", ";", "}" ]
for delete, the listeners are attached to a request returned from the store.
[ "for", "delete", "the", "listeners", "are", "attached", "to", "a", "request", "returned", "from", "the", "store", "." ]
ad62dfa699d0fd6933f1d4d897f4c099c56d734d
https://github.com/bevacqua/indexeddb-mock/blob/ad62dfa699d0fd6933f1d4d897f4c099c56d734d/indexeddb.js#L278-L293
43,269
bevacqua/indexeddb-mock
indexeddb.js
function (data_id) { if (mockIndexedDBTestFlags.canClear === true) { mockIndexedDB_storeClearTimer = setTimeout(function () { mockIndexedDBStoreTransaction.callSuccessHandler(); mockIndexedDB_clearSuccess = true; }, 20); } else { mockIndexedDB_storeClearTimer = setTimeout(function () { mockIndexedDBStoreTransaction.callErrorHandler(); mockIndexedDB_clearFail = true; }, 20); } return mockIndexedDBStoreTransaction; }
javascript
function (data_id) { if (mockIndexedDBTestFlags.canClear === true) { mockIndexedDB_storeClearTimer = setTimeout(function () { mockIndexedDBStoreTransaction.callSuccessHandler(); mockIndexedDB_clearSuccess = true; }, 20); } else { mockIndexedDB_storeClearTimer = setTimeout(function () { mockIndexedDBStoreTransaction.callErrorHandler(); mockIndexedDB_clearFail = true; }, 20); } return mockIndexedDBStoreTransaction; }
[ "function", "(", "data_id", ")", "{", "if", "(", "mockIndexedDBTestFlags", ".", "canClear", "===", "true", ")", "{", "mockIndexedDB_storeClearTimer", "=", "setTimeout", "(", "function", "(", ")", "{", "mockIndexedDBStoreTransaction", ".", "callSuccessHandler", "(", ")", ";", "mockIndexedDB_clearSuccess", "=", "true", ";", "}", ",", "20", ")", ";", "}", "else", "{", "mockIndexedDB_storeClearTimer", "=", "setTimeout", "(", "function", "(", ")", "{", "mockIndexedDBStoreTransaction", ".", "callErrorHandler", "(", ")", ";", "mockIndexedDB_clearFail", "=", "true", ";", "}", ",", "20", ")", ";", "}", "return", "mockIndexedDBStoreTransaction", ";", "}" ]
for clear, the listeners are attached to a request returned from the store.
[ "for", "clear", "the", "listeners", "are", "attached", "to", "a", "request", "returned", "from", "the", "store", "." ]
ad62dfa699d0fd6933f1d4d897f4c099c56d734d
https://github.com/bevacqua/indexeddb-mock/blob/ad62dfa699d0fd6933f1d4d897f4c099c56d734d/indexeddb.js#L296-L311
43,270
ForbesLindesay/redux-wait
example/middleware/api.js
getNextPageUrl
function getNextPageUrl(response) { const link = response.headers.get('link'); if (!link) { return null; } const nextLink = link.split(',').filter(s => s.indexOf('rel="next"') > -1)[0]; if (!nextLink) { return null; } return nextLink.split(';')[0].slice(1, -1); }
javascript
function getNextPageUrl(response) { const link = response.headers.get('link'); if (!link) { return null; } const nextLink = link.split(',').filter(s => s.indexOf('rel="next"') > -1)[0]; if (!nextLink) { return null; } return nextLink.split(';')[0].slice(1, -1); }
[ "function", "getNextPageUrl", "(", "response", ")", "{", "const", "link", "=", "response", ".", "headers", ".", "get", "(", "'link'", ")", ";", "if", "(", "!", "link", ")", "{", "return", "null", ";", "}", "const", "nextLink", "=", "link", ".", "split", "(", "','", ")", ".", "filter", "(", "s", "=>", "s", ".", "indexOf", "(", "'rel=\"next\"'", ")", ">", "-", "1", ")", "[", "0", "]", ";", "if", "(", "!", "nextLink", ")", "{", "return", "null", ";", "}", "return", "nextLink", ".", "split", "(", "';'", ")", "[", "0", "]", ".", "slice", "(", "1", ",", "-", "1", ")", ";", "}" ]
Extracts the next page URL from Github API response.
[ "Extracts", "the", "next", "page", "URL", "from", "Github", "API", "response", "." ]
94a6f3c5900604a3e241b7e76338f1af584647bb
https://github.com/ForbesLindesay/redux-wait/blob/94a6f3c5900604a3e241b7e76338f1af584647bb/example/middleware/api.js#L10-L22
43,271
hhromic/e131-node
lib/e131/packet.js
Packet
function Packet(arg) { if (this instanceof Packet === false) { return new Packet(arg); } if (arg === undefined) { throw new TypeError('arg should be a Buffer object or a number of slots'); } if (Buffer.isBuffer(arg)) { // initialize from a buffer if (arg.length < 126) { throw new RangeError('buffer size should be of at least 126 bytes'); } this._buffer = arg; } else if (Number.isInteger(arg)) { // initialize using number of slots if (arg < 1 || arg > 512) { throw new RangeError("number of slots should be in the range [1-512]"); } this._buffer = Buffer.alloc(126 + arg); } this._rootLayer = new RootLayer(this._buffer.slice(0, 38)); this._frameLayer = new FrameLayer(this._buffer.slice(38, 115)); this._dmpLayer = new DMPLayer(this._buffer.slice(115)); if (Number.isInteger(arg)) { this.init(arg); } }
javascript
function Packet(arg) { if (this instanceof Packet === false) { return new Packet(arg); } if (arg === undefined) { throw new TypeError('arg should be a Buffer object or a number of slots'); } if (Buffer.isBuffer(arg)) { // initialize from a buffer if (arg.length < 126) { throw new RangeError('buffer size should be of at least 126 bytes'); } this._buffer = arg; } else if (Number.isInteger(arg)) { // initialize using number of slots if (arg < 1 || arg > 512) { throw new RangeError("number of slots should be in the range [1-512]"); } this._buffer = Buffer.alloc(126 + arg); } this._rootLayer = new RootLayer(this._buffer.slice(0, 38)); this._frameLayer = new FrameLayer(this._buffer.slice(38, 115)); this._dmpLayer = new DMPLayer(this._buffer.slice(115)); if (Number.isInteger(arg)) { this.init(arg); } }
[ "function", "Packet", "(", "arg", ")", "{", "if", "(", "this", "instanceof", "Packet", "===", "false", ")", "{", "return", "new", "Packet", "(", "arg", ")", ";", "}", "if", "(", "arg", "===", "undefined", ")", "{", "throw", "new", "TypeError", "(", "'arg should be a Buffer object or a number of slots'", ")", ";", "}", "if", "(", "Buffer", ".", "isBuffer", "(", "arg", ")", ")", "{", "// initialize from a buffer", "if", "(", "arg", ".", "length", "<", "126", ")", "{", "throw", "new", "RangeError", "(", "'buffer size should be of at least 126 bytes'", ")", ";", "}", "this", ".", "_buffer", "=", "arg", ";", "}", "else", "if", "(", "Number", ".", "isInteger", "(", "arg", ")", ")", "{", "// initialize using number of slots", "if", "(", "arg", "<", "1", "||", "arg", ">", "512", ")", "{", "throw", "new", "RangeError", "(", "\"number of slots should be in the range [1-512]\"", ")", ";", "}", "this", ".", "_buffer", "=", "Buffer", ".", "alloc", "(", "126", "+", "arg", ")", ";", "}", "this", ".", "_rootLayer", "=", "new", "RootLayer", "(", "this", ".", "_buffer", ".", "slice", "(", "0", ",", "38", ")", ")", ";", "this", ".", "_frameLayer", "=", "new", "FrameLayer", "(", "this", ".", "_buffer", ".", "slice", "(", "38", ",", "115", ")", ")", ";", "this", ".", "_dmpLayer", "=", "new", "DMPLayer", "(", "this", ".", "_buffer", ".", "slice", "(", "115", ")", ")", ";", "if", "(", "Number", ".", "isInteger", "(", "arg", ")", ")", "{", "this", ".", "init", "(", "arg", ")", ";", "}", "}" ]
packet object constructor
[ "packet", "object", "constructor" ]
3a33b9219d917f46c52d1cb02bf36447f5fa6172
https://github.com/hhromic/e131-node/blob/3a33b9219d917f46c52d1cb02bf36447f5fa6172/lib/e131/packet.js#L28-L57
43,272
popomore/social-share
share.js
getData
function getData(obj) { var data = {}; each(supportParam, function(i, o) { var a = obj.getAttribute('data-' + o); if (a) data[o] = a; }); return data; }
javascript
function getData(obj) { var data = {}; each(supportParam, function(i, o) { var a = obj.getAttribute('data-' + o); if (a) data[o] = a; }); return data; }
[ "function", "getData", "(", "obj", ")", "{", "var", "data", "=", "{", "}", ";", "each", "(", "supportParam", ",", "function", "(", "i", ",", "o", ")", "{", "var", "a", "=", "obj", ".", "getAttribute", "(", "'data-'", "+", "o", ")", ";", "if", "(", "a", ")", "data", "[", "o", "]", "=", "a", ";", "}", ")", ";", "return", "data", ";", "}" ]
Get DATA-API
[ "Get", "DATA", "-", "API" ]
515fea3cce780ff78f8e9d052908d4705e0172fd
https://github.com/popomore/social-share/blob/515fea3cce780ff78f8e9d052908d4705e0172fd/share.js#L54-L61
43,273
hhromic/e131-node
lib/server.js
Server
function Server(universes, port) { if (this instanceof Server === false) { return new Server(port); } EventEmitter.call(this); if (universes !== undefined && !Array.isArray(universes)) { universes = [universes]; } this.universes = universes || [0x01]; this.port = port || e131.DEFAULT_PORT; this._socket = dgram.createSocket('udp4'); this._lastSequenceNumber = {}; var self = this; this.universes.forEach(function (universe) { self._lastSequenceNumber[universe] = 0; }); this._socket.on('error', function onError(err) { self.emit('error', err); }); this._socket.on('listening', function onListening() { self.emit('listening'); }); this._socket.on('close', function onClose() { self.emit('close'); }); this._socket.on('message', function onMessage(msg) { var packet = new e131.Packet(msg); var validation = packet.validate(); if (validation !== packet.ERR_NONE) { self.emit('packet-error', packet, validation); return; } if (packet.discard(self._lastSequenceNumber[packet.getUniverse()])) { self.emit('packet-out-of-order', packet); } else { self.emit('packet', packet); } self._lastSequenceNumber[packet.getUniverse()] = packet.getSequenceNumber(); }); this._socket.bind(this.port, function onListening() { self.universes.forEach(function (universe) { var multicastGroup = e131.getMulticastGroup(universe); self._socket.addMembership(multicastGroup); }); }); }
javascript
function Server(universes, port) { if (this instanceof Server === false) { return new Server(port); } EventEmitter.call(this); if (universes !== undefined && !Array.isArray(universes)) { universes = [universes]; } this.universes = universes || [0x01]; this.port = port || e131.DEFAULT_PORT; this._socket = dgram.createSocket('udp4'); this._lastSequenceNumber = {}; var self = this; this.universes.forEach(function (universe) { self._lastSequenceNumber[universe] = 0; }); this._socket.on('error', function onError(err) { self.emit('error', err); }); this._socket.on('listening', function onListening() { self.emit('listening'); }); this._socket.on('close', function onClose() { self.emit('close'); }); this._socket.on('message', function onMessage(msg) { var packet = new e131.Packet(msg); var validation = packet.validate(); if (validation !== packet.ERR_NONE) { self.emit('packet-error', packet, validation); return; } if (packet.discard(self._lastSequenceNumber[packet.getUniverse()])) { self.emit('packet-out-of-order', packet); } else { self.emit('packet', packet); } self._lastSequenceNumber[packet.getUniverse()] = packet.getSequenceNumber(); }); this._socket.bind(this.port, function onListening() { self.universes.forEach(function (universe) { var multicastGroup = e131.getMulticastGroup(universe); self._socket.addMembership(multicastGroup); }); }); }
[ "function", "Server", "(", "universes", ",", "port", ")", "{", "if", "(", "this", "instanceof", "Server", "===", "false", ")", "{", "return", "new", "Server", "(", "port", ")", ";", "}", "EventEmitter", ".", "call", "(", "this", ")", ";", "if", "(", "universes", "!==", "undefined", "&&", "!", "Array", ".", "isArray", "(", "universes", ")", ")", "{", "universes", "=", "[", "universes", "]", ";", "}", "this", ".", "universes", "=", "universes", "||", "[", "0x01", "]", ";", "this", ".", "port", "=", "port", "||", "e131", ".", "DEFAULT_PORT", ";", "this", ".", "_socket", "=", "dgram", ".", "createSocket", "(", "'udp4'", ")", ";", "this", ".", "_lastSequenceNumber", "=", "{", "}", ";", "var", "self", "=", "this", ";", "this", ".", "universes", ".", "forEach", "(", "function", "(", "universe", ")", "{", "self", ".", "_lastSequenceNumber", "[", "universe", "]", "=", "0", ";", "}", ")", ";", "this", ".", "_socket", ".", "on", "(", "'error'", ",", "function", "onError", "(", "err", ")", "{", "self", ".", "emit", "(", "'error'", ",", "err", ")", ";", "}", ")", ";", "this", ".", "_socket", ".", "on", "(", "'listening'", ",", "function", "onListening", "(", ")", "{", "self", ".", "emit", "(", "'listening'", ")", ";", "}", ")", ";", "this", ".", "_socket", ".", "on", "(", "'close'", ",", "function", "onClose", "(", ")", "{", "self", ".", "emit", "(", "'close'", ")", ";", "}", ")", ";", "this", ".", "_socket", ".", "on", "(", "'message'", ",", "function", "onMessage", "(", "msg", ")", "{", "var", "packet", "=", "new", "e131", ".", "Packet", "(", "msg", ")", ";", "var", "validation", "=", "packet", ".", "validate", "(", ")", ";", "if", "(", "validation", "!==", "packet", ".", "ERR_NONE", ")", "{", "self", ".", "emit", "(", "'packet-error'", ",", "packet", ",", "validation", ")", ";", "return", ";", "}", "if", "(", "packet", ".", "discard", "(", "self", ".", "_lastSequenceNumber", "[", "packet", ".", "getUniverse", "(", ")", "]", ")", ")", "{", "self", ".", "emit", "(", "'packet-out-of-order'", ",", "packet", ")", ";", "}", "else", "{", "self", ".", "emit", "(", "'packet'", ",", "packet", ")", ";", "}", "self", ".", "_lastSequenceNumber", "[", "packet", ".", "getUniverse", "(", ")", "]", "=", "packet", ".", "getSequenceNumber", "(", ")", ";", "}", ")", ";", "this", ".", "_socket", ".", "bind", "(", "this", ".", "port", ",", "function", "onListening", "(", ")", "{", "self", ".", "universes", ".", "forEach", "(", "function", "(", "universe", ")", "{", "var", "multicastGroup", "=", "e131", ".", "getMulticastGroup", "(", "universe", ")", ";", "self", ".", "_socket", ".", "addMembership", "(", "multicastGroup", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
E1.31 server object constructor
[ "E1", ".", "31", "server", "object", "constructor" ]
3a33b9219d917f46c52d1cb02bf36447f5fa6172
https://github.com/hhromic/e131-node/blob/3a33b9219d917f46c52d1cb02bf36447f5fa6172/lib/server.js#L29-L76
43,274
TooTallNate/array-index
index.js
ArrayIndex
function ArrayIndex (_length) { Object.defineProperty(this, 'length', { get: getLength, set: setLength, enumerable: false, configurable: true }); this[length] = 0; if (arguments.length > 0) { setLength.call(this, _length); } }
javascript
function ArrayIndex (_length) { Object.defineProperty(this, 'length', { get: getLength, set: setLength, enumerable: false, configurable: true }); this[length] = 0; if (arguments.length > 0) { setLength.call(this, _length); } }
[ "function", "ArrayIndex", "(", "_length", ")", "{", "Object", ".", "defineProperty", "(", "this", ",", "'length'", ",", "{", "get", ":", "getLength", ",", "set", ":", "setLength", ",", "enumerable", ":", "false", ",", "configurable", ":", "true", "}", ")", ";", "this", "[", "length", "]", "=", "0", ";", "if", "(", "arguments", ".", "length", ">", "0", ")", "{", "setLength", ".", "call", "(", "this", ",", "_length", ")", ";", "}", "}" ]
Subclass this.
[ "Subclass", "this", "." ]
4b3cc059c70eefd8ef2a0d4213d681b671eb3d11
https://github.com/TooTallNate/array-index/blob/4b3cc059c70eefd8ef2a0d4213d681b671eb3d11/index.js#L32-L45
43,275
TooTallNate/array-index
index.js
setup
function setup (index) { function get () { return this[ArrayIndex.get](index); } function set (v) { return this[ArrayIndex.set](index, v); } return { enumerable: true, configurable: true, get: get, set: set }; }
javascript
function setup (index) { function get () { return this[ArrayIndex.get](index); } function set (v) { return this[ArrayIndex.set](index, v); } return { enumerable: true, configurable: true, get: get, set: set }; }
[ "function", "setup", "(", "index", ")", "{", "function", "get", "(", ")", "{", "return", "this", "[", "ArrayIndex", ".", "get", "]", "(", "index", ")", ";", "}", "function", "set", "(", "v", ")", "{", "return", "this", "[", "ArrayIndex", ".", "set", "]", "(", "index", ",", "v", ")", ";", "}", "return", "{", "enumerable", ":", "true", ",", "configurable", ":", "true", ",", "get", ":", "get", ",", "set", ":", "set", "}", ";", "}" ]
Returns a property descriptor for the given "index", with "get" and "set" functions created within the closure. @api private
[ "Returns", "a", "property", "descriptor", "for", "the", "given", "index", "with", "get", "and", "set", "functions", "created", "within", "the", "closure", "." ]
4b3cc059c70eefd8ef2a0d4213d681b671eb3d11
https://github.com/TooTallNate/array-index/blob/4b3cc059c70eefd8ef2a0d4213d681b671eb3d11/index.js#L169-L182
43,276
azu/searchive
packages/searchive-app/static/pdfjs/web/l10n.js
loadLocale
function loadLocale(lang, callback) { // RFC 4646, section 2.1 states that language tags have to be treated as // case-insensitive. Convert to lowercase for case-insensitive comparisons. if (lang) { lang = lang.toLowerCase(); } callback = callback || function _callback() {}; clear(); gLanguage = lang; // check all <link type="application/l10n" href="..." /> nodes // and load the resource files var langLinks = getL10nResourceLinks(); var langCount = langLinks.length; if (langCount === 0) { // we might have a pre-compiled dictionary instead var dict = getL10nDictionary(); if (dict && dict.locales && dict.default_locale) { console.log("using the embedded JSON directory, early way out"); gL10nData = dict.locales[lang]; if (!gL10nData) { var defaultLocale = dict.default_locale.toLowerCase(); for (var anyCaseLang in dict.locales) { anyCaseLang = anyCaseLang.toLowerCase(); if (anyCaseLang === lang) { gL10nData = dict.locales[lang]; break; } else if (anyCaseLang === defaultLocale) { gL10nData = dict.locales[defaultLocale]; } } } callback(); } else { console.log("no resource to load, early way out"); } // early way out fireL10nReadyEvent(lang); gReadyState = "complete"; return; } // start the callback when all resources are loaded var onResourceLoaded = null; var gResourceCount = 0; onResourceLoaded = function() { gResourceCount++; if (gResourceCount >= langCount) { callback(); fireL10nReadyEvent(lang); gReadyState = "complete"; } }; // load all resource files function L10nResourceLink(link) { var href = link.href; // Note: If |gAsyncResourceLoading| is false, then the following callbacks // are synchronously called. this.load = function(lang, callback) { parseResource(href, lang, callback, function() { console.warn(href + " not found."); // lang not found, used default resource instead console.warn('"' + lang + '" resource not found'); gLanguage = ""; // Resource not loaded, but we still need to call the callback. callback(); }); }; } for (var i = 0; i < langCount; i++) { var resource = new L10nResourceLink(langLinks[i]); resource.load(lang, onResourceLoaded); } }
javascript
function loadLocale(lang, callback) { // RFC 4646, section 2.1 states that language tags have to be treated as // case-insensitive. Convert to lowercase for case-insensitive comparisons. if (lang) { lang = lang.toLowerCase(); } callback = callback || function _callback() {}; clear(); gLanguage = lang; // check all <link type="application/l10n" href="..." /> nodes // and load the resource files var langLinks = getL10nResourceLinks(); var langCount = langLinks.length; if (langCount === 0) { // we might have a pre-compiled dictionary instead var dict = getL10nDictionary(); if (dict && dict.locales && dict.default_locale) { console.log("using the embedded JSON directory, early way out"); gL10nData = dict.locales[lang]; if (!gL10nData) { var defaultLocale = dict.default_locale.toLowerCase(); for (var anyCaseLang in dict.locales) { anyCaseLang = anyCaseLang.toLowerCase(); if (anyCaseLang === lang) { gL10nData = dict.locales[lang]; break; } else if (anyCaseLang === defaultLocale) { gL10nData = dict.locales[defaultLocale]; } } } callback(); } else { console.log("no resource to load, early way out"); } // early way out fireL10nReadyEvent(lang); gReadyState = "complete"; return; } // start the callback when all resources are loaded var onResourceLoaded = null; var gResourceCount = 0; onResourceLoaded = function() { gResourceCount++; if (gResourceCount >= langCount) { callback(); fireL10nReadyEvent(lang); gReadyState = "complete"; } }; // load all resource files function L10nResourceLink(link) { var href = link.href; // Note: If |gAsyncResourceLoading| is false, then the following callbacks // are synchronously called. this.load = function(lang, callback) { parseResource(href, lang, callback, function() { console.warn(href + " not found."); // lang not found, used default resource instead console.warn('"' + lang + '" resource not found'); gLanguage = ""; // Resource not loaded, but we still need to call the callback. callback(); }); }; } for (var i = 0; i < langCount; i++) { var resource = new L10nResourceLink(langLinks[i]); resource.load(lang, onResourceLoaded); } }
[ "function", "loadLocale", "(", "lang", ",", "callback", ")", "{", "// RFC 4646, section 2.1 states that language tags have to be treated as", "// case-insensitive. Convert to lowercase for case-insensitive comparisons.", "if", "(", "lang", ")", "{", "lang", "=", "lang", ".", "toLowerCase", "(", ")", ";", "}", "callback", "=", "callback", "||", "function", "_callback", "(", ")", "{", "}", ";", "clear", "(", ")", ";", "gLanguage", "=", "lang", ";", "// check all <link type=\"application/l10n\" href=\"...\" /> nodes", "// and load the resource files", "var", "langLinks", "=", "getL10nResourceLinks", "(", ")", ";", "var", "langCount", "=", "langLinks", ".", "length", ";", "if", "(", "langCount", "===", "0", ")", "{", "// we might have a pre-compiled dictionary instead", "var", "dict", "=", "getL10nDictionary", "(", ")", ";", "if", "(", "dict", "&&", "dict", ".", "locales", "&&", "dict", ".", "default_locale", ")", "{", "console", ".", "log", "(", "\"using the embedded JSON directory, early way out\"", ")", ";", "gL10nData", "=", "dict", ".", "locales", "[", "lang", "]", ";", "if", "(", "!", "gL10nData", ")", "{", "var", "defaultLocale", "=", "dict", ".", "default_locale", ".", "toLowerCase", "(", ")", ";", "for", "(", "var", "anyCaseLang", "in", "dict", ".", "locales", ")", "{", "anyCaseLang", "=", "anyCaseLang", ".", "toLowerCase", "(", ")", ";", "if", "(", "anyCaseLang", "===", "lang", ")", "{", "gL10nData", "=", "dict", ".", "locales", "[", "lang", "]", ";", "break", ";", "}", "else", "if", "(", "anyCaseLang", "===", "defaultLocale", ")", "{", "gL10nData", "=", "dict", ".", "locales", "[", "defaultLocale", "]", ";", "}", "}", "}", "callback", "(", ")", ";", "}", "else", "{", "console", ".", "log", "(", "\"no resource to load, early way out\"", ")", ";", "}", "// early way out", "fireL10nReadyEvent", "(", "lang", ")", ";", "gReadyState", "=", "\"complete\"", ";", "return", ";", "}", "// start the callback when all resources are loaded", "var", "onResourceLoaded", "=", "null", ";", "var", "gResourceCount", "=", "0", ";", "onResourceLoaded", "=", "function", "(", ")", "{", "gResourceCount", "++", ";", "if", "(", "gResourceCount", ">=", "langCount", ")", "{", "callback", "(", ")", ";", "fireL10nReadyEvent", "(", "lang", ")", ";", "gReadyState", "=", "\"complete\"", ";", "}", "}", ";", "// load all resource files", "function", "L10nResourceLink", "(", "link", ")", "{", "var", "href", "=", "link", ".", "href", ";", "// Note: If |gAsyncResourceLoading| is false, then the following callbacks", "// are synchronously called.", "this", ".", "load", "=", "function", "(", "lang", ",", "callback", ")", "{", "parseResource", "(", "href", ",", "lang", ",", "callback", ",", "function", "(", ")", "{", "console", ".", "warn", "(", "href", "+", "\" not found.\"", ")", ";", "// lang not found, used default resource instead", "console", ".", "warn", "(", "'\"'", "+", "lang", "+", "'\" resource not found'", ")", ";", "gLanguage", "=", "\"\"", ";", "// Resource not loaded, but we still need to call the callback.", "callback", "(", ")", ";", "}", ")", ";", "}", ";", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "langCount", ";", "i", "++", ")", "{", "var", "resource", "=", "new", "L10nResourceLink", "(", "langLinks", "[", "i", "]", ")", ";", "resource", ".", "load", "(", "lang", ",", "onResourceLoaded", ")", ";", "}", "}" ]
load and parse all resources for the specified locale
[ "load", "and", "parse", "all", "resources", "for", "the", "specified", "locale" ]
f541f962ba0ce621455285e6b46d0eb1031e61f8
https://github.com/azu/searchive/blob/f541f962ba0ce621455285e6b46d0eb1031e61f8/packages/searchive-app/static/pdfjs/web/l10n.js#L297-L374
43,277
azu/searchive
packages/searchive-app/static/pdfjs/web/l10n.js
L10nResourceLink
function L10nResourceLink(link) { var href = link.href; // Note: If |gAsyncResourceLoading| is false, then the following callbacks // are synchronously called. this.load = function(lang, callback) { parseResource(href, lang, callback, function() { console.warn(href + " not found."); // lang not found, used default resource instead console.warn('"' + lang + '" resource not found'); gLanguage = ""; // Resource not loaded, but we still need to call the callback. callback(); }); }; }
javascript
function L10nResourceLink(link) { var href = link.href; // Note: If |gAsyncResourceLoading| is false, then the following callbacks // are synchronously called. this.load = function(lang, callback) { parseResource(href, lang, callback, function() { console.warn(href + " not found."); // lang not found, used default resource instead console.warn('"' + lang + '" resource not found'); gLanguage = ""; // Resource not loaded, but we still need to call the callback. callback(); }); }; }
[ "function", "L10nResourceLink", "(", "link", ")", "{", "var", "href", "=", "link", ".", "href", ";", "// Note: If |gAsyncResourceLoading| is false, then the following callbacks", "// are synchronously called.", "this", ".", "load", "=", "function", "(", "lang", ",", "callback", ")", "{", "parseResource", "(", "href", ",", "lang", ",", "callback", ",", "function", "(", ")", "{", "console", ".", "warn", "(", "href", "+", "\" not found.\"", ")", ";", "// lang not found, used default resource instead", "console", ".", "warn", "(", "'\"'", "+", "lang", "+", "'\" resource not found'", ")", ";", "gLanguage", "=", "\"\"", ";", "// Resource not loaded, but we still need to call the callback.", "callback", "(", ")", ";", "}", ")", ";", "}", ";", "}" ]
load all resource files
[ "load", "all", "resource", "files" ]
f541f962ba0ce621455285e6b46d0eb1031e61f8
https://github.com/azu/searchive/blob/f541f962ba0ce621455285e6b46d0eb1031e61f8/packages/searchive-app/static/pdfjs/web/l10n.js#L354-L368
43,278
azu/searchive
packages/searchive-app/static/pdfjs/web/l10n.js
getL10nData
function getL10nData(key, args, fallback) { var data = gL10nData[key]; if (!data) { console.warn("#" + key + " is undefined."); if (!fallback) { return null; } data = fallback; } /** This is where l10n expressions should be processed. * The plan is to support C-style expressions from the l20n project; * until then, only two kinds of simple expressions are supported: * {[ index ]} and {{ arguments }}. */ var rv = {}; for (var prop in data) { var str = data[prop]; str = substIndexes(str, args, key, prop); str = substArguments(str, args, key); rv[prop] = str; } return rv; }
javascript
function getL10nData(key, args, fallback) { var data = gL10nData[key]; if (!data) { console.warn("#" + key + " is undefined."); if (!fallback) { return null; } data = fallback; } /** This is where l10n expressions should be processed. * The plan is to support C-style expressions from the l20n project; * until then, only two kinds of simple expressions are supported: * {[ index ]} and {{ arguments }}. */ var rv = {}; for (var prop in data) { var str = data[prop]; str = substIndexes(str, args, key, prop); str = substArguments(str, args, key); rv[prop] = str; } return rv; }
[ "function", "getL10nData", "(", "key", ",", "args", ",", "fallback", ")", "{", "var", "data", "=", "gL10nData", "[", "key", "]", ";", "if", "(", "!", "data", ")", "{", "console", ".", "warn", "(", "\"#\"", "+", "key", "+", "\" is undefined.\"", ")", ";", "if", "(", "!", "fallback", ")", "{", "return", "null", ";", "}", "data", "=", "fallback", ";", "}", "/** This is where l10n expressions should be processed.\n * The plan is to support C-style expressions from the l20n project;\n * until then, only two kinds of simple expressions are supported:\n * {[ index ]} and {{ arguments }}.\n */", "var", "rv", "=", "{", "}", ";", "for", "(", "var", "prop", "in", "data", ")", "{", "var", "str", "=", "data", "[", "prop", "]", ";", "str", "=", "substIndexes", "(", "str", ",", "args", ",", "key", ",", "prop", ")", ";", "str", "=", "substArguments", "(", "str", ",", "args", ",", "key", ")", ";", "rv", "[", "prop", "]", "=", "str", ";", "}", "return", "rv", ";", "}" ]
l10n dictionary functions fetch an l10n object, warn if not found, apply `args' if possible
[ "l10n", "dictionary", "functions", "fetch", "an", "l10n", "object", "warn", "if", "not", "found", "apply", "args", "if", "possible" ]
f541f962ba0ce621455285e6b46d0eb1031e61f8
https://github.com/azu/searchive/blob/f541f962ba0ce621455285e6b46d0eb1031e61f8/packages/searchive-app/static/pdfjs/web/l10n.js#L772-L795
43,279
azu/searchive
packages/searchive-app/static/pdfjs/web/l10n.js
function(key, args, fallbackString) { var index = key.lastIndexOf("."); var prop = gTextProp; if (index > 0) { // An attribute has been specified prop = key.substr(index + 1); key = key.substring(0, index); } var fallback; if (fallbackString) { fallback = {}; fallback[prop] = fallbackString; } var data = getL10nData(key, args, fallback); if (data && prop in data) { return data[prop]; } return "{{" + key + "}}"; }
javascript
function(key, args, fallbackString) { var index = key.lastIndexOf("."); var prop = gTextProp; if (index > 0) { // An attribute has been specified prop = key.substr(index + 1); key = key.substring(0, index); } var fallback; if (fallbackString) { fallback = {}; fallback[prop] = fallbackString; } var data = getL10nData(key, args, fallback); if (data && prop in data) { return data[prop]; } return "{{" + key + "}}"; }
[ "function", "(", "key", ",", "args", ",", "fallbackString", ")", "{", "var", "index", "=", "key", ".", "lastIndexOf", "(", "\".\"", ")", ";", "var", "prop", "=", "gTextProp", ";", "if", "(", "index", ">", "0", ")", "{", "// An attribute has been specified", "prop", "=", "key", ".", "substr", "(", "index", "+", "1", ")", ";", "key", "=", "key", ".", "substring", "(", "0", ",", "index", ")", ";", "}", "var", "fallback", ";", "if", "(", "fallbackString", ")", "{", "fallback", "=", "{", "}", ";", "fallback", "[", "prop", "]", "=", "fallbackString", ";", "}", "var", "data", "=", "getL10nData", "(", "key", ",", "args", ",", "fallback", ")", ";", "if", "(", "data", "&&", "prop", "in", "data", ")", "{", "return", "data", "[", "prop", "]", ";", "}", "return", "\"{{\"", "+", "key", "+", "\"}}\"", ";", "}" ]
get a localized string
[ "get", "a", "localized", "string" ]
f541f962ba0ce621455285e6b46d0eb1031e61f8
https://github.com/azu/searchive/blob/f541f962ba0ce621455285e6b46d0eb1031e61f8/packages/searchive-app/static/pdfjs/web/l10n.js#L916-L934
43,280
sokeroner/Delaunay-Triangulation
src/geom/Triangle.js
Triangle
function Triangle ( point1, point2, point3 ) { /** * @member {Point} * @default {x:0,y:0} */ this.p1 = point1 || new Point(0,0); /** * @member {Point} * @default {x:0,y:0} */ this.p2 = point2 || new Point(0,0); /** * @member {Point} * @default {x:0,y:0} */ this.p3 = point3 || new Point(0,0); /** * @member {Point} */ this.mid0 = new Point ( this.p1.x + ( this.p2.x - this.p1.x )/2, this.p1.y + ( this.p2.y - this.p1.y )/2 ); /** * @member {Point} */ this.mid1 = new Point ( this.p2.x + ( this.p3.x - this.p2.x )/2, this.p2.y + ( this.p3.y - this.p2.y )/2 ); /** * @member {Point} */ this.mid2 = new Point ( this.p3.x + ( this.p1.x - this.p3.x )/2, this.p3.y + ( this.p1.y - this.p3.y )/2 ); }
javascript
function Triangle ( point1, point2, point3 ) { /** * @member {Point} * @default {x:0,y:0} */ this.p1 = point1 || new Point(0,0); /** * @member {Point} * @default {x:0,y:0} */ this.p2 = point2 || new Point(0,0); /** * @member {Point} * @default {x:0,y:0} */ this.p3 = point3 || new Point(0,0); /** * @member {Point} */ this.mid0 = new Point ( this.p1.x + ( this.p2.x - this.p1.x )/2, this.p1.y + ( this.p2.y - this.p1.y )/2 ); /** * @member {Point} */ this.mid1 = new Point ( this.p2.x + ( this.p3.x - this.p2.x )/2, this.p2.y + ( this.p3.y - this.p2.y )/2 ); /** * @member {Point} */ this.mid2 = new Point ( this.p3.x + ( this.p1.x - this.p3.x )/2, this.p3.y + ( this.p1.y - this.p3.y )/2 ); }
[ "function", "Triangle", "(", "point1", ",", "point2", ",", "point3", ")", "{", "/**\n * @member {Point}\n * @default {x:0,y:0}\n */", "this", ".", "p1", "=", "point1", "||", "new", "Point", "(", "0", ",", "0", ")", ";", "/**\n * @member {Point}\n * @default {x:0,y:0}\n */", "this", ".", "p2", "=", "point2", "||", "new", "Point", "(", "0", ",", "0", ")", ";", "/**\n * @member {Point}\n * @default {x:0,y:0}\n */", "this", ".", "p3", "=", "point3", "||", "new", "Point", "(", "0", ",", "0", ")", ";", "/**\n * @member {Point}\n */", "this", ".", "mid0", "=", "new", "Point", "(", "this", ".", "p1", ".", "x", "+", "(", "this", ".", "p2", ".", "x", "-", "this", ".", "p1", ".", "x", ")", "/", "2", ",", "this", ".", "p1", ".", "y", "+", "(", "this", ".", "p2", ".", "y", "-", "this", ".", "p1", ".", "y", ")", "/", "2", ")", ";", "/**\n * @member {Point}\n */", "this", ".", "mid1", "=", "new", "Point", "(", "this", ".", "p2", ".", "x", "+", "(", "this", ".", "p3", ".", "x", "-", "this", ".", "p2", ".", "x", ")", "/", "2", ",", "this", ".", "p2", ".", "y", "+", "(", "this", ".", "p3", ".", "y", "-", "this", ".", "p2", ".", "y", ")", "/", "2", ")", ";", "/**\n * @member {Point}\n */", "this", ".", "mid2", "=", "new", "Point", "(", "this", ".", "p3", ".", "x", "+", "(", "this", ".", "p1", ".", "x", "-", "this", ".", "p3", ".", "x", ")", "/", "2", ",", "this", ".", "p3", ".", "y", "+", "(", "this", ".", "p1", ".", "y", "-", "this", ".", "p3", ".", "y", ")", "/", "2", ")", ";", "}" ]
The Triangle object represents a set of three points. @class @param [point1={x:0,y:0}] {Point} one of the three points @param [point2={x:0,y:0}] {Point} one of the three points @param [point3={x:0,y:0}] {Point} one of the three points
[ "The", "Triangle", "object", "represents", "a", "set", "of", "three", "points", "." ]
b5bbbe66964ed7fcf72a7a6d26d88a41d68309ae
https://github.com/sokeroner/Delaunay-Triangulation/blob/b5bbbe66964ed7fcf72a7a6d26d88a41d68309ae/src/geom/Triangle.js#L13-L54
43,281
sean-perkins/ngx-select
examples/webpack/dist/app.e100c23eefa4ef71b346.js
_buildFromEncodedParts
function _buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) { var /** @type {?} */ out = []; if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_scheme)) { out.push(opt_scheme + ':'); } if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_domain)) { out.push('//'); if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_userInfo)) { out.push(opt_userInfo + '@'); } out.push(opt_domain); if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_port)) { out.push(':' + opt_port); } } if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_path)) { out.push(opt_path); } if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_queryData)) { out.push('?' + opt_queryData); } if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_fragment)) { out.push('#' + opt_fragment); } return out.join(''); }
javascript
function _buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) { var /** @type {?} */ out = []; if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_scheme)) { out.push(opt_scheme + ':'); } if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_domain)) { out.push('//'); if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_userInfo)) { out.push(opt_userInfo + '@'); } out.push(opt_domain); if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_port)) { out.push(':' + opt_port); } } if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_path)) { out.push(opt_path); } if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_queryData)) { out.push('?' + opt_queryData); } if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(opt_fragment)) { out.push('#' + opt_fragment); } return out.join(''); }
[ "function", "_buildFromEncodedParts", "(", "opt_scheme", ",", "opt_userInfo", ",", "opt_domain", ",", "opt_port", ",", "opt_path", ",", "opt_queryData", ",", "opt_fragment", ")", "{", "var", "/** @type {?} */", "out", "=", "[", "]", ";", "if", "(", "__webpack_require__", ".", "i", "(", "__WEBPACK_IMPORTED_MODULE_1__facade_lang__", "[", "\"c\"", "/* isPresent */", "]", ")", "(", "opt_scheme", ")", ")", "{", "out", ".", "push", "(", "opt_scheme", "+", "':'", ")", ";", "}", "if", "(", "__webpack_require__", ".", "i", "(", "__WEBPACK_IMPORTED_MODULE_1__facade_lang__", "[", "\"c\"", "/* isPresent */", "]", ")", "(", "opt_domain", ")", ")", "{", "out", ".", "push", "(", "'//'", ")", ";", "if", "(", "__webpack_require__", ".", "i", "(", "__WEBPACK_IMPORTED_MODULE_1__facade_lang__", "[", "\"c\"", "/* isPresent */", "]", ")", "(", "opt_userInfo", ")", ")", "{", "out", ".", "push", "(", "opt_userInfo", "+", "'@'", ")", ";", "}", "out", ".", "push", "(", "opt_domain", ")", ";", "if", "(", "__webpack_require__", ".", "i", "(", "__WEBPACK_IMPORTED_MODULE_1__facade_lang__", "[", "\"c\"", "/* isPresent */", "]", ")", "(", "opt_port", ")", ")", "{", "out", ".", "push", "(", "':'", "+", "opt_port", ")", ";", "}", "}", "if", "(", "__webpack_require__", ".", "i", "(", "__WEBPACK_IMPORTED_MODULE_1__facade_lang__", "[", "\"c\"", "/* isPresent */", "]", ")", "(", "opt_path", ")", ")", "{", "out", ".", "push", "(", "opt_path", ")", ";", "}", "if", "(", "__webpack_require__", ".", "i", "(", "__WEBPACK_IMPORTED_MODULE_1__facade_lang__", "[", "\"c\"", "/* isPresent */", "]", ")", "(", "opt_queryData", ")", ")", "{", "out", ".", "push", "(", "'?'", "+", "opt_queryData", ")", ";", "}", "if", "(", "__webpack_require__", ".", "i", "(", "__WEBPACK_IMPORTED_MODULE_1__facade_lang__", "[", "\"c\"", "/* isPresent */", "]", ")", "(", "opt_fragment", ")", ")", "{", "out", ".", "push", "(", "'#'", "+", "opt_fragment", ")", ";", "}", "return", "out", ".", "join", "(", "''", ")", ";", "}" ]
Builds a URI string from already-encoded parts. No encoding is performed. Any component may be omitted as either null or undefined. @param {?=} opt_scheme The scheme such as 'http'. @param {?=} opt_userInfo The user name before the '\@'. @param {?=} opt_domain The domain such as 'www.google.com', already URI-encoded. @param {?=} opt_port The port number. @param {?=} opt_path The path, already URI-encoded. If it is not empty, it must begin with a slash. @param {?=} opt_queryData The URI-encoded query data. @param {?=} opt_fragment The URI-encoded fragment identifier. @return {?} The fully combined URI.
[ "Builds", "a", "URI", "string", "from", "already", "-", "encoded", "parts", "." ]
27eb48f8e49cdaeb4e79937e58e7b16e43e7e390
https://github.com/sean-perkins/ngx-select/blob/27eb48f8e49cdaeb4e79937e58e7b16e43e7e390/examples/webpack/dist/app.e100c23eefa4ef71b346.js#L10605-L10630
43,282
sean-perkins/ngx-select
examples/webpack/dist/app.e100c23eefa4ef71b346.js
_resolveUrl
function _resolveUrl(base, url) { var /** @type {?} */ parts = _split(encodeURI(url)); var /** @type {?} */ baseParts = _split(base); if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(parts[_ComponentIndex.Scheme])) { return _joinAndCanonicalizePath(parts); } else { parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme]; } for (var /** @type {?} */ i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) { if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["d" /* isBlank */])(parts[i])) { parts[i] = baseParts[i]; } } if (parts[_ComponentIndex.Path][0] == '/') { return _joinAndCanonicalizePath(parts); } var /** @type {?} */ path = baseParts[_ComponentIndex.Path]; if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["d" /* isBlank */])(path)) path = '/'; var /** @type {?} */ index = path.lastIndexOf('/'); path = path.substring(0, index + 1) + parts[_ComponentIndex.Path]; parts[_ComponentIndex.Path] = path; return _joinAndCanonicalizePath(parts); }
javascript
function _resolveUrl(base, url) { var /** @type {?} */ parts = _split(encodeURI(url)); var /** @type {?} */ baseParts = _split(base); if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(parts[_ComponentIndex.Scheme])) { return _joinAndCanonicalizePath(parts); } else { parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme]; } for (var /** @type {?} */ i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) { if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["d" /* isBlank */])(parts[i])) { parts[i] = baseParts[i]; } } if (parts[_ComponentIndex.Path][0] == '/') { return _joinAndCanonicalizePath(parts); } var /** @type {?} */ path = baseParts[_ComponentIndex.Path]; if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["d" /* isBlank */])(path)) path = '/'; var /** @type {?} */ index = path.lastIndexOf('/'); path = path.substring(0, index + 1) + parts[_ComponentIndex.Path]; parts[_ComponentIndex.Path] = path; return _joinAndCanonicalizePath(parts); }
[ "function", "_resolveUrl", "(", "base", ",", "url", ")", "{", "var", "/** @type {?} */", "parts", "=", "_split", "(", "encodeURI", "(", "url", ")", ")", ";", "var", "/** @type {?} */", "baseParts", "=", "_split", "(", "base", ")", ";", "if", "(", "__webpack_require__", ".", "i", "(", "__WEBPACK_IMPORTED_MODULE_1__facade_lang__", "[", "\"c\"", "/* isPresent */", "]", ")", "(", "parts", "[", "_ComponentIndex", ".", "Scheme", "]", ")", ")", "{", "return", "_joinAndCanonicalizePath", "(", "parts", ")", ";", "}", "else", "{", "parts", "[", "_ComponentIndex", ".", "Scheme", "]", "=", "baseParts", "[", "_ComponentIndex", ".", "Scheme", "]", ";", "}", "for", "(", "var", "/** @type {?} */", "i", "=", "_ComponentIndex", ".", "Scheme", ";", "i", "<=", "_ComponentIndex", ".", "Port", ";", "i", "++", ")", "{", "if", "(", "__webpack_require__", ".", "i", "(", "__WEBPACK_IMPORTED_MODULE_1__facade_lang__", "[", "\"d\"", "/* isBlank */", "]", ")", "(", "parts", "[", "i", "]", ")", ")", "{", "parts", "[", "i", "]", "=", "baseParts", "[", "i", "]", ";", "}", "}", "if", "(", "parts", "[", "_ComponentIndex", ".", "Path", "]", "[", "0", "]", "==", "'/'", ")", "{", "return", "_joinAndCanonicalizePath", "(", "parts", ")", ";", "}", "var", "/** @type {?} */", "path", "=", "baseParts", "[", "_ComponentIndex", ".", "Path", "]", ";", "if", "(", "__webpack_require__", ".", "i", "(", "__WEBPACK_IMPORTED_MODULE_1__facade_lang__", "[", "\"d\"", "/* isBlank */", "]", ")", "(", "path", ")", ")", "path", "=", "'/'", ";", "var", "/** @type {?} */", "index", "=", "path", ".", "lastIndexOf", "(", "'/'", ")", ";", "path", "=", "path", ".", "substring", "(", "0", ",", "index", "+", "1", ")", "+", "parts", "[", "_ComponentIndex", ".", "Path", "]", ";", "parts", "[", "_ComponentIndex", ".", "Path", "]", "=", "path", ";", "return", "_joinAndCanonicalizePath", "(", "parts", ")", ";", "}" ]
Resolves a URL. @param {?} base The URL acting as the base URL. @param {?} url @return {?}
[ "Resolves", "a", "URL", "." ]
27eb48f8e49cdaeb4e79937e58e7b16e43e7e390
https://github.com/sean-perkins/ngx-select/blob/27eb48f8e49cdaeb4e79937e58e7b16e43e7e390/examples/webpack/dist/app.e100c23eefa4ef71b346.js#L10803-L10827
43,283
sean-perkins/ngx-select
examples/webpack/dist/app.e100c23eefa4ef71b346.js
convertPropertyBinding
function convertPropertyBinding(builder, nameResolver, implicitReceiver, expression, bindingId) { var /** @type {?} */ currValExpr = createCurrValueExpr(bindingId); var /** @type {?} */ stmts = []; if (!nameResolver) { nameResolver = new DefaultNameResolver(); } var /** @type {?} */ visitor = new _AstToIrVisitor(builder, nameResolver, implicitReceiver, VAL_UNWRAPPER_VAR, bindingId, false); var /** @type {?} */ outputExpr = expression.visit(visitor, _Mode.Expression); if (!outputExpr) { // e.g. an empty expression was given return null; } if (visitor.temporaryCount) { for (var /** @type {?} */ i = 0; i < visitor.temporaryCount; i++) { stmts.push(temporaryDeclaration(bindingId, i)); } } if (visitor.needsValueUnwrapper) { var /** @type {?} */ initValueUnwrapperStmt = VAL_UNWRAPPER_VAR.callMethod('reset', []).toStmt(); stmts.push(initValueUnwrapperStmt); } stmts.push(currValExpr.set(outputExpr).toDeclStmt(null, [__WEBPACK_IMPORTED_MODULE_3__output_output_ast__["k" /* StmtModifier */].Final])); if (visitor.needsValueUnwrapper) { return new ConvertPropertyBindingResult(stmts, currValExpr, VAL_UNWRAPPER_VAR.prop('hasWrappedValue')); } else { return new ConvertPropertyBindingResult(stmts, currValExpr, null); } }
javascript
function convertPropertyBinding(builder, nameResolver, implicitReceiver, expression, bindingId) { var /** @type {?} */ currValExpr = createCurrValueExpr(bindingId); var /** @type {?} */ stmts = []; if (!nameResolver) { nameResolver = new DefaultNameResolver(); } var /** @type {?} */ visitor = new _AstToIrVisitor(builder, nameResolver, implicitReceiver, VAL_UNWRAPPER_VAR, bindingId, false); var /** @type {?} */ outputExpr = expression.visit(visitor, _Mode.Expression); if (!outputExpr) { // e.g. an empty expression was given return null; } if (visitor.temporaryCount) { for (var /** @type {?} */ i = 0; i < visitor.temporaryCount; i++) { stmts.push(temporaryDeclaration(bindingId, i)); } } if (visitor.needsValueUnwrapper) { var /** @type {?} */ initValueUnwrapperStmt = VAL_UNWRAPPER_VAR.callMethod('reset', []).toStmt(); stmts.push(initValueUnwrapperStmt); } stmts.push(currValExpr.set(outputExpr).toDeclStmt(null, [__WEBPACK_IMPORTED_MODULE_3__output_output_ast__["k" /* StmtModifier */].Final])); if (visitor.needsValueUnwrapper) { return new ConvertPropertyBindingResult(stmts, currValExpr, VAL_UNWRAPPER_VAR.prop('hasWrappedValue')); } else { return new ConvertPropertyBindingResult(stmts, currValExpr, null); } }
[ "function", "convertPropertyBinding", "(", "builder", ",", "nameResolver", ",", "implicitReceiver", ",", "expression", ",", "bindingId", ")", "{", "var", "/** @type {?} */", "currValExpr", "=", "createCurrValueExpr", "(", "bindingId", ")", ";", "var", "/** @type {?} */", "stmts", "=", "[", "]", ";", "if", "(", "!", "nameResolver", ")", "{", "nameResolver", "=", "new", "DefaultNameResolver", "(", ")", ";", "}", "var", "/** @type {?} */", "visitor", "=", "new", "_AstToIrVisitor", "(", "builder", ",", "nameResolver", ",", "implicitReceiver", ",", "VAL_UNWRAPPER_VAR", ",", "bindingId", ",", "false", ")", ";", "var", "/** @type {?} */", "outputExpr", "=", "expression", ".", "visit", "(", "visitor", ",", "_Mode", ".", "Expression", ")", ";", "if", "(", "!", "outputExpr", ")", "{", "// e.g. an empty expression was given", "return", "null", ";", "}", "if", "(", "visitor", ".", "temporaryCount", ")", "{", "for", "(", "var", "/** @type {?} */", "i", "=", "0", ";", "i", "<", "visitor", ".", "temporaryCount", ";", "i", "++", ")", "{", "stmts", ".", "push", "(", "temporaryDeclaration", "(", "bindingId", ",", "i", ")", ")", ";", "}", "}", "if", "(", "visitor", ".", "needsValueUnwrapper", ")", "{", "var", "/** @type {?} */", "initValueUnwrapperStmt", "=", "VAL_UNWRAPPER_VAR", ".", "callMethod", "(", "'reset'", ",", "[", "]", ")", ".", "toStmt", "(", ")", ";", "stmts", ".", "push", "(", "initValueUnwrapperStmt", ")", ";", "}", "stmts", ".", "push", "(", "currValExpr", ".", "set", "(", "outputExpr", ")", ".", "toDeclStmt", "(", "null", ",", "[", "__WEBPACK_IMPORTED_MODULE_3__output_output_ast__", "[", "\"k\"", "/* StmtModifier */", "]", ".", "Final", "]", ")", ")", ";", "if", "(", "visitor", ".", "needsValueUnwrapper", ")", "{", "return", "new", "ConvertPropertyBindingResult", "(", "stmts", ",", "currValExpr", ",", "VAL_UNWRAPPER_VAR", ".", "prop", "(", "'hasWrappedValue'", ")", ")", ";", "}", "else", "{", "return", "new", "ConvertPropertyBindingResult", "(", "stmts", ",", "currValExpr", ",", "null", ")", ";", "}", "}" ]
Converts the given expression AST into an executable output AST, assuming the expression is used in a property binding. @param {?} builder @param {?} nameResolver @param {?} implicitReceiver @param {?} expression @param {?} bindingId @return {?}
[ "Converts", "the", "given", "expression", "AST", "into", "an", "executable", "output", "AST", "assuming", "the", "expression", "is", "used", "in", "a", "property", "binding", "." ]
27eb48f8e49cdaeb4e79937e58e7b16e43e7e390
https://github.com/sean-perkins/ngx-select/blob/27eb48f8e49cdaeb4e79937e58e7b16e43e7e390/examples/webpack/dist/app.e100c23eefa4ef71b346.js#L15187-L15215
43,284
sean-perkins/ngx-select
examples/webpack/dist/app.e100c23eefa4ef71b346.js
function (prototype) { // if the prototype is ZoneAwareError.prototype // we just return the prebuilt errorProperties. if (prototype === ZoneAwareError.prototype) { return errorProperties; } var newProps = Object.create(null); var cKeys = Object.getOwnPropertyNames(errorProperties); var keys = Object.getOwnPropertyNames(prototype); cKeys.forEach(function (cKey) { if (keys.filter(function (key) { return key === cKey; }) .length === 0) { newProps[cKey] = errorProperties[cKey]; } }); return newProps; }
javascript
function (prototype) { // if the prototype is ZoneAwareError.prototype // we just return the prebuilt errorProperties. if (prototype === ZoneAwareError.prototype) { return errorProperties; } var newProps = Object.create(null); var cKeys = Object.getOwnPropertyNames(errorProperties); var keys = Object.getOwnPropertyNames(prototype); cKeys.forEach(function (cKey) { if (keys.filter(function (key) { return key === cKey; }) .length === 0) { newProps[cKey] = errorProperties[cKey]; } }); return newProps; }
[ "function", "(", "prototype", ")", "{", "// if the prototype is ZoneAwareError.prototype", "// we just return the prebuilt errorProperties.", "if", "(", "prototype", "===", "ZoneAwareError", ".", "prototype", ")", "{", "return", "errorProperties", ";", "}", "var", "newProps", "=", "Object", ".", "create", "(", "null", ")", ";", "var", "cKeys", "=", "Object", ".", "getOwnPropertyNames", "(", "errorProperties", ")", ";", "var", "keys", "=", "Object", ".", "getOwnPropertyNames", "(", "prototype", ")", ";", "cKeys", ".", "forEach", "(", "function", "(", "cKey", ")", "{", "if", "(", "keys", ".", "filter", "(", "function", "(", "key", ")", "{", "return", "key", "===", "cKey", ";", "}", ")", ".", "length", "===", "0", ")", "{", "newProps", "[", "cKey", "]", "=", "errorProperties", "[", "cKey", "]", ";", "}", "}", ")", ";", "return", "newProps", ";", "}" ]
for derived Error class which extends ZoneAwareError we should not override the derived class's property so we create a new props object only copy the properties from errorProperties which not exist in derived Error's prototype
[ "for", "derived", "Error", "class", "which", "extends", "ZoneAwareError", "we", "should", "not", "override", "the", "derived", "class", "s", "property", "so", "we", "create", "a", "new", "props", "object", "only", "copy", "the", "properties", "from", "errorProperties", "which", "not", "exist", "in", "derived", "Error", "s", "prototype" ]
27eb48f8e49cdaeb4e79937e58e7b16e43e7e390
https://github.com/sean-perkins/ngx-select/blob/27eb48f8e49cdaeb4e79937e58e7b16e43e7e390/examples/webpack/dist/app.e100c23eefa4ef71b346.js#L61441-L61459
43,285
sean-perkins/ngx-select
examples/webpack/dist/app.e100c23eefa4ef71b346.js
ZoneAwareError
function ZoneAwareError() { // make sure we have a valid this // if this is undefined(call Error without new) or this is global // or this is some other objects, we should force to create a // valid ZoneAwareError by call Object.create() if (!(this instanceof ZoneAwareError)) { return ZoneAwareError.apply(Object.create(ZoneAwareError.prototype), arguments); } // Create an Error. var error = NativeError.apply(this, arguments); this[__symbol__('error')] = error; // Save original stack trace error.originalStack = error.stack; // Process the stack trace and rewrite the frames. if (ZoneAwareError[stackRewrite] && error.originalStack) { var frames_1 = error.originalStack.split('\n'); var zoneFrame = _currentZoneFrame; var i = 0; // Find the first frame while (frames_1[i] !== zoneAwareFrame && i < frames_1.length) { i++; } for (; i < frames_1.length && zoneFrame; i++) { var frame = frames_1[i]; if (frame.trim()) { var frameType = blackListedStackFrames.hasOwnProperty(frame) && blackListedStackFrames[frame]; if (frameType === FrameType.blackList) { frames_1.splice(i, 1); i--; } else if (frameType === FrameType.transition) { if (zoneFrame.parent) { // This is the special frame where zone changed. Print and process it accordingly frames_1[i] += " [" + zoneFrame.parent.zone.name + " => " + zoneFrame.zone.name + "]"; zoneFrame = zoneFrame.parent; } else { zoneFrame = null; } } else { frames_1[i] += " [" + zoneFrame.zone.name + "]"; } } } error.stack = error.zoneAwareStack = frames_1.join('\n'); } // use defineProperties here instead of copy property value // because of issue #595 which will break angular2. Object.defineProperties(this, getErrorPropertiesForPrototype(Object.getPrototypeOf(this))); return this; }
javascript
function ZoneAwareError() { // make sure we have a valid this // if this is undefined(call Error without new) or this is global // or this is some other objects, we should force to create a // valid ZoneAwareError by call Object.create() if (!(this instanceof ZoneAwareError)) { return ZoneAwareError.apply(Object.create(ZoneAwareError.prototype), arguments); } // Create an Error. var error = NativeError.apply(this, arguments); this[__symbol__('error')] = error; // Save original stack trace error.originalStack = error.stack; // Process the stack trace and rewrite the frames. if (ZoneAwareError[stackRewrite] && error.originalStack) { var frames_1 = error.originalStack.split('\n'); var zoneFrame = _currentZoneFrame; var i = 0; // Find the first frame while (frames_1[i] !== zoneAwareFrame && i < frames_1.length) { i++; } for (; i < frames_1.length && zoneFrame; i++) { var frame = frames_1[i]; if (frame.trim()) { var frameType = blackListedStackFrames.hasOwnProperty(frame) && blackListedStackFrames[frame]; if (frameType === FrameType.blackList) { frames_1.splice(i, 1); i--; } else if (frameType === FrameType.transition) { if (zoneFrame.parent) { // This is the special frame where zone changed. Print and process it accordingly frames_1[i] += " [" + zoneFrame.parent.zone.name + " => " + zoneFrame.zone.name + "]"; zoneFrame = zoneFrame.parent; } else { zoneFrame = null; } } else { frames_1[i] += " [" + zoneFrame.zone.name + "]"; } } } error.stack = error.zoneAwareStack = frames_1.join('\n'); } // use defineProperties here instead of copy property value // because of issue #595 which will break angular2. Object.defineProperties(this, getErrorPropertiesForPrototype(Object.getPrototypeOf(this))); return this; }
[ "function", "ZoneAwareError", "(", ")", "{", "// make sure we have a valid this", "// if this is undefined(call Error without new) or this is global", "// or this is some other objects, we should force to create a", "// valid ZoneAwareError by call Object.create()", "if", "(", "!", "(", "this", "instanceof", "ZoneAwareError", ")", ")", "{", "return", "ZoneAwareError", ".", "apply", "(", "Object", ".", "create", "(", "ZoneAwareError", ".", "prototype", ")", ",", "arguments", ")", ";", "}", "// Create an Error.", "var", "error", "=", "NativeError", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", "[", "__symbol__", "(", "'error'", ")", "]", "=", "error", ";", "// Save original stack trace", "error", ".", "originalStack", "=", "error", ".", "stack", ";", "// Process the stack trace and rewrite the frames.", "if", "(", "ZoneAwareError", "[", "stackRewrite", "]", "&&", "error", ".", "originalStack", ")", "{", "var", "frames_1", "=", "error", ".", "originalStack", ".", "split", "(", "'\\n'", ")", ";", "var", "zoneFrame", "=", "_currentZoneFrame", ";", "var", "i", "=", "0", ";", "// Find the first frame", "while", "(", "frames_1", "[", "i", "]", "!==", "zoneAwareFrame", "&&", "i", "<", "frames_1", ".", "length", ")", "{", "i", "++", ";", "}", "for", "(", ";", "i", "<", "frames_1", ".", "length", "&&", "zoneFrame", ";", "i", "++", ")", "{", "var", "frame", "=", "frames_1", "[", "i", "]", ";", "if", "(", "frame", ".", "trim", "(", ")", ")", "{", "var", "frameType", "=", "blackListedStackFrames", ".", "hasOwnProperty", "(", "frame", ")", "&&", "blackListedStackFrames", "[", "frame", "]", ";", "if", "(", "frameType", "===", "FrameType", ".", "blackList", ")", "{", "frames_1", ".", "splice", "(", "i", ",", "1", ")", ";", "i", "--", ";", "}", "else", "if", "(", "frameType", "===", "FrameType", ".", "transition", ")", "{", "if", "(", "zoneFrame", ".", "parent", ")", "{", "// This is the special frame where zone changed. Print and process it accordingly", "frames_1", "[", "i", "]", "+=", "\" [\"", "+", "zoneFrame", ".", "parent", ".", "zone", ".", "name", "+", "\" => \"", "+", "zoneFrame", ".", "zone", ".", "name", "+", "\"]\"", ";", "zoneFrame", "=", "zoneFrame", ".", "parent", ";", "}", "else", "{", "zoneFrame", "=", "null", ";", "}", "}", "else", "{", "frames_1", "[", "i", "]", "+=", "\" [\"", "+", "zoneFrame", ".", "zone", ".", "name", "+", "\"]\"", ";", "}", "}", "}", "error", ".", "stack", "=", "error", ".", "zoneAwareStack", "=", "frames_1", ".", "join", "(", "'\\n'", ")", ";", "}", "// use defineProperties here instead of copy property value", "// because of issue #595 which will break angular2.", "Object", ".", "defineProperties", "(", "this", ",", "getErrorPropertiesForPrototype", "(", "Object", ".", "getPrototypeOf", "(", "this", ")", ")", ")", ";", "return", "this", ";", "}" ]
This is ZoneAwareError which processes the stack frame and cleans up extra frames as well as adds zone information to it.
[ "This", "is", "ZoneAwareError", "which", "processes", "the", "stack", "frame", "and", "cleans", "up", "extra", "frames", "as", "well", "as", "adds", "zone", "information", "to", "it", "." ]
27eb48f8e49cdaeb4e79937e58e7b16e43e7e390
https://github.com/sean-perkins/ngx-select/blob/27eb48f8e49cdaeb4e79937e58e7b16e43e7e390/examples/webpack/dist/app.e100c23eefa4ef71b346.js#L61464-L61515
43,286
sean-perkins/ngx-select
examples/webpack/dist/app.e100c23eefa4ef71b346.js
createI18nMessageFactory
function createI18nMessageFactory(interpolationConfig) { var /** @type {?} */ visitor = new _I18nVisitor(_expParser, interpolationConfig); return function (nodes, meaning, description) { return visitor.toI18nMessage(nodes, meaning, description); }; }
javascript
function createI18nMessageFactory(interpolationConfig) { var /** @type {?} */ visitor = new _I18nVisitor(_expParser, interpolationConfig); return function (nodes, meaning, description) { return visitor.toI18nMessage(nodes, meaning, description); }; }
[ "function", "createI18nMessageFactory", "(", "interpolationConfig", ")", "{", "var", "/** @type {?} */", "visitor", "=", "new", "_I18nVisitor", "(", "_expParser", ",", "interpolationConfig", ")", ";", "return", "function", "(", "nodes", ",", "meaning", ",", "description", ")", "{", "return", "visitor", ".", "toI18nMessage", "(", "nodes", ",", "meaning", ",", "description", ")", ";", "}", ";", "}" ]
Returns a function converting html nodes to an i18n Message given an interpolationConfig @param {?} interpolationConfig @return {?}
[ "Returns", "a", "function", "converting", "html", "nodes", "to", "an", "i18n", "Message", "given", "an", "interpolationConfig" ]
27eb48f8e49cdaeb4e79937e58e7b16e43e7e390
https://github.com/sean-perkins/ngx-select/blob/27eb48f8e49cdaeb4e79937e58e7b16e43e7e390/examples/webpack/dist/app.e100c23eefa4ef71b346.js#L66303-L66308
43,287
sean-perkins/ngx-select
examples/webpack/dist/app.e100c23eefa4ef71b346.js
_getOuterContainerOrSelf
function _getOuterContainerOrSelf(node) { var /** @type {?} */ view = node.view; while (_isNgContainer(node.parent, view)) { node = node.parent; } return node; }
javascript
function _getOuterContainerOrSelf(node) { var /** @type {?} */ view = node.view; while (_isNgContainer(node.parent, view)) { node = node.parent; } return node; }
[ "function", "_getOuterContainerOrSelf", "(", "node", ")", "{", "var", "/** @type {?} */", "view", "=", "node", ".", "view", ";", "while", "(", "_isNgContainer", "(", "node", ".", "parent", ",", "view", ")", ")", "{", "node", "=", "node", ".", "parent", ";", "}", "return", "node", ";", "}" ]
Walks up the nodes while the direct parent is a container. Returns the outer container or the node itself when it is not a direct child of a container. \@internal @param {?} node @return {?}
[ "Walks", "up", "the", "nodes", "while", "the", "direct", "parent", "is", "a", "container", "." ]
27eb48f8e49cdaeb4e79937e58e7b16e43e7e390
https://github.com/sean-perkins/ngx-select/blob/27eb48f8e49cdaeb4e79937e58e7b16e43e7e390/examples/webpack/dist/app.e100c23eefa4ef71b346.js#L71079-L71085
43,288
sean-perkins/ngx-select
examples/webpack/dist/app.e100c23eefa4ef71b346.js
_getOuterContainerParentOrSelf
function _getOuterContainerParentOrSelf(el) { var /** @type {?} */ view = el.view; while (_isNgContainer(el, view)) { el = el.parent; } return el; }
javascript
function _getOuterContainerParentOrSelf(el) { var /** @type {?} */ view = el.view; while (_isNgContainer(el, view)) { el = el.parent; } return el; }
[ "function", "_getOuterContainerParentOrSelf", "(", "el", ")", "{", "var", "/** @type {?} */", "view", "=", "el", ".", "view", ";", "while", "(", "_isNgContainer", "(", "el", ",", "view", ")", ")", "{", "el", "=", "el", ".", "parent", ";", "}", "return", "el", ";", "}" ]
Walks up the nodes while they are container and returns the first parent which is not. Returns the parent of the outer container or the node itself when it is not a container. \@internal @param {?} el @return {?}
[ "Walks", "up", "the", "nodes", "while", "they", "are", "container", "and", "returns", "the", "first", "parent", "which", "is", "not", "." ]
27eb48f8e49cdaeb4e79937e58e7b16e43e7e390
https://github.com/sean-perkins/ngx-select/blob/27eb48f8e49cdaeb4e79937e58e7b16e43e7e390/examples/webpack/dist/app.e100c23eefa4ef71b346.js#L71095-L71101
43,289
sean-perkins/ngx-select
examples/webpack/dist/app.e100c23eefa4ef71b346.js
function(TYPE){ var IS_MAP = TYPE == 1 , IS_EVERY = TYPE == 4; return function(object, callbackfn, that /* = undefined */){ var f = ctx(callbackfn, that, 3) , O = toIObject(object) , result = IS_MAP || TYPE == 7 || TYPE == 2 ? new (typeof this == 'function' ? this : Dict) : undefined , key, val, res; for(key in O)if(has(O, key)){ val = O[key]; res = f(val, key, object); if(TYPE){ if(IS_MAP)result[key] = res; // map else if(res)switch(TYPE){ case 2: result[key] = val; break; // filter case 3: return true; // some case 5: return val; // find case 6: return key; // findKey case 7: result[res[0]] = res[1]; // mapPairs } else if(IS_EVERY)return false; // every } } return TYPE == 3 || IS_EVERY ? IS_EVERY : result; }; }
javascript
function(TYPE){ var IS_MAP = TYPE == 1 , IS_EVERY = TYPE == 4; return function(object, callbackfn, that /* = undefined */){ var f = ctx(callbackfn, that, 3) , O = toIObject(object) , result = IS_MAP || TYPE == 7 || TYPE == 2 ? new (typeof this == 'function' ? this : Dict) : undefined , key, val, res; for(key in O)if(has(O, key)){ val = O[key]; res = f(val, key, object); if(TYPE){ if(IS_MAP)result[key] = res; // map else if(res)switch(TYPE){ case 2: result[key] = val; break; // filter case 3: return true; // some case 5: return val; // find case 6: return key; // findKey case 7: result[res[0]] = res[1]; // mapPairs } else if(IS_EVERY)return false; // every } } return TYPE == 3 || IS_EVERY ? IS_EVERY : result; }; }
[ "function", "(", "TYPE", ")", "{", "var", "IS_MAP", "=", "TYPE", "==", "1", ",", "IS_EVERY", "=", "TYPE", "==", "4", ";", "return", "function", "(", "object", ",", "callbackfn", ",", "that", "/* = undefined */", ")", "{", "var", "f", "=", "ctx", "(", "callbackfn", ",", "that", ",", "3", ")", ",", "O", "=", "toIObject", "(", "object", ")", ",", "result", "=", "IS_MAP", "||", "TYPE", "==", "7", "||", "TYPE", "==", "2", "?", "new", "(", "typeof", "this", "==", "'function'", "?", "this", ":", "Dict", ")", ":", "undefined", ",", "key", ",", "val", ",", "res", ";", "for", "(", "key", "in", "O", ")", "if", "(", "has", "(", "O", ",", "key", ")", ")", "{", "val", "=", "O", "[", "key", "]", ";", "res", "=", "f", "(", "val", ",", "key", ",", "object", ")", ";", "if", "(", "TYPE", ")", "{", "if", "(", "IS_MAP", ")", "result", "[", "key", "]", "=", "res", ";", "// map", "else", "if", "(", "res", ")", "switch", "(", "TYPE", ")", "{", "case", "2", ":", "result", "[", "key", "]", "=", "val", ";", "break", ";", "// filter", "case", "3", ":", "return", "true", ";", "// some", "case", "5", ":", "return", "val", ";", "// find", "case", "6", ":", "return", "key", ";", "// findKey", "case", "7", ":", "result", "[", "res", "[", "0", "]", "]", "=", "res", "[", "1", "]", ";", "// mapPairs", "}", "else", "if", "(", "IS_EVERY", ")", "return", "false", ";", "// every", "}", "}", "return", "TYPE", "==", "3", "||", "IS_EVERY", "?", "IS_EVERY", ":", "result", ";", "}", ";", "}" ]
0 -> Dict.forEach 1 -> Dict.map 2 -> Dict.filter 3 -> Dict.some 4 -> Dict.every 5 -> Dict.find 6 -> Dict.findKey 7 -> Dict.mapPairs
[ "0", "-", ">", "Dict", ".", "forEach", "1", "-", ">", "Dict", ".", "map", "2", "-", ">", "Dict", ".", "filter", "3", "-", ">", "Dict", ".", "some", "4", "-", ">", "Dict", ".", "every", "5", "-", ">", "Dict", ".", "find", "6", "-", ">", "Dict", ".", "findKey", "7", "-", ">", "Dict", ".", "mapPairs" ]
27eb48f8e49cdaeb4e79937e58e7b16e43e7e390
https://github.com/sean-perkins/ngx-select/blob/27eb48f8e49cdaeb4e79937e58e7b16e43e7e390/examples/webpack/dist/app.e100c23eefa4ef71b346.js#L79032-L79057
43,290
mvo5/sha512crypt-node
sha512crypt.js
_sha512crypt_intermediate
function _sha512crypt_intermediate(password, salt) { var digest_a = rstr_sha512(password + salt); var digest_b = rstr_sha512(password + salt + password); var key_len = password.length; // extend digest b so that it has the same size as password var digest_b_extended = _extend(digest_b, password.length); var intermediate_input = password + salt + digest_b_extended; for (cnt = key_len; cnt > 0; cnt >>= 1) { if ((cnt & 1) != 0) intermediate_input += digest_b else intermediate_input += password; } var intermediate = rstr_sha512(intermediate_input); return intermediate; }
javascript
function _sha512crypt_intermediate(password, salt) { var digest_a = rstr_sha512(password + salt); var digest_b = rstr_sha512(password + salt + password); var key_len = password.length; // extend digest b so that it has the same size as password var digest_b_extended = _extend(digest_b, password.length); var intermediate_input = password + salt + digest_b_extended; for (cnt = key_len; cnt > 0; cnt >>= 1) { if ((cnt & 1) != 0) intermediate_input += digest_b else intermediate_input += password; } var intermediate = rstr_sha512(intermediate_input); return intermediate; }
[ "function", "_sha512crypt_intermediate", "(", "password", ",", "salt", ")", "{", "var", "digest_a", "=", "rstr_sha512", "(", "password", "+", "salt", ")", ";", "var", "digest_b", "=", "rstr_sha512", "(", "password", "+", "salt", "+", "password", ")", ";", "var", "key_len", "=", "password", ".", "length", ";", "// extend digest b so that it has the same size as password", "var", "digest_b_extended", "=", "_extend", "(", "digest_b", ",", "password", ".", "length", ")", ";", "var", "intermediate_input", "=", "password", "+", "salt", "+", "digest_b_extended", ";", "for", "(", "cnt", "=", "key_len", ";", "cnt", ">", "0", ";", "cnt", ">>=", "1", ")", "{", "if", "(", "(", "cnt", "&", "1", ")", "!=", "0", ")", "intermediate_input", "+=", "digest_b", "else", "intermediate_input", "+=", "password", ";", "}", "var", "intermediate", "=", "rstr_sha512", "(", "intermediate_input", ")", ";", "return", "intermediate", ";", "}" ]
steps 1-12
[ "steps", "1", "-", "12" ]
169e901a484870eca6dbed5caee9411a1acde263
https://github.com/mvo5/sha512crypt-node/blob/169e901a484870eca6dbed5caee9411a1acde263/sha512crypt.js#L55-L73
43,291
alexindigo/fbbot
lib/middleware.js
use
function use(events, middleware) { // if no middleware supplied assume it's single argument call if (!middleware) { middleware = events; events = null; } // make it uniform events = normalizeEvents(events); // store middleware per event events.forEach(function(e) { // bind middleware to the current context (this._stack[e] = this._stack[e] || []).push(middleware.bind(this)); // make mark in history this.logger.debug({message: 'Added middleware to the stack', event: e, middleware: middleware}); }.bind(this)); }
javascript
function use(events, middleware) { // if no middleware supplied assume it's single argument call if (!middleware) { middleware = events; events = null; } // make it uniform events = normalizeEvents(events); // store middleware per event events.forEach(function(e) { // bind middleware to the current context (this._stack[e] = this._stack[e] || []).push(middleware.bind(this)); // make mark in history this.logger.debug({message: 'Added middleware to the stack', event: e, middleware: middleware}); }.bind(this)); }
[ "function", "use", "(", "events", ",", "middleware", ")", "{", "// if no middleware supplied assume it's single argument call", "if", "(", "!", "middleware", ")", "{", "middleware", "=", "events", ";", "events", "=", "null", ";", "}", "// make it uniform", "events", "=", "normalizeEvents", "(", "events", ")", ";", "// store middleware per event", "events", ".", "forEach", "(", "function", "(", "e", ")", "{", "// bind middleware to the current context", "(", "this", ".", "_stack", "[", "e", "]", "=", "this", ".", "_stack", "[", "e", "]", "||", "[", "]", ")", ".", "push", "(", "middleware", ".", "bind", "(", "this", ")", ")", ";", "// make mark in history", "this", ".", "logger", ".", "debug", "(", "{", "message", ":", "'Added middleware to the stack'", ",", "event", ":", "e", ",", "middleware", ":", "middleware", "}", ")", ";", "}", ".", "bind", "(", "this", ")", ")", ";", "}" ]
Adds provided middleware to the stack, with optional list of events @this Fbbot# @param {string|array} [events] - list of events to associate middleware with @param {function} middleware - request/event handler
[ "Adds", "provided", "middleware", "to", "the", "stack", "with", "optional", "list", "of", "events" ]
b78a0418ebdfd106723348d94b4378ac67f7d4bf
https://github.com/alexindigo/fbbot/blob/b78a0418ebdfd106723348d94b4378ac67f7d4bf/lib/middleware.js#L22-L43
43,292
alexindigo/fbbot
lib/middleware.js
run
function run(events, payload, callback) { // if no callback supplied assume it's two arguments call if (!callback) { callback = payload; payload = events; events = null; } // make it uniform events = normalizeEvents(events); // apply events/middleware asynchronously and sequentially pipeline(events, payload, function(e, data, cb) { if (!Array.isArray(this._stack[e])) { this.logger.debug({message: 'Reached end of the stack', event: e, data: data}); cb(null, payload); return; } pipeline(this._stack[e], data, tryCall, cb); }.bind(this), callback); }
javascript
function run(events, payload, callback) { // if no callback supplied assume it's two arguments call if (!callback) { callback = payload; payload = events; events = null; } // make it uniform events = normalizeEvents(events); // apply events/middleware asynchronously and sequentially pipeline(events, payload, function(e, data, cb) { if (!Array.isArray(this._stack[e])) { this.logger.debug({message: 'Reached end of the stack', event: e, data: data}); cb(null, payload); return; } pipeline(this._stack[e], data, tryCall, cb); }.bind(this), callback); }
[ "function", "run", "(", "events", ",", "payload", ",", "callback", ")", "{", "// if no callback supplied assume it's two arguments call", "if", "(", "!", "callback", ")", "{", "callback", "=", "payload", ";", "payload", "=", "events", ";", "events", "=", "null", ";", "}", "// make it uniform", "events", "=", "normalizeEvents", "(", "events", ")", ";", "// apply events/middleware asynchronously and sequentially", "pipeline", "(", "events", ",", "payload", ",", "function", "(", "e", ",", "data", ",", "cb", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "this", ".", "_stack", "[", "e", "]", ")", ")", "{", "this", ".", "logger", ".", "debug", "(", "{", "message", ":", "'Reached end of the stack'", ",", "event", ":", "e", ",", "data", ":", "data", "}", ")", ";", "cb", "(", "null", ",", "payload", ")", ";", "return", ";", "}", "pipeline", "(", "this", ".", "_stack", "[", "e", "]", ",", "data", ",", "tryCall", ",", "cb", ")", ";", "}", ".", "bind", "(", "this", ")", ",", "callback", ")", ";", "}" ]
Runs middleware in the stack for the provided events with passed payload @this Fbbot# @param {string|array} [events] - list of events to determine middleware set to iterate over @param {object} payload - event payload to pass along to middleware @param {function} callback - invoked after (if) all middleware been processed
[ "Runs", "middleware", "in", "the", "stack", "for", "the", "provided", "events", "with", "passed", "payload" ]
b78a0418ebdfd106723348d94b4378ac67f7d4bf
https://github.com/alexindigo/fbbot/blob/b78a0418ebdfd106723348d94b4378ac67f7d4bf/lib/middleware.js#L53-L78
43,293
alexindigo/fbbot
lib/middleware.js
normalizeEvents
function normalizeEvents(events) { // start with converting falsy events into catch-all placeholder events = events || entryPoint; if (!Array.isArray(events)) { events = [events]; } // return shallow copy return events.concat(); }
javascript
function normalizeEvents(events) { // start with converting falsy events into catch-all placeholder events = events || entryPoint; if (!Array.isArray(events)) { events = [events]; } // return shallow copy return events.concat(); }
[ "function", "normalizeEvents", "(", "events", ")", "{", "// start with converting falsy events into catch-all placeholder", "events", "=", "events", "||", "entryPoint", ";", "if", "(", "!", "Array", ".", "isArray", "(", "events", ")", ")", "{", "events", "=", "[", "events", "]", ";", "}", "// return shallow copy", "return", "events", ".", "concat", "(", ")", ";", "}" ]
Normalizes provided events to keep `add` and `apply` on the same page @private @param {null|string|array} events - events to normalize @returns {array} - normalized list of events
[ "Normalizes", "provided", "events", "to", "keep", "add", "and", "apply", "on", "the", "same", "page" ]
b78a0418ebdfd106723348d94b4378ac67f7d4bf
https://github.com/alexindigo/fbbot/blob/b78a0418ebdfd106723348d94b4378ac67f7d4bf/lib/middleware.js#L106-L118
43,294
alexindigo/fbbot
lib/send.js
generateMessage
function generateMessage(type, data) { var message; switch (type) { // default message type, no need to perform special actions, will be sent as is case types.MESSAGE: message = data; break; case types.TEXT: // `text` must be UTF-8 and has a 320 character limit // https://developers.facebook.com/docs/messenger-platform/send-api-reference/text-message message = {text: data.substr(0, 320)}; break; case types.AUDIO: case types.FILE: case types.IMAGE: case types.VIDEO: message = {attachment: {type: type, payload: {url: data}}}; break; case types.QUICK_REPLIES: // `quick_replies` is limited to 10 // https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies message = {text: data.text, quick_replies: data.quick_replies.slice(0, 10)}; break; case types.GENERIC: message = templates.generic.call(this, data); break; case types.BUTTON: message = templates.button.call(this, data); break; case types.RECEIPT: message = templates.receipt.call(this, data); break; default: this.logger.error({message: 'Unrecognized message type', type: type, payload: data}); } return message; }
javascript
function generateMessage(type, data) { var message; switch (type) { // default message type, no need to perform special actions, will be sent as is case types.MESSAGE: message = data; break; case types.TEXT: // `text` must be UTF-8 and has a 320 character limit // https://developers.facebook.com/docs/messenger-platform/send-api-reference/text-message message = {text: data.substr(0, 320)}; break; case types.AUDIO: case types.FILE: case types.IMAGE: case types.VIDEO: message = {attachment: {type: type, payload: {url: data}}}; break; case types.QUICK_REPLIES: // `quick_replies` is limited to 10 // https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies message = {text: data.text, quick_replies: data.quick_replies.slice(0, 10)}; break; case types.GENERIC: message = templates.generic.call(this, data); break; case types.BUTTON: message = templates.button.call(this, data); break; case types.RECEIPT: message = templates.receipt.call(this, data); break; default: this.logger.error({message: 'Unrecognized message type', type: type, payload: data}); } return message; }
[ "function", "generateMessage", "(", "type", ",", "data", ")", "{", "var", "message", ";", "switch", "(", "type", ")", "{", "// default message type, no need to perform special actions, will be sent as is", "case", "types", ".", "MESSAGE", ":", "message", "=", "data", ";", "break", ";", "case", "types", ".", "TEXT", ":", "// `text` must be UTF-8 and has a 320 character limit", "// https://developers.facebook.com/docs/messenger-platform/send-api-reference/text-message", "message", "=", "{", "text", ":", "data", ".", "substr", "(", "0", ",", "320", ")", "}", ";", "break", ";", "case", "types", ".", "AUDIO", ":", "case", "types", ".", "FILE", ":", "case", "types", ".", "IMAGE", ":", "case", "types", ".", "VIDEO", ":", "message", "=", "{", "attachment", ":", "{", "type", ":", "type", ",", "payload", ":", "{", "url", ":", "data", "}", "}", "}", ";", "break", ";", "case", "types", ".", "QUICK_REPLIES", ":", "// `quick_replies` is limited to 10", "// https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies", "message", "=", "{", "text", ":", "data", ".", "text", ",", "quick_replies", ":", "data", ".", "quick_replies", ".", "slice", "(", "0", ",", "10", ")", "}", ";", "break", ";", "case", "types", ".", "GENERIC", ":", "message", "=", "templates", ".", "generic", ".", "call", "(", "this", ",", "data", ")", ";", "break", ";", "case", "types", ".", "BUTTON", ":", "message", "=", "templates", ".", "button", ".", "call", "(", "this", ",", "data", ")", ";", "break", ";", "case", "types", ".", "RECEIPT", ":", "message", "=", "templates", ".", "receipt", ".", "call", "(", "this", ",", "data", ")", ";", "break", ";", "default", ":", "this", ".", "logger", ".", "error", "(", "{", "message", ":", "'Unrecognized message type'", ",", "type", ":", "type", ",", "payload", ":", "data", "}", ")", ";", "}", "return", "message", ";", "}" ]
Generates message from the provided data object with respect for the message type @private @this Fbbot# @param {string} type - message type @param {object} data - message data object @returns {object} - generated message object
[ "Generates", "message", "from", "the", "provided", "data", "object", "with", "respect", "for", "the", "message", "type" ]
b78a0418ebdfd106723348d94b4378ac67f7d4bf
https://github.com/alexindigo/fbbot/blob/b78a0418ebdfd106723348d94b4378ac67f7d4bf/lib/send.js#L165-L212
43,295
alexindigo/fbbot
lib/request.js
request
function request(url, options, callback) { var connection; if (typeof options == 'function') { callback = options; options = {}; } connection = hyperquest(url, options, once(function(error, response) { if (error) { callback(error, response); return; } // set body response.body = ''; // accumulate response body response.on('data', function(data) { response.body += data.toString(); }); response.on('end', function() { callback(null, response); }); })); return connection; }
javascript
function request(url, options, callback) { var connection; if (typeof options == 'function') { callback = options; options = {}; } connection = hyperquest(url, options, once(function(error, response) { if (error) { callback(error, response); return; } // set body response.body = ''; // accumulate response body response.on('data', function(data) { response.body += data.toString(); }); response.on('end', function() { callback(null, response); }); })); return connection; }
[ "function", "request", "(", "url", ",", "options", ",", "callback", ")", "{", "var", "connection", ";", "if", "(", "typeof", "options", "==", "'function'", ")", "{", "callback", "=", "options", ";", "options", "=", "{", "}", ";", "}", "connection", "=", "hyperquest", "(", "url", ",", "options", ",", "once", "(", "function", "(", "error", ",", "response", ")", "{", "if", "(", "error", ")", "{", "callback", "(", "error", ",", "response", ")", ";", "return", ";", "}", "// set body", "response", ".", "body", "=", "''", ";", "// accumulate response body", "response", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "response", ".", "body", "+=", "data", ".", "toString", "(", ")", ";", "}", ")", ";", "response", ".", "on", "(", "'end'", ",", "function", "(", ")", "{", "callback", "(", "null", ",", "response", ")", ";", "}", ")", ";", "}", ")", ")", ";", "return", "connection", ";", "}" ]
Wraps hyperquest to provide extra convenience with handling responses @param {string} url - url to request @param {object} [options] - request options @param {function} callback - invoked on response @returns {stream.Duplex} - request stream
[ "Wraps", "hyperquest", "to", "provide", "extra", "convenience", "with", "handling", "responses" ]
b78a0418ebdfd106723348d94b4378ac67f7d4bf
https://github.com/alexindigo/fbbot/blob/b78a0418ebdfd106723348d94b4378ac67f7d4bf/lib/request.js#L19-L53
43,296
alexindigo/fbbot
lib/request.js
parseJson
function parseJson(payload) { var data; try { data = JSON.parse(payload); } catch (e) { this.logger.error({message: 'Unable to parse provided JSON', error: e, payload: payload}); } return data; }
javascript
function parseJson(payload) { var data; try { data = JSON.parse(payload); } catch (e) { this.logger.error({message: 'Unable to parse provided JSON', error: e, payload: payload}); } return data; }
[ "function", "parseJson", "(", "payload", ")", "{", "var", "data", ";", "try", "{", "data", "=", "JSON", ".", "parse", "(", "payload", ")", ";", "}", "catch", "(", "e", ")", "{", "this", ".", "logger", ".", "error", "(", "{", "message", ":", "'Unable to parse provided JSON'", ",", "error", ":", "e", ",", "payload", ":", "payload", "}", ")", ";", "}", "return", "data", ";", "}" ]
Parses provided JSON payload into object @private @this Fbbot# @param {string} payload - JSON string to parse @returns {object|undefined} - parsed object or `undefined` if unable to parse
[ "Parses", "provided", "JSON", "payload", "into", "object" ]
b78a0418ebdfd106723348d94b4378ac67f7d4bf
https://github.com/alexindigo/fbbot/blob/b78a0418ebdfd106723348d94b4378ac67f7d4bf/lib/request.js#L123-L137
43,297
alexindigo/fbbot
incoming/user_init.js
userInit
function userInit(payload, callback) { var type = messaging.getType(payload); if (payload.sender && payload[type]) { // detach new object from the source payload[type].user = clone(payload.sender); // add user tailored send functions // but keep it outside of own properties payload[type].user.__proto__ = {send: send.factory(this, payload[type].user)}; } callback(null, payload); }
javascript
function userInit(payload, callback) { var type = messaging.getType(payload); if (payload.sender && payload[type]) { // detach new object from the source payload[type].user = clone(payload.sender); // add user tailored send functions // but keep it outside of own properties payload[type].user.__proto__ = {send: send.factory(this, payload[type].user)}; } callback(null, payload); }
[ "function", "userInit", "(", "payload", ",", "callback", ")", "{", "var", "type", "=", "messaging", ".", "getType", "(", "payload", ")", ";", "if", "(", "payload", ".", "sender", "&&", "payload", "[", "type", "]", ")", "{", "// detach new object from the source", "payload", "[", "type", "]", ".", "user", "=", "clone", "(", "payload", ".", "sender", ")", ";", "// add user tailored send functions", "// but keep it outside of own properties", "payload", "[", "type", "]", ".", "user", ".", "__proto__", "=", "{", "send", ":", "send", ".", "factory", "(", "this", ",", "payload", "[", "type", "]", ".", "user", ")", "}", ";", "}", "callback", "(", "null", ",", "payload", ")", ";", "}" ]
Creates `user` object within `message`, based on `sender` property. @this Fbbot# @param {object} payload - messaging envelop object @param {function} callback - invoked after type casting is done
[ "Creates", "user", "object", "within", "message", "based", "on", "sender", "property", "." ]
b78a0418ebdfd106723348d94b4378ac67f7d4bf
https://github.com/alexindigo/fbbot/blob/b78a0418ebdfd106723348d94b4378ac67f7d4bf/incoming/user_init.js#L16-L31
43,298
alexindigo/fbbot
outgoing/quick_reply.js
quickReply
function quickReply(payload, callback) { if (typeof payload.payload != 'string') { payload.payload = JSON.stringify(payload.payload); } callback(null, payload); }
javascript
function quickReply(payload, callback) { if (typeof payload.payload != 'string') { payload.payload = JSON.stringify(payload.payload); } callback(null, payload); }
[ "function", "quickReply", "(", "payload", ",", "callback", ")", "{", "if", "(", "typeof", "payload", ".", "payload", "!=", "'string'", ")", "{", "payload", ".", "payload", "=", "JSON", ".", "stringify", "(", "payload", ".", "payload", ")", ";", "}", "callback", "(", "null", ",", "payload", ")", ";", "}" ]
Stringifies provided quick reply payload @this Fbbot# @param {object} payload - quick_reply object @param {function} callback - invoked after stringification is done
[ "Stringifies", "provided", "quick", "reply", "payload" ]
b78a0418ebdfd106723348d94b4378ac67f7d4bf
https://github.com/alexindigo/fbbot/blob/b78a0418ebdfd106723348d94b4378ac67f7d4bf/outgoing/quick_reply.js#L10-L18
43,299
insin/redux-action-utils
lib/index.js
actionCreator
function actionCreator(type) { var props = Array.isArray(arguments[1]) ? arguments[1] : slice.call(arguments, 1) return function() { if (!props.length) { return {type: type} } var args = slice.call(arguments) return props.reduce(function(action, prop, index) { return (action[prop] = args[index], action) }, {type: type}) } }
javascript
function actionCreator(type) { var props = Array.isArray(arguments[1]) ? arguments[1] : slice.call(arguments, 1) return function() { if (!props.length) { return {type: type} } var args = slice.call(arguments) return props.reduce(function(action, prop, index) { return (action[prop] = args[index], action) }, {type: type}) } }
[ "function", "actionCreator", "(", "type", ")", "{", "var", "props", "=", "Array", ".", "isArray", "(", "arguments", "[", "1", "]", ")", "?", "arguments", "[", "1", "]", ":", "slice", ".", "call", "(", "arguments", ",", "1", ")", "return", "function", "(", ")", "{", "if", "(", "!", "props", ".", "length", ")", "{", "return", "{", "type", ":", "type", "}", "}", "var", "args", "=", "slice", ".", "call", "(", "arguments", ")", "return", "props", ".", "reduce", "(", "function", "(", "action", ",", "prop", ",", "index", ")", "{", "return", "(", "action", "[", "prop", "]", "=", "args", "[", "index", "]", ",", "action", ")", "}", ",", "{", "type", ":", "type", "}", ")", "}", "}" ]
Creates an action creator for the given action type, which optionally adds positional arguments given to it to the action object using specified property names. Property names can be specified as an Array of strings or as any number of addiitonal String arguments; arguments passed to the action creator will be assigned to property names in the same order the names were given in.
[ "Creates", "an", "action", "creator", "for", "the", "given", "action", "type", "which", "optionally", "adds", "positional", "arguments", "given", "to", "it", "to", "the", "action", "object", "using", "specified", "property", "names", "." ]
10a0464815751355fb9d43281cf5e41a9a65d1ae
https://github.com/insin/redux-action-utils/blob/10a0464815751355fb9d43281cf5e41a9a65d1ae/lib/index.js#L14-L25