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
19,400
riot/compiler
src/generators/template/utils.js
updateNodeScope
function updateNodeScope(path) { if (!isGlobal(path)) { replacePathScope(path, path.node) return false } this.traverse(path) }
javascript
function updateNodeScope(path) { if (!isGlobal(path)) { replacePathScope(path, path.node) return false } this.traverse(path) }
[ "function", "updateNodeScope", "(", "path", ")", "{", "if", "(", "!", "isGlobal", "(", "path", ")", ")", "{", "replacePathScope", "(", "path", ",", "path", ".", "node", ")", "return", "false", "}", "this", ".", "traverse", "(", "path", ")", "}" ]
Change the nodes scope adding the `scope` prefix @param { types.NodePath } path - containing the current node visited @returns { boolean } return false if we want to stop the tree traversal @context { types.visit }
[ "Change", "the", "nodes", "scope", "adding", "the", "scope", "prefix" ]
fa9cea9cf6b8a369e057c966c4e2698940a3fafc
https://github.com/riot/compiler/blob/fa9cea9cf6b8a369e057c966c4e2698940a3fafc/src/generators/template/utils.js#L86-L94
19,401
riot/compiler
src/generators/template/utils.js
visitMemberExpression
function visitMemberExpression(path) { if (!isGlobal({ node: path.node.object, scope: path.scope })) { replacePathScope(path, isThisExpression(path.node.object) ? path.node.property : path.node) } return false }
javascript
function visitMemberExpression(path) { if (!isGlobal({ node: path.node.object, scope: path.scope })) { replacePathScope(path, isThisExpression(path.node.object) ? path.node.property : path.node) } return false }
[ "function", "visitMemberExpression", "(", "path", ")", "{", "if", "(", "!", "isGlobal", "(", "{", "node", ":", "path", ".", "node", ".", "object", ",", "scope", ":", "path", ".", "scope", "}", ")", ")", "{", "replacePathScope", "(", "path", ",", "isT...
Change the scope of the member expressions @param { types.NodePath } path - containing the current node visited @returns { boolean } return always false because we want to check only the first node object
[ "Change", "the", "scope", "of", "the", "member", "expressions" ]
fa9cea9cf6b8a369e057c966c4e2698940a3fafc
https://github.com/riot/compiler/blob/fa9cea9cf6b8a369e057c966c4e2698940a3fafc/src/generators/template/utils.js#L101-L107
19,402
riot/compiler
src/generators/template/utils.js
visitProperty
function visitProperty(path) { const value = path.node.value if (isIdentifier(value)) { updateNodeScope(path.get('value')) } else { this.traverse(path.get('value')) } return false }
javascript
function visitProperty(path) { const value = path.node.value if (isIdentifier(value)) { updateNodeScope(path.get('value')) } else { this.traverse(path.get('value')) } return false }
[ "function", "visitProperty", "(", "path", ")", "{", "const", "value", "=", "path", ".", "node", ".", "value", "if", "(", "isIdentifier", "(", "value", ")", ")", "{", "updateNodeScope", "(", "path", ".", "get", "(", "'value'", ")", ")", "}", "else", "...
Objects properties should be handled a bit differently from the Identifier @param { types.NodePath } path - containing the current node visited @returns { boolean } return false if we want to stop the tree traversal
[ "Objects", "properties", "should", "be", "handled", "a", "bit", "differently", "from", "the", "Identifier" ]
fa9cea9cf6b8a369e057c966c4e2698940a3fafc
https://github.com/riot/compiler/blob/fa9cea9cf6b8a369e057c966c4e2698940a3fafc/src/generators/template/utils.js#L115-L125
19,403
riot/compiler
src/index.js
createMeta
function createMeta(source, options) { return { tagName: null, fragments: null, options: { ...DEFAULT_OPTIONS, ...options }, source } }
javascript
function createMeta(source, options) { return { tagName: null, fragments: null, options: { ...DEFAULT_OPTIONS, ...options }, source } }
[ "function", "createMeta", "(", "source", ",", "options", ")", "{", "return", "{", "tagName", ":", "null", ",", "fragments", ":", "null", ",", "options", ":", "{", "...", "DEFAULT_OPTIONS", ",", "...", "options", "}", ",", "source", "}", "}" ]
Create the compilation meta object @param { string } source - source code of the tag we will need to compile @param { string } options - compiling options @returns {Object} meta object
[ "Create", "the", "compilation", "meta", "object" ]
fa9cea9cf6b8a369e057c966c4e2698940a3fafc
https://github.com/riot/compiler/blob/fa9cea9cf6b8a369e057c966c4e2698940a3fafc/src/index.js#L80-L90
19,404
riot/compiler
src/index.js
hookGenerator
function hookGenerator(transformer, sourceNode, source, meta) { if ( // filter missing nodes !sourceNode || // filter nodes without children (sourceNode.nodes && !sourceNode.nodes.length) || // filter empty javascript and css nodes (!sourceNode.nodes && !sourceNode.text)) { return result =...
javascript
function hookGenerator(transformer, sourceNode, source, meta) { if ( // filter missing nodes !sourceNode || // filter nodes without children (sourceNode.nodes && !sourceNode.nodes.length) || // filter empty javascript and css nodes (!sourceNode.nodes && !sourceNode.text)) { return result =...
[ "function", "hookGenerator", "(", "transformer", ",", "sourceNode", ",", "source", ",", "meta", ")", "{", "if", "(", "// filter missing nodes", "!", "sourceNode", "||", "// filter nodes without children", "(", "sourceNode", ".", "nodes", "&&", "!", "sourceNode", "...
Prepare the riot parser node transformers @param { Function } transformer - transformer function @param { Object } sourceNode - riot parser node @param { string } source - component source code @param { Object } meta - compilation meta information @returns { Promise<Output> } object containing output code and s...
[ "Prepare", "the", "riot", "parser", "node", "transformers" ]
fa9cea9cf6b8a369e057c966c4e2698940a3fafc
https://github.com/riot/compiler/blob/fa9cea9cf6b8a369e057c966c4e2698940a3fafc/src/index.js#L142-L154
19,405
rbtech/css-purge
lib/css-purge.js
processHTML
function processHTML(cssSelectors = [], htmlDataIn = null, htmlOptionsIn = null) { //read html files if (OPTIONS.html !== '' && OPTIONS.html !== undefined && OPTIONS.special_reduce_with_html) { var htmlFiles = OPTIONS.html; tmpHTMLPaths = []; //check for file or files switch (typeof htmlFiles) { ...
javascript
function processHTML(cssSelectors = [], htmlDataIn = null, htmlOptionsIn = null) { //read html files if (OPTIONS.html !== '' && OPTIONS.html !== undefined && OPTIONS.special_reduce_with_html) { var htmlFiles = OPTIONS.html; tmpHTMLPaths = []; //check for file or files switch (typeof htmlFiles) { ...
[ "function", "processHTML", "(", "cssSelectors", "=", "[", "]", ",", "htmlDataIn", "=", "null", ",", "htmlOptionsIn", "=", "null", ")", "{", "//read html files", "if", "(", "OPTIONS", ".", "html", "!==", "''", "&&", "OPTIONS", ".", "html", "!==", "undefined...
end of processHTMLSelectors
[ "end", "of", "processHTMLSelectors" ]
4c23ea9cd86056a79bb63117a79ef139ad9b0f2c
https://github.com/rbtech/css-purge/blob/4c23ea9cd86056a79bb63117a79ef139ad9b0f2c/lib/css-purge.js#L1361-L1446
19,406
rbtech/css-purge
lib/css-purge.js
getFilePaths
function getFilePaths(strPath = '', exts = ['.css']) { if (validUrl.isUri(strPath)){ switch(exts[0]) { case '.css': tmpCSSPaths.push(strPath); break; case '.html': case '.htm': tmpHTMLPaths.push(strPath); break; case '.js': tmpJSPaths.push(strPath); break; } } e...
javascript
function getFilePaths(strPath = '', exts = ['.css']) { if (validUrl.isUri(strPath)){ switch(exts[0]) { case '.css': tmpCSSPaths.push(strPath); break; case '.html': case '.htm': tmpHTMLPaths.push(strPath); break; case '.js': tmpJSPaths.push(strPath); break; } } e...
[ "function", "getFilePaths", "(", "strPath", "=", "''", ",", "exts", "=", "[", "'.css'", "]", ")", "{", "if", "(", "validUrl", ".", "isUri", "(", "strPath", ")", ")", "{", "switch", "(", "exts", "[", "0", "]", ")", "{", "case", "'.css'", ":", "tmp...
end of processCSSFiles
[ "end", "of", "processCSSFiles" ]
4c23ea9cd86056a79bb63117a79ef139ad9b0f2c
https://github.com/rbtech/css-purge/blob/4c23ea9cd86056a79bb63117a79ef139ad9b0f2c/lib/css-purge.js#L1992-L2101
19,407
rbtech/css-purge
lib/css-purge.js
processRulesReset
function processRulesReset() { declarationsNameCounts = null; declarationsValueCounts = null; valKey = null; key = null; declarationsValueCountsCount = null; amountRemoved = 1; duplicate_ids = null; selectorPropertiesList = null; }
javascript
function processRulesReset() { declarationsNameCounts = null; declarationsValueCounts = null; valKey = null; key = null; declarationsValueCountsCount = null; amountRemoved = 1; duplicate_ids = null; selectorPropertiesList = null; }
[ "function", "processRulesReset", "(", ")", "{", "declarationsNameCounts", "=", "null", ";", "declarationsValueCounts", "=", "null", ";", "valKey", "=", "null", ";", "key", "=", "null", ";", "declarationsValueCountsCount", "=", "null", ";", "amountRemoved", "=", ...
end of processRules
[ "end", "of", "processRules" ]
4c23ea9cd86056a79bb63117a79ef139ad9b0f2c
https://github.com/rbtech/css-purge/blob/4c23ea9cd86056a79bb63117a79ef139ad9b0f2c/lib/css-purge.js#L5765-L5775
19,408
zalmoxisus/remotedev
examples/reflux/js/store.js
function(list){ localStorage.setItem(localStorageKey, JSON.stringify(list)); // if we used a real database, we would likely do the below in a callback this.list = list; this.trigger(list); // sends the updated list to all listening components (TodoApp) }
javascript
function(list){ localStorage.setItem(localStorageKey, JSON.stringify(list)); // if we used a real database, we would likely do the below in a callback this.list = list; this.trigger(list); // sends the updated list to all listening components (TodoApp) }
[ "function", "(", "list", ")", "{", "localStorage", ".", "setItem", "(", "localStorageKey", ",", "JSON", ".", "stringify", "(", "list", ")", ")", ";", "// if we used a real database, we would likely do the below in a callback", "this", ".", "list", "=", "list", ";", ...
called whenever we change a list. normally this would mean a database API call
[ "called", "whenever", "we", "change", "a", "list", ".", "normally", "this", "would", "mean", "a", "database", "API", "call" ]
f8256d934316b37a94cd24870fc1d3efcbe7d0b9
https://github.com/zalmoxisus/remotedev/blob/f8256d934316b37a94cd24870fc1d3efcbe7d0b9/examples/reflux/js/store.js#L63-L68
19,409
zalmoxisus/remotedev
examples/reflux/js/store.js
function() { var loadedList = localStorage.getItem(localStorageKey); if (!loadedList) { // If no list is in localstorage, start out with a default one this.list = [{ key: todoCounter++, created: new Date(), ...
javascript
function() { var loadedList = localStorage.getItem(localStorageKey); if (!loadedList) { // If no list is in localstorage, start out with a default one this.list = [{ key: todoCounter++, created: new Date(), ...
[ "function", "(", ")", "{", "var", "loadedList", "=", "localStorage", ".", "getItem", "(", "localStorageKey", ")", ";", "if", "(", "!", "loadedList", ")", "{", "// If no list is in localstorage, start out with a default one", "this", ".", "list", "=", "[", "{", "...
this will be called by all listening components as they register their listeners
[ "this", "will", "be", "called", "by", "all", "listening", "components", "as", "they", "register", "their", "listeners" ]
f8256d934316b37a94cd24870fc1d3efcbe7d0b9
https://github.com/zalmoxisus/remotedev/blob/f8256d934316b37a94cd24870fc1d3efcbe7d0b9/examples/reflux/js/store.js#L70-L93
19,410
DaftMonk/angular-tour
src/tour/tour.js
getTargetScope
function getTargetScope() { var targetElement = scope.ttElement ? angular.element(scope.ttElement) : element; var targetScope = scope; if (targetElement !== element && !scope.ttSourceScope) targetScope = targetElement.scope(); return ...
javascript
function getTargetScope() { var targetElement = scope.ttElement ? angular.element(scope.ttElement) : element; var targetScope = scope; if (targetElement !== element && !scope.ttSourceScope) targetScope = targetElement.scope(); return ...
[ "function", "getTargetScope", "(", ")", "{", "var", "targetElement", "=", "scope", ".", "ttElement", "?", "angular", ".", "element", "(", "scope", ".", "ttElement", ")", ":", "element", ";", "var", "targetScope", "=", "scope", ";", "if", "(", "targetElemen...
determining target scope. It's used only when using virtual steps and there is some action performed like on-show or on-progress. Without virtual steps action would performed on element's scope and that would work just fine however, when using virtual steps, whose steps can be placed in different controller, so it affe...
[ "determining", "target", "scope", ".", "It", "s", "used", "only", "when", "using", "virtual", "steps", "and", "there", "is", "some", "action", "performed", "like", "on", "-", "show", "or", "on", "-", "progress", ".", "Without", "virtual", "steps", "action"...
07433ccef7cfb632dfd1b379835c7d126968cf0c
https://github.com/DaftMonk/angular-tour/blob/07433ccef7cfb632dfd1b379835c7d126968cf0c/src/tour/tour.js#L270-L278
19,411
SU-SWS/decanter
webpack.config.js
recursiveIssuer
function recursiveIssuer(module) { if (module.issuer) { return recursiveIssuer(module.issuer); } else if (module.name) { return module.name; } else { return false; } }
javascript
function recursiveIssuer(module) { if (module.issuer) { return recursiveIssuer(module.issuer); } else if (module.name) { return module.name; } else { return false; } }
[ "function", "recursiveIssuer", "(", "module", ")", "{", "if", "(", "module", ".", "issuer", ")", "{", "return", "recursiveIssuer", "(", "module", ".", "issuer", ")", ";", "}", "else", "if", "(", "module", ".", "name", ")", "{", "return", "module", ".",...
For MiniCssExtractPlugin Loops through the module variable that is nested looking for a name.
[ "For", "MiniCssExtractPlugin", "Loops", "through", "the", "module", "variable", "that", "is", "nested", "looking", "for", "a", "name", "." ]
2a00f03066f4abc07032308597a60fff4744cc06
https://github.com/SU-SWS/decanter/blob/2a00f03066f4abc07032308597a60fff4744cc06/webpack.config.js#L30-L40
19,412
sidorares/node-tick
lib/tickprocessor.js
readFile
function readFile(fileName) { try { return read(fileName); } catch (e) { print(fileName + ': ' + (e.message || e)); throw e; } }
javascript
function readFile(fileName) { try { return read(fileName); } catch (e) { print(fileName + ': ' + (e.message || e)); throw e; } }
[ "function", "readFile", "(", "fileName", ")", "{", "try", "{", "return", "read", "(", "fileName", ")", ";", "}", "catch", "(", "e", ")", "{", "print", "(", "fileName", "+", "': '", "+", "(", "e", ".", "message", "||", "e", ")", ")", ";", "throw",...
A thin wrapper around shell's 'read' function showing a file name on error.
[ "A", "thin", "wrapper", "around", "shell", "s", "read", "function", "showing", "a", "file", "name", "on", "error", "." ]
350c64c5a12588e25be9e8e6acc861e40315eeaa
https://github.com/sidorares/node-tick/blob/350c64c5a12588e25be9e8e6acc861e40315eeaa/lib/tickprocessor.js#L70-L77
19,413
sidorares/node-tick
lib/tickprocessor.js
parseState
function parseState(s) { switch (s) { case "": return Profile.CodeState.COMPILED; case "~": return Profile.CodeState.OPTIMIZABLE; case "*": return Profile.CodeState.OPTIMIZED; } throw new Error("unknown code state: " + s); }
javascript
function parseState(s) { switch (s) { case "": return Profile.CodeState.COMPILED; case "~": return Profile.CodeState.OPTIMIZABLE; case "*": return Profile.CodeState.OPTIMIZED; } throw new Error("unknown code state: " + s); }
[ "function", "parseState", "(", "s", ")", "{", "switch", "(", "s", ")", "{", "case", "\"\"", ":", "return", "Profile", ".", "CodeState", ".", "COMPILED", ";", "case", "\"~\"", ":", "return", "Profile", ".", "CodeState", ".", "OPTIMIZABLE", ";", "case", ...
Parser for dynamic code optimization state.
[ "Parser", "for", "dynamic", "code", "optimization", "state", "." ]
350c64c5a12588e25be9e8e6acc861e40315eeaa
https://github.com/sidorares/node-tick/blob/350c64c5a12588e25be9e8e6acc861e40315eeaa/lib/tickprocessor.js#L83-L90
19,414
Azure/azure-documentdb-node-q
documentclientwrapper.js
function () { var deferred = Q.defer(); var that = this; this._innerQueryIterator.nextItem(function (error, item, responseHeaders) { if (error) { addOrMergeHeadersForError(error, responseHeaders); deferred.reject(error); ...
javascript
function () { var deferred = Q.defer(); var that = this; this._innerQueryIterator.nextItem(function (error, item, responseHeaders) { if (error) { addOrMergeHeadersForError(error, responseHeaders); deferred.reject(error); ...
[ "function", "(", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "var", "that", "=", "this", ";", "this", ".", "_innerQueryIterator", ".", "nextItem", "(", "function", "(", "error", ",", "item", ",", "responseHeaders", ")", "{", "...
Gets the next element in the QueryIterator. @memberof QueryIteratorWrapper @instance @Returns {Object} A promise object for the request completion. The onFulfilled callback is of type {@link ResourceResponse} and onError callback is of type {@link ResponseError}
[ "Gets", "the", "next", "element", "in", "the", "QueryIterator", "." ]
ffd0ad09b52942f5c1e167cc54f795553929234d
https://github.com/Azure/azure-documentdb-node-q/blob/ffd0ad09b52942f5c1e167cc54f795553929234d/documentclientwrapper.js#L209-L222
19,415
Azure/azure-documentdb-node-q
documentclientwrapper.js
function () { var deferred = Q.defer(); var that = this; this._innerQueryIterator.executeNext(function (error, resources, responseHeaders) { if (error) { addOrMergeHeadersForError(error, responseHeaders); deferred.reject(e...
javascript
function () { var deferred = Q.defer(); var that = this; this._innerQueryIterator.executeNext(function (error, resources, responseHeaders) { if (error) { addOrMergeHeadersForError(error, responseHeaders); deferred.reject(e...
[ "function", "(", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "var", "that", "=", "this", ";", "this", ".", "_innerQueryIterator", ".", "executeNext", "(", "function", "(", "error", ",", "resources", ",", "responseHeaders", ")", ...
Retrieve the next batch of the feed and pass them as an array to a function @memberof QueryIteratorWrapper @instance @Returns {Object} A promise object for the request completion. the onFulfilled callback is of type {@link FeedResponse} and onError callback is of type {@link ResponseError}
[ "Retrieve", "the", "next", "batch", "of", "the", "feed", "and", "pass", "them", "as", "an", "array", "to", "a", "function" ]
ffd0ad09b52942f5c1e167cc54f795553929234d
https://github.com/Azure/azure-documentdb-node-q/blob/ffd0ad09b52942f5c1e167cc54f795553929234d/documentclientwrapper.js#L230-L243
19,416
Azure/azure-documentdb-node-q
documentclientwrapper.js
function(sprocLink, params, options) { var deferred = Q.defer(); this._innerDocumentclient.executeStoredProcedure(sprocLink, params, options, function (error, result, responseHeaders) { if (error) { addOrMergeHeadersForError(error, responseHeaders); ...
javascript
function(sprocLink, params, options) { var deferred = Q.defer(); this._innerDocumentclient.executeStoredProcedure(sprocLink, params, options, function (error, result, responseHeaders) { if (error) { addOrMergeHeadersForError(error, responseHeaders); ...
[ "function", "(", "sprocLink", ",", "params", ",", "options", ")", "{", "var", "deferred", "=", "Q", ".", "defer", "(", ")", ";", "this", ".", "_innerDocumentclient", ".", "executeStoredProcedure", "(", "sprocLink", ",", "params", ",", "options", ",", "func...
Execute the StoredProcedure represented by the object. @memberof DocumentClientWrapper @instance @param {string} sprocLink - The self-link of the stored procedure. @param {Array} [params] - Represent the parameters of the stored procedure. @param {Object} [options] - optio...
[ "Execute", "the", "StoredProcedure", "represented", "by", "the", "object", "." ]
ffd0ad09b52942f5c1e167cc54f795553929234d
https://github.com/Azure/azure-documentdb-node-q/blob/ffd0ad09b52942f5c1e167cc54f795553929234d/documentclientwrapper.js#L1261-L1272
19,417
edx/ux-pattern-library
pldoc/static/js/ui.js
function() { var target; $('a[href^="#"]').not('.pldoc-tab-wrapper .pldoc-link').on('click', function(event) { event.preventDefault(); target = $(event.currentTarget).attr('href'); $('html, body').stop().animate({ scrollTop: $...
javascript
function() { var target; $('a[href^="#"]').not('.pldoc-tab-wrapper .pldoc-link').on('click', function(event) { event.preventDefault(); target = $(event.currentTarget).attr('href'); $('html, body').stop().animate({ scrollTop: $...
[ "function", "(", ")", "{", "var", "target", ";", "$", "(", "'a[href^=\"#\"]'", ")", ".", "not", "(", "'.pldoc-tab-wrapper .pldoc-link'", ")", ".", "on", "(", "'click'", ",", "function", "(", "event", ")", "{", "event", ".", "preventDefault", "(", ")", ";...
smoothscroll to target links
[ "smoothscroll", "to", "target", "links" ]
ca09258db3805e8315c5347d404a4f343d7700d5
https://github.com/edx/ux-pattern-library/blob/ca09258db3805e8315c5347d404a4f343d7700d5/pldoc/static/js/ui.js#L48-L61
19,418
KissKissBankBank/kitten
src/components/navigation/pagination.js
range
function range(start, end) { return Array(end - start + 1).fill().map(function (_, index) { return start + index; }); }
javascript
function range(start, end) { return Array(end - start + 1).fill().map(function (_, index) { return start + index; }); }
[ "function", "range", "(", "start", ",", "end", ")", "{", "return", "Array", "(", "end", "-", "start", "+", "1", ")", ".", "fill", "(", ")", ".", "map", "(", "function", "(", "_", ",", "index", ")", "{", "return", "start", "+", "index", ";", "}"...
Returns an array with the given bounds
[ "Returns", "an", "array", "with", "the", "given", "bounds" ]
b002b08d71dfa09719bdd90cf51c902910dd5293
https://github.com/KissKissBankBank/kitten/blob/b002b08d71dfa09719bdd90cf51c902910dd5293/src/components/navigation/pagination.js#L50-L54
19,419
williamkapke/bson-objectid
objectid.js
ObjectID
function ObjectID(arg) { if(!(this instanceof ObjectID)) return new ObjectID(arg); if(arg && ((arg instanceof ObjectID) || arg._bsontype==="ObjectID")) return arg; var buf; if(isBuffer(arg) || (Array.isArray(arg) && arg.length===12)) { buf = Array.prototype.slice.call(arg); } else if(typeof arg ==...
javascript
function ObjectID(arg) { if(!(this instanceof ObjectID)) return new ObjectID(arg); if(arg && ((arg instanceof ObjectID) || arg._bsontype==="ObjectID")) return arg; var buf; if(isBuffer(arg) || (Array.isArray(arg) && arg.length===12)) { buf = Array.prototype.slice.call(arg); } else if(typeof arg ==...
[ "function", "ObjectID", "(", "arg", ")", "{", "if", "(", "!", "(", "this", "instanceof", "ObjectID", ")", ")", "return", "new", "ObjectID", "(", "arg", ")", ";", "if", "(", "arg", "&&", "(", "(", "arg", "instanceof", "ObjectID", ")", "||", "arg", "...
Create a new immutable ObjectID instance @class Represents the BSON ObjectID type @param {String|Number} arg Can be a 24 byte hex string, 12 byte binary string or a Number. @return {Object} instance of ObjectID.
[ "Create", "a", "new", "immutable", "ObjectID", "instance" ]
df4eada0816a423dc4447411f356c7931808353c
https://github.com/williamkapke/bson-objectid/blob/df4eada0816a423dc4447411f356c7931808353c/objectid.js#L29-L56
19,420
stevenbenner/jquery-powertip
src/core.js
apiShowTip
function apiShowTip(element, event) { // if we were given a mouse event then run the hover intent testing, // otherwise, simply show the tooltip asap if (isMouseEvent(event)) { trackMouse(event); session.previousX = event.pageX; session.previousY = event.pageY; $(element).data(DATA_DISPLAYCONTROLLER)....
javascript
function apiShowTip(element, event) { // if we were given a mouse event then run the hover intent testing, // otherwise, simply show the tooltip asap if (isMouseEvent(event)) { trackMouse(event); session.previousX = event.pageX; session.previousY = event.pageY; $(element).data(DATA_DISPLAYCONTROLLER)....
[ "function", "apiShowTip", "(", "element", ",", "event", ")", "{", "// if we were given a mouse event then run the hover intent testing,", "// otherwise, simply show the tooltip asap", "if", "(", "isMouseEvent", "(", "event", ")", ")", "{", "trackMouse", "(", "event", ")", ...
Attempts to show the tooltip for the specified element. @param {jQuery|Element} element The element to open the tooltip for. @param {jQuery.Event=} event jQuery event for hover intent and mouse tracking (optional). @return {jQuery|Element} The original jQuery object or DOM Element.
[ "Attempts", "to", "show", "the", "tooltip", "for", "the", "specified", "element", "." ]
58a576d409e2452673d90695f4520b9378ba7c48
https://github.com/stevenbenner/jquery-powertip/blob/58a576d409e2452673d90695f4520b9378ba7c48/src/core.js#L231-L243
19,421
stevenbenner/jquery-powertip
src/core.js
apiCloseTip
function apiCloseTip(element, immediate) { var displayController; // set immediate to true when no element is specified immediate = element ? immediate : true; // find the relevant display controller if (element) { displayController = $(element).first().data(DATA_DISPLAYCONTROLLER); } else if (session....
javascript
function apiCloseTip(element, immediate) { var displayController; // set immediate to true when no element is specified immediate = element ? immediate : true; // find the relevant display controller if (element) { displayController = $(element).first().data(DATA_DISPLAYCONTROLLER); } else if (session....
[ "function", "apiCloseTip", "(", "element", ",", "immediate", ")", "{", "var", "displayController", ";", "// set immediate to true when no element is specified", "immediate", "=", "element", "?", "immediate", ":", "true", ";", "// find the relevant display controller", "if",...
Attempts to close any open tooltips. @param {(jQuery|Element)=} element The element with the tooltip that should be closed (optional). @param {boolean=} immediate Disable close delay (optional). @return {jQuery|Element|undefined} The original jQuery object or DOM Element, if one was specified.
[ "Attempts", "to", "close", "any", "open", "tooltips", "." ]
58a576d409e2452673d90695f4520b9378ba7c48
https://github.com/stevenbenner/jquery-powertip/blob/58a576d409e2452673d90695f4520b9378ba7c48/src/core.js#L263-L282
19,422
stevenbenner/jquery-powertip
src/core.js
apiToggle
function apiToggle(element, event) { if (session.activeHover && session.activeHover.is(element)) { // tooltip for element is active, so close it $.powerTip.hide(element, !isMouseEvent(event)); } else { // tooltip for element is not active, so open it $.powerTip.show(element, event); } return element...
javascript
function apiToggle(element, event) { if (session.activeHover && session.activeHover.is(element)) { // tooltip for element is active, so close it $.powerTip.hide(element, !isMouseEvent(event)); } else { // tooltip for element is not active, so open it $.powerTip.show(element, event); } return element...
[ "function", "apiToggle", "(", "element", ",", "event", ")", "{", "if", "(", "session", ".", "activeHover", "&&", "session", ".", "activeHover", ".", "is", "(", "element", ")", ")", "{", "// tooltip for element is active, so close it", "$", ".", "powerTip", "."...
Toggles the tooltip for the specified element. This will open a closed tooltip, or close an open tooltip. @param {jQuery|Element} element The element with the tooltip that should be toggled. @param {jQuery.Event=} event jQuery event for hover intent and mouse tracking (optional). @return {jQuery|Element} The original j...
[ "Toggles", "the", "tooltip", "for", "the", "specified", "element", ".", "This", "will", "open", "a", "closed", "tooltip", "or", "close", "an", "open", "tooltip", "." ]
58a576d409e2452673d90695f4520b9378ba7c48
https://github.com/stevenbenner/jquery-powertip/blob/58a576d409e2452673d90695f4520b9378ba7c48/src/core.js#L293-L302
19,423
fernandojsg/aframe-teleport-controls
index.js
function () { var collisionEntities; var data = this.data; var el = this.el; if (!data.collisionEntities) { this.collisionEntities = []; return; } collisionEntities = [].slice.call(el.sceneEl.querySelectorAll(data.collisionEntities)); this.collisionEntities = collisionEntities;...
javascript
function () { var collisionEntities; var data = this.data; var el = this.el; if (!data.collisionEntities) { this.collisionEntities = []; return; } collisionEntities = [].slice.call(el.sceneEl.querySelectorAll(data.collisionEntities)); this.collisionEntities = collisionEntities;...
[ "function", "(", ")", "{", "var", "collisionEntities", ";", "var", "data", "=", "this", ".", "data", ";", "var", "el", "=", "this", ".", "el", ";", "if", "(", "!", "data", ".", "collisionEntities", ")", "{", "this", ".", "collisionEntities", "=", "["...
Run `querySelectorAll` for `collisionEntities` and maintain it with `child-attached` and `child-detached` events.
[ "Run", "querySelectorAll", "for", "collisionEntities", "and", "maintain", "it", "with", "child", "-", "attached", "and", "child", "-", "detached", "events", "." ]
d5ed39291c0bb99183fdd71a5071dafbb4cd259c
https://github.com/fernandojsg/aframe-teleport-controls/blob/d5ed39291c0bb99183fdd71a5071dafbb4cd259c/index.js#L248-L277
19,424
fernandojsg/aframe-teleport-controls
index.js
function (i, next) { // @todo We should add a property to define if the collisionEntity is dynamic or static // If static we should do the map just once, otherwise we're recreating the array in every // loop when aiming. var meshes; if (!this.data.collisionEntities) { meshes = this.defaultColl...
javascript
function (i, next) { // @todo We should add a property to define if the collisionEntity is dynamic or static // If static we should do the map just once, otherwise we're recreating the array in every // loop when aiming. var meshes; if (!this.data.collisionEntities) { meshes = this.defaultColl...
[ "function", "(", "i", ",", "next", ")", "{", "// @todo We should add a property to define if the collisionEntity is dynamic or static", "// If static we should do the map just once, otherwise we're recreating the array in every", "// loop when aiming.", "var", "meshes", ";", "if", "(", ...
Check for raycaster intersection. @param {number} Line fragment point index. @param {number} Next line fragment point index. @returns {boolean} true if there's an intersection.
[ "Check", "for", "raycaster", "intersection", "." ]
d5ed39291c0bb99183fdd71a5071dafbb4cd259c
https://github.com/fernandojsg/aframe-teleport-controls/blob/d5ed39291c0bb99183fdd71a5071dafbb4cd259c/index.js#L352-L389
19,425
fernandojsg/aframe-teleport-controls
index.js
createHitEntity
function createHitEntity (data) { var cylinder; var hitEntity; var torus; // Parent. hitEntity = document.createElement('a-entity'); hitEntity.className = 'hitEntity'; // Torus. torus = document.createElement('a-entity'); torus.setAttribute('geometry', { primitive: 'torus', radius: data.hitC...
javascript
function createHitEntity (data) { var cylinder; var hitEntity; var torus; // Parent. hitEntity = document.createElement('a-entity'); hitEntity.className = 'hitEntity'; // Torus. torus = document.createElement('a-entity'); torus.setAttribute('geometry', { primitive: 'torus', radius: data.hitC...
[ "function", "createHitEntity", "(", "data", ")", "{", "var", "cylinder", ";", "var", "hitEntity", ";", "var", "torus", ";", "// Parent.", "hitEntity", "=", "document", ".", "createElement", "(", "'a-entity'", ")", ";", "hitEntity", ".", "className", "=", "'h...
Create mesh to represent the area of intersection. Default to a combination of torus and cylinder.
[ "Create", "mesh", "to", "represent", "the", "area", "of", "intersection", ".", "Default", "to", "a", "combination", "of", "torus", "and", "cylinder", "." ]
d5ed39291c0bb99183fdd71a5071dafbb4cd259c
https://github.com/fernandojsg/aframe-teleport-controls/blob/d5ed39291c0bb99183fdd71a5071dafbb4cd259c/index.js#L407-L453
19,426
natefaubion/sparkler
src/utils.js
cloneSyntax
function cloneSyntax(stx) { function F(){} F.prototype = stx.__proto__; var s = new F(); extend(s, stx); s.token = extend({}, s.token); return s; }
javascript
function cloneSyntax(stx) { function F(){} F.prototype = stx.__proto__; var s = new F(); extend(s, stx); s.token = extend({}, s.token); return s; }
[ "function", "cloneSyntax", "(", "stx", ")", "{", "function", "F", "(", ")", "{", "}", "F", ".", "prototype", "=", "stx", ".", "__proto__", ";", "var", "s", "=", "new", "F", "(", ")", ";", "extend", "(", "s", ",", "stx", ")", ";", "s", ".", "t...
HACK! Sweet.js needs to expose syntax cloning to macros
[ "HACK!", "Sweet", ".", "js", "needs", "to", "expose", "syntax", "cloning", "to", "macros" ]
c8ab2c14787b5b0256f93c03d2dd11a732356fb3
https://github.com/natefaubion/sparkler/blob/c8ab2c14787b5b0256f93c03d2dd11a732356fb3/src/utils.js#L220-L227
19,427
chr15m/bugout
index.js
attach
function attach(bugout, identifier, wire, addr) { debug("saw wire", wire.peerId, identifier); wire.use(extension(bugout, identifier, wire)); wire.on("close", partial(detach, bugout, identifier, wire)); }
javascript
function attach(bugout, identifier, wire, addr) { debug("saw wire", wire.peerId, identifier); wire.use(extension(bugout, identifier, wire)); wire.on("close", partial(detach, bugout, identifier, wire)); }
[ "function", "attach", "(", "bugout", ",", "identifier", ",", "wire", ",", "addr", ")", "{", "debug", "(", "\"saw wire\"", ",", "wire", ".", "peerId", ",", "identifier", ")", ";", "wire", ".", "use", "(", "extension", "(", "bugout", ",", "identifier", "...
extension protocol plumbing
[ "extension", "protocol", "plumbing" ]
0795437ff7d674d17d2b8cd0463c7c2386d5b478
https://github.com/chr15m/bugout/blob/0795437ff7d674d17d2b8cd0463c7c2386d5b478/index.js#L415-L419
19,428
not-an-aardvark/eslint-plugin-eslint-plugin
lib/rules/report-message-format.js
processMessageNode
function processMessageNode (message) { if ( (message.type === 'Literal' && typeof message.value === 'string' && !pattern.test(message.value)) || (message.type === 'TemplateLiteral' && message.quasis.length === 1 && !pattern.test(message.quasis[0].value.cooked)) ) { context.report({ ...
javascript
function processMessageNode (message) { if ( (message.type === 'Literal' && typeof message.value === 'string' && !pattern.test(message.value)) || (message.type === 'TemplateLiteral' && message.quasis.length === 1 && !pattern.test(message.quasis[0].value.cooked)) ) { context.report({ ...
[ "function", "processMessageNode", "(", "message", ")", "{", "if", "(", "(", "message", ".", "type", "===", "'Literal'", "&&", "typeof", "message", ".", "value", "===", "'string'", "&&", "!", "pattern", ".", "test", "(", "message", ".", "value", ")", ")",...
Report a message node if it doesn't match the given formatting @param {ASTNode} message The message AST node @returns {void}
[ "Report", "a", "message", "node", "if", "it", "doesn", "t", "match", "the", "given", "formatting" ]
660074eaaa342f6c25128c1bfc541663388921ef
https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/660074eaaa342f6c25128c1bfc541663388921ef/lib/rules/report-message-format.js#L37-L48
19,429
not-an-aardvark/eslint-plugin-eslint-plugin
lib/rules/require-meta-docs-url.js
isExpectedUrl
function isExpectedUrl (node) { return Boolean( node && node.type === 'Literal' && typeof node.value === 'string' && ( expectedUrl === undefined || node.value === expectedUrl ) ); }
javascript
function isExpectedUrl (node) { return Boolean( node && node.type === 'Literal' && typeof node.value === 'string' && ( expectedUrl === undefined || node.value === expectedUrl ) ); }
[ "function", "isExpectedUrl", "(", "node", ")", "{", "return", "Boolean", "(", "node", "&&", "node", ".", "type", "===", "'Literal'", "&&", "typeof", "node", ".", "value", "===", "'string'", "&&", "(", "expectedUrl", "===", "undefined", "||", "node", ".", ...
Check whether a given node is the expected URL. @param {Node} node The node of property value to check. @returns {boolean} `true` if the node is the expected URL.
[ "Check", "whether", "a", "given", "node", "is", "the", "expected", "URL", "." ]
660074eaaa342f6c25128c1bfc541663388921ef
https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/660074eaaa342f6c25128c1bfc541663388921ef/lib/rules/require-meta-docs-url.js#L55-L65
19,430
not-an-aardvark/eslint-plugin-eslint-plugin
lib/rules/require-meta-docs-url.js
insertProperty
function insertProperty (fixer, node, propertyText) { if (node.properties.length === 0) { return fixer.replaceText(node, `{\n${propertyText}\n}`); } return fixer.insertTextAfter( sourceCode.getLastToken(node.properties[node.properties.length - 1]), `,\n${propertyText}` );...
javascript
function insertProperty (fixer, node, propertyText) { if (node.properties.length === 0) { return fixer.replaceText(node, `{\n${propertyText}\n}`); } return fixer.insertTextAfter( sourceCode.getLastToken(node.properties[node.properties.length - 1]), `,\n${propertyText}` );...
[ "function", "insertProperty", "(", "fixer", ",", "node", ",", "propertyText", ")", "{", "if", "(", "node", ".", "properties", ".", "length", "===", "0", ")", "{", "return", "fixer", ".", "replaceText", "(", "node", ",", "`", "\\n", "${", "propertyText", ...
Insert a given property into a given object literal. @param {SourceCodeFixer} fixer The fixer. @param {Node} node The ObjectExpression node to insert a property. @param {string} propertyText The property code to insert. @returns {void}
[ "Insert", "a", "given", "property", "into", "a", "given", "object", "literal", "." ]
660074eaaa342f6c25128c1bfc541663388921ef
https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/660074eaaa342f6c25128c1bfc541663388921ef/lib/rules/require-meta-docs-url.js#L74-L82
19,431
not-an-aardvark/eslint-plugin-eslint-plugin
lib/rules/no-useless-token-range.js
isRangeAccess
function isRangeAccess (node) { return node.type === 'MemberExpression' && node.property.type === 'Identifier' && node.property.name === 'range'; }
javascript
function isRangeAccess (node) { return node.type === 'MemberExpression' && node.property.type === 'Identifier' && node.property.name === 'range'; }
[ "function", "isRangeAccess", "(", "node", ")", "{", "return", "node", ".", "type", "===", "'MemberExpression'", "&&", "node", ".", "property", ".", "type", "===", "'Identifier'", "&&", "node", ".", "property", ".", "name", "===", "'range'", ";", "}" ]
Determines whether a node is a MemberExpression that accesses the `range` property @param {ASTNode} node The node @returns {boolean} `true` if the node is a MemberExpression that accesses the `range` property
[ "Determines", "whether", "a", "node", "is", "a", "MemberExpression", "that", "accesses", "the", "range", "property" ]
660074eaaa342f6c25128c1bfc541663388921ef
https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/660074eaaa342f6c25128c1bfc541663388921ef/lib/rules/no-useless-token-range.js#L58-L60
19,432
ceejbot/fivebeans
lib/client.js
argHashToArray
function argHashToArray(hash) { var keys = Object.keys(hash); var result = []; for (var i = 0; i < keys.length; i++) { result[parseInt(keys[i], 10)] = hash[keys[i]]; } return result; }
javascript
function argHashToArray(hash) { var keys = Object.keys(hash); var result = []; for (var i = 0; i < keys.length; i++) { result[parseInt(keys[i], 10)] = hash[keys[i]]; } return result; }
[ "function", "argHashToArray", "(", "hash", ")", "{", "var", "keys", "=", "Object", ".", "keys", "(", "hash", ")", ";", "var", "result", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "i", "++", ...
utilities Turn a function argument hash into an array for slicing.
[ "utilities", "Turn", "a", "function", "argument", "hash", "into", "an", "array", "for", "slicing", "." ]
1849d0286b5bea6a1de7582da9b910a567f8ed4f
https://github.com/ceejbot/fivebeans/blob/1849d0286b5bea6a1de7582da9b910a567f8ed4f/lib/client.js#L15-L24
19,433
ceejbot/fivebeans
lib/client.js
makeBeanstalkCommand
function makeBeanstalkCommand(command, expectedResponse, sendsData) { // Commands are called as client.COMMAND(arg1, arg2, ... data, callback); // They're sent to beanstalkd as: COMMAND arg1 arg2 ... // followed by data. // So we slice the callback & data from the passed-in arguments, prepend // the command, then ...
javascript
function makeBeanstalkCommand(command, expectedResponse, sendsData) { // Commands are called as client.COMMAND(arg1, arg2, ... data, callback); // They're sent to beanstalkd as: COMMAND arg1 arg2 ... // followed by data. // So we slice the callback & data from the passed-in arguments, prepend // the command, then ...
[ "function", "makeBeanstalkCommand", "(", "command", ",", "expectedResponse", ",", "sendsData", ")", "{", "// Commands are called as client.COMMAND(arg1, arg2, ... data, callback);", "// They're sent to beanstalkd as: COMMAND arg1 arg2 ...", "// followed by data.", "// So we slice the callb...
Implementing the beanstalkd interface.
[ "Implementing", "the", "beanstalkd", "interface", "." ]
1849d0286b5bea6a1de7582da9b910a567f8ed4f
https://github.com/ceejbot/fivebeans/blob/1849d0286b5bea6a1de7582da9b910a567f8ed4f/lib/client.js#L266-L305
19,434
Leanplum/Leanplum-JavaScript-SDK
dist/sw/sw.js
pushListener
function pushListener(event) { var jsonString = event.data && event.data.text() ? event.data.text() : null; if (!jsonString) { console.log('Leanplum: Push received without payload, skipping display.'); return; } // noinspection JSCheckFunctionSignatures var options = JSON.parse(jsonStr...
javascript
function pushListener(event) { var jsonString = event.data && event.data.text() ? event.data.text() : null; if (!jsonString) { console.log('Leanplum: Push received without payload, skipping display.'); return; } // noinspection JSCheckFunctionSignatures var options = JSON.parse(jsonStr...
[ "function", "pushListener", "(", "event", ")", "{", "var", "jsonString", "=", "event", ".", "data", "&&", "event", ".", "data", ".", "text", "(", ")", "?", "event", ".", "data", ".", "text", "(", ")", ":", "null", ";", "if", "(", "!", "jsonString",...
Triggered on push message received. @param {object} event The push payload that the browser received.
[ "Triggered", "on", "push", "message", "received", "." ]
a9fc6c6feba3fc9a9f500b80b797a350db3c0caa
https://github.com/Leanplum/Leanplum-JavaScript-SDK/blob/a9fc6c6feba3fc9a9f500b80b797a350db3c0caa/dist/sw/sw.js#L64-L94
19,435
Leanplum/Leanplum-JavaScript-SDK
dist/sw/sw.js
notificationClickListener
function notificationClickListener(event) { console.log('Leanplum: [Service Worker] Notification click received.'); event.notification.close(); if (!event.notification || !event.notification.tag) { console.log('Leanplum: No notification or tag/id received, skipping open action.'); return; ...
javascript
function notificationClickListener(event) { console.log('Leanplum: [Service Worker] Notification click received.'); event.notification.close(); if (!event.notification || !event.notification.tag) { console.log('Leanplum: No notification or tag/id received, skipping open action.'); return; ...
[ "function", "notificationClickListener", "(", "event", ")", "{", "console", ".", "log", "(", "'Leanplum: [Service Worker] Notification click received.'", ")", ";", "event", ".", "notification", ".", "close", "(", ")", ";", "if", "(", "!", "event", ".", "notificati...
Callback that handles clicks on the notification. @param {object} event The notification event object. @param {object} event.notification The notification object. @param {function} event.waitUntil The browser will keep the service worker running until the promise you passed in has settled.
[ "Callback", "that", "handles", "clicks", "on", "the", "notification", "." ]
a9fc6c6feba3fc9a9f500b80b797a350db3c0caa
https://github.com/Leanplum/Leanplum-JavaScript-SDK/blob/a9fc6c6feba3fc9a9f500b80b797a350db3c0caa/dist/sw/sw.js#L103-L124
19,436
rochars/wavefile
dist/wavefile.js
bitDepth
function bitDepth(input, original, target, output) { validateBitDepth_(original); validateBitDepth_(target); /** @type {!Function} */ let toFunction = getBitDepthFunction_(original, target); /** @type {!Object<string, number>} */ let options = { oldMin: Math.pow(2, parseInt(original, 10)) / 2, newMi...
javascript
function bitDepth(input, original, target, output) { validateBitDepth_(original); validateBitDepth_(target); /** @type {!Function} */ let toFunction = getBitDepthFunction_(original, target); /** @type {!Object<string, number>} */ let options = { oldMin: Math.pow(2, parseInt(original, 10)) / 2, newMi...
[ "function", "bitDepth", "(", "input", ",", "original", ",", "target", ",", "output", ")", "{", "validateBitDepth_", "(", "original", ")", ";", "validateBitDepth_", "(", "target", ")", ";", "/** @type {!Function} */", "let", "toFunction", "=", "getBitDepthFunction_...
Change the bit depth of samples. The input array. @param {!TypedArray} input The samples. @param {string} original The original bit depth of the data. One of "8" ... "53", "32f", "64" @param {string} target The desired bit depth for the data. One of "8" ... "53", "32f", "64" @param {!TypedArray} output The output array...
[ "Change", "the", "bit", "depth", "of", "samples", ".", "The", "input", "array", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L46-L76
19,437
rochars/wavefile
dist/wavefile.js
intToInt_
function intToInt_(sample, args) { if (sample > 0) { sample = parseInt((sample / args.oldMax) * args.newMax, 10); } else { sample = parseInt((sample / args.oldMin) * args.newMin, 10); } return sample; }
javascript
function intToInt_(sample, args) { if (sample > 0) { sample = parseInt((sample / args.oldMax) * args.newMax, 10); } else { sample = parseInt((sample / args.oldMin) * args.newMin, 10); } return sample; }
[ "function", "intToInt_", "(", "sample", ",", "args", ")", "{", "if", "(", "sample", ">", "0", ")", "{", "sample", "=", "parseInt", "(", "(", "sample", "/", "args", ".", "oldMax", ")", "*", "args", ".", "newMax", ",", "10", ")", ";", "}", "else", ...
Change the bit depth from int to int. @param {number} sample The sample. @param {!Object<string, number>} args Data about the original and target bit depths. @return {number} @private
[ "Change", "the", "bit", "depth", "from", "int", "to", "int", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L85-L92
19,438
rochars/wavefile
dist/wavefile.js
floatToInt_
function floatToInt_(sample, args) { return parseInt( sample > 0 ? sample * args.newMax : sample * args.newMin, 10); }
javascript
function floatToInt_(sample, args) { return parseInt( sample > 0 ? sample * args.newMax : sample * args.newMin, 10); }
[ "function", "floatToInt_", "(", "sample", ",", "args", ")", "{", "return", "parseInt", "(", "sample", ">", "0", "?", "sample", "*", "args", ".", "newMax", ":", "sample", "*", "args", ".", "newMin", ",", "10", ")", ";", "}" ]
Change the bit depth from float to int. @param {number} sample The sample. @param {!Object<string, number>} args Data about the original and target bit depths. @return {number} @private
[ "Change", "the", "bit", "depth", "from", "float", "to", "int", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L101-L104
19,439
rochars/wavefile
dist/wavefile.js
getBitDepthFunction_
function getBitDepthFunction_(original, target) { /** @type {!Function} */ let func = function(x) {return x;}; if (original != target) { if (["32f", "64"].includes(original)) { if (["32f", "64"].includes(target)) { func = floatToFloat_; } else { func = floatToInt_; } } el...
javascript
function getBitDepthFunction_(original, target) { /** @type {!Function} */ let func = function(x) {return x;}; if (original != target) { if (["32f", "64"].includes(original)) { if (["32f", "64"].includes(target)) { func = floatToFloat_; } else { func = floatToInt_; } } el...
[ "function", "getBitDepthFunction_", "(", "original", ",", "target", ")", "{", "/** @type {!Function} */", "let", "func", "=", "function", "(", "x", ")", "{", "return", "x", ";", "}", ";", "if", "(", "original", "!=", "target", ")", "{", "if", "(", "[", ...
Return the function to change the bit depth of a sample. @param {string} original The original bit depth of the data. One of "8" ... "53", "32f", "64" @param {string} target The new bit depth of the data. One of "8" ... "53", "32f", "64" @return {!Function} @private
[ "Return", "the", "function", "to", "change", "the", "bit", "depth", "of", "a", "sample", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L137-L156
19,440
rochars/wavefile
dist/wavefile.js
decode
function decode(adpcmSamples, blockAlign=256) { /** @type {!Int16Array} */ let samples = new Int16Array(adpcmSamples.length * 2); /** @type {!Array<number>} */ let block = []; /** @type {number} */ let fileIndex = 0; for (let i=0; i<adpcmSamples.length; i++) { if (i % blockAlign == 0 && i != 0) { ...
javascript
function decode(adpcmSamples, blockAlign=256) { /** @type {!Int16Array} */ let samples = new Int16Array(adpcmSamples.length * 2); /** @type {!Array<number>} */ let block = []; /** @type {number} */ let fileIndex = 0; for (let i=0; i<adpcmSamples.length; i++) { if (i % blockAlign == 0 && i != 0) { ...
[ "function", "decode", "(", "adpcmSamples", ",", "blockAlign", "=", "256", ")", "{", "/** @type {!Int16Array} */", "let", "samples", "=", "new", "Int16Array", "(", "adpcmSamples", ".", "length", "*", "2", ")", ";", "/** @type {!Array<number>} */", "let", "block", ...
Decode IMA ADPCM samples into 16-bit PCM samples. @param {!Uint8Array} adpcmSamples A array of ADPCM samples. @param {number} blockAlign The block size. @return {!Int16Array}
[ "Decode", "IMA", "ADPCM", "samples", "into", "16", "-", "bit", "PCM", "samples", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L284-L300
19,441
rochars/wavefile
dist/wavefile.js
encodeBlock
function encodeBlock(block) { /** @type {!Array<number>} */ let adpcmSamples = blockHead_(block[0]); for (let i=3; i<block.length; i+=2) { /** @type {number} */ let sample2 = encodeSample_(block[i]); /** @type {number} */ let sample = encodeSample_(block[i + 1]); adpcmSamples.push((sample << 4...
javascript
function encodeBlock(block) { /** @type {!Array<number>} */ let adpcmSamples = blockHead_(block[0]); for (let i=3; i<block.length; i+=2) { /** @type {number} */ let sample2 = encodeSample_(block[i]); /** @type {number} */ let sample = encodeSample_(block[i + 1]); adpcmSamples.push((sample << 4...
[ "function", "encodeBlock", "(", "block", ")", "{", "/** @type {!Array<number>} */", "let", "adpcmSamples", "=", "blockHead_", "(", "block", "[", "0", "]", ")", ";", "for", "(", "let", "i", "=", "3", ";", "i", "<", "block", ".", "length", ";", "i", "+="...
Encode a block of 505 16-bit samples as 4-bit ADPCM samples. @param {!Array<number>} block A sample block of 505 samples. @return {!Array<number>}
[ "Encode", "a", "block", "of", "505", "16", "-", "bit", "samples", "as", "4", "-", "bit", "ADPCM", "samples", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L307-L321
19,442
rochars/wavefile
dist/wavefile.js
decodeBlock
function decodeBlock(block) { decoderPredicted_ = sign_((block[1] << 8) | block[0]); decoderIndex_ = block[2]; decoderStep_ = STEP_TABLE[decoderIndex_]; /** @type {!Array<number>} */ let result = [ decoderPredicted_, sign_((block[3] << 8) | block[2]) ]; for (let i=4; i<block.length; i++) { ...
javascript
function decodeBlock(block) { decoderPredicted_ = sign_((block[1] << 8) | block[0]); decoderIndex_ = block[2]; decoderStep_ = STEP_TABLE[decoderIndex_]; /** @type {!Array<number>} */ let result = [ decoderPredicted_, sign_((block[3] << 8) | block[2]) ]; for (let i=4; i<block.length; i++) { ...
[ "function", "decodeBlock", "(", "block", ")", "{", "decoderPredicted_", "=", "sign_", "(", "(", "block", "[", "1", "]", "<<", "8", ")", "|", "block", "[", "0", "]", ")", ";", "decoderIndex_", "=", "block", "[", "2", "]", ";", "decoderStep_", "=", "...
Decode a block of ADPCM samples into 16-bit PCM samples. @param {!Array<number>} block A adpcm sample block. @return {!Array<number>}
[ "Decode", "a", "block", "of", "ADPCM", "samples", "into", "16", "-", "bit", "PCM", "samples", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L328-L348
19,443
rochars/wavefile
dist/wavefile.js
encodeSample_
function encodeSample_(sample) { /** @type {number} */ let delta = sample - encoderPredicted_; /** @type {number} */ let value = 0; if (delta >= 0) { value = 0; } else { value = 8; delta = -delta; } /** @type {number} */ let step = STEP_TABLE[encoderIndex_]; /** @type {number} */ let d...
javascript
function encodeSample_(sample) { /** @type {number} */ let delta = sample - encoderPredicted_; /** @type {number} */ let value = 0; if (delta >= 0) { value = 0; } else { value = 8; delta = -delta; } /** @type {number} */ let step = STEP_TABLE[encoderIndex_]; /** @type {number} */ let d...
[ "function", "encodeSample_", "(", "sample", ")", "{", "/** @type {number} */", "let", "delta", "=", "sample", "-", "encoderPredicted_", ";", "/** @type {number} */", "let", "value", "=", "0", ";", "if", "(", "delta", ">=", "0", ")", "{", "value", "=", "0", ...
Compress a 16-bit PCM sample into a 4-bit ADPCM sample. @param {number} sample The sample. @return {number} @private
[ "Compress", "a", "16", "-", "bit", "PCM", "sample", "into", "a", "4", "-", "bit", "ADPCM", "sample", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L366-L399
19,444
rochars/wavefile
dist/wavefile.js
decodeSample_
function decodeSample_(nibble) { /** @type {number} */ let difference = 0; if (nibble & 4) { difference += decoderStep_; } if (nibble & 2) { difference += decoderStep_ >> 1; } if (nibble & 1) { difference += decoderStep_ >> 2; } difference += decoderStep_ >> 3; if (nibble & 8) { diff...
javascript
function decodeSample_(nibble) { /** @type {number} */ let difference = 0; if (nibble & 4) { difference += decoderStep_; } if (nibble & 2) { difference += decoderStep_ >> 1; } if (nibble & 1) { difference += decoderStep_ >> 2; } difference += decoderStep_ >> 3; if (nibble & 8) { diff...
[ "function", "decodeSample_", "(", "nibble", ")", "{", "/** @type {number} */", "let", "difference", "=", "0", ";", "if", "(", "nibble", "&", "4", ")", "{", "difference", "+=", "decoderStep_", ";", "}", "if", "(", "nibble", "&", "2", ")", "{", "difference...
Decode a 4-bit ADPCM sample into a 16-bit PCM sample. @param {number} nibble A 4-bit adpcm sample. @return {number} @private
[ "Decode", "a", "4", "-", "bit", "ADPCM", "sample", "into", "a", "16", "-", "bit", "PCM", "sample", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L433-L457
19,445
rochars/wavefile
dist/wavefile.js
blockHead_
function blockHead_(sample) { encodeSample_(sample); /** @type {!Array<number>} */ let adpcmSamples = []; adpcmSamples.push(sample & 0xFF); adpcmSamples.push((sample >> 8) & 0xFF); adpcmSamples.push(encoderIndex_); adpcmSamples.push(0); return adpcmSamples; }
javascript
function blockHead_(sample) { encodeSample_(sample); /** @type {!Array<number>} */ let adpcmSamples = []; adpcmSamples.push(sample & 0xFF); adpcmSamples.push((sample >> 8) & 0xFF); adpcmSamples.push(encoderIndex_); adpcmSamples.push(0); return adpcmSamples; }
[ "function", "blockHead_", "(", "sample", ")", "{", "encodeSample_", "(", "sample", ")", ";", "/** @type {!Array<number>} */", "let", "adpcmSamples", "=", "[", "]", ";", "adpcmSamples", ".", "push", "(", "sample", "&", "0xFF", ")", ";", "adpcmSamples", ".", "...
Return the head of a ADPCM sample block. @param {number} sample The first sample of the block. @return {!Array<number>} @private
[ "Return", "the", "head", "of", "a", "ADPCM", "sample", "block", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L480-L489
19,446
rochars/wavefile
dist/wavefile.js
encodeSample
function encodeSample(sample) { /** @type {number} */ let compandedValue; sample = (sample ==-32768) ? -32767 : sample; /** @type {number} */ let sign = ((~sample) >> 8) & 0x80; if (!sign) { sample = sample * -1; } if (sample > 32635) { sample = 32635; } if (sample >= 256) { /** @ty...
javascript
function encodeSample(sample) { /** @type {number} */ let compandedValue; sample = (sample ==-32768) ? -32767 : sample; /** @type {number} */ let sign = ((~sample) >> 8) & 0x80; if (!sign) { sample = sample * -1; } if (sample > 32635) { sample = 32635; } if (sample >= 256) { /** @ty...
[ "function", "encodeSample", "(", "sample", ")", "{", "/** @type {number} */", "let", "compandedValue", ";", "sample", "=", "(", "sample", "==", "-", "32768", ")", "?", "-", "32767", ":", "sample", ";", "/** @type {number} */", "let", "sign", "=", "(", "(", ...
Encode a 16-bit linear PCM sample as 8-bit A-Law. @param {number} sample A 16-bit PCM sample @return {number}
[ "Encode", "a", "16", "-", "bit", "linear", "PCM", "sample", "as", "8", "-", "bit", "A", "-", "Law", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L537-L559
19,447
rochars/wavefile
dist/wavefile.js
decodeSample
function decodeSample(aLawSample) { /** @type {number} */ let sign = 0; aLawSample ^= 0x55; if (aLawSample & 0x80) { aLawSample &= ~(1 << 7); sign = -1; } /** @type {number} */ let position = ((aLawSample & 0xF0) >> 4) + 4; /** @type {number} */ let decoded = 0; if (position != 4) { deco...
javascript
function decodeSample(aLawSample) { /** @type {number} */ let sign = 0; aLawSample ^= 0x55; if (aLawSample & 0x80) { aLawSample &= ~(1 << 7); sign = -1; } /** @type {number} */ let position = ((aLawSample & 0xF0) >> 4) + 4; /** @type {number} */ let decoded = 0; if (position != 4) { deco...
[ "function", "decodeSample", "(", "aLawSample", ")", "{", "/** @type {number} */", "let", "sign", "=", "0", ";", "aLawSample", "^=", "0x55", ";", "if", "(", "aLawSample", "&", "0x80", ")", "{", "aLawSample", "&=", "~", "(", "1", "<<", "7", ")", ";", "si...
Decode a 8-bit A-Law sample as 16-bit PCM. @param {number} aLawSample The 8-bit A-Law sample @return {number}
[ "Decode", "a", "8", "-", "bit", "A", "-", "Law", "sample", "as", "16", "-", "bit", "PCM", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L566-L587
19,448
rochars/wavefile
dist/wavefile.js
decode$1
function decode$1(samples) { /** @type {!Int16Array} */ let pcmSamples = new Int16Array(samples.length); for (let i=0; i<samples.length; i++) { pcmSamples[i] = decodeSample(samples[i]); } return pcmSamples; }
javascript
function decode$1(samples) { /** @type {!Int16Array} */ let pcmSamples = new Int16Array(samples.length); for (let i=0; i<samples.length; i++) { pcmSamples[i] = decodeSample(samples[i]); } return pcmSamples; }
[ "function", "decode$1", "(", "samples", ")", "{", "/** @type {!Int16Array} */", "let", "pcmSamples", "=", "new", "Int16Array", "(", "samples", ".", "length", ")", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "samples", ".", "length", ";", "i", ...
Decode 8-bit A-Law samples into 16-bit linear PCM samples. @param {!Uint8Array} samples A array of 8-bit A-Law samples. @return {!Int16Array}
[ "Decode", "8", "-", "bit", "A", "-", "Law", "samples", "into", "16", "-", "bit", "linear", "PCM", "samples", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L608-L615
19,449
rochars/wavefile
dist/wavefile.js
encodeSample$1
function encodeSample$1(sample) { /** @type {number} */ let sign; /** @type {number} */ let exponent; /** @type {number} */ let mantissa; /** @type {number} */ let muLawSample; /** get the sample into sign-magnitude **/ sign = (sample >> 8) & 0x80; if (sign != 0) sample = -sample; if (sample > C...
javascript
function encodeSample$1(sample) { /** @type {number} */ let sign; /** @type {number} */ let exponent; /** @type {number} */ let mantissa; /** @type {number} */ let muLawSample; /** get the sample into sign-magnitude **/ sign = (sample >> 8) & 0x80; if (sign != 0) sample = -sample; if (sample > C...
[ "function", "encodeSample$1", "(", "sample", ")", "{", "/** @type {number} */", "let", "sign", ";", "/** @type {number} */", "let", "exponent", ";", "/** @type {number} */", "let", "mantissa", ";", "/** @type {number} */", "let", "muLawSample", ";", "/** get the sample in...
Encode a 16-bit linear PCM sample as 8-bit mu-Law. @param {number} sample A 16-bit PCM sample @return {number}
[ "Encode", "a", "16", "-", "bit", "linear", "PCM", "sample", "as", "8", "-", "bit", "mu", "-", "Law", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L692-L712
19,450
rochars/wavefile
dist/wavefile.js
decodeSample$1
function decodeSample$1(muLawSample) { /** @type {number} */ let sign; /** @type {number} */ let exponent; /** @type {number} */ let mantissa; /** @type {number} */ let sample; muLawSample = ~muLawSample; sign = (muLawSample & 0x80); exponent = (muLawSample >> 4) & 0x07; mantissa = muLawSample &...
javascript
function decodeSample$1(muLawSample) { /** @type {number} */ let sign; /** @type {number} */ let exponent; /** @type {number} */ let mantissa; /** @type {number} */ let sample; muLawSample = ~muLawSample; sign = (muLawSample & 0x80); exponent = (muLawSample >> 4) & 0x07; mantissa = muLawSample &...
[ "function", "decodeSample$1", "(", "muLawSample", ")", "{", "/** @type {number} */", "let", "sign", ";", "/** @type {number} */", "let", "exponent", ";", "/** @type {number} */", "let", "mantissa", ";", "/** @type {number} */", "let", "sample", ";", "muLawSample", "=", ...
Decode a 8-bit mu-Law sample as 16-bit PCM. @param {number} muLawSample The 8-bit mu-Law sample @return {number}
[ "Decode", "a", "8", "-", "bit", "mu", "-", "Law", "sample", "as", "16", "-", "bit", "PCM", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L719-L735
19,451
rochars/wavefile
dist/wavefile.js
swap
function swap(bytes, offset, index) { offset--; for(let x = 0; x < offset; x++) { /** @type {*} */ let theByte = bytes[index + x]; bytes[index + x] = bytes[index + offset]; bytes[index + offset] = theByte; offset--; } }
javascript
function swap(bytes, offset, index) { offset--; for(let x = 0; x < offset; x++) { /** @type {*} */ let theByte = bytes[index + x]; bytes[index + x] = bytes[index + offset]; bytes[index + offset] = theByte; offset--; } }
[ "function", "swap", "(", "bytes", ",", "offset", ",", "index", ")", "{", "offset", "--", ";", "for", "(", "let", "x", "=", "0", ";", "x", "<", "offset", ";", "x", "++", ")", "{", "/** @type {*} */", "let", "theByte", "=", "bytes", "[", "index", "...
Swap the byte order of a value in a buffer. The buffer is modified in place. @param {!Array|!Uint8Array} bytes The bytes. @param {number} offset The byte offset. @param {number} index The start index. @private
[ "Swap", "the", "byte", "order", "of", "a", "value", "in", "a", "buffer", ".", "The", "buffer", "is", "modified", "in", "place", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L915-L924
19,452
rochars/wavefile
dist/wavefile.js
pack
function pack(str, buffer, index=0) { for (let i = 0, len = str.length; i < len; i++) { /** @type {number} */ let codePoint = str.codePointAt(i); if (codePoint < 128) { buffer[index] = codePoint; index++; } else { /** @type {number} */ let count = 0; /** @type {number} */...
javascript
function pack(str, buffer, index=0) { for (let i = 0, len = str.length; i < len; i++) { /** @type {number} */ let codePoint = str.codePointAt(i); if (codePoint < 128) { buffer[index] = codePoint; index++; } else { /** @type {number} */ let count = 0; /** @type {number} */...
[ "function", "pack", "(", "str", ",", "buffer", ",", "index", "=", "0", ")", "{", "for", "(", "let", "i", "=", "0", ",", "len", "=", "str", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "/** @type {number} */", "let", "codePoint",...
Write a string of UTF-8 characters to a byte buffer. @see https://encoding.spec.whatwg.org/#utf-8-encoder @param {string} str The string to pack. @param {!Uint8Array|!Array<number>} buffer The buffer to pack the string to. @param {number=} index The buffer index to start writing. @return {number} The next index to writ...
[ "Write", "a", "string", "of", "UTF", "-", "8", "characters", "to", "a", "byte", "buffer", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L1040-L1073
19,453
rochars/wavefile
dist/wavefile.js
unpackString
function unpackString(buffer, index=0, end=buffer.length) { return unpack(buffer, index, end); }
javascript
function unpackString(buffer, index=0, end=buffer.length) { return unpack(buffer, index, end); }
[ "function", "unpackString", "(", "buffer", ",", "index", "=", "0", ",", "end", "=", "buffer", ".", "length", ")", "{", "return", "unpack", "(", "buffer", ",", "index", ",", "end", ")", ";", "}" ]
Read a string of UTF-8 characters from a byte buffer. @param {!Uint8Array|!Array<number>} buffer A byte buffer. @param {number=} index The buffer index to start reading. @param {number=} end The buffer index to stop reading, non inclusive. Assumes buffer length if undefined. @return {string}
[ "Read", "a", "string", "of", "UTF", "-", "8", "characters", "from", "a", "byte", "buffer", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L1742-L1744
19,454
rochars/wavefile
dist/wavefile.js
unpackArrayTo
function unpackArrayTo( buffer, theType, output, start=0, end=buffer.length, safe=false) { theType = theType || {}; /** @type {NumberBuffer} */ let packer = new NumberBuffer(theType.bits, theType.fp, theType.signed); /** @type {number} */ let offset = packer.offset; // getUnpackLen_ will either fix the ...
javascript
function unpackArrayTo( buffer, theType, output, start=0, end=buffer.length, safe=false) { theType = theType || {}; /** @type {NumberBuffer} */ let packer = new NumberBuffer(theType.bits, theType.fp, theType.signed); /** @type {number} */ let offset = packer.offset; // getUnpackLen_ will either fix the ...
[ "function", "unpackArrayTo", "(", "buffer", ",", "theType", ",", "output", ",", "start", "=", "0", ",", "end", "=", "buffer", ".", "length", ",", "safe", "=", "false", ")", "{", "theType", "=", "theType", "||", "{", "}", ";", "/** @type {NumberBuffer} */...
Unpack a array of numbers to a typed array. All other unpacking functions are interfaces to this function. @param {!Uint8Array|!Array<number>} buffer The byte buffer. @param {!Object} theType The type definition. @param {!TypedArray|!Array<number>} output The output array. @param {number=} start The buffer index to sta...
[ "Unpack", "a", "array", "of", "numbers", "to", "a", "typed", "array", ".", "All", "other", "unpacking", "functions", "are", "interfaces", "to", "this", "function", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L1822-L1849
19,455
rochars/wavefile
dist/wavefile.js
packTo
function packTo(value, theType, buffer, index=0) { return packArrayTo([value], theType, buffer, index); }
javascript
function packTo(value, theType, buffer, index=0) { return packArrayTo([value], theType, buffer, index); }
[ "function", "packTo", "(", "value", ",", "theType", ",", "buffer", ",", "index", "=", "0", ")", "{", "return", "packArrayTo", "(", "[", "value", "]", ",", "theType", ",", "buffer", ",", "index", ")", ";", "}" ]
Pack a number to a byte buffer. @param {number} value The value. @param {!Object} theType The type definition. @param {!Uint8Array|!Array<number>} buffer The output buffer. @param {number=} index The buffer index to write. Assumes 0 if undefined. @return {number} The next index to write. @throws {Error} If the type def...
[ "Pack", "a", "number", "to", "a", "byte", "buffer", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L1861-L1863
19,456
rochars/wavefile
dist/wavefile.js
unpackArray
function unpackArray( buffer, theType, start=0, end=buffer.length, safe=false) { /** @type {!Array<number>} */ let output = []; unpackArrayTo(buffer, theType, output, start, end, safe); return output; }
javascript
function unpackArray( buffer, theType, start=0, end=buffer.length, safe=false) { /** @type {!Array<number>} */ let output = []; unpackArrayTo(buffer, theType, output, start, end, safe); return output; }
[ "function", "unpackArray", "(", "buffer", ",", "theType", ",", "start", "=", "0", ",", "end", "=", "buffer", ".", "length", ",", "safe", "=", "false", ")", "{", "/** @type {!Array<number>} */", "let", "output", "=", "[", "]", ";", "unpackArrayTo", "(", "...
Unpack an array of numbers from a byte buffer. @param {!Uint8Array|!Array<number>} buffer The byte buffer. @param {!Object} theType The type definition. @param {number=} start The buffer index to start reading. Assumes zero if undefined. @param {number=} end The buffer index to stop reading. Assumes the buffer length i...
[ "Unpack", "an", "array", "of", "numbers", "from", "a", "byte", "buffer", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L1896-L1902
19,457
rochars/wavefile
dist/wavefile.js
unpack$1
function unpack$1(buffer, theType, index=0) { return unpackArray( buffer, theType, index, index + Math.ceil(theType.bits / 8), true)[0]; }
javascript
function unpack$1(buffer, theType, index=0) { return unpackArray( buffer, theType, index, index + Math.ceil(theType.bits / 8), true)[0]; }
[ "function", "unpack$1", "(", "buffer", ",", "theType", ",", "index", "=", "0", ")", "{", "return", "unpackArray", "(", "buffer", ",", "theType", ",", "index", ",", "index", "+", "Math", ".", "ceil", "(", "theType", ".", "bits", "/", "8", ")", ",", ...
Unpack a number from a byte buffer. @param {!Uint8Array|!Array<number>} buffer The byte buffer. @param {!Object} theType The type definition. @param {number=} index The buffer index to read. Assumes zero if undefined. @return {number} @throws {Error} If the type definition is not valid @throws {Error} On bad buffer len...
[ "Unpack", "a", "number", "from", "a", "byte", "buffer", "." ]
fb9d9c7adb38f6a046857cef24e3651e8a849102
https://github.com/rochars/wavefile/blob/fb9d9c7adb38f6a046857cef24e3651e8a849102/dist/wavefile.js#L1914-L1917
19,458
yatskevich/grunt-bower-task
tasks/lib/layouts_manager.js
function(layout, fail) { if (_.isFunction(layout)) { return layout; } if (!_.isString(layout)) { fail('Layout should be specified by name or as a function'); } if (_(defaultLayouts).has(layout)) { return defaultLayouts[layout]; } fail('The following named layouts are sup...
javascript
function(layout, fail) { if (_.isFunction(layout)) { return layout; } if (!_.isString(layout)) { fail('Layout should be specified by name or as a function'); } if (_(defaultLayouts).has(layout)) { return defaultLayouts[layout]; } fail('The following named layouts are sup...
[ "function", "(", "layout", ",", "fail", ")", "{", "if", "(", "_", ".", "isFunction", "(", "layout", ")", ")", "{", "return", "layout", ";", "}", "if", "(", "!", "_", ".", "isString", "(", "layout", ")", ")", "{", "fail", "(", "'Layout should be spe...
Resolves named layouts, returns functions as is @param {string | Function} layout name or layout function @param { Function } fail handler @returns {Function} layout function
[ "Resolves", "named", "layouts", "returns", "functions", "as", "is" ]
76525ba9e45f097f9a07845b06c03ae5c8eb79cb
https://github.com/yatskevich/grunt-bower-task/blob/76525ba9e45f097f9a07845b06c03ae5c8eb79cb/tasks/lib/layouts_manager.js#L32-L46
19,459
dollarshaveclub/ember-uni-form
addon/utils/pathify.js
pathifyModel
function pathifyModel (model, store, prefix) { let result = [] if (prefix) result.push(prefix) if (get(model, '_internalModel.modelName') === 'uni-form') { const propPath = propertyPath('payload', prefix) if (model.get('payload') instanceof DS.Model) { return result.concat(pathifyModel(model.get('p...
javascript
function pathifyModel (model, store, prefix) { let result = [] if (prefix) result.push(prefix) if (get(model, '_internalModel.modelName') === 'uni-form') { const propPath = propertyPath('payload', prefix) if (model.get('payload') instanceof DS.Model) { return result.concat(pathifyModel(model.get('p...
[ "function", "pathifyModel", "(", "model", ",", "store", ",", "prefix", ")", "{", "let", "result", "=", "[", "]", "if", "(", "prefix", ")", "result", ".", "push", "(", "prefix", ")", "if", "(", "get", "(", "model", ",", "'_internalModel.modelName'", ")"...
Belt-and-suspenders approach gets field paths from both the ultimate payload and the model data structure in memory.
[ "Belt", "-", "and", "-", "suspenders", "approach", "gets", "field", "paths", "from", "both", "the", "ultimate", "payload", "and", "the", "model", "data", "structure", "in", "memory", "." ]
47ae76aa0bddb250fb41f572caf2ca351a87a4f3
https://github.com/dollarshaveclub/ember-uni-form/blob/47ae76aa0bddb250fb41f572caf2ca351a87a4f3/addon/utils/pathify.js#L36-L75
19,460
zalando/dress-code
docs/demo/assets/scripts/fabricator.js
function () { options.menu = !fabricator.dom.root.classList.contains('f-menu-active'); fabricator.dom.root.classList.toggle('f-menu-active'); if (fabricator.test.sessionStorage) { sessionStorage.setItem('fabricator', JSON.stringify(options)); } }
javascript
function () { options.menu = !fabricator.dom.root.classList.contains('f-menu-active'); fabricator.dom.root.classList.toggle('f-menu-active'); if (fabricator.test.sessionStorage) { sessionStorage.setItem('fabricator', JSON.stringify(options)); } }
[ "function", "(", ")", "{", "options", ".", "menu", "=", "!", "fabricator", ".", "dom", ".", "root", ".", "classList", ".", "contains", "(", "'f-menu-active'", ")", ";", "fabricator", ".", "dom", ".", "root", ".", "classList", ".", "toggle", "(", "'f-me...
toggle classes on certain elements
[ "toggle", "classes", "on", "certain", "elements" ]
041f6c4bf26a1ee630d2ef6bdef09e7c581b452c
https://github.com/zalando/dress-code/blob/041f6c4bf26a1ee630d2ef6bdef09e7c581b452c/docs/demo/assets/scripts/fabricator.js#L179-L186
19,461
zalando/dress-code
docs/demo/assets/scripts/fabricator.js
function (list) { if (!list.matches) { root.classList.remove('f-menu-active'); } else { if (fabricator.getOptions().menu) { root.classList.add('f-menu-active'); } else { root.classList.remove('f-menu-active'); } } }
javascript
function (list) { if (!list.matches) { root.classList.remove('f-menu-active'); } else { if (fabricator.getOptions().menu) { root.classList.add('f-menu-active'); } else { root.classList.remove('f-menu-active'); } } }
[ "function", "(", "list", ")", "{", "if", "(", "!", "list", ".", "matches", ")", "{", "root", ".", "classList", ".", "remove", "(", "'f-menu-active'", ")", ";", "}", "else", "{", "if", "(", "fabricator", ".", "getOptions", "(", ")", ".", "menu", ")"...
if small screen
[ "if", "small", "screen" ]
041f6c4bf26a1ee630d2ef6bdef09e7c581b452c
https://github.com/zalando/dress-code/blob/041f6c4bf26a1ee630d2ef6bdef09e7c581b452c/docs/demo/assets/scripts/fabricator.js#L343-L353
19,462
zalando/dress-code
gulp/util/sassdoc.js
getColors
function getColors(rawData) { // Regular expression matching colors variables naming pattern var REGEX = /^dc-(.*?)[0-9]+$/; var content = rawData .filter((item) => { var group = item.group[0]; return group === 'colors' && item.context.type === 'variable' ...
javascript
function getColors(rawData) { // Regular expression matching colors variables naming pattern var REGEX = /^dc-(.*?)[0-9]+$/; var content = rawData .filter((item) => { var group = item.group[0]; return group === 'colors' && item.context.type === 'variable' ...
[ "function", "getColors", "(", "rawData", ")", "{", "// Regular expression matching colors variables naming pattern", "var", "REGEX", "=", "/", "^dc-(.*?)[0-9]+$", "/", ";", "var", "content", "=", "rawData", ".", "filter", "(", "(", "item", ")", "=>", "{", "var", ...
Get colors view model from sassdoc raw data @param {Array} rawData - sassdoc items @return {Object}
[ "Get", "colors", "view", "model", "from", "sassdoc", "raw", "data" ]
041f6c4bf26a1ee630d2ef6bdef09e7c581b452c
https://github.com/zalando/dress-code/blob/041f6c4bf26a1ee630d2ef6bdef09e7c581b452c/gulp/util/sassdoc.js#L9-L37
19,463
zalando/dress-code
gulp/util/sassdoc.js
getSassReference
function getSassReference(rawData) { // group sassdoc items (variables, mixins, functions, etc.) by @group var content = _.groupBy(rawData, (item) => item.group[0]); Object.keys(content).forEach((group) => { content[group] = content[group].map((item) => { // boolean flag for deprecated ...
javascript
function getSassReference(rawData) { // group sassdoc items (variables, mixins, functions, etc.) by @group var content = _.groupBy(rawData, (item) => item.group[0]); Object.keys(content).forEach((group) => { content[group] = content[group].map((item) => { // boolean flag for deprecated ...
[ "function", "getSassReference", "(", "rawData", ")", "{", "// group sassdoc items (variables, mixins, functions, etc.) by @group", "var", "content", "=", "_", ".", "groupBy", "(", "rawData", ",", "(", "item", ")", "=>", "item", ".", "group", "[", "0", "]", ")", ...
Get sass reference view model from sassdoc raw data @param {Array} rawData - sassdoc items @return {Object}
[ "Get", "sass", "reference", "view", "model", "from", "sassdoc", "raw", "data" ]
041f6c4bf26a1ee630d2ef6bdef09e7c581b452c
https://github.com/zalando/dress-code/blob/041f6c4bf26a1ee630d2ef6bdef09e7c581b452c/gulp/util/sassdoc.js#L45-L61
19,464
apache/cordova-serve
src/browser.js
getErrorMessage
function getErrorMessage (err, target, defaultMsg) { var errMessage; if (err) { errMessage = err.toString(); } else { errMessage = defaultMsg; } return errMessage.replace('%target%', target); }
javascript
function getErrorMessage (err, target, defaultMsg) { var errMessage; if (err) { errMessage = err.toString(); } else { errMessage = defaultMsg; } return errMessage.replace('%target%', target); }
[ "function", "getErrorMessage", "(", "err", ",", "target", ",", "defaultMsg", ")", "{", "var", "errMessage", ";", "if", "(", "err", ")", "{", "errMessage", "=", "err", ".", "toString", "(", ")", ";", "}", "else", "{", "errMessage", "=", "defaultMsg", ";...
err might be null, in which case defaultMsg is used. target MUST be defined or an error is thrown.
[ "err", "might", "be", "null", "in", "which", "case", "defaultMsg", "is", "used", ".", "target", "MUST", "be", "defined", "or", "an", "error", "is", "thrown", "." ]
18ace76f16667ebf2ec5bc2125c100a199fb8f44
https://github.com/apache/cordova-serve/blob/18ace76f16667ebf2ec5bc2125c100a199fb8f44/src/browser.js#L145-L153
19,465
bitcoinjs/merkle-lib
index.js
merkle
function merkle (values, digestFn) { if (!Array.isArray(values)) throw TypeError('Expected values Array') if (typeof digestFn !== 'function') throw TypeError('Expected digest Function') if (values.length === 1) return values.concat() var levels = [values] var level = values do { level = _derive(level,...
javascript
function merkle (values, digestFn) { if (!Array.isArray(values)) throw TypeError('Expected values Array') if (typeof digestFn !== 'function') throw TypeError('Expected digest Function') if (values.length === 1) return values.concat() var levels = [values] var level = values do { level = _derive(level,...
[ "function", "merkle", "(", "values", ",", "digestFn", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "values", ")", ")", "throw", "TypeError", "(", "'Expected values Array'", ")", "if", "(", "typeof", "digestFn", "!==", "'function'", ")", "throw",...
returns the merkle tree
[ "returns", "the", "merkle", "tree" ]
e233148537006fc45daeacebcfc5fd0bdcc1625f
https://github.com/bitcoinjs/merkle-lib/blob/e233148537006fc45daeacebcfc5fd0bdcc1625f/index.js#L18-L32
19,466
almost/through2-concurrent
through2-concurrent.js
callOnFinish
function callOnFinish (original) { return function (callback) { if (concurrent === 0) { original.call(this, callback); } else { pendingFinish = original.bind(this, callback); } } }
javascript
function callOnFinish (original) { return function (callback) { if (concurrent === 0) { original.call(this, callback); } else { pendingFinish = original.bind(this, callback); } } }
[ "function", "callOnFinish", "(", "original", ")", "{", "return", "function", "(", "callback", ")", "{", "if", "(", "concurrent", "===", "0", ")", "{", "original", ".", "call", "(", "this", ",", "callback", ")", ";", "}", "else", "{", "pendingFinish", "...
Flush is always called only after Final has finished to ensure that data from Final gets processed, so we only need one pending callback at a time
[ "Flush", "is", "always", "called", "only", "after", "Final", "has", "finished", "to", "ensure", "that", "data", "from", "Final", "gets", "processed", "so", "we", "only", "need", "one", "pending", "callback", "at", "a", "time" ]
ce8b0dc6c00e2a5c12b82e280f5e1972ed0c6e4e
https://github.com/almost/through2-concurrent/blob/ce8b0dc6c00e2a5c12b82e280f5e1972ed0c6e4e/through2-concurrent.js#L75-L83
19,467
jasonbellamy/git-label
dist/lib/package.js
findPackages
function findPackages(path) { return new Promise(function (resolve, reject) { (0, _glob.glob)(path, function (err, res) { if (err) { reject(err); } resolve(res.filter(function (file) { return file.endsWith('.json'); })); }); }); }
javascript
function findPackages(path) { return new Promise(function (resolve, reject) { (0, _glob.glob)(path, function (err, res) { if (err) { reject(err); } resolve(res.filter(function (file) { return file.endsWith('.json'); })); }); }); }
[ "function", "findPackages", "(", "path", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "(", "0", ",", "_glob", ".", "glob", ")", "(", "path", ",", "function", "(", "err", ",", "res", ")", "{", "if",...
Takes a glob and returns a list of label package files @name findPackages @function @param {String} path a globbing pattern @return {Promise} array containing any found label packages
[ "Takes", "a", "glob", "and", "returns", "a", "list", "of", "label", "package", "files" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/lib/package.js#L22-L33
19,468
jasonbellamy/git-label
dist/lib/package.js
readPackages
function readPackages() { var packages = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; return Promise.all(packages.map(readPackage)).then(function (labels) { return labels.reduce(function (prev, curr) { return prev.concat(curr); }); }); }
javascript
function readPackages() { var packages = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0]; return Promise.all(packages.map(readPackage)).then(function (labels) { return labels.reduce(function (prev, curr) { return prev.concat(curr); }); }); }
[ "function", "readPackages", "(", ")", "{", "var", "packages", "=", "arguments", ".", "length", "<=", "0", "||", "arguments", "[", "0", "]", "===", "undefined", "?", "[", "]", ":", "arguments", "[", "0", "]", ";", "return", "Promise", ".", "all", "(",...
Processes a list of packages and concatenates their contents into a single object. @name readPackages @function @param {Array} packages array of paths to package files @return {Promise}
[ "Processes", "a", "list", "of", "packages", "and", "concatenates", "their", "contents", "into", "a", "single", "object", "." ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/lib/package.js#L43-L51
19,469
jasonbellamy/git-label
dist/lib/request.js
requestPromisfied
function requestPromisfied(options) { return new Promise(function (resolve, reject) { (0, _request2.default)(options, function (err, res) { if (err) { reject(err); } resolve(res.body); }); }); }
javascript
function requestPromisfied(options) { return new Promise(function (resolve, reject) { (0, _request2.default)(options, function (err, res) { if (err) { reject(err); } resolve(res.body); }); }); }
[ "function", "requestPromisfied", "(", "options", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "(", "0", ",", "_request2", ".", "default", ")", "(", "options", ",", "function", "(", "err", ",", "res", "...
Creates a "Promisfied" HTTPRequest object @name requestPromisfied @function @param {Object} options request options: https://github.com/request/request) @return {Promise}
[ "Creates", "a", "Promisfied", "HTTPRequest", "object" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/lib/request.js#L22-L31
19,470
jasonbellamy/git-label
dist/lib/config.js
configure
function configure(_ref) { var api = _ref.api; var token = _ref.token; var repo = _ref.repo; return { api: api, repo: "repos/" + repo, token: token }; }
javascript
function configure(_ref) { var api = _ref.api; var token = _ref.token; var repo = _ref.repo; return { api: api, repo: "repos/" + repo, token: token }; }
[ "function", "configure", "(", "_ref", ")", "{", "var", "api", "=", "_ref", ".", "api", ";", "var", "token", "=", "_ref", ".", "token", ";", "var", "repo", "=", "_ref", ".", "repo", ";", "return", "{", "api", ":", "api", ",", "repo", ":", "\"repos...
Configures and returns an object with the git server settings @name configure @function @param {Object} server the server configuration object @param {String} server.api the api endpoint to connect to @param {String} server.token the api token to use @param {String} server.repo the git repo to manipulate @return {Obje...
[ "Configures", "and", "returns", "an", "object", "with", "the", "git", "server", "settings" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/lib/config.js#L18-L28
19,471
jasonbellamy/git-label
dist/index.js
add
function add(server, labels) { return (0, _label.createLabels)((0, _config.configure)(server), labels).then(_handlers.createSuccessHandler).catch(_handlers.errorHandler); }
javascript
function add(server, labels) { return (0, _label.createLabels)((0, _config.configure)(server), labels).then(_handlers.createSuccessHandler).catch(_handlers.errorHandler); }
[ "function", "add", "(", "server", ",", "labels", ")", "{", "return", "(", "0", ",", "_label", ".", "createLabels", ")", "(", "(", "0", ",", "_config", ".", "configure", ")", "(", "server", ")", ",", "labels", ")", ".", "then", "(", "_handlers", "."...
Automates and simplifies the creation of labels for GitHub repositories @name add @function @param {Object} server the server configuration object @param {String} server.api the api endpoint to connect to @param {String} server.token the api token to use @param {String} server.repo the git repo to manipulate @param {A...
[ "Automates", "and", "simplifies", "the", "creation", "of", "labels", "for", "GitHub", "repositories" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/index.js#L30-L32
19,472
jasonbellamy/git-label
dist/index.js
remove
function remove(server, labels) { return (0, _label.deleteLabels)((0, _config.configure)(server), labels).then(_handlers.deleteSuccessHandler).catch(_handlers.errorHandler); }
javascript
function remove(server, labels) { return (0, _label.deleteLabels)((0, _config.configure)(server), labels).then(_handlers.deleteSuccessHandler).catch(_handlers.errorHandler); }
[ "function", "remove", "(", "server", ",", "labels", ")", "{", "return", "(", "0", ",", "_label", ".", "deleteLabels", ")", "(", "(", "0", ",", "_config", ".", "configure", ")", "(", "server", ")", ",", "labels", ")", ".", "then", "(", "_handlers", ...
Removes all of the specified labels associated with the GitHub repo @name remove @function @param {Object} server the server configuration object @param {String} server.api the api endpoint to connect to @param {String} server.token the api token to use @param {String} server.repo the git repo to manipulate @param {Ar...
[ "Removes", "all", "of", "the", "specified", "labels", "associated", "with", "the", "GitHub", "repo" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/index.js#L46-L48
19,473
jasonbellamy/git-label
dist/lib/label.js
createLabel
function createLabel(_ref, name, color) { var api = _ref.api; var token = _ref.token; var repo = _ref.repo; return (0, _request2.default)({ headers: { 'User-Agent': 'request', 'Authorization': 'token ' + token }, url: api + '/' + repo + '/labels', form: JSON.stringify({ name: name, color: color }),...
javascript
function createLabel(_ref, name, color) { var api = _ref.api; var token = _ref.token; var repo = _ref.repo; return (0, _request2.default)({ headers: { 'User-Agent': 'request', 'Authorization': 'token ' + token }, url: api + '/' + repo + '/labels', form: JSON.stringify({ name: name, color: color }),...
[ "function", "createLabel", "(", "_ref", ",", "name", ",", "color", ")", "{", "var", "api", "=", "_ref", ".", "api", ";", "var", "token", "=", "_ref", ".", "token", ";", "var", "repo", "=", "_ref", ".", "repo", ";", "return", "(", "0", ",", "_requ...
Sends a request to GitHub to create a label @name createLabel @function @param {Object} server the server configuration object @param {String} server.api the api endpoint to connect to @param {String} server.token the api token to use @param {String} server.repo the git repo to manipulate @param {String} name the name...
[ "Sends", "a", "request", "to", "GitHub", "to", "create", "a", "label" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/lib/label.js#L32-L44
19,474
jasonbellamy/git-label
dist/lib/label.js
deleteLabel
function deleteLabel(_ref2, name) { var api = _ref2.api; var token = _ref2.token; var repo = _ref2.repo; return (0, _request2.default)({ headers: { 'User-Agent': 'request', 'Authorization': 'token ' + token }, url: api + '/' + repo + '/labels/' + name, method: 'DELETE', json: true }); }
javascript
function deleteLabel(_ref2, name) { var api = _ref2.api; var token = _ref2.token; var repo = _ref2.repo; return (0, _request2.default)({ headers: { 'User-Agent': 'request', 'Authorization': 'token ' + token }, url: api + '/' + repo + '/labels/' + name, method: 'DELETE', json: true }); }
[ "function", "deleteLabel", "(", "_ref2", ",", "name", ")", "{", "var", "api", "=", "_ref2", ".", "api", ";", "var", "token", "=", "_ref2", ".", "token", ";", "var", "repo", "=", "_ref2", ".", "repo", ";", "return", "(", "0", ",", "_request2", ".", ...
Sends a request to GitHub to delete a label @name deleteLabel @function @param {Object} server the server configuration object @param {String} server.api the api endpoint to connect to @param {String} server.token the api token to use @param {String} server.repo the git repo to manipulate @param {String} name the name...
[ "Sends", "a", "request", "to", "GitHub", "to", "delete", "a", "label" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/lib/label.js#L58-L69
19,475
jasonbellamy/git-label
dist/lib/label.js
getLabels
function getLabels(_ref3) { var api = _ref3.api; var token = _ref3.token; var repo = _ref3.repo; return (0, _request2.default)({ headers: { 'User-Agent': 'request', 'Authorization': 'token ' + token }, url: api + '/' + repo + '/labels', method: 'GET', json: true }); }
javascript
function getLabels(_ref3) { var api = _ref3.api; var token = _ref3.token; var repo = _ref3.repo; return (0, _request2.default)({ headers: { 'User-Agent': 'request', 'Authorization': 'token ' + token }, url: api + '/' + repo + '/labels', method: 'GET', json: true }); }
[ "function", "getLabels", "(", "_ref3", ")", "{", "var", "api", "=", "_ref3", ".", "api", ";", "var", "token", "=", "_ref3", ".", "token", ";", "var", "repo", "=", "_ref3", ".", "repo", ";", "return", "(", "0", ",", "_request2", ".", "default", ")",...
Retrieves a list of labels from Github @name getLabels @function @param {Object} server the server configuration object @param {String} server.api the api endpoint to connect to @param {String} server.token the api token to use @param {String} server.repo the git repo to manipulate @return {Promise}
[ "Retrieves", "a", "list", "of", "labels", "from", "Github" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/lib/label.js#L82-L93
19,476
jasonbellamy/git-label
dist/lib/label.js
formatLabel
function formatLabel(_ref4) { var name = _ref4.name; var color = _ref4.color; return { name: name, color: color.replace('#', '') }; }
javascript
function formatLabel(_ref4) { var name = _ref4.name; var color = _ref4.color; return { name: name, color: color.replace('#', '') }; }
[ "function", "formatLabel", "(", "_ref4", ")", "{", "var", "name", "=", "_ref4", ".", "name", ";", "var", "color", "=", "_ref4", ".", "color", ";", "return", "{", "name", ":", "name", ",", "color", ":", "color", ".", "replace", "(", "'#'", ",", "''"...
Properly formats an object for a label for a GitHub request @name formatLabel @function @param {String} name the name of the label @param {String} color the hexidecimal color of the label @return {Object} a properly formated label object that can be sent to GitHub
[ "Properly", "formats", "an", "object", "for", "a", "label", "for", "a", "GitHub", "request" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/lib/label.js#L104-L109
19,477
jasonbellamy/git-label
dist/lib/label.js
createLabels
function createLabels(server, labels) { return Promise.all(labels.map(formatLabel).map(function (_ref5) { var name = _ref5.name; var color = _ref5.color; return createLabel(server, name, color); })); }
javascript
function createLabels(server, labels) { return Promise.all(labels.map(formatLabel).map(function (_ref5) { var name = _ref5.name; var color = _ref5.color; return createLabel(server, name, color); })); }
[ "function", "createLabels", "(", "server", ",", "labels", ")", "{", "return", "Promise", ".", "all", "(", "labels", ".", "map", "(", "formatLabel", ")", ".", "map", "(", "function", "(", "_ref5", ")", "{", "var", "name", "=", "_ref5", ".", "name", ";...
Prepares and sends a request to GitHub to create multiple labels @name createLabels @function @param {Object} server the server configuration object @param {String} server.api the api endpoint to connect to @param {String} server.token the api token to use @param {String} server.repo the git repo to manipulate @param ...
[ "Prepares", "and", "sends", "a", "request", "to", "GitHub", "to", "create", "multiple", "labels" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/lib/label.js#L123-L129
19,478
jasonbellamy/git-label
dist/lib/label.js
deleteLabels
function deleteLabels(server, labels) { return Promise.all(labels.map(formatLabel).map(function (_ref6) { var name = _ref6.name; var color = _ref6.color; return deleteLabel(server, name); })); }
javascript
function deleteLabels(server, labels) { return Promise.all(labels.map(formatLabel).map(function (_ref6) { var name = _ref6.name; var color = _ref6.color; return deleteLabel(server, name); })); }
[ "function", "deleteLabels", "(", "server", ",", "labels", ")", "{", "return", "Promise", ".", "all", "(", "labels", ".", "map", "(", "formatLabel", ")", ".", "map", "(", "function", "(", "_ref6", ")", "{", "var", "name", "=", "_ref6", ".", "name", ";...
Deletes all of the current labels associated with the GitHub repo @name deleteLabels @function @param {Object} server the server configuration object @param {String} server.api the api endpoint to connect to @param {String} server.token the api token to use @param {String} server.repo the git repo to manipulate @retur...
[ "Deletes", "all", "of", "the", "current", "labels", "associated", "with", "the", "GitHub", "repo" ]
ad33c23a1805cf99beb04e07039d9879fa632d2b
https://github.com/jasonbellamy/git-label/blob/ad33c23a1805cf99beb04e07039d9879fa632d2b/dist/lib/label.js#L142-L148
19,479
taozhi8833998/node-sql-parser
lib/util.js
replaceParams
function replaceParams(ast, keys) { Object.keys(ast) .filter(key => { const value = ast[key] return Array.isArray(value) || (typeof value === 'object' && value !== null) }) .forEach(key => { const expr = ast[key] if (!(typeof expr === 'object' && expr.type === 'param')) return rep...
javascript
function replaceParams(ast, keys) { Object.keys(ast) .filter(key => { const value = ast[key] return Array.isArray(value) || (typeof value === 'object' && value !== null) }) .forEach(key => { const expr = ast[key] if (!(typeof expr === 'object' && expr.type === 'param')) return rep...
[ "function", "replaceParams", "(", "ast", ",", "keys", ")", "{", "Object", ".", "keys", "(", "ast", ")", ".", "filter", "(", "key", "=>", "{", "const", "value", "=", "ast", "[", "key", "]", "return", "Array", ".", "isArray", "(", "value", ")", "||",...
Replace param expressions @param {Object} ast - AST object @param {Object} keys - Keys = parameter names, values = parameter values @return {Object} - Newly created AST object
[ "Replace", "param", "expressions" ]
762944764e08018f9b432e56e3532cfd1b8eb58b
https://github.com/taozhi8833998/node-sql-parser/blob/762944764e08018f9b432e56e3532cfd1b8eb58b/lib/util.js#L51-L68
19,480
mage/mage
lib/mage/Mage.js
Mage
function Mage(mageRootModule) { EventEmitter.call(this); this.workerId = require('./worker').getId(); this.MageError = require('./MageError'); this.task = null; this._runState = 'init'; this._modulesList = []; this._modulePaths = [ applicationModulesPath ]; this._setupQueue = []; this._teardownQueue = [];...
javascript
function Mage(mageRootModule) { EventEmitter.call(this); this.workerId = require('./worker').getId(); this.MageError = require('./MageError'); this.task = null; this._runState = 'init'; this._modulesList = []; this._modulePaths = [ applicationModulesPath ]; this._setupQueue = []; this._teardownQueue = [];...
[ "function", "Mage", "(", "mageRootModule", ")", "{", "EventEmitter", ".", "call", "(", "this", ")", ";", "this", ".", "workerId", "=", "require", "(", "'./worker'", ")", ".", "getId", "(", ")", ";", "this", ".", "MageError", "=", "require", "(", "'./Ma...
The mage class. @constructor @extends EventEmitter
[ "The", "mage", "class", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/mage/Mage.js#L41-L101
19,481
mage/mage
lib/archivist/vaults/file/directories.js
recursiveFileList
function recursiveFileList(rootPath, cb) { var fileList = []; var errorList = []; var q = async.queue(function (filename, callback) { var filePath = path.join(rootPath, filename); fs.stat(filePath, function (error, stat) { if (error) { errorList.push(error); return callback(error); } // If no...
javascript
function recursiveFileList(rootPath, cb) { var fileList = []; var errorList = []; var q = async.queue(function (filename, callback) { var filePath = path.join(rootPath, filename); fs.stat(filePath, function (error, stat) { if (error) { errorList.push(error); return callback(error); } // If no...
[ "function", "recursiveFileList", "(", "rootPath", ",", "cb", ")", "{", "var", "fileList", "=", "[", "]", ";", "var", "errorList", "=", "[", "]", ";", "var", "q", "=", "async", ".", "queue", "(", "function", "(", "filename", ",", "callback", ")", "{",...
Recursively scans a directory for all files. This will then yield an array of all filenames relative to the give rootPath or an error. @param {String} rootPath @param {Function} cb
[ "Recursively", "scans", "a", "directory", "for", "all", "files", ".", "This", "will", "then", "yield", "an", "array", "of", "all", "filenames", "relative", "to", "the", "give", "rootPath", "or", "an", "error", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/archivist/vaults/file/directories.js#L14-L71
19,482
mage/mage
lib/archivist/vaults/file/directories.js
purgeEmptyParentFolders
function purgeEmptyParentFolders(rootPath, subfolderPath, logger, cb) { var fullPath = path.join(rootPath, subfolderPath); // Don't delete if we have reached the base if (!subfolderPath || subfolderPath === '.') { return cb(); } fs.rmdir(fullPath, function (error) { if (error) { return cb(error); } l...
javascript
function purgeEmptyParentFolders(rootPath, subfolderPath, logger, cb) { var fullPath = path.join(rootPath, subfolderPath); // Don't delete if we have reached the base if (!subfolderPath || subfolderPath === '.') { return cb(); } fs.rmdir(fullPath, function (error) { if (error) { return cb(error); } l...
[ "function", "purgeEmptyParentFolders", "(", "rootPath", ",", "subfolderPath", ",", "logger", ",", "cb", ")", "{", "var", "fullPath", "=", "path", ".", "join", "(", "rootPath", ",", "subfolderPath", ")", ";", "// Don't delete if we have reached the base", "if", "("...
Recursively purges empty folders from subfolderPath and working its way through its parents until reaching rootPath. @param {String} rootPath - root path to which the given subfolder belongs @param {String} subfolderPath - subfolder path relative to the root path @param {Object} logger @param {Function} cb
[ "Recursively", "purges", "empty", "folders", "from", "subfolderPath", "and", "working", "its", "way", "through", "its", "parents", "until", "reaching", "rootPath", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/archivist/vaults/file/directories.js#L85-L102
19,483
mage/mage
lib/archivist/vaults/file/directories.js
purgeEmptySubFolders
function purgeEmptySubFolders(rootPath, subfolderPath, logger, cb) { subfolderPath = subfolderPath || ''; var fullPath = path.join(rootPath, subfolderPath); fs.readdir(fullPath, function (error, files) { if (error) { return cb(); } async.eachLimit(files, MAX_PARALLEL, function (file, callback) { var fi...
javascript
function purgeEmptySubFolders(rootPath, subfolderPath, logger, cb) { subfolderPath = subfolderPath || ''; var fullPath = path.join(rootPath, subfolderPath); fs.readdir(fullPath, function (error, files) { if (error) { return cb(); } async.eachLimit(files, MAX_PARALLEL, function (file, callback) { var fi...
[ "function", "purgeEmptySubFolders", "(", "rootPath", ",", "subfolderPath", ",", "logger", ",", "cb", ")", "{", "subfolderPath", "=", "subfolderPath", "||", "''", ";", "var", "fullPath", "=", "path", ".", "join", "(", "rootPath", ",", "subfolderPath", ")", ";...
Scans all subdirectories for a given root path and attempts to delete any empty subfolders. It will traverse to the deepest child of each branch and work backwards deleting any empty folders. If there is an error during directory removal, we just ignore it and call the callback. @param {String} rootPath - root path fo...
[ "Scans", "all", "subdirectories", "for", "a", "given", "root", "path", "and", "attempts", "to", "delete", "any", "empty", "subfolders", ".", "It", "will", "traverse", "to", "the", "deepest", "child", "of", "each", "branch", "and", "work", "backwards", "delet...
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/archivist/vaults/file/directories.js#L116-L153
19,484
mage/mage
lib/archivist/migration.js
getAvailableMigrations
function getAvailableMigrations(vaultName, cb) { var path = configuration.getMigrationsPath(vaultName); fs.readdir(path, function (error, files) { if (error) { if (error.code === 'ENOENT') { logger.warning('No migration folder found for vault', vaultName, '(skipping).'); return cb(null, []); } re...
javascript
function getAvailableMigrations(vaultName, cb) { var path = configuration.getMigrationsPath(vaultName); fs.readdir(path, function (error, files) { if (error) { if (error.code === 'ENOENT') { logger.warning('No migration folder found for vault', vaultName, '(skipping).'); return cb(null, []); } re...
[ "function", "getAvailableMigrations", "(", "vaultName", ",", "cb", ")", "{", "var", "path", "=", "configuration", ".", "getMigrationsPath", "(", "vaultName", ")", ";", "fs", ".", "readdir", "(", "path", ",", "function", "(", "error", ",", "files", ")", "{"...
Scans the hard disk for available migration files for this vault and returns the version names. @param {string} vaultName The vault name for which to migrate. @param {Function} cb Callback that receives the found version numbers that can be migrated to or from.
[ "Scans", "the", "hard", "disk", "for", "available", "migration", "files", "for", "this", "vault", "and", "returns", "the", "version", "names", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/archivist/migration.js#L116-L141
19,485
mage/mage
lib/archivist/migration.js
migrateVaultToVersion
function migrateVaultToVersion(vault, targetVersion, cb) { var preventMigrate = mage.core.config.get(['archivist', 'vaults', vault.name, 'config', 'preventMigrate'], false); if (preventMigrate) { logger.warning(`Vault ${vault.name} has disabled migrate operation (skipping)`); return cb(); } if (typeof vault.ge...
javascript
function migrateVaultToVersion(vault, targetVersion, cb) { var preventMigrate = mage.core.config.get(['archivist', 'vaults', vault.name, 'config', 'preventMigrate'], false); if (preventMigrate) { logger.warning(`Vault ${vault.name} has disabled migrate operation (skipping)`); return cb(); } if (typeof vault.ge...
[ "function", "migrateVaultToVersion", "(", "vault", ",", "targetVersion", ",", "cb", ")", "{", "var", "preventMigrate", "=", "mage", ".", "core", ".", "config", ".", "get", "(", "[", "'archivist'", ",", "'vaults'", ",", "vault", ".", "name", ",", "'config'"...
This analyzes the strategy for migrating a single vault to a given version. Then executes that strategy. @param {Object} vault The vault to migrate @param {string} targetVersion The version to migrate to @param {Function} cb A callback to be called after migration of this vault completes
[ "This", "analyzes", "the", "strategy", "for", "migrating", "a", "single", "vault", "to", "a", "given", "version", ".", "Then", "executes", "that", "strategy", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/archivist/migration.js#L220-L262
19,486
mage/mage
scripts/create.js
copy
function copy(from, to) { var mode = fs.statSync(from).mode; var src = fs.readFileSync(from, 'utf8'); var re = /%([0-9A-Z\_]+)%/g; function replacer(_, match) { // We support the %PERIOD% variable to allow .gitignore to be created. The reason: // npm "kindly" ignores .gitignore files, so we have to use ...
javascript
function copy(from, to) { var mode = fs.statSync(from).mode; var src = fs.readFileSync(from, 'utf8'); var re = /%([0-9A-Z\_]+)%/g; function replacer(_, match) { // We support the %PERIOD% variable to allow .gitignore to be created. The reason: // npm "kindly" ignores .gitignore files, so we have to use ...
[ "function", "copy", "(", "from", ",", "to", ")", "{", "var", "mode", "=", "fs", ".", "statSync", "(", "from", ")", ".", "mode", ";", "var", "src", "=", "fs", ".", "readFileSync", "(", "from", ",", "'utf8'", ")", ";", "var", "re", "=", "/", "%([...
Copies a file from "from" to "to", and replaces template vars in filenames and file content. @param {String} from from-path @param {String} to to-path
[ "Copies", "a", "file", "from", "from", "to", "to", "and", "replaces", "template", "vars", "in", "filenames", "and", "file", "content", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/scripts/create.js#L121-L152
19,487
mage/mage
lib/archivist/vaults/couchbase/defaultTopicApi.js
flagsToStr
function flagsToStr(flags) { if (!flags) { return; } var buff = new Buffer(4); buff.writeUInt32BE(flags, 0); // return a 0-byte terminated or 4-byte string switch (0) { case buff[0]: return; case buff[1]: return buff.toString('utf8', 0, 1); case buff[2]: return buff.toString('utf8', 0, 2); case buf...
javascript
function flagsToStr(flags) { if (!flags) { return; } var buff = new Buffer(4); buff.writeUInt32BE(flags, 0); // return a 0-byte terminated or 4-byte string switch (0) { case buff[0]: return; case buff[1]: return buff.toString('utf8', 0, 1); case buff[2]: return buff.toString('utf8', 0, 2); case buf...
[ "function", "flagsToStr", "(", "flags", ")", "{", "if", "(", "!", "flags", ")", "{", "return", ";", "}", "var", "buff", "=", "new", "Buffer", "(", "4", ")", ";", "buff", ".", "writeUInt32BE", "(", "flags", ",", "0", ")", ";", "// return a 0-byte term...
Turns uint32 into a max 4 char string. The node.js Buffer class provides a good uint32 conversion algorithm that we want to use. @param {number} flags @returns {string}
[ "Turns", "uint32", "into", "a", "max", "4", "char", "string", ".", "The", "node", ".", "js", "Buffer", "class", "provides", "a", "good", "uint32", "conversion", "algorithm", "that", "we", "want", "to", "use", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/archivist/vaults/couchbase/defaultTopicApi.js#L28-L50
19,488
mage/mage
lib/archivist/vaults/couchbase/defaultTopicApi.js
strToFlags
function strToFlags(str) { if (!str) { return; } var buff = new Buffer([0, 0, 0, 0]); buff.write(str, 0, 4, 'ascii'); return buff.readUInt32BE(0); }
javascript
function strToFlags(str) { if (!str) { return; } var buff = new Buffer([0, 0, 0, 0]); buff.write(str, 0, 4, 'ascii'); return buff.readUInt32BE(0); }
[ "function", "strToFlags", "(", "str", ")", "{", "if", "(", "!", "str", ")", "{", "return", ";", "}", "var", "buff", "=", "new", "Buffer", "(", "[", "0", ",", "0", ",", "0", ",", "0", "]", ")", ";", "buff", ".", "write", "(", "str", ",", "0"...
Turns a max 4 char string into a uint32. The node.js Buffer class provides a good uint32 conversion algorithm that we want to use. @param {string} str @returns {number}
[ "Turns", "a", "max", "4", "char", "string", "into", "a", "uint32", ".", "The", "node", ".", "js", "Buffer", "class", "provides", "a", "good", "uint32", "conversion", "algorithm", "that", "we", "want", "to", "use", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/archivist/vaults/couchbase/defaultTopicApi.js#L61-L69
19,489
mage/mage
lib/config/Matryoshka/index.js
getRawRecursive
function getRawRecursive(matryoshka) { if (matryoshka.type !== 'object') { return matryoshka.value; } const returnObj = {}; for (const key of Object.keys(matryoshka.value)) { returnObj[key] = getRawRecursive(matryoshka.value[key]); } return returnObj; }
javascript
function getRawRecursive(matryoshka) { if (matryoshka.type !== 'object') { return matryoshka.value; } const returnObj = {}; for (const key of Object.keys(matryoshka.value)) { returnObj[key] = getRawRecursive(matryoshka.value[key]); } return returnObj; }
[ "function", "getRawRecursive", "(", "matryoshka", ")", "{", "if", "(", "matryoshka", ".", "type", "!==", "'object'", ")", "{", "return", "matryoshka", ".", "value", ";", "}", "const", "returnObj", "=", "{", "}", ";", "for", "(", "const", "key", "of", "...
Recursively unpeel a matryoshka to recover the raw data. @param {Matryoshka} matryoshka The matryoshka to unwrap. @return {*} The raw representation of the data contained in the matryoshka. @private
[ "Recursively", "unpeel", "a", "matryoshka", "to", "recover", "the", "raw", "data", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/config/Matryoshka/index.js#L251-L263
19,490
mage/mage
lib/config/Matryoshka/index.js
merge
function merge(a, b) { // If a is not a matryoshka, then return a copy of b (override). if (!(a instanceof Matryoshka)) { return b.copy(); } // If b is not a matryoshka, then just keep a. if (!(b instanceof Matryoshka)) { return a.copy(); } // If we reached here, both a and b are matryoshkas. // Types ar...
javascript
function merge(a, b) { // If a is not a matryoshka, then return a copy of b (override). if (!(a instanceof Matryoshka)) { return b.copy(); } // If b is not a matryoshka, then just keep a. if (!(b instanceof Matryoshka)) { return a.copy(); } // If we reached here, both a and b are matryoshkas. // Types ar...
[ "function", "merge", "(", "a", ",", "b", ")", "{", "// If a is not a matryoshka, then return a copy of b (override).", "if", "(", "!", "(", "a", "instanceof", "Matryoshka", ")", ")", "{", "return", "b", ".", "copy", "(", ")", ";", "}", "// If b is not a matryosh...
Merges a and b together into a new Matryoshka. Does not affect the state of a or b, and b overrides a. At least one is guaranteed to be a Matryoshka. @param {Matryoshka} a Matryoshka of lesser importance. @param {Matryoshka} b Matryoshka of greater importance. @return {Matryoshka} Resultant merge of a and b.
[ "Merges", "a", "and", "b", "together", "into", "a", "new", "Matryoshka", ".", "Does", "not", "affect", "the", "state", "of", "a", "or", "b", "and", "b", "overrides", "a", ".", "At", "least", "one", "is", "guaranteed", "to", "be", "a", "Matryoshka", "...
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/config/Matryoshka/index.js#L274-L333
19,491
mage/mage
lib/commandCenter/commandCenter.js
serializeCommandResult
function serializeCommandResult(result) { const out = []; out.push(result.errorCode || 'null'); out.push(result.response || 'null'); if (result.myEvents && result.myEvents.length) { out.push('[' + result.myEvents.join(',') + ']'); } return '[' + out.join(',') + ']'; }
javascript
function serializeCommandResult(result) { const out = []; out.push(result.errorCode || 'null'); out.push(result.response || 'null'); if (result.myEvents && result.myEvents.length) { out.push('[' + result.myEvents.join(',') + ']'); } return '[' + out.join(',') + ']'; }
[ "function", "serializeCommandResult", "(", "result", ")", "{", "const", "out", "=", "[", "]", ";", "out", ".", "push", "(", "result", ".", "errorCode", "||", "'null'", ")", ";", "out", ".", "push", "(", "result", ".", "response", "||", "'null'", ")", ...
Serializes a single command response into a string. @param {Object} result The result of the user command, including pre-serialized arguments @param {string} [result.errorCode] JSON serialized error code @param {string} [result.response] JSON serialized response value @param {string[]} [result.myEvents...
[ "Serializes", "a", "single", "command", "response", "into", "a", "string", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/commandCenter/commandCenter.js#L353-L364
19,492
mage/mage
lib/commandCenter/commandCenter.js
generateCommandPromise
function generateCommandPromise(cmdInfo, state, paramList) { const mod = cmdInfo.mod; const execute = () => mod.execute.apply(mod, paramList); if (cmdInfo.isAsync) { // Async user commands will need to take the response value, and feed it // to `state.respond` const isJson = mod.serialize === false; return...
javascript
function generateCommandPromise(cmdInfo, state, paramList) { const mod = cmdInfo.mod; const execute = () => mod.execute.apply(mod, paramList); if (cmdInfo.isAsync) { // Async user commands will need to take the response value, and feed it // to `state.respond` const isJson = mod.serialize === false; return...
[ "function", "generateCommandPromise", "(", "cmdInfo", ",", "state", ",", "paramList", ")", "{", "const", "mod", "=", "cmdInfo", ".", "mod", ";", "const", "execute", "=", "(", ")", "=>", "mod", ".", "execute", ".", "apply", "(", "mod", ",", "paramList", ...
Promisify the user command execute method, or ensure its return value is passed to state.respond Once callback-based user commands are removed from MAGE, you will be able to remove this method. @param {*} cmdInfo @param {State} state @param {*} paramList
[ "Promisify", "the", "user", "command", "execute", "method", "or", "ensure", "its", "return", "value", "is", "passed", "to", "state", ".", "respond" ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/commandCenter/commandCenter.js#L417-L433
19,493
mage/mage
lib/commandCenter/commandCenter.js
createTimerPromise
function createTimerPromise(commandName, timeout) { let timer; const promise = new Promise((resolve, reject) => { if (timeout) { timer = setTimeout(() => reject(new UserCommandExecutionTimeout(commandName)), timeout); } }); promise.clear = () => clearTimeout(timer); return promise; }
javascript
function createTimerPromise(commandName, timeout) { let timer; const promise = new Promise((resolve, reject) => { if (timeout) { timer = setTimeout(() => reject(new UserCommandExecutionTimeout(commandName)), timeout); } }); promise.clear = () => clearTimeout(timer); return promise; }
[ "function", "createTimerPromise", "(", "commandName", ",", "timeout", ")", "{", "let", "timer", ";", "const", "promise", "=", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "if", "(", "timeout", ")", "{", "timer", "=", "setTimeout"...
Create a promise timer Useful when using Promise.race. @param {number} timeout
[ "Create", "a", "promise", "timer" ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/commandCenter/commandCenter.js#L442-L454
19,494
mage/mage
lib/commandCenter/commandCenter.js
processBatchHeader
function processBatchHeader(state, batch, cb) { if (messageHooks.length === 0) { return cb(); } var hookData = {}; for (var i = 0; i < batch.header.length; i += 1) { var header = batch.header[i]; if (header.name) { hookData[header.name] = header; } } async.eachSeries( messageHooks, function (hook...
javascript
function processBatchHeader(state, batch, cb) { if (messageHooks.length === 0) { return cb(); } var hookData = {}; for (var i = 0; i < batch.header.length; i += 1) { var header = batch.header[i]; if (header.name) { hookData[header.name] = header; } } async.eachSeries( messageHooks, function (hook...
[ "function", "processBatchHeader", "(", "state", ",", "batch", ",", "cb", ")", "{", "if", "(", "messageHooks", ".", "length", "===", "0", ")", "{", "return", "cb", "(", ")", ";", "}", "var", "hookData", "=", "{", "}", ";", "for", "(", "var", "i", ...
Calls all message hooks required for a batch. @param {State} state MAGE state object. @param {Object} batch Command batch object. @param {Object} batch.app The app object that this batch is for (hooks can filter on app.name). @param {string} batch.rawData The ra...
[ "Calls", "all", "message", "hooks", "required", "for", "a", "batch", "." ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/commandCenter/commandCenter.js#L665-L706
19,495
mage/mage
lib/commandCenter/commandCenter.js
respond
function respond(options, content, cache) { // cache the response var cached = that.responseCache.set(state, queryId, options, cache); // send the response back to the client cb(null, content, options); // log the execution time var msg = cached ? 'Executed and cached user command batc...
javascript
function respond(options, content, cache) { // cache the response var cached = that.responseCache.set(state, queryId, options, cache); // send the response back to the client cb(null, content, options); // log the execution time var msg = cached ? 'Executed and cached user command batc...
[ "function", "respond", "(", "options", ",", "content", ",", "cache", ")", "{", "// cache the response", "var", "cached", "=", "that", ".", "responseCache", ".", "set", "(", "state", ",", "queryId", ",", "options", ",", "cache", ")", ";", "// send the respons...
start executing commands and build a serialized output response
[ "start", "executing", "commands", "and", "build", "a", "serialized", "output", "response" ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/commandCenter/commandCenter.js#L781-L805
19,496
mage/mage
lib/commandCenter/commandCenter.js
runCommand
function runCommand(output, cache, cmdIndex) { var cmd = batch.commands[cmdIndex]; if (cmd) { if (cacheContent.length !== 0 && isCachedCommand(cmd)) { logger.warning .data({ cmd: cmd.cmdName }) .log('Re-sending cached command response'); output += (output ? ',' : '[') + cacheCont...
javascript
function runCommand(output, cache, cmdIndex) { var cmd = batch.commands[cmdIndex]; if (cmd) { if (cacheContent.length !== 0 && isCachedCommand(cmd)) { logger.warning .data({ cmd: cmd.cmdName }) .log('Re-sending cached command response'); output += (output ? ',' : '[') + cacheCont...
[ "function", "runCommand", "(", "output", ",", "cache", ",", "cmdIndex", ")", "{", "var", "cmd", "=", "batch", ".", "commands", "[", "cmdIndex", "]", ";", "if", "(", "cmd", ")", "{", "if", "(", "cacheContent", ".", "length", "!==", "0", "&&", "isCache...
recursively runs each command, until done, then calls respond
[ "recursively", "runs", "each", "command", "until", "done", "then", "calls", "respond" ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/commandCenter/commandCenter.js#L809-L874
19,497
mage/mage
lib/archivist/vaults/mysql/index.js
MysqlVault
function MysqlVault(name, logger) { var that = this; // required exposed properties this.name = name; // the unique vault name this.archive = new Archive(this); // archivist bindings // internals this.mysql = null; // node-mysql library this.config = null; ...
javascript
function MysqlVault(name, logger) { var that = this; // required exposed properties this.name = name; // the unique vault name this.archive = new Archive(this); // archivist bindings // internals this.mysql = null; // node-mysql library this.config = null; ...
[ "function", "MysqlVault", "(", "name", ",", "logger", ")", "{", "var", "that", "=", "this", ";", "// required exposed properties", "this", ".", "name", "=", "name", ";", "// the unique vault name", "this", ".", "archive", "=", "new", "Archive", "(", "this", ...
Vault wrapper around node-mysql
[ "Vault", "wrapper", "around", "node", "-", "mysql" ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/archivist/vaults/mysql/index.js#L38-L60
19,498
mage/mage
lib/tasks/serve.js
setupModules
function setupModules(callback) { if (mage.core.processManager.isMaster) { return callback(); } mage.setupModules(callback); }
javascript
function setupModules(callback) { if (mage.core.processManager.isMaster) { return callback(); } mage.setupModules(callback); }
[ "function", "setupModules", "(", "callback", ")", "{", "if", "(", "mage", ".", "core", ".", "processManager", ".", "isMaster", ")", "{", "return", "callback", "(", ")", ";", "}", "mage", ".", "setupModules", "(", "callback", ")", ";", "}" ]
Set up the modules
[ "Set", "up", "the", "modules" ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/tasks/serve.js#L48-L54
19,499
mage/mage
lib/tasks/serve.js
createApps
function createApps(callback) { if (mage.core.processManager.isMaster) { return callback(); } try { mage.core.app.createApps(); } catch (error) { return callback(error); } return callback(); }
javascript
function createApps(callback) { if (mage.core.processManager.isMaster) { return callback(); } try { mage.core.app.createApps(); } catch (error) { return callback(error); } return callback(); }
[ "function", "createApps", "(", "callback", ")", "{", "if", "(", "mage", ".", "core", ".", "processManager", ".", "isMaster", ")", "{", "return", "callback", "(", ")", ";", "}", "try", "{", "mage", ".", "core", ".", "app", ".", "createApps", "(", ")",...
Create the apps
[ "Create", "the", "apps" ]
617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9
https://github.com/mage/mage/blob/617968b6b9ebfa5371ae7e9115a5d1e0733a0ff9/lib/tasks/serve.js#L58-L70