repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
adrai/node-eventstore
lib/eventstore.js
function (callback) { var self = this; function initDispatcher() { debug('init event dispatcher'); self.dispatcher = new EventDispatcher(self.publisher, self); self.dispatcher.start(callback); } this.store.on('connect', function () { self.emit('connect'); }); this.stor...
javascript
function (callback) { var self = this; function initDispatcher() { debug('init event dispatcher'); self.dispatcher = new EventDispatcher(self.publisher, self); self.dispatcher.start(callback); } this.store.on('connect', function () { self.emit('connect'); }); this.stor...
[ "function", "(", "callback", ")", "{", "var", "self", "=", "this", ";", "function", "initDispatcher", "(", ")", "{", "debug", "(", "'init event dispatcher'", ")", ";", "self", ".", "dispatcher", "=", "new", "EventDispatcher", "(", "self", ".", "publisher", ...
Call this function to initialize the eventstore. If an event publisher function was injected it will additionally initialize an event dispatcher. @param {Function} callback the function that will be called when this action has finished [optional]
[ "Call", "this", "function", "to", "initialize", "the", "eventstore", ".", "If", "an", "event", "publisher", "function", "was", "injected", "it", "will", "additionally", "initialize", "an", "event", "dispatcher", "." ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L77-L111
train
adrai/node-eventstore
lib/eventstore.js
function (query, skip, limit) { if (!this.store.streamEvents) { throw new Error('Streaming API is not suppoted by '+(this.options.type || 'inmemory') +' db implementation.'); } if (typeof query === 'number') { limit = skip; skip = query; query = {}; }; if (typeof quer...
javascript
function (query, skip, limit) { if (!this.store.streamEvents) { throw new Error('Streaming API is not suppoted by '+(this.options.type || 'inmemory') +' db implementation.'); } if (typeof query === 'number') { limit = skip; skip = query; query = {}; }; if (typeof quer...
[ "function", "(", "query", ",", "skip", ",", "limit", ")", "{", "if", "(", "!", "this", ".", "store", ".", "streamEvents", ")", "{", "throw", "new", "Error", "(", "'Streaming API is not suppoted by '", "+", "(", "this", ".", "options", ".", "type", "||", ...
streaming api streams the events @param {Object || String} query the query object [optional] @param {Number} skip how many events should be skipped? [optional] @param {Number} limit how many events do you want in the result? [optional] @returns {Stream} a stream with the events
[ "streaming", "api", "streams", "the", "events" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L123-L139
train
adrai/node-eventstore
lib/eventstore.js
function (commitStamp, skip, limit) { if (!this.store.streamEvents) { throw new Error('Streaming API is not suppoted by '+(this.options.type || 'inmemory') +' db implementation.'); } if (!commitStamp) { var err = new Error('Please pass in a date object!'); debug(err); throw err; ...
javascript
function (commitStamp, skip, limit) { if (!this.store.streamEvents) { throw new Error('Streaming API is not suppoted by '+(this.options.type || 'inmemory') +' db implementation.'); } if (!commitStamp) { var err = new Error('Please pass in a date object!'); debug(err); throw err; ...
[ "function", "(", "commitStamp", ",", "skip", ",", "limit", ")", "{", "if", "(", "!", "this", ".", "store", ".", "streamEvents", ")", "{", "throw", "new", "Error", "(", "'Streaming API is not suppoted by '", "+", "(", "this", ".", "options", ".", "type", ...
streams all the events since passed commitStamp @param {Date} commitStamp the date object @param {Number} skip how many events should be skipped? [optional] @param {Number} limit how many events do you want in the result? [optional] @returns {Stream} a stream with the events
[ "streams", "all", "the", "events", "since", "passed", "commitStamp" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L148-L163
train
adrai/node-eventstore
lib/eventstore.js
function (query, revMin, revMax) { if (typeof query === 'string') { query = { aggregateId: query }; } if (!query.aggregateId) { var err = new Error('An aggregateId should be passed!'); debug(err); if (callback) callback(err); return; } return this.store.streamEventsBy...
javascript
function (query, revMin, revMax) { if (typeof query === 'string') { query = { aggregateId: query }; } if (!query.aggregateId) { var err = new Error('An aggregateId should be passed!'); debug(err); if (callback) callback(err); return; } return this.store.streamEventsBy...
[ "function", "(", "query", ",", "revMin", ",", "revMax", ")", "{", "if", "(", "typeof", "query", "===", "'string'", ")", "{", "query", "=", "{", "aggregateId", ":", "query", "}", ";", "}", "if", "(", "!", "query", ".", "aggregateId", ")", "{", "var"...
stream events by revision @param {Object || String} query the query object @param {Number} revMin revision start point [optional] @param {Number} revMax revision end point (hint: -1 = to end) [optional] @returns {Stream} a stream with the events
[ "stream", "events", "by", "revision" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L173-L186
train
adrai/node-eventstore
lib/eventstore.js
function (commitStamp, skip, limit, callback) { if (!commitStamp) { var err = new Error('Please pass in a date object!'); debug(err); throw err; } if (typeof skip === 'function') { callback = skip; skip = 0; limit = -1; } else if (typeof limit === 'function') { ...
javascript
function (commitStamp, skip, limit, callback) { if (!commitStamp) { var err = new Error('Please pass in a date object!'); debug(err); throw err; } if (typeof skip === 'function') { callback = skip; skip = 0; limit = -1; } else if (typeof limit === 'function') { ...
[ "function", "(", "commitStamp", ",", "skip", ",", "limit", ",", "callback", ")", "{", "if", "(", "!", "commitStamp", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass in a date object!'", ")", ";", "debug", "(", "err", ")", ";", "throw", ...
loads all the events since passed commitStamp @param {Date} commitStamp the date object @param {Number} skip how many events should be skipped? [optional] @param {Number} limit how many events do you want in the result? [optional] @param {Function} callback the function that will be called when ...
[ "loads", "all", "the", "events", "since", "passed", "commitStamp" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L255-L294
train
adrai/node-eventstore
lib/eventstore.js
function (query, revMin, revMax, callback) { if (typeof revMin === 'function') { callback = revMin; revMin = 0; revMax = -1; } else if (typeof revMax === 'function') { callback = revMax; revMax = -1; } if (typeof query === 'string') { query = { aggregateId: query }; ...
javascript
function (query, revMin, revMax, callback) { if (typeof revMin === 'function') { callback = revMin; revMin = 0; revMax = -1; } else if (typeof revMax === 'function') { callback = revMax; revMax = -1; } if (typeof query === 'string') { query = { aggregateId: query }; ...
[ "function", "(", "query", ",", "revMin", ",", "revMax", ",", "callback", ")", "{", "if", "(", "typeof", "revMin", "===", "'function'", ")", "{", "callback", "=", "revMin", ";", "revMin", "=", "0", ";", "revMax", "=", "-", "1", ";", "}", "else", "if...
loads the event stream @param {Object || String} query the query object @param {Number} revMin revision start point [optional] @param {Number} revMax revision end point (hint: -1 = to end) [optional] @param {Function} callback the function that will be called when this action has fini...
[ "loads", "the", "event", "stream" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L336-L365
train
adrai/node-eventstore
lib/eventstore.js
function (query, revMax, callback) { if (typeof revMax === 'function') { callback = revMax; revMax = -1; } if (typeof query === 'string') { query = { aggregateId: query }; } if (!query.aggregateId) { var err = new Error('An aggregateId should be passed!'); debug(err);...
javascript
function (query, revMax, callback) { if (typeof revMax === 'function') { callback = revMax; revMax = -1; } if (typeof query === 'string') { query = { aggregateId: query }; } if (!query.aggregateId) { var err = new Error('An aggregateId should be passed!'); debug(err);...
[ "function", "(", "query", ",", "revMax", ",", "callback", ")", "{", "if", "(", "typeof", "revMax", "===", "'function'", ")", "{", "callback", "=", "revMax", ";", "revMax", "=", "-", "1", ";", "}", "if", "(", "typeof", "query", "===", "'string'", ")",...
loads the next snapshot back from given max revision @param {Object || String} query the query object @param {Number} revMax revision end point (hint: -1 = to end) [optional] @param {Function} callback the function that will be called when this action has finished `function(err, snapshot, eventst...
[ "loads", "the", "next", "snapshot", "back", "from", "given", "max", "revision" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L374-L421
train
adrai/node-eventstore
lib/eventstore.js
function(obj, callback) { if (obj.streamId && !obj.aggregateId) { obj.aggregateId = obj.streamId; } if (!obj.aggregateId) { var err = new Error('An aggregateId should be passed!'); debug(err); if (callback) callback(err); return; } obj.streamId = obj.aggregateId; ...
javascript
function(obj, callback) { if (obj.streamId && !obj.aggregateId) { obj.aggregateId = obj.streamId; } if (!obj.aggregateId) { var err = new Error('An aggregateId should be passed!'); debug(err); if (callback) callback(err); return; } obj.streamId = obj.aggregateId; ...
[ "function", "(", "obj", ",", "callback", ")", "{", "if", "(", "obj", ".", "streamId", "&&", "!", "obj", ".", "aggregateId", ")", "{", "obj", ".", "aggregateId", "=", "obj", ".", "streamId", ";", "}", "if", "(", "!", "obj", ".", "aggregateId", ")", ...
stores a new snapshot @param {Object} obj the snapshot data @param {Function} callback the function that will be called when this action has finished [optional]
[ "stores", "a", "new", "snapshot" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L428-L466
train
adrai/node-eventstore
lib/eventstore.js
function(eventstream, callback) { var self = this; async.waterfall([ function getNewCommitId(callback) { self.getNewId(callback); }, function commitEvents(id, callback) { // start committing. var event, currentRevision = eventstream.currentRevision(), ...
javascript
function(eventstream, callback) { var self = this; async.waterfall([ function getNewCommitId(callback) { self.getNewId(callback); }, function commitEvents(id, callback) { // start committing. var event, currentRevision = eventstream.currentRevision(), ...
[ "function", "(", "eventstream", ",", "callback", ")", "{", "var", "self", "=", "this", ";", "async", ".", "waterfall", "(", "[", "function", "getNewCommitId", "(", "callback", ")", "{", "self", ".", "getNewId", "(", "callback", ")", ";", "}", ",", "fun...
commits all uncommittedEvents in the eventstream @param eventstream the eventstream that should be saved (hint: directly use the commit function on eventstream) @param {Function} callback the function that will be called when this action has finished `function(err, eventstream){}` (hint: eventstream.eventsToDispatch)
[ "commits", "all", "uncommittedEvents", "in", "the", "eventstream" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L474-L535
train
adrai/node-eventstore
lib/eventstore.js
function (query, callback) { if (!callback) { callback = query; query = null; } if (typeof query === 'string') { query = { aggregateId: query }; } this.store.getUndispatchedEvents(query, callback); }
javascript
function (query, callback) { if (!callback) { callback = query; query = null; } if (typeof query === 'string') { query = { aggregateId: query }; } this.store.getUndispatchedEvents(query, callback); }
[ "function", "(", "query", ",", "callback", ")", "{", "if", "(", "!", "callback", ")", "{", "callback", "=", "query", ";", "query", "=", "null", ";", "}", "if", "(", "typeof", "query", "===", "'string'", ")", "{", "query", "=", "{", "aggregateId", "...
loads all undispatched events @param {Object || String} query the query object [optional] @param {Function} callback the function that will be called when this action has finished `function(err, events){}`
[ "loads", "all", "undispatched", "events" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L543-L554
train
adrai/node-eventstore
lib/eventstore.js
function (query, callback) { if (!callback) { callback = query; query = null; } if (typeof query === 'string') { query = { aggregateId: query }; } this.store.getLastEvent(query, callback); }
javascript
function (query, callback) { if (!callback) { callback = query; query = null; } if (typeof query === 'string') { query = { aggregateId: query }; } this.store.getLastEvent(query, callback); }
[ "function", "(", "query", ",", "callback", ")", "{", "if", "(", "!", "callback", ")", "{", "callback", "=", "query", ";", "query", "=", "null", ";", "}", "if", "(", "typeof", "query", "===", "'string'", ")", "{", "query", "=", "{", "aggregateId", "...
loads the last event @param {Object || String} query the query object [optional] @param {Function} callback the function that will be called when this action has finished `function(err, event){}`
[ "loads", "the", "last", "event" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L562-L573
train
adrai/node-eventstore
lib/eventstore.js
function (query, callback) { if (!callback) { callback = query; query = null; } if (typeof query === 'string') { query = { aggregateId: query }; } var self = this; this.store.getLastEvent(query, function (err, evt) { if (err) return callback(err); callback(null,...
javascript
function (query, callback) { if (!callback) { callback = query; query = null; } if (typeof query === 'string') { query = { aggregateId: query }; } var self = this; this.store.getLastEvent(query, function (err, evt) { if (err) return callback(err); callback(null,...
[ "function", "(", "query", ",", "callback", ")", "{", "if", "(", "!", "callback", ")", "{", "callback", "=", "query", ";", "query", "=", "null", ";", "}", "if", "(", "typeof", "query", "===", "'string'", ")", "{", "query", "=", "{", "aggregateId", "...
loads the last event in a stream @param {Object || String} query the query object [optional] @param {Function} callback the function that will be called when this action has finished `function(err, eventstream){}`
[ "loads", "the", "last", "event", "in", "a", "stream" ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L581-L598
train
adrai/node-eventstore
lib/eventstore.js
function (evtOrId, callback) { if (typeof evtOrId === 'object') { evtOrId = evtOrId.id; } this.store.setEventToDispatched(evtOrId, callback); }
javascript
function (evtOrId, callback) { if (typeof evtOrId === 'object') { evtOrId = evtOrId.id; } this.store.setEventToDispatched(evtOrId, callback); }
[ "function", "(", "evtOrId", ",", "callback", ")", "{", "if", "(", "typeof", "evtOrId", "===", "'object'", ")", "{", "evtOrId", "=", "evtOrId", ".", "id", ";", "}", "this", ".", "store", ".", "setEventToDispatched", "(", "evtOrId", ",", "callback", ")", ...
Sets the given event to dispatched. @param {Object || String} evtOrId the event object or its id @param {Function} callback the function that will be called when this action has finished [optional]
[ "Sets", "the", "given", "event", "to", "dispatched", "." ]
5ba58aa68d79b2ff81dd390b2464dab62f5c4c40
https://github.com/adrai/node-eventstore/blob/5ba58aa68d79b2ff81dd390b2464dab62f5c4c40/lib/eventstore.js#L605-L610
train
magicbookproject/magicbook
src/plugins/toc.js
getSections
function getSections($, root, relative) { var items = []; var sections = root.children("section[data-type], div[data-type='part']"); sections.each(function(index, el) { var jel = $(el); var header = jel.find("> header"); // create section item var item = { id: jel.attr("id"), type...
javascript
function getSections($, root, relative) { var items = []; var sections = root.children("section[data-type], div[data-type='part']"); sections.each(function(index, el) { var jel = $(el); var header = jel.find("> header"); // create section item var item = { id: jel.attr("id"), type...
[ "function", "getSections", "(", "$", ",", "root", ",", "relative", ")", "{", "var", "items", "=", "[", "]", ";", "var", "sections", "=", "root", ".", "children", "(", "\"section[data-type], div[data-type='part']\"", ")", ";", "sections", ".", "each", "(", ...
takes an element and finds all direct section in its children. recursively calls itself on all section children to get a tree of sections.
[ "takes", "an", "element", "and", "finds", "all", "direct", "section", "in", "its", "children", ".", "recursively", "calls", "itself", "on", "all", "section", "children", "to", "get", "a", "tree", "of", "sections", "." ]
626486dd46f5d65b61e71321832540cbfc722725
https://github.com/magicbookproject/magicbook/blob/626486dd46f5d65b61e71321832540cbfc722725/src/plugins/toc.js#L45-L87
train
magicbookproject/magicbook
src/plugins/toc.js
function(config, stream, extras, callback) { var tocFiles = this.tocFiles = []; // First run through every file and get a tree of the section // navigation within that file. Save to our nav object. stream = stream.pipe(through.obj(function(file, enc, cb) { // create cheerio element for file if ...
javascript
function(config, stream, extras, callback) { var tocFiles = this.tocFiles = []; // First run through every file and get a tree of the section // navigation within that file. Save to our nav object. stream = stream.pipe(through.obj(function(file, enc, cb) { // create cheerio element for file if ...
[ "function", "(", "config", ",", "stream", ",", "extras", ",", "callback", ")", "{", "var", "tocFiles", "=", "this", ".", "tocFiles", "=", "[", "]", ";", "// First run through every file and get a tree of the section", "// navigation within that file. Save to our nav objec...
When the files have been converted, we run the TOC generation. This is happening before the layouts, because it won't work if the markup is wrapped in container div's. We should rewrite the TOC generation to work with this.
[ "When", "the", "files", "have", "been", "converted", "we", "run", "the", "TOC", "generation", ".", "This", "is", "happening", "before", "the", "layouts", "because", "it", "won", "t", "work", "if", "the", "markup", "is", "wrapped", "in", "container", "div",...
626486dd46f5d65b61e71321832540cbfc722725
https://github.com/magicbookproject/magicbook/blob/626486dd46f5d65b61e71321832540cbfc722725/src/plugins/toc.js#L106-L133
train
magicbookproject/magicbook
src/plugins/toc.js
relativeTOC
function relativeTOC(file, parent) { _.each(parent.children, function(child) { if(child.relative) { var href = ""; if(config.format != "pdf") { var relativeFolder = path.relative(path.dirname(file.relative), path.dirname(child.relative)); href = path...
javascript
function relativeTOC(file, parent) { _.each(parent.children, function(child) { if(child.relative) { var href = ""; if(config.format != "pdf") { var relativeFolder = path.relative(path.dirname(file.relative), path.dirname(child.relative)); href = path...
[ "function", "relativeTOC", "(", "file", ",", "parent", ")", "{", "_", ".", "each", "(", "parent", ".", "children", ",", "function", "(", "child", ")", "{", "if", "(", "child", ".", "relative", ")", "{", "var", "href", "=", "\"\"", ";", "if", "(", ...
a function to turn a toc tree into relative URL's for a specific file.
[ "a", "function", "to", "turn", "a", "toc", "tree", "into", "relative", "URL", "s", "for", "a", "specific", "file", "." ]
626486dd46f5d65b61e71321832540cbfc722725
https://github.com/magicbookproject/magicbook/blob/626486dd46f5d65b61e71321832540cbfc722725/src/plugins/toc.js#L195-L213
train
magicbookproject/magicbook
src/index.js
loadConfig
function loadConfig(path) { try { var configJSON = JSON.parse(fs.readFileSync(process.cwd() + "/" + path)); console.log("Config file detected: " + path) return configJSON; } catch(e) { console.log("Config file: " + e.toString()) } }
javascript
function loadConfig(path) { try { var configJSON = JSON.parse(fs.readFileSync(process.cwd() + "/" + path)); console.log("Config file detected: " + path) return configJSON; } catch(e) { console.log("Config file: " + e.toString()) } }
[ "function", "loadConfig", "(", "path", ")", "{", "try", "{", "var", "configJSON", "=", "JSON", ".", "parse", "(", "fs", ".", "readFileSync", "(", "process", ".", "cwd", "(", ")", "+", "\"/\"", "+", "path", ")", ")", ";", "console", ".", "log", "(",...
Loads the config file into a JS object
[ "Loads", "the", "config", "file", "into", "a", "JS", "object" ]
626486dd46f5d65b61e71321832540cbfc722725
https://github.com/magicbookproject/magicbook/blob/626486dd46f5d65b61e71321832540cbfc722725/src/index.js#L14-L23
train
magicbookproject/magicbook
src/index.js
triggerBuild
function triggerBuild() { // Pick command lines options that take precedence var cmdConfig = _.pick(argv, ['files', 'verbose']);; // load config file and merge into config var jsonConfig = loadConfig(argv.config || 'magicbook.json'); _.defaults(cmdConfig, jsonConfig); // trigger the build with the new co...
javascript
function triggerBuild() { // Pick command lines options that take precedence var cmdConfig = _.pick(argv, ['files', 'verbose']);; // load config file and merge into config var jsonConfig = loadConfig(argv.config || 'magicbook.json'); _.defaults(cmdConfig, jsonConfig); // trigger the build with the new co...
[ "function", "triggerBuild", "(", ")", "{", "// Pick command lines options that take precedence", "var", "cmdConfig", "=", "_", ".", "pick", "(", "argv", ",", "[", "'files'", ",", "'verbose'", "]", ")", ";", ";", "// load config file and merge into config", "var", "j...
Trigger a build
[ "Trigger", "a", "build" ]
626486dd46f5d65b61e71321832540cbfc722725
https://github.com/magicbookproject/magicbook/blob/626486dd46f5d65b61e71321832540cbfc722725/src/index.js#L26-L40
train
magicbookproject/magicbook
src/plugins/fonts.js
function(config, extras, callback) { // load all files in the source folder vfs.src(config.fonts.files) // vinyl-fs dest automatically determines whether a file // should be updated or not, based on the mtime timestamp. // so we don't need to do that manually. .pipe(vfs.dest(path.join(...
javascript
function(config, extras, callback) { // load all files in the source folder vfs.src(config.fonts.files) // vinyl-fs dest automatically determines whether a file // should be updated or not, based on the mtime timestamp. // so we don't need to do that manually. .pipe(vfs.dest(path.join(...
[ "function", "(", "config", ",", "extras", ",", "callback", ")", "{", "// load all files in the source folder", "vfs", ".", "src", "(", "config", ".", "fonts", ".", "files", ")", "// vinyl-fs dest automatically determines whether a file", "// should be updated or not, based ...
simply move all font files at setup
[ "simply", "move", "all", "font", "files", "at", "setup" ]
626486dd46f5d65b61e71321832540cbfc722725
https://github.com/magicbookproject/magicbook/blob/626486dd46f5d65b61e71321832540cbfc722725/src/plugins/fonts.js#L15-L27
train
magicbookproject/magicbook
src/plugins/navigation.js
function(config, stream, extras, callback) { // Finish the stream so we get a full array of files, that // we can use to figure out whether add prev/next placeholders. streamHelpers.finishWithFiles(stream, function(files) { // loop through each file and get the title of the heading // as well ...
javascript
function(config, stream, extras, callback) { // Finish the stream so we get a full array of files, that // we can use to figure out whether add prev/next placeholders. streamHelpers.finishWithFiles(stream, function(files) { // loop through each file and get the title of the heading // as well ...
[ "function", "(", "config", ",", "stream", ",", "extras", ",", "callback", ")", "{", "// Finish the stream so we get a full array of files, that", "// we can use to figure out whether add prev/next placeholders.", "streamHelpers", ".", "finishWithFiles", "(", "stream", ",", "fun...
On load we add placeholders, to be filled in later in the build process when we have the correct filenames.
[ "On", "load", "we", "add", "placeholders", "to", "be", "filled", "in", "later", "in", "the", "build", "process", "when", "we", "have", "the", "correct", "filenames", "." ]
626486dd46f5d65b61e71321832540cbfc722725
https://github.com/magicbookproject/magicbook/blob/626486dd46f5d65b61e71321832540cbfc722725/src/plugins/navigation.js#L16-L51
train
magicbookproject/magicbook
src/plugins/navigation.js
function(config, stream, extras, callback) { stream = stream.pipe(through.obj(function(file, enc, cb) { var contents = file.contents.toString(); var changed = false; if(file.prev) { changed = true; file.prev.$el = file.prev.$el || cheerio.load(file.prev.contents.toString()); ...
javascript
function(config, stream, extras, callback) { stream = stream.pipe(through.obj(function(file, enc, cb) { var contents = file.contents.toString(); var changed = false; if(file.prev) { changed = true; file.prev.$el = file.prev.$el || cheerio.load(file.prev.contents.toString()); ...
[ "function", "(", "config", ",", "stream", ",", "extras", ",", "callback", ")", "{", "stream", "=", "stream", ".", "pipe", "(", "through", ".", "obj", "(", "function", "(", "file", ",", "enc", ",", "cb", ")", "{", "var", "contents", "=", "file", "."...
Pipe through all the files and insert the title and link instead of the placeholders.
[ "Pipe", "through", "all", "the", "files", "and", "insert", "the", "title", "and", "link", "instead", "of", "the", "placeholders", "." ]
626486dd46f5d65b61e71321832540cbfc722725
https://github.com/magicbookproject/magicbook/blob/626486dd46f5d65b61e71321832540cbfc722725/src/plugins/navigation.js#L55-L88
train
magicbookproject/magicbook
src/plugins/images.js
mapImages
function mapImages(imageMap, srcFolder, destFolder) { return through.obj(function(file, enc, cb) { // find the relative path to image. If any pipe has changed the filename, // it's the original is set in orgRelative, so we look at that first. var relativeFrom = file.orgRelative || file.relative; var r...
javascript
function mapImages(imageMap, srcFolder, destFolder) { return through.obj(function(file, enc, cb) { // find the relative path to image. If any pipe has changed the filename, // it's the original is set in orgRelative, so we look at that first. var relativeFrom = file.orgRelative || file.relative; var r...
[ "function", "mapImages", "(", "imageMap", ",", "srcFolder", ",", "destFolder", ")", "{", "return", "through", ".", "obj", "(", "function", "(", "file", ",", "enc", ",", "cb", ")", "{", "// find the relative path to image. If any pipe has changed the filename,", "// ...
through2 pipe function that creates a hasmap of old -> image names.
[ "through2", "pipe", "function", "that", "creates", "a", "hasmap", "of", "old", "-", ">", "image", "names", "." ]
626486dd46f5d65b61e71321832540cbfc722725
https://github.com/magicbookproject/magicbook/blob/626486dd46f5d65b61e71321832540cbfc722725/src/plugins/images.js#L20-L29
train
magicbookproject/magicbook
src/plugins/images.js
replaceSrc
function replaceSrc(imageMap) { return through.obj(function(file, enc, cb) { file.$el = file.$el || cheerio.load(file.contents.toString()); var changed = false; // loop over each image file.$el("img").each(function(i, el) { // convert el to cheerio el var jel = file.$el(this); var ...
javascript
function replaceSrc(imageMap) { return through.obj(function(file, enc, cb) { file.$el = file.$el || cheerio.load(file.contents.toString()); var changed = false; // loop over each image file.$el("img").each(function(i, el) { // convert el to cheerio el var jel = file.$el(this); var ...
[ "function", "replaceSrc", "(", "imageMap", ")", "{", "return", "through", ".", "obj", "(", "function", "(", "file", ",", "enc", ",", "cb", ")", "{", "file", ".", "$el", "=", "file", ".", "$el", "||", "cheerio", ".", "load", "(", "file", ".", "conte...
through2 pipe function that replaces images src attributes based on values in hashmap.
[ "through2", "pipe", "function", "that", "replaces", "images", "src", "attributes", "based", "on", "values", "in", "hashmap", "." ]
626486dd46f5d65b61e71321832540cbfc722725
https://github.com/magicbookproject/magicbook/blob/626486dd46f5d65b61e71321832540cbfc722725/src/plugins/images.js#L33-L70
train
Kurento/kurento-client-js
lib/KurentoClient.js
serializeParams
function serializeParams(params) { for (var key in params) { var param = params[key]; if (param instanceof MediaObject || (param && (params.object !== undefined || params.hub !== undefined || params.sink !== undefined))) { if (param && param.id != null) { params[key] = param.id; ...
javascript
function serializeParams(params) { for (var key in params) { var param = params[key]; if (param instanceof MediaObject || (param && (params.object !== undefined || params.hub !== undefined || params.sink !== undefined))) { if (param && param.id != null) { params[key] = param.id; ...
[ "function", "serializeParams", "(", "params", ")", "{", "for", "(", "var", "key", "in", "params", ")", "{", "var", "param", "=", "params", "[", "key", "]", ";", "if", "(", "param", "instanceof", "MediaObject", "||", "(", "param", "&&", "(", "params", ...
Serialize objects using their id @function module:kurentoClient.KurentoClient~serializeParams @param {external:Object} params @return {external:Object}
[ "Serialize", "objects", "using", "their", "id" ]
c17823b0c0a4381112fb2f084f407cbca627fc42
https://github.com/Kurento/kurento-client-js/blob/c17823b0c0a4381112fb2f084f407cbca627fc42/lib/KurentoClient.js#L82-L95
train
Kurento/kurento-client-js
lib/KurentoClient.js
encodeRpc
function encodeRpc(transaction, method, params, callback) { if (transaction) return transactionOperation.call(transaction, method, params, callback); var object = params.object; if (object && object.transactions && object.transactions.length) { var error = new TransactionNotCommitedExce...
javascript
function encodeRpc(transaction, method, params, callback) { if (transaction) return transactionOperation.call(transaction, method, params, callback); var object = params.object; if (object && object.transactions && object.transactions.length) { var error = new TransactionNotCommitedExce...
[ "function", "encodeRpc", "(", "transaction", ",", "method", ",", "params", ",", "callback", ")", "{", "if", "(", "transaction", ")", "return", "transactionOperation", ".", "call", "(", "transaction", ",", "method", ",", "params", ",", "callback", ")", ";", ...
Request a generic functionality to be procesed by the server
[ "Request", "a", "generic", "functionality", "to", "be", "procesed", "by", "the", "server" ]
c17823b0c0a4381112fb2f084f407cbca627fc42
https://github.com/Kurento/kurento-client-js/blob/c17823b0c0a4381112fb2f084f407cbca627fc42/lib/KurentoClient.js#L544-L597
train
Kurento/kurento-client-js
lib/disguise.js
disguise
function disguise(target, source, unthenable) { if (source == null || target === source) return target for (var key in source) { if (target[key] !== undefined) continue if (unthenable && (key === 'then' || key === 'catch')) continue if (typeof source[key] === 'function') var descriptor = { ...
javascript
function disguise(target, source, unthenable) { if (source == null || target === source) return target for (var key in source) { if (target[key] !== undefined) continue if (unthenable && (key === 'then' || key === 'catch')) continue if (typeof source[key] === 'function') var descriptor = { ...
[ "function", "disguise", "(", "target", ",", "source", ",", "unthenable", ")", "{", "if", "(", "source", "==", "null", "||", "target", "===", "source", ")", "return", "target", "for", "(", "var", "key", "in", "source", ")", "{", "if", "(", "target", "...
Public API Disguise an object giving it the appearance of another Add bind'ed functions and properties to a `target` object delegating the actions and attributes updates to the `source` one while retaining its original personality (i.e. duplicates and `instanceof` are preserved) @param {Object} target - the object ...
[ "Public", "API", "Disguise", "an", "object", "giving", "it", "the", "appearance", "of", "another" ]
c17823b0c0a4381112fb2f084f407cbca627fc42
https://github.com/Kurento/kurento-client-js/blob/c17823b0c0a4381112fb2f084f407cbca627fc42/lib/disguise.js#L32-L58
train
Kurento/kurento-client-js
lib/disguise.js
disguiseThenable
function disguiseThenable(target, source) { if (target === source) return target if (target.then instanceof Function) { var target_then = target.then function then(onFulfilled, onRejected) { if (onFulfilled != null) onFulfilled = onFulfilled.bind(target) if (onRejected != null) onRejected = on...
javascript
function disguiseThenable(target, source) { if (target === source) return target if (target.then instanceof Function) { var target_then = target.then function then(onFulfilled, onRejected) { if (onFulfilled != null) onFulfilled = onFulfilled.bind(target) if (onRejected != null) onRejected = on...
[ "function", "disguiseThenable", "(", "target", ",", "source", ")", "{", "if", "(", "target", "===", "source", ")", "return", "target", "if", "(", "target", ".", "then", "instanceof", "Function", ")", "{", "var", "target_then", "=", "target", ".", "then", ...
Disguise a thenable object If available, `target.then()` gets replaced by a method that exec the `onFulfilled` and `onRejected` callbacks using `source` as `this` object, and return the Promise returned by the original `target.then()` method already disguised. It also add a `target.catch()` method pointing to the newl...
[ "Disguise", "a", "thenable", "object" ]
c17823b0c0a4381112fb2f084f407cbca627fc42
https://github.com/Kurento/kurento-client-js/blob/c17823b0c0a4381112fb2f084f407cbca627fc42/lib/disguise.js#L74-L100
train
Kurento/kurento-client-js
lib/MediaObjectCreator.js
getConstructor
function getConstructor(type, strict) { var result = register.classes[type.qualifiedType] || register.abstracts[type .qualifiedType] || register.classes[type.type] || register.abstracts[type.type] || register.classes[type] || register.abstracts[type]; if (result) return result; if (type.hierarchy !...
javascript
function getConstructor(type, strict) { var result = register.classes[type.qualifiedType] || register.abstracts[type .qualifiedType] || register.classes[type.type] || register.abstracts[type.type] || register.classes[type] || register.abstracts[type]; if (result) return result; if (type.hierarchy !...
[ "function", "getConstructor", "(", "type", ",", "strict", ")", "{", "var", "result", "=", "register", ".", "classes", "[", "type", ".", "qualifiedType", "]", "||", "register", ".", "abstracts", "[", "type", ".", "qualifiedType", "]", "||", "register", ".",...
Get the constructor for a type If the type is not registered, use generic {module:core/abstracts.MediaObject} @function module:kurentoClient~MediaObjectCreator~getConstructor @param {external:string} type @param {external:Boolean} strict @return {module:core/abstracts.MediaObject}
[ "Get", "the", "constructor", "for", "a", "type" ]
c17823b0c0a4381112fb2f084f407cbca627fc42
https://github.com/Kurento/kurento-client-js/blob/c17823b0c0a4381112fb2f084f407cbca627fc42/lib/MediaObjectCreator.js#L40-L63
train
Kurento/kurento-client-js
lib/MediaObjectCreator.js
createMediaObject
function createMediaObject(item, callback) { var transaction = item.transaction; delete item.transaction; var constructor = createConstructor(item, strict); item = constructor.item; delete constructor.item; var params = item.params || {}; delete item.params; if (params.mediaPipeline ...
javascript
function createMediaObject(item, callback) { var transaction = item.transaction; delete item.transaction; var constructor = createConstructor(item, strict); item = constructor.item; delete constructor.item; var params = item.params || {}; delete item.params; if (params.mediaPipeline ...
[ "function", "createMediaObject", "(", "item", ",", "callback", ")", "{", "var", "transaction", "=", "item", ".", "transaction", ";", "delete", "item", ".", "transaction", ";", "var", "constructor", "=", "createConstructor", "(", "item", ",", "strict", ")", "...
Request to the server to create a new MediaElement @param item @param {module:kurentoClient~MediaObjectCreator~createMediaObjectCallback} [callback]
[ "Request", "to", "the", "server", "to", "create", "a", "new", "MediaElement" ]
c17823b0c0a4381112fb2f084f407cbca627fc42
https://github.com/Kurento/kurento-client-js/blob/c17823b0c0a4381112fb2f084f407cbca627fc42/lib/MediaObjectCreator.js#L136-L176
train
glimmerjs/glimmer-vm
bin/run-qunit.js
exec
function exec(command, args) { execa.sync(command, args, { stdio: 'inherit', preferLocal: true, }); }
javascript
function exec(command, args) { execa.sync(command, args, { stdio: 'inherit', preferLocal: true, }); }
[ "function", "exec", "(", "command", ",", "args", ")", "{", "execa", ".", "sync", "(", "command", ",", "args", ",", "{", "stdio", ":", "'inherit'", ",", "preferLocal", ":", "true", ",", "}", ")", ";", "}" ]
Executes a command and pipes stdout back to the user.
[ "Executes", "a", "command", "and", "pipes", "stdout", "back", "to", "the", "user", "." ]
6978df9dc54721dbbec36e8c3024eb187626b999
https://github.com/glimmerjs/glimmer-vm/blob/6978df9dc54721dbbec36e8c3024eb187626b999/bin/run-qunit.js#L28-L33
train
orling/grapheme-splitter
index.js
codePointAt
function codePointAt(str, idx){ if(idx === undefined){ idx = 0; } var code = str.charCodeAt(idx); // if a high surrogate if (0xD800 <= code && code <= 0xDBFF && idx < str.length - 1){ var hi = code; var low = str.charCodeAt(idx + 1); if (0xDC00 <= low && low <= 0xDFFF){ return ((hi - 0xD8...
javascript
function codePointAt(str, idx){ if(idx === undefined){ idx = 0; } var code = str.charCodeAt(idx); // if a high surrogate if (0xD800 <= code && code <= 0xDBFF && idx < str.length - 1){ var hi = code; var low = str.charCodeAt(idx + 1); if (0xDC00 <= low && low <= 0xDFFF){ return ((hi - 0xD8...
[ "function", "codePointAt", "(", "str", ",", "idx", ")", "{", "if", "(", "idx", "===", "undefined", ")", "{", "idx", "=", "0", ";", "}", "var", "code", "=", "str", ".", "charCodeAt", "(", "idx", ")", ";", "// if a high surrogate", "if", "(", "0xD800",...
Private function, gets a Unicode code point from a JavaScript UTF-16 string handling surrogate pairs appropriately
[ "Private", "function", "gets", "a", "Unicode", "code", "point", "from", "a", "JavaScript", "UTF", "-", "16", "string", "handling", "surrogate", "pairs", "appropriately" ]
0609d90dcbc93b42d8ceebb7aec0eda38b5d916d
https://github.com/orling/grapheme-splitter/blob/0609d90dcbc93b42d8ceebb7aec0eda38b5d916d/index.js#L45-L76
train
Galooshi/import-js
lib/ModuleFinder.js
expandFiles
function expandFiles(files, workingDirectory) { const promises = []; files.forEach((file) => { if ( file.path !== './package.json' && file.path !== './npm-shrinkwrap.json' ) { promises.push(Promise.resolve(file)); return; } findPackageDependencies(workingDirectory, true).forEach((d...
javascript
function expandFiles(files, workingDirectory) { const promises = []; files.forEach((file) => { if ( file.path !== './package.json' && file.path !== './npm-shrinkwrap.json' ) { promises.push(Promise.resolve(file)); return; } findPackageDependencies(workingDirectory, true).forEach((d...
[ "function", "expandFiles", "(", "files", ",", "workingDirectory", ")", "{", "const", "promises", "=", "[", "]", ";", "files", ".", "forEach", "(", "(", "file", ")", "=>", "{", "if", "(", "file", ".", "path", "!==", "'./package.json'", "&&", "file", "."...
Checks for package.json or npm-shrinkwrap.json inside a list of files and expands the list of files to include package dependencies if so.
[ "Checks", "for", "package", ".", "json", "or", "npm", "-", "shrinkwrap", ".", "json", "inside", "a", "list", "of", "files", "and", "expands", "the", "list", "of", "files", "to", "include", "package", "dependencies", "if", "so", "." ]
dc8a158d15df50b2f15be3461f73706958df986d
https://github.com/Galooshi/import-js/blob/dc8a158d15df50b2f15be3461f73706958df986d/lib/ModuleFinder.js#L18-L53
train
Galooshi/import-js
lib/findExports.js
findAliasesForExports
function findAliasesForExports(nodes) { const result = new Set(['exports']); nodes.forEach((node) => { if (node.type !== 'VariableDeclaration') { return; } node.declarations.forEach(({ id, init }) => { if (!init) { return; } if (init.type !== 'Identifier') { retur...
javascript
function findAliasesForExports(nodes) { const result = new Set(['exports']); nodes.forEach((node) => { if (node.type !== 'VariableDeclaration') { return; } node.declarations.forEach(({ id, init }) => { if (!init) { return; } if (init.type !== 'Identifier') { retur...
[ "function", "findAliasesForExports", "(", "nodes", ")", "{", "const", "result", "=", "new", "Set", "(", "[", "'exports'", "]", ")", ";", "nodes", ".", "forEach", "(", "(", "node", ")", "=>", "{", "if", "(", "node", ".", "type", "!==", "'VariableDeclara...
This function will find variable declarations where `exports` is redefined as something else. E.g. const moduleName = exports;
[ "This", "function", "will", "find", "variable", "declarations", "where", "exports", "is", "redefined", "as", "something", "else", ".", "E", ".", "g", "." ]
dc8a158d15df50b2f15be3461f73706958df986d
https://github.com/Galooshi/import-js/blob/dc8a158d15df50b2f15be3461f73706958df986d/lib/findExports.js#L280-L302
train
mapbox/wellknown
index.js
stringify
function stringify (gj) { if (gj.type === 'Feature') { gj = gj.geometry; } function pairWKT (c) { return c.join(' '); } function ringWKT (r) { return r.map(pairWKT).join(', '); } function ringsWKT (r) { return r.map(ringWKT).map(wrapParens).join(', '); } function multiRingsWKT (r) ...
javascript
function stringify (gj) { if (gj.type === 'Feature') { gj = gj.geometry; } function pairWKT (c) { return c.join(' '); } function ringWKT (r) { return r.map(pairWKT).join(', '); } function ringsWKT (r) { return r.map(ringWKT).map(wrapParens).join(', '); } function multiRingsWKT (r) ...
[ "function", "stringify", "(", "gj", ")", "{", "if", "(", "gj", ".", "type", "===", "'Feature'", ")", "{", "gj", "=", "gj", ".", "geometry", ";", "}", "function", "pairWKT", "(", "c", ")", "{", "return", "c", ".", "join", "(", "' '", ")", ";", "...
Stringifies a GeoJSON object into WKT
[ "Stringifies", "a", "GeoJSON", "object", "into", "WKT" ]
2d22aee0968bcfc11d58ea7dea0d7da1f1def541
https://github.com/mapbox/wellknown/blob/2d22aee0968bcfc11d58ea7dea0d7da1f1def541/index.js#L229-L270
train
anvilresearch/connect
oidc/sendVerificationEmail.js
sendVerificationEmail
function sendVerificationEmail (req, res, next) { // skip if we don't need to send the email if (!req.sendVerificationEmail) { next() // send the email } else { var user = req.user var ttl = (settings.emailVerification && settings.emailVerification.tokenTTL) || (3600 * 24 * 7) One...
javascript
function sendVerificationEmail (req, res, next) { // skip if we don't need to send the email if (!req.sendVerificationEmail) { next() // send the email } else { var user = req.user var ttl = (settings.emailVerification && settings.emailVerification.tokenTTL) || (3600 * 24 * 7) One...
[ "function", "sendVerificationEmail", "(", "req", ",", "res", ",", "next", ")", "{", "// skip if we don't need to send the email", "if", "(", "!", "req", ".", "sendVerificationEmail", ")", "{", "next", "(", ")", "// send the email", "}", "else", "{", "var", "user...
Send verification email middleware
[ "Send", "verification", "email", "middleware" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/sendVerificationEmail.js#L13-L71
train
anvilresearch/connect
oidc/determineProvider.js
determineProvider
function determineProvider (req, res, next) { var providerID = req.params.provider || req.body.provider if (providerID && settings.providers[providerID]) { req.provider = providers[providerID] } next() }
javascript
function determineProvider (req, res, next) { var providerID = req.params.provider || req.body.provider if (providerID && settings.providers[providerID]) { req.provider = providers[providerID] } next() }
[ "function", "determineProvider", "(", "req", ",", "res", ",", "next", ")", "{", "var", "providerID", "=", "req", ".", "params", ".", "provider", "||", "req", ".", "body", ".", "provider", "if", "(", "providerID", "&&", "settings", ".", "providers", "[", ...
Determine provider middleware
[ "Determine", "provider", "middleware" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/determineProvider.js#L12-L18
train
anvilresearch/connect
lib/authenticator.js
setUserOnRequest
function setUserOnRequest (req, res, next) { if (!req.session || !req.session.user) { return next() } User.get(req.session.user, function (err, user) { if (err) { return next(err) } if (!user) { delete req.session.user return next() } req.user = user next() }) }
javascript
function setUserOnRequest (req, res, next) { if (!req.session || !req.session.user) { return next() } User.get(req.session.user, function (err, user) { if (err) { return next(err) } if (!user) { delete req.session.user return next() } req.user = user next() }) }
[ "function", "setUserOnRequest", "(", "req", ",", "res", ",", "next", ")", "{", "if", "(", "!", "req", ".", "session", "||", "!", "req", ".", "session", ".", "user", ")", "{", "return", "next", "(", ")", "}", "User", ".", "get", "(", "req", ".", ...
Set req.user
[ "Set", "req", ".", "user" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/lib/authenticator.js#L44-L60
train
anvilresearch/connect
models/User.js
hashPassword
function hashPassword (data) { var password = data.password var hash = data.hash if (password) { var salt = bcrypt.genSaltSync(10) hash = bcrypt.hashSync(password, salt) } this.hash = hash }
javascript
function hashPassword (data) { var password = data.password var hash = data.hash if (password) { var salt = bcrypt.genSaltSync(10) hash = bcrypt.hashSync(password, salt) } this.hash = hash }
[ "function", "hashPassword", "(", "data", ")", "{", "var", "password", "=", "data", ".", "password", "var", "hash", "=", "data", ".", "hash", "if", "(", "password", ")", "{", "var", "salt", "=", "bcrypt", ".", "genSaltSync", "(", "10", ")", "hash", "=...
Hash Password Setter
[ "Hash", "Password", "Setter" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/models/User.js#L93-L103
train
anvilresearch/connect
models/Client.js
function (req, callback) { var params = req.body var clientId = params.client_id var clientSecret = params.client_secret // missing credentials if (!clientId || !clientSecret) { return callback(new AuthorizationError({ error: 'unauthorized_client', error_description: 'Missing ...
javascript
function (req, callback) { var params = req.body var clientId = params.client_id var clientSecret = params.client_secret // missing credentials if (!clientId || !clientSecret) { return callback(new AuthorizationError({ error: 'unauthorized_client', error_description: 'Missing ...
[ "function", "(", "req", ",", "callback", ")", "{", "var", "params", "=", "req", ".", "body", "var", "clientId", "=", "params", ".", "client_id", "var", "clientSecret", "=", "params", ".", "client_secret", "// missing credentials", "if", "(", "!", "clientId",...
HTTP POST body authentication
[ "HTTP", "POST", "body", "authentication" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/models/Client.js#L1007-L1044
train
anvilresearch/connect
protocols/LDAP.js
dnToDomain
function dnToDomain (dn) { if (!dn || typeof dn !== 'string') { return null } var matches = domainDnRegex.exec(dn) if (matches) { return matches[1].replace(dnPartRegex, '$1.').toLowerCase() } else { return null } }
javascript
function dnToDomain (dn) { if (!dn || typeof dn !== 'string') { return null } var matches = domainDnRegex.exec(dn) if (matches) { return matches[1].replace(dnPartRegex, '$1.').toLowerCase() } else { return null } }
[ "function", "dnToDomain", "(", "dn", ")", "{", "if", "(", "!", "dn", "||", "typeof", "dn", "!==", "'string'", ")", "{", "return", "null", "}", "var", "matches", "=", "domainDnRegex", ".", "exec", "(", "dn", ")", "if", "(", "matches", ")", "{", "ret...
Extracts a lowercased domain from a distinguished name for comparison purposes. e.g. "CN=User,OU=MyBusiness,DC=example,DC=com" will return "example.com."
[ "Extracts", "a", "lowercased", "domain", "from", "a", "distinguished", "name", "for", "comparison", "purposes", "." ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/protocols/LDAP.js#L26-L34
train
anvilresearch/connect
protocols/LDAP.js
normalizeDN
function normalizeDN (dn) { if (!dn || typeof dn !== 'string') { return null } var normalizedDN = '' // Take advantage of replace() to grab the matched segments of the DN. If what // is left over contains unexpected characters, we assume the original DN was // malformed. var extra = dn.replace(dnPartRegex, ...
javascript
function normalizeDN (dn) { if (!dn || typeof dn !== 'string') { return null } var normalizedDN = '' // Take advantage of replace() to grab the matched segments of the DN. If what // is left over contains unexpected characters, we assume the original DN was // malformed. var extra = dn.replace(dnPartRegex, ...
[ "function", "normalizeDN", "(", "dn", ")", "{", "if", "(", "!", "dn", "||", "typeof", "dn", "!==", "'string'", ")", "{", "return", "null", "}", "var", "normalizedDN", "=", "''", "// Take advantage of replace() to grab the matched segments of the DN. If what", "// is...
Normalizes distinguished names, removing any extra whitespace, lowercasing the DN, and running some basic validation checks. If the DN is found to be malformed, will return null.
[ "Normalizes", "distinguished", "names", "removing", "any", "extra", "whitespace", "lowercasing", "the", "DN", "and", "running", "some", "basic", "validation", "checks", "." ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/protocols/LDAP.js#L43-L56
train
anvilresearch/connect
protocols/OAuth2.js
authorizationCodeGrant
function authorizationCodeGrant (code, done) { var endpoint = this.endpoints.token var provider = this.provider var client = this.client var url = endpoint.url var method = endpoint.method && endpoint.method.toLowerCase() var auth = endpoint.auth var parser = endpoint.parser var accept = endpoint.accept...
javascript
function authorizationCodeGrant (code, done) { var endpoint = this.endpoints.token var provider = this.provider var client = this.client var url = endpoint.url var method = endpoint.method && endpoint.method.toLowerCase() var auth = endpoint.auth var parser = endpoint.parser var accept = endpoint.accept...
[ "function", "authorizationCodeGrant", "(", "code", ",", "done", ")", "{", "var", "endpoint", "=", "this", ".", "endpoints", ".", "token", "var", "provider", "=", "this", ".", "provider", "var", "client", "=", "this", ".", "client", "var", "url", "=", "en...
Authorization Code Grant Request
[ "Authorization", "Code", "Grant", "Request" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/protocols/OAuth2.js#L166-L214
train
anvilresearch/connect
models/UserApplications.js
function (done) { Client.listByTrusted('true', { select: [ '_id', 'client_name', 'client_uri', 'application_type', 'logo_uri', 'trusted', 'scopes', 'created', 'modified' ] }, function (err, clients) { ...
javascript
function (done) { Client.listByTrusted('true', { select: [ '_id', 'client_name', 'client_uri', 'application_type', 'logo_uri', 'trusted', 'scopes', 'created', 'modified' ] }, function (err, clients) { ...
[ "function", "(", "done", ")", "{", "Client", ".", "listByTrusted", "(", "'true'", ",", "{", "select", ":", "[", "'_id'", ",", "'client_name'", ",", "'client_uri'", ",", "'application_type'", ",", "'logo_uri'", ",", "'trusted'", ",", "'scopes'", ",", "'create...
List the trusted clients
[ "List", "the", "trusted", "clients" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/models/UserApplications.js#L15-L32
train
anvilresearch/connect
models/UserApplications.js
function (done) { user.authorizedScope(function (err, scopes) { if (err) { return done(err) } done(null, scopes) }) }
javascript
function (done) { user.authorizedScope(function (err, scopes) { if (err) { return done(err) } done(null, scopes) }) }
[ "function", "(", "done", ")", "{", "user", ".", "authorizedScope", "(", "function", "(", "err", ",", "scopes", ")", "{", "if", "(", "err", ")", "{", "return", "done", "(", "err", ")", "}", "done", "(", "null", ",", "scopes", ")", "}", ")", "}" ]
Get the authorized scope for the user
[ "Get", "the", "authorized", "scope", "for", "the", "user" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/models/UserApplications.js#L35-L40
train
anvilresearch/connect
models/UserApplications.js
function (done) { var index = 'users:' + user._id + ':clients' Client.__client.zrevrange(index, 0, -1, function (err, ids) { if (err) { return done(err) } done(null, ids) }) }
javascript
function (done) { var index = 'users:' + user._id + ':clients' Client.__client.zrevrange(index, 0, -1, function (err, ids) { if (err) { return done(err) } done(null, ids) }) }
[ "function", "(", "done", ")", "{", "var", "index", "=", "'users:'", "+", "user", ".", "_id", "+", "':clients'", "Client", ".", "__client", ".", "zrevrange", "(", "index", ",", "0", ",", "-", "1", ",", "function", "(", "err", ",", "ids", ")", "{", ...
List of client ids the user has visited
[ "List", "of", "client", "ids", "the", "user", "has", "visited" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/models/UserApplications.js#L43-L49
train
anvilresearch/connect
public/javascript/session.js
setOPBrowserState
function setOPBrowserState (event) { var key = 'anvil.connect.op.state' var current = localStorage[key] var update = event.data if (current !== update) { document.cookie = 'anvil.connect.op.state=' + update localStorage['anvil.connect.op.state'] = update } }
javascript
function setOPBrowserState (event) { var key = 'anvil.connect.op.state' var current = localStorage[key] var update = event.data if (current !== update) { document.cookie = 'anvil.connect.op.state=' + update localStorage['anvil.connect.op.state'] = update } }
[ "function", "setOPBrowserState", "(", "event", ")", "{", "var", "key", "=", "'anvil.connect.op.state'", "var", "current", "=", "localStorage", "[", "key", "]", "var", "update", "=", "event", ".", "data", "if", "(", "current", "!==", "update", ")", "{", "do...
Set browser state
[ "Set", "browser", "state" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/public/javascript/session.js#L29-L38
train
anvilresearch/connect
public/javascript/session.js
pushToRP
function pushToRP (event) { if (source) { console.log('updating RP: changed') source.postMessage('changed', origin) } else { console.log('updateRP called but source undefined') } }
javascript
function pushToRP (event) { if (source) { console.log('updating RP: changed') source.postMessage('changed', origin) } else { console.log('updateRP called but source undefined') } }
[ "function", "pushToRP", "(", "event", ")", "{", "if", "(", "source", ")", "{", "console", ".", "log", "(", "'updating RP: changed'", ")", "source", ".", "postMessage", "(", "'changed'", ",", "origin", ")", "}", "else", "{", "console", ".", "log", "(", ...
Watch localStorage and keep the RP updated
[ "Watch", "localStorage", "and", "keep", "the", "RP", "updated" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/public/javascript/session.js#L51-L58
train
anvilresearch/connect
public/javascript/session.js
respondToRPMessage
function respondToRPMessage (event) { var parser, messenger, clientId, rpss, salt, opbs, input, opss, comparison // Parse message origin origin = event.origin parser = document.createElement('a') parser.href = document.referrer messenger = parser.protocol + '//' + parser.host // Igno...
javascript
function respondToRPMessage (event) { var parser, messenger, clientId, rpss, salt, opbs, input, opss, comparison // Parse message origin origin = event.origin parser = document.createElement('a') parser.href = document.referrer messenger = parser.protocol + '//' + parser.host // Igno...
[ "function", "respondToRPMessage", "(", "event", ")", "{", "var", "parser", ",", "messenger", ",", "clientId", ",", "rpss", ",", "salt", ",", "opbs", ",", "input", ",", "opss", ",", "comparison", "// Parse message origin", "origin", "=", "event", ".", "origin...
Respond to RP postMessage
[ "Respond", "to", "RP", "postMessage" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/public/javascript/session.js#L74-L115
train
anvilresearch/connect
oidc/getBearerToken.js
getBearerToken
function getBearerToken (req, res, next) { // check for access token in the authorization header if (req.authorization.scheme && req.authorization.scheme.match(/Bearer/i)) { req.bearer = req.authorization.credentials } // check for access token in the query params if (req.query && req.query.access_token)...
javascript
function getBearerToken (req, res, next) { // check for access token in the authorization header if (req.authorization.scheme && req.authorization.scheme.match(/Bearer/i)) { req.bearer = req.authorization.credentials } // check for access token in the query params if (req.query && req.query.access_token)...
[ "function", "getBearerToken", "(", "req", ",", "res", ",", "next", ")", "{", "// check for access token in the authorization header", "if", "(", "req", ".", "authorization", ".", "scheme", "&&", "req", ".", "authorization", ".", "scheme", ".", "match", "(", "/",...
Get Bearer Token NOTE: This middleware assumes parseAuthorizationHeader has been invoked upstream.
[ "Get", "Bearer", "Token" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/getBearerToken.js#L14-L56
train
anvilresearch/connect
oidc/selectConnectParams.js
selectConnectParams
function selectConnectParams (req, res, next) { req.connectParams = req[lookupField[req.method]] || {} next() }
javascript
function selectConnectParams (req, res, next) { req.connectParams = req[lookupField[req.method]] || {} next() }
[ "function", "selectConnectParams", "(", "req", ",", "res", ",", "next", ")", "{", "req", ".", "connectParams", "=", "req", "[", "lookupField", "[", "req", ".", "method", "]", "]", "||", "{", "}", "next", "(", ")", "}" ]
Select Authorization Parameters
[ "Select", "Authorization", "Parameters" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/selectConnectParams.js#L18-L21
train
anvilresearch/connect
models/AccessToken.js
function (done) { // the token is random if (token.indexOf('.') === -1) { AccessToken.get(token, function (err, instance) { if (err) { return done(err) } if (!instance) { return done(new UnauthorizedError({ realm: 'user', ...
javascript
function (done) { // the token is random if (token.indexOf('.') === -1) { AccessToken.get(token, function (err, instance) { if (err) { return done(err) } if (!instance) { return done(new UnauthorizedError({ realm: 'user', ...
[ "function", "(", "done", ")", "{", "// the token is random", "if", "(", "token", ".", "indexOf", "(", "'.'", ")", "===", "-", "1", ")", "{", "AccessToken", ".", "get", "(", "token", ",", "function", "(", "err", ",", "instance", ")", "{", "if", "(", ...
Fetch from database
[ "Fetch", "from", "database" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/models/AccessToken.js#L279-L311
train
anvilresearch/connect
oidc/determineClientScope.js
determineClientScope
function determineClientScope (req, res, next) { var params = req.connectParams var subject = req.client var scope = params.scope || subject.default_client_scope if (params.grant_type === 'client_credentials') { Scope.determine(scope, subject, function (err, scope, scopes) { if (err) { return next(er...
javascript
function determineClientScope (req, res, next) { var params = req.connectParams var subject = req.client var scope = params.scope || subject.default_client_scope if (params.grant_type === 'client_credentials') { Scope.determine(scope, subject, function (err, scope, scopes) { if (err) { return next(er...
[ "function", "determineClientScope", "(", "req", ",", "res", ",", "next", ")", "{", "var", "params", "=", "req", ".", "connectParams", "var", "subject", "=", "req", ".", "client", "var", "scope", "=", "params", ".", "scope", "||", "subject", ".", "default...
Determine client scope
[ "Determine", "client", "scope" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/determineClientScope.js#L11-L26
train
anvilresearch/connect
oidc/unstashParams.js
unstashParams
function unstashParams (req, res, next) { // OAuth 2.0 callbacks should have a state param // OAuth 1.0 must use the session to store the state value var id = req.query.state || req.session.state var key = 'authorization:' + id if (!id) { // && request is OAuth 2.0 return next(new MissingStateError()) ...
javascript
function unstashParams (req, res, next) { // OAuth 2.0 callbacks should have a state param // OAuth 1.0 must use the session to store the state value var id = req.query.state || req.session.state var key = 'authorization:' + id if (!id) { // && request is OAuth 2.0 return next(new MissingStateError()) ...
[ "function", "unstashParams", "(", "req", ",", "res", ",", "next", ")", "{", "// OAuth 2.0 callbacks should have a state param", "// OAuth 1.0 must use the session to store the state value", "var", "id", "=", "req", ".", "query", ".", "state", "||", "req", ".", "session"...
Unstash authorization params
[ "Unstash", "authorization", "params" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/unstashParams.js#L13-L37
train
anvilresearch/connect
oidc/verifyAuthorizationCode.js
verifyAuthorizationCode
function verifyAuthorizationCode (req, res, next) { var params = req.connectParams if (params.grant_type === 'authorization_code') { AuthorizationCode.getByCode(params.code, function (err, ac) { if (err) { return next(err) } // Can't find authorization code if (!ac) { return next(new...
javascript
function verifyAuthorizationCode (req, res, next) { var params = req.connectParams if (params.grant_type === 'authorization_code') { AuthorizationCode.getByCode(params.code, function (err, ac) { if (err) { return next(err) } // Can't find authorization code if (!ac) { return next(new...
[ "function", "verifyAuthorizationCode", "(", "req", ",", "res", ",", "next", ")", "{", "var", "params", "=", "req", ".", "connectParams", "if", "(", "params", ".", "grant_type", "===", "'authorization_code'", ")", "{", "AuthorizationCode", ".", "getByCode", "("...
Verify authorization code
[ "Verify", "authorization", "code" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/verifyAuthorizationCode.js#L13-L84
train
anvilresearch/connect
oidc/parseAuthorizationHeader.js
parseAuthorizationHeader
function parseAuthorizationHeader (req, res, next) { // parse the header if it's present in the request if (req.headers && req.headers.authorization) { var components = req.headers.authorization.split(' ') var scheme = components[0] var credentials = components[1] // ensure the correct number of co...
javascript
function parseAuthorizationHeader (req, res, next) { // parse the header if it's present in the request if (req.headers && req.headers.authorization) { var components = req.headers.authorization.split(' ') var scheme = components[0] var credentials = components[1] // ensure the correct number of co...
[ "function", "parseAuthorizationHeader", "(", "req", ",", "res", ",", "next", ")", "{", "// parse the header if it's present in the request", "if", "(", "req", ".", "headers", "&&", "req", ".", "headers", ".", "authorization", ")", "{", "var", "components", "=", ...
Parse Authorization Header
[ "Parse", "Authorization", "Header" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/parseAuthorizationHeader.js#L11-L47
train
anvilresearch/connect
routes/signup.js
createUser
function createUser (req, res, next) { User.insert(req.body, { private: true }, function (err, user) { if (err) { res.render('signup', { params: qs.stringify(req.body), request: req.body, providers: settings.providers, error: err.message }) } else ...
javascript
function createUser (req, res, next) { User.insert(req.body, { private: true }, function (err, user) { if (err) { res.render('signup', { params: qs.stringify(req.body), request: req.body, providers: settings.providers, error: err.message }) } else ...
[ "function", "createUser", "(", "req", ",", "res", ",", "next", ")", "{", "User", ".", "insert", "(", "req", ".", "body", ",", "{", "private", ":", "true", "}", ",", "function", "(", "err", ",", "user", ")", "{", "if", "(", "err", ")", "{", "res...
Password signup handler
[ "Password", "signup", "handler" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/routes/signup.js#L41-L64
train
anvilresearch/connect
oidc/verifyClientToken.js
verifyClientToken
function verifyClientToken (req, res, next) { var header = req.headers['authorization'] // missing header if (!header) { return next(new UnauthorizedError({ realm: 'client', error: 'unauthorized_client', error_description: 'Missing authorization header', statusCode: 403 })) // ...
javascript
function verifyClientToken (req, res, next) { var header = req.headers['authorization'] // missing header if (!header) { return next(new UnauthorizedError({ realm: 'client', error: 'unauthorized_client', error_description: 'Missing authorization header', statusCode: 403 })) // ...
[ "function", "verifyClientToken", "(", "req", ",", "res", ",", "next", ")", "{", "var", "header", "=", "req", ".", "headers", "[", "'authorization'", "]", "// missing header", "if", "(", "!", "header", ")", "{", "return", "next", "(", "new", "UnauthorizedEr...
Client Bearer Token Authentication Middleware
[ "Client", "Bearer", "Token", "Authentication", "Middleware" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/verifyClientToken.js#L13-L46
train
anvilresearch/connect
boot/mailer.js
render
function render (template, locals, callback) { var engineExt = engineName.charAt(0) === '.' ? engineName : ('.' + engineName) var tmplPath = path.join(templatesDir, template + engineExt) var origTmplPath = path.join(origTemplatesDir, template + engineExt) function renderToText (html) { var text = htmlToT...
javascript
function render (template, locals, callback) { var engineExt = engineName.charAt(0) === '.' ? engineName : ('.' + engineName) var tmplPath = path.join(templatesDir, template + engineExt) var origTmplPath = path.join(origTemplatesDir, template + engineExt) function renderToText (html) { var text = htmlToT...
[ "function", "render", "(", "template", ",", "locals", ",", "callback", ")", "{", "var", "engineExt", "=", "engineName", ".", "charAt", "(", "0", ")", "===", "'.'", "?", "engineName", ":", "(", "'.'", "+", "engineName", ")", "var", "tmplPath", "=", "pat...
Render e-mail templates to HTML and text
[ "Render", "e", "-", "mail", "templates", "to", "HTML", "and", "text" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/boot/mailer.js#L20-L45
train
anvilresearch/connect
boot/mailer.js
sendMail
function sendMail (template, locals, options, callback) { var self = this this.render(template, locals, function (err, html, text) { if (err) { return callback(err) } self.transport.sendMail({ from: options.from || defaultFrom, to: options.to, subject: options.subject, html: html, ...
javascript
function sendMail (template, locals, options, callback) { var self = this this.render(template, locals, function (err, html, text) { if (err) { return callback(err) } self.transport.sendMail({ from: options.from || defaultFrom, to: options.to, subject: options.subject, html: html, ...
[ "function", "sendMail", "(", "template", ",", "locals", ",", "options", ",", "callback", ")", "{", "var", "self", "=", "this", "this", ".", "render", "(", "template", ",", "locals", ",", "function", "(", "err", ",", "html", ",", "text", ")", "{", "if...
Helper function to send e-mails using templates
[ "Helper", "function", "to", "send", "e", "-", "mails", "using", "templates" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/boot/mailer.js#L51-L64
train
anvilresearch/connect
oidc/setSessionAmr.js
setSessionAmr
function setSessionAmr (session, amr) { if (amr) { if (!Array.isArray(amr)) { session.amr = [amr] } else if (session.amr.indexOf(amr) === -1) { session.amr.push(amr) } } }
javascript
function setSessionAmr (session, amr) { if (amr) { if (!Array.isArray(amr)) { session.amr = [amr] } else if (session.amr.indexOf(amr) === -1) { session.amr.push(amr) } } }
[ "function", "setSessionAmr", "(", "session", ",", "amr", ")", "{", "if", "(", "amr", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "amr", ")", ")", "{", "session", ".", "amr", "=", "[", "amr", "]", "}", "else", "if", "(", "session", "...
Set Session `amr` claim The `amr` claim is an OIDC ID Token property used to indicate the type(s) of authentication for the current session. This value is set when users authenticate.
[ "Set", "Session", "amr", "claim" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/setSessionAmr.js#L10-L18
train
anvilresearch/connect
boot/setup.js
isOOB
function isOOB (cb) { User.listByRoles('authority', function (err, users) { if (err) { return cb(err) } // return true if there are no authority users return cb(null, !users || !users.length) }) }
javascript
function isOOB (cb) { User.listByRoles('authority', function (err, users) { if (err) { return cb(err) } // return true if there are no authority users return cb(null, !users || !users.length) }) }
[ "function", "isOOB", "(", "cb", ")", "{", "User", ".", "listByRoles", "(", "'authority'", ",", "function", "(", "err", ",", "users", ")", "{", "if", "(", "err", ")", "{", "return", "cb", "(", "err", ")", "}", "// return true if there are no authority users...
Check if server is in out-of-box mode
[ "Check", "if", "server", "is", "in", "out", "-", "of", "-", "box", "mode" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/boot/setup.js#L15-L21
train
anvilresearch/connect
boot/setup.js
readSetupToken
function readSetupToken (cb) { var token var write = false try { // try to read setup token from filesystem token = keygen.loadSetupToken() // if token is blank, try to generate a new token and save it if (!token.trim()) { write = true } } catch (err) { // if unable to read, try t...
javascript
function readSetupToken (cb) { var token var write = false try { // try to read setup token from filesystem token = keygen.loadSetupToken() // if token is blank, try to generate a new token and save it if (!token.trim()) { write = true } } catch (err) { // if unable to read, try t...
[ "function", "readSetupToken", "(", "cb", ")", "{", "var", "token", "var", "write", "=", "false", "try", "{", "// try to read setup token from filesystem", "token", "=", "keygen", ".", "loadSetupToken", "(", ")", "// if token is blank, try to generate a new token and save ...
Read setup token from filesystem or create if missing
[ "Read", "setup", "token", "from", "filesystem", "or", "create", "if", "missing" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/boot/setup.js#L29-L56
train
anvilresearch/connect
oidc/verifyClientIdentifiers.js
verifyClientIdentifiers
function verifyClientIdentifiers (req, res, next) { // mismatching client identifiers if (req.token.payload.sub !== req.params.clientId) { return next(new AuthorizationError({ error: 'unauthorized_client', error_description: 'Mismatching client id', statusCode: 403 })) // all's well }...
javascript
function verifyClientIdentifiers (req, res, next) { // mismatching client identifiers if (req.token.payload.sub !== req.params.clientId) { return next(new AuthorizationError({ error: 'unauthorized_client', error_description: 'Mismatching client id', statusCode: 403 })) // all's well }...
[ "function", "verifyClientIdentifiers", "(", "req", ",", "res", ",", "next", ")", "{", "// mismatching client identifiers", "if", "(", "req", ".", "token", ".", "payload", ".", "sub", "!==", "req", ".", "params", ".", "clientId", ")", "{", "return", "next", ...
Verify Client Params
[ "Verify", "Client", "Params" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/verifyClientIdentifiers.js#L11-L24
train
anvilresearch/connect
oidc/verifyRedirectURI.js
verifyRedirectURI
function verifyRedirectURI (req, res, next) { var params = req.connectParams Client.get(params.client_id, { private: true }, function (err, client) { if (err) { return next(err) } // The client must be registered. if (!client || client.redirect_uris.indexOf(params.redirect_uri) === -1) { d...
javascript
function verifyRedirectURI (req, res, next) { var params = req.connectParams Client.get(params.client_id, { private: true }, function (err, client) { if (err) { return next(err) } // The client must be registered. if (!client || client.redirect_uris.indexOf(params.redirect_uri) === -1) { d...
[ "function", "verifyRedirectURI", "(", "req", ",", "res", ",", "next", ")", "{", "var", "params", "=", "req", ".", "connectParams", "Client", ".", "get", "(", "params", ".", "client_id", ",", "{", "private", ":", "true", "}", ",", "function", "(", "err"...
Verify Redirect URI This route-specific middleware retrieves a registered client and adds it to the request object for use downstream. It verifies that the client is registered and that the redirect_uri parameter matches the configuration of the registered client. However, unlike the verifyClient middleware, this mid...
[ "Verify", "Redirect", "URI" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/verifyRedirectURI.js#L20-L42
train
anvilresearch/connect
oidc/determineUserScope.js
determineUserScope
function determineUserScope (req, res, next) { var params = req.connectParams var scope = params.scope var subject = req.user Scope.determine(scope, subject, function (err, scope, scopes) { if (err) { return next(err) } req.scope = scope req.scopes = scopes next() }) }
javascript
function determineUserScope (req, res, next) { var params = req.connectParams var scope = params.scope var subject = req.user Scope.determine(scope, subject, function (err, scope, scopes) { if (err) { return next(err) } req.scope = scope req.scopes = scopes next() }) }
[ "function", "determineUserScope", "(", "req", ",", "res", ",", "next", ")", "{", "var", "params", "=", "req", ".", "connectParams", "var", "scope", "=", "params", ".", "scope", "var", "subject", "=", "req", ".", "user", "Scope", ".", "determine", "(", ...
Determine user scope
[ "Determine", "user", "scope" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/determineUserScope.js#L11-L22
train
anvilresearch/connect
oidc/promptToAuthorize.js
promptToAuthorize
function promptToAuthorize (req, res, next) { var params = req.connectParams var client = req.client var user = req.user var scopes = req.scopes // The client is not trusted and the user has yet to decide on consent if (client.trusted !== true && typeof params.authorize === 'undefined') { // check for ...
javascript
function promptToAuthorize (req, res, next) { var params = req.connectParams var client = req.client var user = req.user var scopes = req.scopes // The client is not trusted and the user has yet to decide on consent if (client.trusted !== true && typeof params.authorize === 'undefined') { // check for ...
[ "function", "promptToAuthorize", "(", "req", ",", "res", ",", "next", ")", "{", "var", "params", "=", "req", ".", "connectParams", "var", "client", "=", "req", ".", "client", "var", "user", "=", "req", ".", "user", "var", "scopes", "=", "req", ".", "...
Prompt to authorize
[ "Prompt", "to", "authorize" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/promptToAuthorize.js#L12-L57
train
anvilresearch/connect
oidc/verifyClientRegistration.js
verifyClientRegistration
function verifyClientRegistration (req, res, next) { // check if we have a token and a token is required var registration = req.body var claims = req.claims var clientRegType = settings.client_registration var required = (registration.trusted || clientRegType !== 'dynamic') var trustedRegScope = settings.tr...
javascript
function verifyClientRegistration (req, res, next) { // check if we have a token and a token is required var registration = req.body var claims = req.claims var clientRegType = settings.client_registration var required = (registration.trusted || clientRegType !== 'dynamic') var trustedRegScope = settings.tr...
[ "function", "verifyClientRegistration", "(", "req", ",", "res", ",", "next", ")", "{", "// check if we have a token and a token is required", "var", "registration", "=", "req", ".", "body", "var", "claims", "=", "req", ".", "claims", "var", "clientRegType", "=", "...
Verify Client Registration NOTE: verifyAccessToken and its dependencies should be used upstream. This middleware assumes that if a token is present, it has already been verified. It will invoke the error handler if any of the following are true 1. a token is required, but not present 2. registration contains the "tru...
[ "Verify", "Client", "Registration" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/verifyClientRegistration.js#L22-L70
train
anvilresearch/connect
oidc/validateTokenParams.js
validateTokenParams
function validateTokenParams (req, res, next) { var params = req.body // missing grant type if (!params.grant_type) { return next(new AuthorizationError({ error: 'invalid_request', error_description: 'Missing grant type', statusCode: 400 })) } // unsupported grant type if (grantT...
javascript
function validateTokenParams (req, res, next) { var params = req.body // missing grant type if (!params.grant_type) { return next(new AuthorizationError({ error: 'invalid_request', error_description: 'Missing grant type', statusCode: 400 })) } // unsupported grant type if (grantT...
[ "function", "validateTokenParams", "(", "req", ",", "res", ",", "next", ")", "{", "var", "params", "=", "req", ".", "body", "// missing grant type", "if", "(", "!", "params", ".", "grant_type", ")", "{", "return", "next", "(", "new", "AuthorizationError", ...
Validate token parameters
[ "Validate", "token", "parameters" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/validateTokenParams.js#L19-L68
train
anvilresearch/connect
oidc/stashParams.js
stashParams
function stashParams (req, res, next) { var id = crypto.randomBytes(10).toString('hex') var key = 'authorization:' + id var ttl = 1200 // 20 minutes var params = JSON.stringify(req.connectParams) var multi = client.multi() req.session.state = id req.authorizationId = id multi.set(key, params) multi....
javascript
function stashParams (req, res, next) { var id = crypto.randomBytes(10).toString('hex') var key = 'authorization:' + id var ttl = 1200 // 20 minutes var params = JSON.stringify(req.connectParams) var multi = client.multi() req.session.state = id req.authorizationId = id multi.set(key, params) multi....
[ "function", "stashParams", "(", "req", ",", "res", ",", "next", ")", "{", "var", "id", "=", "crypto", ".", "randomBytes", "(", "10", ")", ".", "toString", "(", "'hex'", ")", "var", "key", "=", "'authorization:'", "+", "id", "var", "ttl", "=", "1200",...
Stash authorization params
[ "Stash", "authorization", "params" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/stashParams.js#L12-L27
train
anvilresearch/connect
oidc/getAuthorizedScopes.js
getAuthorizedScopes
function getAuthorizedScopes (req, res, next) { // Get the scopes authorized for the verified and decoded token var scopeNames = req.claims.scope && req.claims.scope.split(' ') Scope.get(scopeNames, function (err, scopes) { if (err) { return next(err) } req.scopes = scopes next() }) }
javascript
function getAuthorizedScopes (req, res, next) { // Get the scopes authorized for the verified and decoded token var scopeNames = req.claims.scope && req.claims.scope.split(' ') Scope.get(scopeNames, function (err, scopes) { if (err) { return next(err) } req.scopes = scopes next() }) }
[ "function", "getAuthorizedScopes", "(", "req", ",", "res", ",", "next", ")", "{", "// Get the scopes authorized for the verified and decoded token", "var", "scopeNames", "=", "req", ".", "claims", ".", "scope", "&&", "req", ".", "claims", ".", "scope", ".", "split...
Get Authorized Scopes Rename this to disambiguate from determineUserScope
[ "Get", "Authorized", "Scopes", "Rename", "this", "to", "disambiguate", "from", "determineUserScope" ]
23bbde151e24df14c20d2e3a209fa46ac46fd751
https://github.com/anvilresearch/connect/blob/23bbde151e24df14c20d2e3a209fa46ac46fd751/oidc/getAuthorizedScopes.js#L12-L21
train
maxogden/websocket-stream
stream.js
writev
function writev (chunks, cb) { var buffers = new Array(chunks.length) for (var i = 0; i < chunks.length; i++) { if (typeof chunks[i].chunk === 'string') { buffers[i] = Buffer.from(chunks[i], 'utf8') } else { buffers[i] = chunks[i].chunk } } this._write(Buffer.concat(bu...
javascript
function writev (chunks, cb) { var buffers = new Array(chunks.length) for (var i = 0; i < chunks.length; i++) { if (typeof chunks[i].chunk === 'string') { buffers[i] = Buffer.from(chunks[i], 'utf8') } else { buffers[i] = chunks[i].chunk } } this._write(Buffer.concat(bu...
[ "function", "writev", "(", "chunks", ",", "cb", ")", "{", "var", "buffers", "=", "new", "Array", "(", "chunks", ".", "length", ")", "for", "(", "var", "i", "=", "0", ";", "i", "<", "chunks", ".", "length", ";", "i", "++", ")", "{", "if", "(", ...
this is to be enabled only if objectMode is false
[ "this", "is", "to", "be", "enabled", "only", "if", "objectMode", "is", "false" ]
55fe5450a54700ebf2be0eae6464981ef929a555
https://github.com/maxogden/websocket-stream/blob/55fe5450a54700ebf2be0eae6464981ef929a555/stream.js#L158-L169
train
dequelabs/pattern-library
lib/composites/menu/events/main.js
onTriggerClick
function onTriggerClick(e, noFocus) { toggleSubmenu(elements.trigger, (_, done) => { Classlist(elements.trigger).toggle(ACTIVE_CLASS); const wasActive = Classlist(elements.menu).contains(ACTIVE_CLASS); const first = wasActive ? ACTIVE_CLASS : 'dqpl-show'; const second = first === ACTIVE_CLAS...
javascript
function onTriggerClick(e, noFocus) { toggleSubmenu(elements.trigger, (_, done) => { Classlist(elements.trigger).toggle(ACTIVE_CLASS); const wasActive = Classlist(elements.menu).contains(ACTIVE_CLASS); const first = wasActive ? ACTIVE_CLASS : 'dqpl-show'; const second = first === ACTIVE_CLAS...
[ "function", "onTriggerClick", "(", "e", ",", "noFocus", ")", "{", "toggleSubmenu", "(", "elements", ".", "trigger", ",", "(", "_", ",", "done", ")", "=>", "{", "Classlist", "(", "elements", ".", "trigger", ")", ".", "toggle", "(", "ACTIVE_CLASS", ")", ...
Handles clicks on trigger - toggles classes - handles animation
[ "Handles", "clicks", "on", "trigger", "-", "toggles", "classes", "-", "handles", "animation" ]
d02a4979eafbc35e3ffdb1505dc25b38fab6861f
https://github.com/dequelabs/pattern-library/blob/d02a4979eafbc35e3ffdb1505dc25b38fab6861f/lib/composites/menu/events/main.js#L268-L287
train
dequelabs/pattern-library
lib/composites/menu/events/main.js
toggleSubmenu
function toggleSubmenu(trigger, toggleFn) { const droplet = document.getElementById(trigger.getAttribute('aria-controls')); if (!droplet) { return; } toggleFn(droplet, (noFocus, focusTarget) => { const prevExpanded = droplet.getAttribute('aria-expanded'); const wasCollapsed = !prevExpanded || ...
javascript
function toggleSubmenu(trigger, toggleFn) { const droplet = document.getElementById(trigger.getAttribute('aria-controls')); if (!droplet) { return; } toggleFn(droplet, (noFocus, focusTarget) => { const prevExpanded = droplet.getAttribute('aria-expanded'); const wasCollapsed = !prevExpanded || ...
[ "function", "toggleSubmenu", "(", "trigger", ",", "toggleFn", ")", "{", "const", "droplet", "=", "document", ".", "getElementById", "(", "trigger", ".", "getAttribute", "(", "'aria-controls'", ")", ")", ";", "if", "(", "!", "droplet", ")", "{", "return", "...
Toggles a menu or submenu
[ "Toggles", "a", "menu", "or", "submenu" ]
d02a4979eafbc35e3ffdb1505dc25b38fab6861f
https://github.com/dequelabs/pattern-library/blob/d02a4979eafbc35e3ffdb1505dc25b38fab6861f/lib/composites/menu/events/main.js#L293-L315
train
dequelabs/pattern-library
lib/commons/rndid/index.js
rndid
function rndid(len) { len = len || 8; const id = rndm(len); if (document.getElementById(id)) { return rndid(len); } return id; }
javascript
function rndid(len) { len = len || 8; const id = rndm(len); if (document.getElementById(id)) { return rndid(len); } return id; }
[ "function", "rndid", "(", "len", ")", "{", "len", "=", "len", "||", "8", ";", "const", "id", "=", "rndm", "(", "len", ")", ";", "if", "(", "document", ".", "getElementById", "(", "id", ")", ")", "{", "return", "rndid", "(", "len", ")", ";", "}"...
Returns a unique dom element id
[ "Returns", "a", "unique", "dom", "element", "id" ]
d02a4979eafbc35e3ffdb1505dc25b38fab6861f
https://github.com/dequelabs/pattern-library/blob/d02a4979eafbc35e3ffdb1505dc25b38fab6861f/lib/commons/rndid/index.js#L8-L17
train
ilearnio/module-alias
index.js
init
function init (options) { if (typeof options === 'string') { options = { base: options } } options = options || {} // There is probably 99% chance that the project root directory in located // above the node_modules directory var base = nodePath.resolve( options.base || nodePath.join(__dirname, '....
javascript
function init (options) { if (typeof options === 'string') { options = { base: options } } options = options || {} // There is probably 99% chance that the project root directory in located // above the node_modules directory var base = nodePath.resolve( options.base || nodePath.join(__dirname, '....
[ "function", "init", "(", "options", ")", "{", "if", "(", "typeof", "options", "===", "'string'", ")", "{", "options", "=", "{", "base", ":", "options", "}", "}", "options", "=", "options", "||", "{", "}", "// There is probably 99% chance that the project root ...
Import aliases from package.json @param {object} options
[ "Import", "aliases", "from", "package", ".", "json" ]
a2db1e6e3785adea0c0f9a837eec518ddb49b360
https://github.com/ilearnio/module-alias/blob/a2db1e6e3785adea0c0f9a837eec518ddb49b360/index.js#L134-L184
train
MariaDB/mariadb-connector-nodejs
benchmarks/common_benchmarks.js
function() { console.log('start : init test : ' + bench.initFcts.length); for (let i = 0; i < bench.initFcts.length; i++) { console.log( 'initializing test data ' + (i + 1) + '/' + bench.initFcts.length ); if (bench.initFcts[i]) { bench.initFcts[i].call(this, benc...
javascript
function() { console.log('start : init test : ' + bench.initFcts.length); for (let i = 0; i < bench.initFcts.length; i++) { console.log( 'initializing test data ' + (i + 1) + '/' + bench.initFcts.length ); if (bench.initFcts[i]) { bench.initFcts[i].call(this, benc...
[ "function", "(", ")", "{", "console", ".", "log", "(", "'start : init test : '", "+", "bench", ".", "initFcts", ".", "length", ")", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "bench", ".", "initFcts", ".", "length", ";", "i", "++", ")", ...
called when the suite starts running
[ "called", "when", "the", "suite", "starts", "running" ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/benchmarks/common_benchmarks.js#L201-L213
train
MariaDB/mariadb-connector-nodejs
benchmarks/common_benchmarks.js
function(event) { this.currentNb++; if (this.currentNb < this.length) pingAll(connList); //to avoid mysql2 taking all the server memory if (promiseMysql2 && promiseMysql2.clearParserCache) promiseMysql2.clearParserCache(); if (mysql2 && mysql2.clearParserCache) mysql2.clearParserCa...
javascript
function(event) { this.currentNb++; if (this.currentNb < this.length) pingAll(connList); //to avoid mysql2 taking all the server memory if (promiseMysql2 && promiseMysql2.clearParserCache) promiseMysql2.clearParserCache(); if (mysql2 && mysql2.clearParserCache) mysql2.clearParserCa...
[ "function", "(", "event", ")", "{", "this", ".", "currentNb", "++", ";", "if", "(", "this", ".", "currentNb", "<", "this", ".", "length", ")", "pingAll", "(", "connList", ")", ";", "//to avoid mysql2 taking all the server memory", "if", "(", "promiseMysql2", ...
called between running benchmarks
[ "called", "between", "running", "benchmarks" ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/benchmarks/common_benchmarks.js#L216-L243
train
MariaDB/mariadb-connector-nodejs
lib/pool-base.js
function(pool, iteration, timeoutEnd) { return new Promise(function(resolve, reject) { const creationTryout = function(resolve, reject) { if (closed) { reject( Errors.createError( 'Cannot create new connection to pool, pool closed', true, ...
javascript
function(pool, iteration, timeoutEnd) { return new Promise(function(resolve, reject) { const creationTryout = function(resolve, reject) { if (closed) { reject( Errors.createError( 'Cannot create new connection to pool, pool closed', true, ...
[ "function", "(", "pool", ",", "iteration", ",", "timeoutEnd", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "const", "creationTryout", "=", "function", "(", "resolve", ",", "reject", ")", "{", "if", "(", ...
Loop for connection creation. This permits to wait before next try after a connection fail. @param pool current pool @param iteration current iteration @param timeoutEnd ending timeout @returns {Promise<any>} Connection if found, error if not
[ "Loop", "for", "connection", "creation", ".", "This", "permits", "to", "wait", "before", "next", "try", "after", "a", "connection", "fail", "." ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/lib/pool-base.js#L305-L346
train
MariaDB/mariadb-connector-nodejs
lib/pool-base.js
function(pool) { if ( !connectionInCreation && pool.idleConnections() < opts.minimumIdle && pool.totalConnections() < opts.connectionLimit && !closed ) { connectionInCreation = true; process.nextTick(() => { const timeoutEnd = Date.now() + opts.initializationTimeout; ...
javascript
function(pool) { if ( !connectionInCreation && pool.idleConnections() < opts.minimumIdle && pool.totalConnections() < opts.connectionLimit && !closed ) { connectionInCreation = true; process.nextTick(() => { const timeoutEnd = Date.now() + opts.initializationTimeout; ...
[ "function", "(", "pool", ")", "{", "if", "(", "!", "connectionInCreation", "&&", "pool", ".", "idleConnections", "(", ")", "<", "opts", ".", "minimumIdle", "&&", "pool", ".", "totalConnections", "(", ")", "<", "opts", ".", "connectionLimit", "&&", "!", "...
Grow pool connections until reaching connection limit.
[ "Grow", "pool", "connections", "until", "reaching", "connection", "limit", "." ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/lib/pool-base.js#L404-L447
train
MariaDB/mariadb-connector-nodejs
lib/pool-base.js
function(pool) { let toRemove = Math.max(1, pool.idleConnections() - opts.minimumIdle); while (toRemove > 0) { const conn = idleConnections.peek(); --toRemove; if (conn && conn.lastUse + opts.idleTimeout * 1000 < Date.now()) { idleConnections.shift(); conn.forceEnd().catch(err ...
javascript
function(pool) { let toRemove = Math.max(1, pool.idleConnections() - opts.minimumIdle); while (toRemove > 0) { const conn = idleConnections.peek(); --toRemove; if (conn && conn.lastUse + opts.idleTimeout * 1000 < Date.now()) { idleConnections.shift(); conn.forceEnd().catch(err ...
[ "function", "(", "pool", ")", "{", "let", "toRemove", "=", "Math", ".", "max", "(", "1", ",", "pool", ".", "idleConnections", "(", ")", "-", "opts", ".", "minimumIdle", ")", ";", "while", "(", "toRemove", ">", "0", ")", "{", "const", "conn", "=", ...
Permit to remove idle connection if unused for some time. @param pool current pool
[ "Permit", "to", "remove", "idle", "connection", "if", "unused", "for", "some", "time", "." ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/lib/pool-base.js#L471-L485
train
MariaDB/mariadb-connector-nodejs
lib/pool-base.js
function() { firstTaskTimeout = clearTimeout(firstTaskTimeout); const task = taskQueue.shift(); if (task) { const conn = idleConnections.shift(); if (conn) { activeConnections[conn.threadId] = conn; resetTimeoutToNextTask(); processTask(conn, task.sql, task.values, task....
javascript
function() { firstTaskTimeout = clearTimeout(firstTaskTimeout); const task = taskQueue.shift(); if (task) { const conn = idleConnections.shift(); if (conn) { activeConnections[conn.threadId] = conn; resetTimeoutToNextTask(); processTask(conn, task.sql, task.values, task....
[ "function", "(", ")", "{", "firstTaskTimeout", "=", "clearTimeout", "(", "firstTaskTimeout", ")", ";", "const", "task", "=", "taskQueue", ".", "shift", "(", ")", ";", "if", "(", "task", ")", "{", "const", "conn", "=", "idleConnections", ".", "shift", "("...
Launch next waiting task request if available connections.
[ "Launch", "next", "waiting", "task", "request", "if", "available", "connections", "." ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/lib/pool-base.js#L496-L512
train
MariaDB/mariadb-connector-nodejs
lib/connection.js
function(authFailHandler) { _timeout = null; const handshake = _receiveQueue.peekFront(); authFailHandler( Errors.createError( 'Connection timeout', true, info, '08S01', Errors.ER_CONNECTION_TIMEOUT, handshake ? handshake.stack : null ) ); }
javascript
function(authFailHandler) { _timeout = null; const handshake = _receiveQueue.peekFront(); authFailHandler( Errors.createError( 'Connection timeout', true, info, '08S01', Errors.ER_CONNECTION_TIMEOUT, handshake ? handshake.stack : null ) ); }
[ "function", "(", "authFailHandler", ")", "{", "_timeout", "=", "null", ";", "const", "handshake", "=", "_receiveQueue", ".", "peekFront", "(", ")", ";", "authFailHandler", "(", "Errors", ".", "createError", "(", "'Connection timeout'", ",", "true", ",", "info"...
Handle connection timeout. @private
[ "Handle", "connection", "timeout", "." ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/lib/connection.js#L1014-L1027
train
MariaDB/mariadb-connector-nodejs
lib/connection.js
function() { const err = Errors.createError( 'socket timeout', true, info, '08S01', Errors.ER_SOCKET_TIMEOUT ); const packetMsgs = info.getLastPackets(); if (packetMsgs !== '') { err.message = err.message + '\nlast received packets:\n' + packetMsgs; } _fatalEr...
javascript
function() { const err = Errors.createError( 'socket timeout', true, info, '08S01', Errors.ER_SOCKET_TIMEOUT ); const packetMsgs = info.getLastPackets(); if (packetMsgs !== '') { err.message = err.message + '\nlast received packets:\n' + packetMsgs; } _fatalEr...
[ "function", "(", ")", "{", "const", "err", "=", "Errors", ".", "createError", "(", "'socket timeout'", ",", "true", ",", "info", ",", "'08S01'", ",", "Errors", ".", "ER_SOCKET_TIMEOUT", ")", ";", "const", "packetMsgs", "=", "info", ".", "getLastPackets", "...
Handle socket timeout. @private
[ "Handle", "socket", "timeout", "." ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/lib/connection.js#L1034-L1047
train
MariaDB/mariadb-connector-nodejs
lib/connection.js
function(authFailHandler, err) { if (_status === Status.CLOSING || _status === Status.CLOSED) return; _socket.writeBuf = () => {}; _socket.flush = () => {}; //socket has been ended without error if (!err) { err = Errors.createError( 'socket has unexpectedly been closed', true...
javascript
function(authFailHandler, err) { if (_status === Status.CLOSING || _status === Status.CLOSED) return; _socket.writeBuf = () => {}; _socket.flush = () => {}; //socket has been ended without error if (!err) { err = Errors.createError( 'socket has unexpectedly been closed', true...
[ "function", "(", "authFailHandler", ",", "err", ")", "{", "if", "(", "_status", "===", "Status", ".", "CLOSING", "||", "_status", "===", "Status", ".", "CLOSED", ")", "return", ";", "_socket", ".", "writeBuf", "=", "(", ")", "=>", "{", "}", ";", "_so...
Handle socket error. @param authFailHandler authentication handler @param err socket error @private
[ "Handle", "socket", "error", "." ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/lib/connection.js#L1128-L1168
train
MariaDB/mariadb-connector-nodejs
lib/filtered-pool-cluster.js
FilteredPoolCluster
function FilteredPoolCluster(poolCluster, patternArg, selectorArg) { const cluster = poolCluster; const pattern = patternArg; const selector = selectorArg; /** * Get a connection according to previously indicated pattern and selector. * * @return {Promise} */ this.getConnection = () => { retu...
javascript
function FilteredPoolCluster(poolCluster, patternArg, selectorArg) { const cluster = poolCluster; const pattern = patternArg; const selector = selectorArg; /** * Get a connection according to previously indicated pattern and selector. * * @return {Promise} */ this.getConnection = () => { retu...
[ "function", "FilteredPoolCluster", "(", "poolCluster", ",", "patternArg", ",", "selectorArg", ")", "{", "const", "cluster", "=", "poolCluster", ";", "const", "pattern", "=", "patternArg", ";", "const", "selector", "=", "selectorArg", ";", "/**\n * Get a connection...
Similar to pool cluster with pre-set pattern and selector. Additional method query @param poolCluster cluster @param patternArg pre-set pattern @param selectorArg pre-set selector @constructor
[ "Similar", "to", "pool", "cluster", "with", "pre", "-", "set", "pattern", "and", "selector", ".", "Additional", "method", "query" ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/lib/filtered-pool-cluster.js#L10-L79
train
MariaDB/mariadb-connector-nodejs
lib/pool-promise.js
function(pool) { const conn = new Connection(options.connOptions); return conn .connect() .then(() => { if (pool.closed) { conn .end() .then(() => {}) .catch(() => {}); return Promise.reject( Errors.createError( ...
javascript
function(pool) { const conn = new Connection(options.connOptions); return conn .connect() .then(() => { if (pool.closed) { conn .end() .then(() => {}) .catch(() => {}); return Promise.reject( Errors.createError( ...
[ "function", "(", "pool", ")", "{", "const", "conn", "=", "new", "Connection", "(", "options", ".", "connOptions", ")", ";", "return", "conn", ".", "connect", "(", ")", ".", "then", "(", "(", ")", "=>", "{", "if", "(", "pool", ".", "closed", ")", ...
Add connection to pool.
[ "Add", "connection", "to", "pool", "." ]
a596445fcfb5c39a6861b65cff3b6cd83a84a359
https://github.com/MariaDB/mariadb-connector-nodejs/blob/a596445fcfb5c39a6861b65cff3b6cd83a84a359/lib/pool-promise.js#L27-L92
train
revolunet/angular-carousel
lib/angular-mobile.js
checkAllowableRegions
function checkAllowableRegions(touchCoordinates, x, y) { for (var i = 0; i < touchCoordinates.length; i += 2) { if (hit(touchCoordinates[i], touchCoordinates[i+1], x, y)) { touchCoordinates.splice(i, i + 2); return true; // allowable region } } return false; // No allowable regio...
javascript
function checkAllowableRegions(touchCoordinates, x, y) { for (var i = 0; i < touchCoordinates.length; i += 2) { if (hit(touchCoordinates[i], touchCoordinates[i+1], x, y)) { touchCoordinates.splice(i, i + 2); return true; // allowable region } } return false; // No allowable regio...
[ "function", "checkAllowableRegions", "(", "touchCoordinates", ",", "x", ",", "y", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "touchCoordinates", ".", "length", ";", "i", "+=", "2", ")", "{", "if", "(", "hit", "(", "touchCoordinates", ...
Checks a list of allowable regions against a click location. Returns true if the click should be allowed. Splices out the allowable region from the list after it has been used.
[ "Checks", "a", "list", "of", "allowable", "regions", "against", "a", "click", "location", ".", "Returns", "true", "if", "the", "click", "should", "be", "allowed", ".", "Splices", "out", "the", "allowable", "region", "from", "the", "list", "after", "it", "h...
adfecc8f5d4f8832dbfb21e311f195c044f8f6eb
https://github.com/revolunet/angular-carousel/blob/adfecc8f5d4f8832dbfb21e311f195c044f8f6eb/lib/angular-mobile.js#L203-L211
train
revolunet/angular-carousel
lib/angular-mobile.js
preventGhostClick
function preventGhostClick(x, y) { if (!touchCoordinates) { $rootElement[0].addEventListener('click', onClick, true); $rootElement[0].addEventListener('touchstart', onTouchStart, true); touchCoordinates = []; } lastPreventedTime = Date.now(); checkAllowableRegions(touchCoordinates, x...
javascript
function preventGhostClick(x, y) { if (!touchCoordinates) { $rootElement[0].addEventListener('click', onClick, true); $rootElement[0].addEventListener('touchstart', onTouchStart, true); touchCoordinates = []; } lastPreventedTime = Date.now(); checkAllowableRegions(touchCoordinates, x...
[ "function", "preventGhostClick", "(", "x", ",", "y", ")", "{", "if", "(", "!", "touchCoordinates", ")", "{", "$rootElement", "[", "0", "]", ".", "addEventListener", "(", "'click'", ",", "onClick", ",", "true", ")", ";", "$rootElement", "[", "0", "]", "...
On the first call, attaches some event handlers. Then whenever it gets called, it creates a zone around the touchstart where clicks will get busted.
[ "On", "the", "first", "call", "attaches", "some", "event", "handlers", ".", "Then", "whenever", "it", "gets", "called", "it", "creates", "a", "zone", "around", "the", "touchstart", "where", "clicks", "will", "get", "busted", "." ]
adfecc8f5d4f8832dbfb21e311f195c044f8f6eb
https://github.com/revolunet/angular-carousel/blob/adfecc8f5d4f8832dbfb21e311f195c044f8f6eb/lib/angular-mobile.js#L264-L274
train
revolunet/angular-carousel
dist/angular-carousel.js
Tweenable
function Tweenable (opt_initialState, opt_config) { this._currentState = opt_initialState || {}; this._configured = false; this._scheduleFunction = DEFAULT_SCHEDULE_FUNCTION; // To prevent unnecessary calls to setConfig do not set default configuration here. // Only set default configurat...
javascript
function Tweenable (opt_initialState, opt_config) { this._currentState = opt_initialState || {}; this._configured = false; this._scheduleFunction = DEFAULT_SCHEDULE_FUNCTION; // To prevent unnecessary calls to setConfig do not set default configuration here. // Only set default configurat...
[ "function", "Tweenable", "(", "opt_initialState", ",", "opt_config", ")", "{", "this", ".", "_currentState", "=", "opt_initialState", "||", "{", "}", ";", "this", ".", "_configured", "=", "false", ";", "this", ".", "_scheduleFunction", "=", "DEFAULT_SCHEDULE_FUN...
Tweenable constructor. @param {Object=} opt_initialState The values that the initial tween should start at if a "from" object is not provided to Tweenable#tween. @param {Object=} opt_config See Tweenable.prototype.setConfig() @constructor
[ "Tweenable", "constructor", "." ]
adfecc8f5d4f8832dbfb21e311f195c044f8f6eb
https://github.com/revolunet/angular-carousel/blob/adfecc8f5d4f8832dbfb21e311f195c044f8f6eb/dist/angular-carousel.js#L934-L944
train
facundoolano/aso
lib/calc.js
aggregate
function aggregate (weights, values) { const max = 10 * R.sum(weights); const min = 1 * R.sum(weights); const sum = R.sum(R.zipWith(R.multiply, weights, values)); return score(min, max, sum); }
javascript
function aggregate (weights, values) { const max = 10 * R.sum(weights); const min = 1 * R.sum(weights); const sum = R.sum(R.zipWith(R.multiply, weights, values)); return score(min, max, sum); }
[ "function", "aggregate", "(", "weights", ",", "values", ")", "{", "const", "max", "=", "10", "*", "R", ".", "sum", "(", "weights", ")", ";", "const", "min", "=", "1", "*", "R", ".", "sum", "(", "weights", ")", ";", "const", "sum", "=", "R", "."...
weighted aggregate score
[ "weighted", "aggregate", "score" ]
cdd7466c3855a0c789c65c847675e0f902bab92e
https://github.com/facundoolano/aso/blob/cdd7466c3855a0c789c65c847675e0f902bab92e/lib/calc.js#L34-L39
train
ember-cli/eslint-plugin-ember
lib/utils/utils.js
findNodes
function findNodes(body, nodeName) { let nodesArray = []; if (body) { nodesArray = body.filter(node => node.type === nodeName); } return nodesArray; }
javascript
function findNodes(body, nodeName) { let nodesArray = []; if (body) { nodesArray = body.filter(node => node.type === nodeName); } return nodesArray; }
[ "function", "findNodes", "(", "body", ",", "nodeName", ")", "{", "let", "nodesArray", "=", "[", "]", ";", "if", "(", "body", ")", "{", "nodesArray", "=", "body", ".", "filter", "(", "node", "=>", "node", ".", "type", "===", "nodeName", ")", ";", "}...
Find nodes of given name @param {Node[]} body Array of nodes @param {String} nodeName @return {Node[]}
[ "Find", "nodes", "of", "given", "name" ]
cce30db8d4c8fd0f27fa26411bfdc57864015231
https://github.com/ember-cli/eslint-plugin-ember/blob/cce30db8d4c8fd0f27fa26411bfdc57864015231/lib/utils/utils.js#L44-L52
train
ember-cli/eslint-plugin-ember
lib/utils/utils.js
isGlobalCallExpression
function isGlobalCallExpression(node, destructuredName, aliases) { const isDestructured = node && node.callee && node.callee.name === destructuredName; const isGlobalCall = node.callee && aliases.indexOf(node.callee.name) > -1; return !isDestructured && isGlobalCall; }
javascript
function isGlobalCallExpression(node, destructuredName, aliases) { const isDestructured = node && node.callee && node.callee.name === destructuredName; const isGlobalCall = node.callee && aliases.indexOf(node.callee.name) > -1; return !isDestructured && isGlobalCall; }
[ "function", "isGlobalCallExpression", "(", "node", ",", "destructuredName", ",", "aliases", ")", "{", "const", "isDestructured", "=", "node", "&&", "node", ".", "callee", "&&", "node", ".", "callee", ".", "name", "===", "destructuredName", ";", "const", "isGlo...
Check if given call is a global call This function checks whether given CallExpression node contains global function call (name is provided in the aliases array). It also gives option to check against already destructrued name and checking aliases. @param {CallExpression} node The node to check. @param {String} ...
[ "Check", "if", "given", "call", "is", "a", "global", "call" ]
cce30db8d4c8fd0f27fa26411bfdc57864015231
https://github.com/ember-cli/eslint-plugin-ember/blob/cce30db8d4c8fd0f27fa26411bfdc57864015231/lib/utils/utils.js#L265-L270
train
ember-cli/eslint-plugin-ember
lib/utils/utils.js
getSize
function getSize(node) { return (node.loc.end.line - node.loc.start.line) + 1; }
javascript
function getSize(node) { return (node.loc.end.line - node.loc.start.line) + 1; }
[ "function", "getSize", "(", "node", ")", "{", "return", "(", "node", ".", "loc", ".", "end", ".", "line", "-", "node", ".", "loc", ".", "start", ".", "line", ")", "+", "1", ";", "}" ]
Get size of expression in lines @param {Object} node The node to check. @return {Integer} Number of lines
[ "Get", "size", "of", "expression", "in", "lines" ]
cce30db8d4c8fd0f27fa26411bfdc57864015231
https://github.com/ember-cli/eslint-plugin-ember/blob/cce30db8d4c8fd0f27fa26411bfdc57864015231/lib/utils/utils.js#L286-L288
train
ember-cli/eslint-plugin-ember
lib/utils/utils.js
parseCallee
function parseCallee(node) { const parsedCallee = []; let callee; if (isCallExpression(node) || isNewExpression(node)) { callee = node.callee; while (isMemberExpression(callee)) { if (isIdentifier(callee.property)) { parsedCallee.push(callee.property.name); } callee = callee.ob...
javascript
function parseCallee(node) { const parsedCallee = []; let callee; if (isCallExpression(node) || isNewExpression(node)) { callee = node.callee; while (isMemberExpression(callee)) { if (isIdentifier(callee.property)) { parsedCallee.push(callee.property.name); } callee = callee.ob...
[ "function", "parseCallee", "(", "node", ")", "{", "const", "parsedCallee", "=", "[", "]", ";", "let", "callee", ";", "if", "(", "isCallExpression", "(", "node", ")", "||", "isNewExpression", "(", "node", ")", ")", "{", "callee", "=", "node", ".", "call...
Parse CallExpression or NewExpression to get array of properties and object name @param {Object} node The node to parse @return {String[]} eg. ['Ember', 'computed', 'alias']
[ "Parse", "CallExpression", "or", "NewExpression", "to", "get", "array", "of", "properties", "and", "object", "name" ]
cce30db8d4c8fd0f27fa26411bfdc57864015231
https://github.com/ember-cli/eslint-plugin-ember/blob/cce30db8d4c8fd0f27fa26411bfdc57864015231/lib/utils/utils.js#L296-L316
train
ember-cli/eslint-plugin-ember
lib/utils/utils.js
parseArgs
function parseArgs(node) { let parsedArgs = []; if (isCallExpression(node)) { parsedArgs = node.arguments .filter(argument => isLiteral(argument) && argument.value) .map(argument => argument.value); } return parsedArgs; }
javascript
function parseArgs(node) { let parsedArgs = []; if (isCallExpression(node)) { parsedArgs = node.arguments .filter(argument => isLiteral(argument) && argument.value) .map(argument => argument.value); } return parsedArgs; }
[ "function", "parseArgs", "(", "node", ")", "{", "let", "parsedArgs", "=", "[", "]", ";", "if", "(", "isCallExpression", "(", "node", ")", ")", "{", "parsedArgs", "=", "node", ".", "arguments", ".", "filter", "(", "argument", "=>", "isLiteral", "(", "ar...
Parse CallExpression to get array of arguments @param {Object} node Node to parse @return {String[]} Literal function's arguments
[ "Parse", "CallExpression", "to", "get", "array", "of", "arguments" ]
cce30db8d4c8fd0f27fa26411bfdc57864015231
https://github.com/ember-cli/eslint-plugin-ember/blob/cce30db8d4c8fd0f27fa26411bfdc57864015231/lib/utils/utils.js#L324-L334
train
ember-cli/eslint-plugin-ember
lib/utils/utils.js
findUnorderedProperty
function findUnorderedProperty(arr) { for (let i = 0; i < arr.length - 1; i++) { if (arr[i].order > arr[i + 1].order) { return arr[i]; } } return null; }
javascript
function findUnorderedProperty(arr) { for (let i = 0; i < arr.length - 1; i++) { if (arr[i].order > arr[i + 1].order) { return arr[i]; } } return null; }
[ "function", "findUnorderedProperty", "(", "arr", ")", "{", "for", "(", "let", "i", "=", "0", ";", "i", "<", "arr", ".", "length", "-", "1", ";", "i", "++", ")", "{", "if", "(", "arr", "[", "i", "]", ".", "order", ">", "arr", "[", "i", "+", ...
Find property that is in wrong order @param {Object[]} arr Properties with their order value @return {Object} Unordered property or null
[ "Find", "property", "that", "is", "in", "wrong", "order" ]
cce30db8d4c8fd0f27fa26411bfdc57864015231
https://github.com/ember-cli/eslint-plugin-ember/blob/cce30db8d4c8fd0f27fa26411bfdc57864015231/lib/utils/utils.js#L342-L350
train
ember-cli/eslint-plugin-ember
lib/utils/utils.js
getPropertyValue
function getPropertyValue(node, path) { const parts = typeof path === 'string' ? path.split('.') : path; if (parts.length === 1) { return node[path]; } const property = node[parts[0]]; if (property && parts.length > 1) { parts.shift(); return getPropertyValue(property, parts); } return pro...
javascript
function getPropertyValue(node, path) { const parts = typeof path === 'string' ? path.split('.') : path; if (parts.length === 1) { return node[path]; } const property = node[parts[0]]; if (property && parts.length > 1) { parts.shift(); return getPropertyValue(property, parts); } return pro...
[ "function", "getPropertyValue", "(", "node", ",", "path", ")", "{", "const", "parts", "=", "typeof", "path", "===", "'string'", "?", "path", ".", "split", "(", "'.'", ")", ":", "path", ";", "if", "(", "parts", ".", "length", "===", "1", ")", "{", "...
Gets a property's value either by property path. @example getPropertyValue('name'); getPropertyValue('parent.key.name'); @param {Object} node @param {String} path @returns
[ "Gets", "a", "property", "s", "value", "either", "by", "property", "path", "." ]
cce30db8d4c8fd0f27fa26411bfdc57864015231
https://github.com/ember-cli/eslint-plugin-ember/blob/cce30db8d4c8fd0f27fa26411bfdc57864015231/lib/utils/utils.js#L363-L378
train
ember-cli/eslint-plugin-ember
lib/utils/utils.js
collectObjectPatternBindings
function collectObjectPatternBindings(node, initialObjToBinding) { if (!isObjectPattern(node.id)) return []; const identifiers = Object.keys(initialObjToBinding); const objBindingName = node.init.name; const bindingIndex = identifiers.indexOf(objBindingName); if (bindingIndex === -1) return []; const bind...
javascript
function collectObjectPatternBindings(node, initialObjToBinding) { if (!isObjectPattern(node.id)) return []; const identifiers = Object.keys(initialObjToBinding); const objBindingName = node.init.name; const bindingIndex = identifiers.indexOf(objBindingName); if (bindingIndex === -1) return []; const bind...
[ "function", "collectObjectPatternBindings", "(", "node", ",", "initialObjToBinding", ")", "{", "if", "(", "!", "isObjectPattern", "(", "node", ".", "id", ")", ")", "return", "[", "]", ";", "const", "identifiers", "=", "Object", ".", "keys", "(", "initialObjT...
Find deconstructed bindings based on the initialObjToBinding hash. Extracts the names of destructured properties, even if they are aliased. `initialObjToBinding` should should have variable names as keys and bindings array as values. Given `const { $: foo } = Ember` it will return `['foo']`. @param {VariableDeclarat...
[ "Find", "deconstructed", "bindings", "based", "on", "the", "initialObjToBinding", "hash", "." ]
cce30db8d4c8fd0f27fa26411bfdc57864015231
https://github.com/ember-cli/eslint-plugin-ember/blob/cce30db8d4c8fd0f27fa26411bfdc57864015231/lib/utils/utils.js#L391-L404
train
ember-cli/eslint-plugin-ember
lib/utils/utils.js
isEmptyMethod
function isEmptyMethod(node) { return node.value.body && node.value.body.body && node.value.body.body.length <= 0; }
javascript
function isEmptyMethod(node) { return node.value.body && node.value.body.body && node.value.body.body.length <= 0; }
[ "function", "isEmptyMethod", "(", "node", ")", "{", "return", "node", ".", "value", ".", "body", "&&", "node", ".", "value", ".", "body", ".", "body", "&&", "node", ".", "value", ".", "body", ".", "body", ".", "length", "<=", "0", ";", "}" ]
Check whether or not a node is a empty method. @param {Object} node The node to check. @returns {boolean} Whether or not the node is an empty method.
[ "Check", "whether", "or", "not", "a", "node", "is", "a", "empty", "method", "." ]
cce30db8d4c8fd0f27fa26411bfdc57864015231
https://github.com/ember-cli/eslint-plugin-ember/blob/cce30db8d4c8fd0f27fa26411bfdc57864015231/lib/utils/utils.js#L412-L416
train
ember-cli/eslint-plugin-ember
lib/utils/utils.js
getParent
function getParent(node, predicate) { let currentNode = node; while (currentNode) { if (predicate(currentNode)) { return currentNode; } currentNode = currentNode.parent; } return null; }
javascript
function getParent(node, predicate) { let currentNode = node; while (currentNode) { if (predicate(currentNode)) { return currentNode; } currentNode = currentNode.parent; } return null; }
[ "function", "getParent", "(", "node", ",", "predicate", ")", "{", "let", "currentNode", "=", "node", ";", "while", "(", "currentNode", ")", "{", "if", "(", "predicate", "(", "currentNode", ")", ")", "{", "return", "currentNode", ";", "}", "currentNode", ...
Travels up the ancestors of a given node, if the predicate function returns truthy for a given node or ancestor, return that node, otherwise return null @name getParent @param {Object} node The child node to start at @param {Function} predicate Function that should return a boolean for a given value @returns {Object|n...
[ "Travels", "up", "the", "ancestors", "of", "a", "given", "node", "if", "the", "predicate", "function", "returns", "truthy", "for", "a", "given", "node", "or", "ancestor", "return", "that", "node", "otherwise", "return", "null" ]
cce30db8d4c8fd0f27fa26411bfdc57864015231
https://github.com/ember-cli/eslint-plugin-ember/blob/cce30db8d4c8fd0f27fa26411bfdc57864015231/lib/utils/utils.js#L427-L438
train