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
lithiumtech/karma-threshold-reporter
istanbul-utils.js
summarizeCoverage
function summarizeCoverage(coverage) { var fileSummary = []; Object.keys(coverage).forEach(function (key) { fileSummary.push(summarizeFileCoverage(coverage[key])); }); return mergeSummaryObjects.apply(null, fileSummary); }
javascript
function summarizeCoverage(coverage) { var fileSummary = []; Object.keys(coverage).forEach(function (key) { fileSummary.push(summarizeFileCoverage(coverage[key])); }); return mergeSummaryObjects.apply(null, fileSummary); }
[ "function", "summarizeCoverage", "(", "coverage", ")", "{", "var", "fileSummary", "=", "[", "]", ";", "Object", ".", "keys", "(", "coverage", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "fileSummary", ".", "push", "(", "summarizeFileCoverage", "(", "coverage", "[", "key", "]", ")", ")", ";", "}", ")", ";", "return", "mergeSummaryObjects", ".", "apply", "(", "null", ",", "fileSummary", ")", ";", "}" ]
returns the coverage summary for a single coverage object. This is wrapper over `summarizeFileCoverage` and `mergeSummaryObjects` for the common case of a single coverage object @method summarizeCoverage @static @param {Object} coverage the coverage object @return {Object} summary coverage metrics across all files in the coverage object
[ "returns", "the", "coverage", "summary", "for", "a", "single", "coverage", "object", ".", "This", "is", "wrapper", "over", "summarizeFileCoverage", "and", "mergeSummaryObjects", "for", "the", "common", "case", "of", "a", "single", "coverage", "object" ]
fe78c5227819ed1c58eeb5f6b776b64338ab2525
https://github.com/lithiumtech/karma-threshold-reporter/blob/fe78c5227819ed1c58eeb5f6b776b64338ab2525/istanbul-utils.js#L293-L299
train
lithiumtech/karma-threshold-reporter
istanbul-utils.js
toYUICoverage
function toYUICoverage(coverage) { var ret = {}; addDerivedInfo(coverage); Object.keys(coverage).forEach(function (k) { var fileCoverage = coverage[k], lines = fileCoverage.l, functions = fileCoverage.f, fnMap = fileCoverage.fnMap, o; o = ret[k] = { lines: {}, calledLines: 0, coveredLines: 0, functions: {}, calledFunctions: 0, coveredFunctions: 0 }; Object.keys(lines).forEach(function (k) { o.lines[k] = lines[k]; o.coveredLines += 1; if (lines[k] > 0) { o.calledLines += 1; } }); Object.keys(functions).forEach(function (k) { var name = fnMap[k].name + ':' + fnMap[k].line; o.functions[name] = functions[k]; o.coveredFunctions += 1; if (functions[k] > 0) { o.calledFunctions += 1; } }); }); return ret; }
javascript
function toYUICoverage(coverage) { var ret = {}; addDerivedInfo(coverage); Object.keys(coverage).forEach(function (k) { var fileCoverage = coverage[k], lines = fileCoverage.l, functions = fileCoverage.f, fnMap = fileCoverage.fnMap, o; o = ret[k] = { lines: {}, calledLines: 0, coveredLines: 0, functions: {}, calledFunctions: 0, coveredFunctions: 0 }; Object.keys(lines).forEach(function (k) { o.lines[k] = lines[k]; o.coveredLines += 1; if (lines[k] > 0) { o.calledLines += 1; } }); Object.keys(functions).forEach(function (k) { var name = fnMap[k].name + ':' + fnMap[k].line; o.functions[name] = functions[k]; o.coveredFunctions += 1; if (functions[k] > 0) { o.calledFunctions += 1; } }); }); return ret; }
[ "function", "toYUICoverage", "(", "coverage", ")", "{", "var", "ret", "=", "{", "}", ";", "addDerivedInfo", "(", "coverage", ")", ";", "Object", ".", "keys", "(", "coverage", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "var", "fileCoverage", "=", "coverage", "[", "k", "]", ",", "lines", "=", "fileCoverage", ".", "l", ",", "functions", "=", "fileCoverage", ".", "f", ",", "fnMap", "=", "fileCoverage", ".", "fnMap", ",", "o", ";", "o", "=", "ret", "[", "k", "]", "=", "{", "lines", ":", "{", "}", ",", "calledLines", ":", "0", ",", "coveredLines", ":", "0", ",", "functions", ":", "{", "}", ",", "calledFunctions", ":", "0", ",", "coveredFunctions", ":", "0", "}", ";", "Object", ".", "keys", "(", "lines", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "o", ".", "lines", "[", "k", "]", "=", "lines", "[", "k", "]", ";", "o", ".", "coveredLines", "+=", "1", ";", "if", "(", "lines", "[", "k", "]", ">", "0", ")", "{", "o", ".", "calledLines", "+=", "1", ";", "}", "}", ")", ";", "Object", ".", "keys", "(", "functions", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "var", "name", "=", "fnMap", "[", "k", "]", ".", "name", "+", "':'", "+", "fnMap", "[", "k", "]", ".", "line", ";", "o", ".", "functions", "[", "name", "]", "=", "functions", "[", "k", "]", ";", "o", ".", "coveredFunctions", "+=", "1", ";", "if", "(", "functions", "[", "k", "]", ">", "0", ")", "{", "o", ".", "calledFunctions", "+=", "1", ";", "}", "}", ")", ";", "}", ")", ";", "return", "ret", ";", "}" ]
makes the coverage object generated by this library yuitest_coverage compatible. Note that this transformation is lossy since the returned object will not have statement and branch coverage. @method toYUICoverage @static @param {Object} coverage The `istanbul` coverage object @return {Object} a coverage object in `yuitest_coverage` format.
[ "makes", "the", "coverage", "object", "generated", "by", "this", "library", "yuitest_coverage", "compatible", ".", "Note", "that", "this", "transformation", "is", "lossy", "since", "the", "returned", "object", "will", "not", "have", "statement", "and", "branch", "coverage", "." ]
fe78c5227819ed1c58eeb5f6b776b64338ab2525
https://github.com/lithiumtech/karma-threshold-reporter/blob/fe78c5227819ed1c58eeb5f6b776b64338ab2525/istanbul-utils.js#L311-L348
train
scijs/nrrd-js
nrrd.js
parseField
function parseField(identifier, descriptor) { switch(identifier) { // Literal (uninterpreted) fields case 'content': case 'number': case 'sampleUnits': break; // Integers case 'dimension': case 'blockSize': case 'lineSkip': case 'byteSkip': case 'spaceDimension': descriptor = parseNRRDInteger(descriptor); break; // Floats case 'min': case 'max': case 'oldMin': case 'oldMax': descriptor = parseNRRDFloat(descriptor); break; // Vectors case 'spaceOrigin': descriptor = parseNRRDVector(descriptor); break; // Lists of strings case 'labels': case 'units': case 'spaceUnits': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDQuotedString); break; // Lists of integers case 'sizes': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDInteger); break; // Lists of floats case 'spacings': case 'thicknesses': case 'axisMins': case 'axisMaxs': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDFloat); break; // Lists of vectors case 'spaceDirections': case 'measurementFrame': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDVector); break; // One-of-a-kind fields case 'type': descriptor = parseNRRDType(descriptor); break; case 'encoding': descriptor = parseNRRDEncoding(descriptor); break; case 'endian': descriptor = parseNRRDEndian(descriptor); break; case 'dataFile': descriptor = parseNRRDDataFile(descriptor); break; case 'centers': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDCenter); break; case 'kinds': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDKind); break; case 'space': descriptor = parseNRRDSpace(descriptor); break; // Something unknown default: console.warn("Unrecognized NRRD field: " + identifier); } return descriptor; }
javascript
function parseField(identifier, descriptor) { switch(identifier) { // Literal (uninterpreted) fields case 'content': case 'number': case 'sampleUnits': break; // Integers case 'dimension': case 'blockSize': case 'lineSkip': case 'byteSkip': case 'spaceDimension': descriptor = parseNRRDInteger(descriptor); break; // Floats case 'min': case 'max': case 'oldMin': case 'oldMax': descriptor = parseNRRDFloat(descriptor); break; // Vectors case 'spaceOrigin': descriptor = parseNRRDVector(descriptor); break; // Lists of strings case 'labels': case 'units': case 'spaceUnits': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDQuotedString); break; // Lists of integers case 'sizes': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDInteger); break; // Lists of floats case 'spacings': case 'thicknesses': case 'axisMins': case 'axisMaxs': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDFloat); break; // Lists of vectors case 'spaceDirections': case 'measurementFrame': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDVector); break; // One-of-a-kind fields case 'type': descriptor = parseNRRDType(descriptor); break; case 'encoding': descriptor = parseNRRDEncoding(descriptor); break; case 'endian': descriptor = parseNRRDEndian(descriptor); break; case 'dataFile': descriptor = parseNRRDDataFile(descriptor); break; case 'centers': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDCenter); break; case 'kinds': descriptor = parseNRRDWhitespaceSeparatedList(descriptor, parseNRRDKind); break; case 'space': descriptor = parseNRRDSpace(descriptor); break; // Something unknown default: console.warn("Unrecognized NRRD field: " + identifier); } return descriptor; }
[ "function", "parseField", "(", "identifier", ",", "descriptor", ")", "{", "switch", "(", "identifier", ")", "{", "case", "'content'", ":", "case", "'number'", ":", "case", "'sampleUnits'", ":", "break", ";", "case", "'dimension'", ":", "case", "'blockSize'", ":", "case", "'lineSkip'", ":", "case", "'byteSkip'", ":", "case", "'spaceDimension'", ":", "descriptor", "=", "parseNRRDInteger", "(", "descriptor", ")", ";", "break", ";", "case", "'min'", ":", "case", "'max'", ":", "case", "'oldMin'", ":", "case", "'oldMax'", ":", "descriptor", "=", "parseNRRDFloat", "(", "descriptor", ")", ";", "break", ";", "case", "'spaceOrigin'", ":", "descriptor", "=", "parseNRRDVector", "(", "descriptor", ")", ";", "break", ";", "case", "'labels'", ":", "case", "'units'", ":", "case", "'spaceUnits'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDQuotedString", ")", ";", "break", ";", "case", "'sizes'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDInteger", ")", ";", "break", ";", "case", "'spacings'", ":", "case", "'thicknesses'", ":", "case", "'axisMins'", ":", "case", "'axisMaxs'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDFloat", ")", ";", "break", ";", "case", "'spaceDirections'", ":", "case", "'measurementFrame'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDVector", ")", ";", "break", ";", "case", "'type'", ":", "descriptor", "=", "parseNRRDType", "(", "descriptor", ")", ";", "break", ";", "case", "'encoding'", ":", "descriptor", "=", "parseNRRDEncoding", "(", "descriptor", ")", ";", "break", ";", "case", "'endian'", ":", "descriptor", "=", "parseNRRDEndian", "(", "descriptor", ")", ";", "break", ";", "case", "'dataFile'", ":", "descriptor", "=", "parseNRRDDataFile", "(", "descriptor", ")", ";", "break", ";", "case", "'centers'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDCenter", ")", ";", "break", ";", "case", "'kinds'", ":", "descriptor", "=", "parseNRRDWhitespaceSeparatedList", "(", "descriptor", ",", "parseNRRDKind", ")", ";", "break", ";", "case", "'space'", ":", "descriptor", "=", "parseNRRDSpace", "(", "descriptor", ")", ";", "break", ";", "default", ":", "console", ".", "warn", "(", "\"Unrecognized NRRD field: \"", "+", "identifier", ")", ";", "}", "return", "descriptor", ";", "}" ]
Parses and normalizes NRRD fields, assumes the field names are already lower case.
[ "Parses", "and", "normalizes", "NRRD", "fields", "assumes", "the", "field", "names", "are", "already", "lower", "case", "." ]
fc106cd9e911b6e8ab096cc61ece5dcb5ac69c40
https://github.com/scijs/nrrd-js/blob/fc106cd9e911b6e8ab096cc61ece5dcb5ac69c40/nrrd.js#L475-L550
train
wbyoung/azul
lib/relations/belongs_to.js
function(instance) { var result = this._related(instance); if (result === undefined) { throw new Error(util.format('The relation "%s" has not yet been ' + 'loaded.', this._name)); } return result; }
javascript
function(instance) { var result = this._related(instance); if (result === undefined) { throw new Error(util.format('The relation "%s" has not yet been ' + 'loaded.', this._name)); } return result; }
[ "function", "(", "instance", ")", "{", "var", "result", "=", "this", ".", "_related", "(", "instance", ")", ";", "if", "(", "result", "===", "undefined", ")", "{", "throw", "new", "Error", "(", "util", ".", "format", "(", "'The relation \"%s\" has not yet been '", "+", "'loaded.'", ",", "this", ".", "_name", ")", ")", ";", "}", "return", "result", ";", "}" ]
The item property for this relation. This property allows access to the cached object that has been fetched for a specific model in a given relation. Before the cache has been filled, accessing this property will throw an exception. It is accessible on an individual model via `<singular>` and via `get<Singular>`. For instance, an article that belongs to an author would cause this method to get triggered via `article.author` or `article.getAuthor`. The naming conventions are set forth in {@link BelongsTo#overrides}. @method @protected @param {Model} instance The model instance on which to operate. @see {@link BaseRelation#methods}
[ "The", "item", "property", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/belongs_to.js#L125-L132
train
wbyoung/azul
lib/relations/belongs_to.js
function(instance) { var cacheName = this._itemObjectsQueryCacheKey; if (!instance[cacheName]) { var where = _.object([ [this.primaryKey, instance.getAttribute(this.foreignKeyAttr)], ]); var cacheResult = _.bind(this.associateFetchedObjects, this, instance); instance[cacheName] = this._relatedModel .objects.where(where).limit(1) .on('result', cacheResult); } return instance[cacheName]; }
javascript
function(instance) { var cacheName = this._itemObjectsQueryCacheKey; if (!instance[cacheName]) { var where = _.object([ [this.primaryKey, instance.getAttribute(this.foreignKeyAttr)], ]); var cacheResult = _.bind(this.associateFetchedObjects, this, instance); instance[cacheName] = this._relatedModel .objects.where(where).limit(1) .on('result', cacheResult); } return instance[cacheName]; }
[ "function", "(", "instance", ")", "{", "var", "cacheName", "=", "this", ".", "_itemObjectsQueryCacheKey", ";", "if", "(", "!", "instance", "[", "cacheName", "]", ")", "{", "var", "where", "=", "_", ".", "object", "(", "[", "[", "this", ".", "primaryKey", ",", "instance", ".", "getAttribute", "(", "this", ".", "foreignKeyAttr", ")", "]", ",", "]", ")", ";", "var", "cacheResult", "=", "_", ".", "bind", "(", "this", ".", "associateFetchedObjects", ",", "this", ",", "instance", ")", ";", "instance", "[", "cacheName", "]", "=", "this", ".", "_relatedModel", ".", "objects", ".", "where", "(", "where", ")", ".", "limit", "(", "1", ")", ".", "on", "(", "'result'", ",", "cacheResult", ")", ";", "}", "return", "instance", "[", "cacheName", "]", ";", "}" ]
The objects query property for this relation. This property allows you access to a query which you can use to fetch the object for a relation on a given model and/or to configure the query to build a new query with more restrictive conditions. When you fetch the object, the result will be cached and accessible via the {@link BelongsTo#collection} (if loaded). The value of this property is a query object that is cached so it will always be the exact same query object (see exceptions below). This allows multiple fetches to simply return the query's cached result. A simple {@link BaseQuery#clone} of the query will ensure that it is always performing a new query in the database. The cache of this property will be invalided (and the resulting object a new query object) when changes are made to the relation. It is currently not accessible on an individual model. @method @protected @param {Model} instance The model instance on which to operate.
[ "The", "objects", "query", "property", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/belongs_to.js#L214-L226
train
wbyoung/azul
lib/relations/belongs_to.js
function(instance) { var self = this; var result = Promise.bind(); var fk = instance.getAttribute(this.foreignKeyAttr); if (fk) { result = result.then(function() { return self.objectsQuery(instance).execute(); }) .then(function(result) { self.validateFetchedObjects(instance, result); return result[0]; }); } else { result = result.then(function() { // pretend like we actually did the whole fetch & got back nothing self.associateFetchedObjects(instance, [null]); }); } return result; }
javascript
function(instance) { var self = this; var result = Promise.bind(); var fk = instance.getAttribute(this.foreignKeyAttr); if (fk) { result = result.then(function() { return self.objectsQuery(instance).execute(); }) .then(function(result) { self.validateFetchedObjects(instance, result); return result[0]; }); } else { result = result.then(function() { // pretend like we actually did the whole fetch & got back nothing self.associateFetchedObjects(instance, [null]); }); } return result; }
[ "function", "(", "instance", ")", "{", "var", "self", "=", "this", ";", "var", "result", "=", "Promise", ".", "bind", "(", ")", ";", "var", "fk", "=", "instance", ".", "getAttribute", "(", "this", ".", "foreignKeyAttr", ")", ";", "if", "(", "fk", ")", "{", "result", "=", "result", ".", "then", "(", "function", "(", ")", "{", "return", "self", ".", "objectsQuery", "(", "instance", ")", ".", "execute", "(", ")", ";", "}", ")", ".", "then", "(", "function", "(", "result", ")", "{", "self", ".", "validateFetchedObjects", "(", "instance", ",", "result", ")", ";", "return", "result", "[", "0", "]", ";", "}", ")", ";", "}", "else", "{", "result", "=", "result", ".", "then", "(", "function", "(", ")", "{", "self", ".", "associateFetchedObjects", "(", "instance", ",", "[", "null", "]", ")", ";", "}", ")", ";", "}", "return", "result", ";", "}" ]
Fetch the related object. If there is no foreign key defined on the instance, this method will not actually query the database. @method @protected @param {Model} instance The model instance on which to operate. @see {@link BaseRelation#methods}
[ "Fetch", "the", "related", "object", ".", "If", "there", "is", "no", "foreign", "key", "defined", "on", "the", "instance", "this", "method", "will", "not", "actually", "query", "the", "database", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/belongs_to.js#L278-L298
train
wbyoung/azul
lib/relations/belongs_to.js
function(instance, objects) { var foreignKeyAttr = this.foreignKeyAttr; var fk = instance.getAttribute(foreignKeyAttr); if (fk && objects.length === 0) { var relatedModel = this._relatedModel; var relatedClass = relatedModel.__identity__; var relatedName = relatedClass.__name__; throw new Error(util.format('Found no %s with %j %d', relatedName, foreignKeyAttr, fk)); } }
javascript
function(instance, objects) { var foreignKeyAttr = this.foreignKeyAttr; var fk = instance.getAttribute(foreignKeyAttr); if (fk && objects.length === 0) { var relatedModel = this._relatedModel; var relatedClass = relatedModel.__identity__; var relatedName = relatedClass.__name__; throw new Error(util.format('Found no %s with %j %d', relatedName, foreignKeyAttr, fk)); } }
[ "function", "(", "instance", ",", "objects", ")", "{", "var", "foreignKeyAttr", "=", "this", ".", "foreignKeyAttr", ";", "var", "fk", "=", "instance", ".", "getAttribute", "(", "foreignKeyAttr", ")", ";", "if", "(", "fk", "&&", "objects", ".", "length", "===", "0", ")", "{", "var", "relatedModel", "=", "this", ".", "_relatedModel", ";", "var", "relatedClass", "=", "relatedModel", ".", "__identity__", ";", "var", "relatedName", "=", "relatedClass", ".", "__name__", ";", "throw", "new", "Error", "(", "util", ".", "format", "(", "'Found no %s with %j %d'", ",", "relatedName", ",", "foreignKeyAttr", ",", "fk", ")", ")", ";", "}", "}" ]
Validate fetched objects, ensuring that exactly one object was obtained when the foreign key is set. @method @protected @param {Model} instance The model instance on which to operate.
[ "Validate", "fetched", "objects", "ensuring", "that", "exactly", "one", "object", "was", "obtained", "when", "the", "foreign", "key", "is", "set", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/belongs_to.js#L308-L318
train
fat/haunt
lib/pull-request.js
attachCommentsToFile
function attachCommentsToFile(files, comments) { return files.filter(function(file) { return file.comments = comments.filter(function(comment) { if (file.filename === comment.path) { return comment.reply = attachCommentReply.call(this, comment); } }.bind(this)); }.bind(this)); }
javascript
function attachCommentsToFile(files, comments) { return files.filter(function(file) { return file.comments = comments.filter(function(comment) { if (file.filename === comment.path) { return comment.reply = attachCommentReply.call(this, comment); } }.bind(this)); }.bind(this)); }
[ "function", "attachCommentsToFile", "(", "files", ",", "comments", ")", "{", "return", "files", ".", "filter", "(", "function", "(", "file", ")", "{", "return", "file", ".", "comments", "=", "comments", ".", "filter", "(", "function", "(", "comment", ")", "{", "if", "(", "file", ".", "filename", "===", "comment", ".", "path", ")", "{", "return", "comment", ".", "reply", "=", "attachCommentReply", ".", "call", "(", "this", ",", "comment", ")", ";", "}", "}", ".", "bind", "(", "this", ")", ")", ";", "}", ".", "bind", "(", "this", ")", ")", ";", "}" ]
attach review comments to the related file
[ "attach", "review", "comments", "to", "the", "related", "file" ]
e7a0f30032f0afec56652dc9ded06b29f0d61509
https://github.com/fat/haunt/blob/e7a0f30032f0afec56652dc9ded06b29f0d61509/lib/pull-request.js#L108-L116
train
fat/haunt
lib/pull-request.js
attachCommentReply
function attachCommentReply(comment) { return function reply(body, callback) { github.replyToReviewComment(this.repo.data.owner.login, this.repo.data.name, this.data.number, comment.id, body, callback); }.bind(this); }
javascript
function attachCommentReply(comment) { return function reply(body, callback) { github.replyToReviewComment(this.repo.data.owner.login, this.repo.data.name, this.data.number, comment.id, body, callback); }.bind(this); }
[ "function", "attachCommentReply", "(", "comment", ")", "{", "return", "function", "reply", "(", "body", ",", "callback", ")", "{", "github", ".", "replyToReviewComment", "(", "this", ".", "repo", ".", "data", ".", "owner", ".", "login", ",", "this", ".", "repo", ".", "data", ".", "name", ",", "this", ".", "data", ".", "number", ",", "comment", ".", "id", ",", "body", ",", "callback", ")", ";", "}", ".", "bind", "(", "this", ")", ";", "}" ]
reply to a comment on a diff
[ "reply", "to", "a", "comment", "on", "a", "diff" ]
e7a0f30032f0afec56652dc9ded06b29f0d61509
https://github.com/fat/haunt/blob/e7a0f30032f0afec56652dc9ded06b29f0d61509/lib/pull-request.js#L119-L123
train
wbyoung/azul
lib/relations/has_many_through.js
function(message) { return override(function() { if (!this._isToMany) { var modelName = this._modelClass.__identity__.__name__; var relationName = this._name; throw new Error(util.format('%s for non many-to-many through relation ' + '%s#%s.', message, modelName, relationName)); } return this._super.apply(this, arguments); }); }
javascript
function(message) { return override(function() { if (!this._isToMany) { var modelName = this._modelClass.__identity__.__name__; var relationName = this._name; throw new Error(util.format('%s for non many-to-many through relation ' + '%s#%s.', message, modelName, relationName)); } return this._super.apply(this, arguments); }); }
[ "function", "(", "message", ")", "{", "return", "override", "(", "function", "(", ")", "{", "if", "(", "!", "this", ".", "_isToMany", ")", "{", "var", "modelName", "=", "this", ".", "_modelClass", ".", "__identity__", ".", "__name__", ";", "var", "relationName", "=", "this", ".", "_name", ";", "throw", "new", "Error", "(", "util", ".", "format", "(", "'%s for non many-to-many through relation '", "+", "'%s#%s.'", ",", "message", ",", "modelName", ",", "relationName", ")", ")", ";", "}", "return", "this", ".", "_super", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ")", ";", "}" ]
A convenience function for creating a through-only method override that will throw an exception if this is not a through relation configured as a simple many-to-many. @function HasMany~manyToManyOnly @param {String} message The error message prefix. @return {Function} The method. @see {@link HasMany~throughOverride}
[ "A", "convenience", "function", "for", "creating", "a", "through", "-", "only", "method", "override", "that", "will", "throw", "an", "exception", "if", "this", "is", "not", "a", "through", "relation", "configured", "as", "a", "simple", "many", "-", "to", "-", "many", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many_through.js#L38-L48
train
wbyoung/azul
lib/relations/has_many.js
function(name) { var before = 'before' + _.capitalize(name); var after = 'after' + _.capitalize(name); return function() { this[before].apply(this, arguments); this._super.apply(this, arguments); this[after].apply(this, arguments); }; }
javascript
function(name) { var before = 'before' + _.capitalize(name); var after = 'after' + _.capitalize(name); return function() { this[before].apply(this, arguments); this._super.apply(this, arguments); this[after].apply(this, arguments); }; }
[ "function", "(", "name", ")", "{", "var", "before", "=", "'before'", "+", "_", ".", "capitalize", "(", "name", ")", ";", "var", "after", "=", "'after'", "+", "_", ".", "capitalize", "(", "name", ")", ";", "return", "function", "(", ")", "{", "this", "[", "before", "]", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "_super", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", "[", "after", "]", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}" ]
Notify of changes around a call to super. @function HasMany~notify @private @param {String} name The suffix of the before/after methods to call. @return {Function} A method that will call before & after methods.
[ "Notify", "of", "changes", "around", "a", "call", "to", "super", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L77-L85
train
wbyoung/azul
lib/relations/has_many.js
function(instance) { var args = _.rest(arguments); var objects = _.flatten(args); this.beforeAddingObjects(instance, objects); this.associateObjects(instance, objects); return Actionable.create(instance.save.bind(instance)); }
javascript
function(instance) { var args = _.rest(arguments); var objects = _.flatten(args); this.beforeAddingObjects(instance, objects); this.associateObjects(instance, objects); return Actionable.create(instance.save.bind(instance)); }
[ "function", "(", "instance", ")", "{", "var", "args", "=", "_", ".", "rest", "(", "arguments", ")", ";", "var", "objects", "=", "_", ".", "flatten", "(", "args", ")", ";", "this", ".", "beforeAddingObjects", "(", "instance", ",", "objects", ")", ";", "this", ".", "associateObjects", "(", "instance", ",", "objects", ")", ";", "return", "Actionable", ".", "create", "(", "instance", ".", "save", ".", "bind", "(", "instance", ")", ")", ";", "}" ]
The add objects method for this relation. This method invalidates the {@link HasMany#objectsQuery} cache and adds the related objects to the {@link HasMany#collection} (if loaded). It is accessible on an individual model via `add<Singular>` and `add<Plural>`. For instance a user that has many articles would cause this method to get triggered via `user.addArticle` or `user.addArticles`. The naming conventions are set forth in {@link HasMany#overrides}. Mixins can override {@link HasMany#addObjects} to change the way related objects are added. This is the default implementation. @method @protected @param {Model} instance The model instance on which to operate. @param {...Object} [args] The arguments to the method. @return {Actionable} A thenable object, use of which will trigger the instance to be saved. @see {@link BaseRelation#methods}
[ "The", "add", "objects", "method", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L147-L153
train
wbyoung/azul
lib/relations/has_many.js
function(instance, objects) { var self = this; var after = this.afterAddingObjects.bind(this, instance, objects); return self._updateForeignKeys(instance, objects, instance.id).tap(after); }
javascript
function(instance, objects) { var self = this; var after = this.afterAddingObjects.bind(this, instance, objects); return self._updateForeignKeys(instance, objects, instance.id).tap(after); }
[ "function", "(", "instance", ",", "objects", ")", "{", "var", "self", "=", "this", ";", "var", "after", "=", "this", ".", "afterAddingObjects", ".", "bind", "(", "this", ",", "instance", ",", "objects", ")", ";", "return", "self", ".", "_updateForeignKeys", "(", "instance", ",", "objects", ",", "instance", ".", "id", ")", ".", "tap", "(", "after", ")", ";", "}" ]
Perform the necessary updates to add objects for this relation. This method invalidates the {@link HasMany#objectsQuery}. Mixins can override {@link HasMany#executeAdd} to change the way updates are performed when related objects are added. This is the default implementation. @method @protected @param {Model} instance The model instance on which to operate. @param {Array} objects The objects to add to the relationship.
[ "Perform", "the", "necessary", "updates", "to", "add", "objects", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L169-L173
train
wbyoung/azul
lib/relations/has_many.js
function(instance) { var args = _.rest(arguments); var objects = _.flatten(args); this.beforeRemovingObjects(instance, objects); this.disassociateObjects(instance, objects); return Actionable.create(instance.save.bind(instance)); }
javascript
function(instance) { var args = _.rest(arguments); var objects = _.flatten(args); this.beforeRemovingObjects(instance, objects); this.disassociateObjects(instance, objects); return Actionable.create(instance.save.bind(instance)); }
[ "function", "(", "instance", ")", "{", "var", "args", "=", "_", ".", "rest", "(", "arguments", ")", ";", "var", "objects", "=", "_", ".", "flatten", "(", "args", ")", ";", "this", ".", "beforeRemovingObjects", "(", "instance", ",", "objects", ")", ";", "this", ".", "disassociateObjects", "(", "instance", ",", "objects", ")", ";", "return", "Actionable", ".", "create", "(", "instance", ".", "save", ".", "bind", "(", "instance", ")", ")", ";", "}" ]
The remove objects method for this relation. This method invalidates the {@link HasMany#objectsQuery} cache and removes the related objects from the {@link HasMany#collection} (if loaded). It is accessible on an individual model via `remove<Singular>` and `remove<Plural>`. For instance a user that has many articles would cause this method to get triggered via `user.removeArticle` or `user.removeArticles`. The naming conventions are set forth in {@link HasMany#overrides}. Mixins can override {@link HasMany#removeObjects} to change the way related objects are removed. This is the default implementation. @method @protected @param {Model} instance The model instance on which to operate. @param {...Object} [args] The arguments to the method. @return {Actionable} A thenable object, use of which will trigger the instance to be saved. @see {@link BaseRelation#methods}
[ "The", "remove", "objects", "method", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L199-L205
train
wbyoung/azul
lib/relations/has_many.js
function(instance, objects) { var self = this; var after = this.afterRemovingObjects.bind(this, instance, objects); var removable = _.filter(objects, 'persisted'); return self._updateForeignKeys(instance, removable, undefined).tap(after); }
javascript
function(instance, objects) { var self = this; var after = this.afterRemovingObjects.bind(this, instance, objects); var removable = _.filter(objects, 'persisted'); return self._updateForeignKeys(instance, removable, undefined).tap(after); }
[ "function", "(", "instance", ",", "objects", ")", "{", "var", "self", "=", "this", ";", "var", "after", "=", "this", ".", "afterRemovingObjects", ".", "bind", "(", "this", ",", "instance", ",", "objects", ")", ";", "var", "removable", "=", "_", ".", "filter", "(", "objects", ",", "'persisted'", ")", ";", "return", "self", ".", "_updateForeignKeys", "(", "instance", ",", "removable", ",", "undefined", ")", ".", "tap", "(", "after", ")", ";", "}" ]
Perform the necessary updates to remove objects for this relation. This method invalidates the {@link HasMany#objectsQuery}. Mixins can override {@link HasMany#executeRemove} to change the way updates are performed when related objects are removed. This is the default implementation. @method @protected @param {Model} instance The model instance on which to operate. @param {Array} objects The objects to remove from the relationship.
[ "Perform", "the", "necessary", "updates", "to", "remove", "objects", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L221-L226
train
wbyoung/azul
lib/relations/has_many.js
function(instance) { var updates = _.object([[this.foreignKey, undefined]]); var query = this.objectsQuery(instance).update(updates); var after = this.afterClearingObjects.bind(this, instance); return query.execute().tap(after); }
javascript
function(instance) { var updates = _.object([[this.foreignKey, undefined]]); var query = this.objectsQuery(instance).update(updates); var after = this.afterClearingObjects.bind(this, instance); return query.execute().tap(after); }
[ "function", "(", "instance", ")", "{", "var", "updates", "=", "_", ".", "object", "(", "[", "[", "this", ".", "foreignKey", ",", "undefined", "]", "]", ")", ";", "var", "query", "=", "this", ".", "objectsQuery", "(", "instance", ")", ".", "update", "(", "updates", ")", ";", "var", "after", "=", "this", ".", "afterClearingObjects", ".", "bind", "(", "this", ",", "instance", ")", ";", "return", "query", ".", "execute", "(", ")", ".", "tap", "(", "after", ")", ";", "}" ]
Perform the necessary updates to clear objects for this relation. This method invalidates the {@link HasMany#objectsQuery}. Mixins can override {@link HasMany#executeClear} to change the way clears are performed when related objects are cleared. This is the default implementation. @method @protected @param {Model} instance The model instance on which to operate.
[ "Perform", "the", "necessary", "updates", "to", "clear", "objects", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_many.js#L268-L273
train
wbyoung/azul
lib/query/mixins/bound_helpers.js
function(association, name) { var context = this._relationCallContext; var through = association.indexOf('.') !== -1 ? util.format(' through %s', association) : ''; return _.extend(new Error(util.format( 'No relation %j found for `%s` on %s query%s.', name, context, this._model.__identity__.__name__, through)), { code: 'RELATION_ITERATION_FAILURE', }); }
javascript
function(association, name) { var context = this._relationCallContext; var through = association.indexOf('.') !== -1 ? util.format(' through %s', association) : ''; return _.extend(new Error(util.format( 'No relation %j found for `%s` on %s query%s.', name, context, this._model.__identity__.__name__, through)), { code: 'RELATION_ITERATION_FAILURE', }); }
[ "function", "(", "association", ",", "name", ")", "{", "var", "context", "=", "this", ".", "_relationCallContext", ";", "var", "through", "=", "association", ".", "indexOf", "(", "'.'", ")", "!==", "-", "1", "?", "util", ".", "format", "(", "' through %s'", ",", "association", ")", ":", "''", ";", "return", "_", ".", "extend", "(", "new", "Error", "(", "util", ".", "format", "(", "'No relation %j found for `%s` on %s query%s.'", ",", "name", ",", "context", ",", "this", ".", "_model", ".", "__identity__", ".", "__name__", ",", "through", ")", ")", ",", "{", "code", ":", "'RELATION_ITERATION_FAILURE'", ",", "}", ")", ";", "}" ]
Create an error for a missing relation during relation iteration. @param {String} association Relation key path. @param {String} name The name that caused the error. @return {Error} The error object.
[ "Create", "an", "error", "for", "a", "missing", "relation", "during", "relation", "iteration", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/query/mixins/bound_helpers.js#L94-L104
train
wbyoung/azul
lib/query/mixins/bound_core.js
function(orig) { this._super(orig); this._priorModel = orig._priorModel; this._model = orig._model; this._modelTable = orig._modelTable; this._arrayTransform = orig._arrayTransform; this._modelTransform = orig._modelTransform; }
javascript
function(orig) { this._super(orig); this._priorModel = orig._priorModel; this._model = orig._model; this._modelTable = orig._modelTable; this._arrayTransform = orig._arrayTransform; this._modelTransform = orig._modelTransform; }
[ "function", "(", "orig", ")", "{", "this", ".", "_super", "(", "orig", ")", ";", "this", ".", "_priorModel", "=", "orig", ".", "_priorModel", ";", "this", ".", "_model", "=", "orig", ".", "_model", ";", "this", ".", "_modelTable", "=", "orig", ".", "_modelTable", ";", "this", ".", "_arrayTransform", "=", "orig", ".", "_arrayTransform", ";", "this", ".", "_modelTransform", "=", "orig", ".", "_modelTransform", ";", "}" ]
Duplication implementation. @method @protected @see {@link BaseQuery#_take}
[ "Duplication", "implementation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/query/mixins/bound_core.js#L20-L27
train
wbyoung/azul
lib/query/mixins/bound_core.js
function() { var model = this._model; var arrayTransform = function(result) { // jscs:ignore jsDoc return result.rows; }; var modelTransform = function(rows) { // jscs:ignore jsDoc return rows.map(model.load.bind(model)); }; var dup = this._dup() .transform(arrayTransform) .transform(modelTransform); dup._arrayTransform = arrayTransform; dup._modelTransform = modelTransform; return dup; }
javascript
function() { var model = this._model; var arrayTransform = function(result) { // jscs:ignore jsDoc return result.rows; }; var modelTransform = function(rows) { // jscs:ignore jsDoc return rows.map(model.load.bind(model)); }; var dup = this._dup() .transform(arrayTransform) .transform(modelTransform); dup._arrayTransform = arrayTransform; dup._modelTransform = modelTransform; return dup; }
[ "function", "(", ")", "{", "var", "model", "=", "this", ".", "_model", ";", "var", "arrayTransform", "=", "function", "(", "result", ")", "{", "return", "result", ".", "rows", ";", "}", ";", "var", "modelTransform", "=", "function", "(", "rows", ")", "{", "return", "rows", ".", "map", "(", "model", ".", "load", ".", "bind", "(", "model", ")", ")", ";", "}", ";", "var", "dup", "=", "this", ".", "_dup", "(", ")", ".", "transform", "(", "arrayTransform", ")", ".", "transform", "(", "modelTransform", ")", ";", "dup", ".", "_arrayTransform", "=", "arrayTransform", ";", "dup", ".", "_modelTransform", "=", "modelTransform", ";", "return", "dup", ";", "}" ]
Enable automatic conversion of the query results to model instances. @method @public @return {ChainedQuery} The newly configured query.
[ "Enable", "automatic", "conversion", "of", "the", "query", "results", "to", "model", "instances", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/query/mixins/bound_core.js#L36-L53
train
wbyoung/azul
lib/query/mixins/bound_core.js
function() { var dup = this._dup(); dup = dup.transform(dup._modelTransform); dup._model = dup._priorModel; dup._priorModel = undefined; return dup; }
javascript
function() { var dup = this._dup(); dup = dup.transform(dup._modelTransform); dup._model = dup._priorModel; dup._priorModel = undefined; return dup; }
[ "function", "(", ")", "{", "var", "dup", "=", "this", ".", "_dup", "(", ")", ";", "dup", "=", "dup", ".", "transform", "(", "dup", ".", "_modelTransform", ")", ";", "dup", ".", "_model", "=", "dup", ".", "_priorModel", ";", "dup", ".", "_priorModel", "=", "undefined", ";", "return", "dup", ";", "}" ]
Reverse the effects of an unbind. @method @public @return {ChainedQuery} The newly configured query.
[ "Reverse", "the", "effects", "of", "an", "unbind", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/query/mixins/bound_core.js#L81-L87
train
wbyoung/azul
lib/cli/actions.js
function(action, azulfile, options, strings) { var db = Database.create(azulfile[env]); var migrator = db.migrator(path.resolve(options.migrations)); var message = ''; var batches = ''; return migrator[action]() .tap(function(migrations) { batches = _(migrations).pluck('batch').unique().join(', '); }) .then(function(migrations) { message += migrations.length ? chalk.magenta(strings.intro, 'migrations, batch', batches, '\n') : chalk.magenta(strings.none, '\n'); migrations.forEach(function(migration) { message += chalk.cyan(migration.name, '\n'); }); message += chalk.gray(_.capitalize(env), 'environment\n'); process.stdout.write(message); }) .catch(function(e) { message += chalk.red(strings.action, 'failed.', e); process.stderr.write(message); process.exit(1); }) .finally(function() { db.disconnect(); }); }
javascript
function(action, azulfile, options, strings) { var db = Database.create(azulfile[env]); var migrator = db.migrator(path.resolve(options.migrations)); var message = ''; var batches = ''; return migrator[action]() .tap(function(migrations) { batches = _(migrations).pluck('batch').unique().join(', '); }) .then(function(migrations) { message += migrations.length ? chalk.magenta(strings.intro, 'migrations, batch', batches, '\n') : chalk.magenta(strings.none, '\n'); migrations.forEach(function(migration) { message += chalk.cyan(migration.name, '\n'); }); message += chalk.gray(_.capitalize(env), 'environment\n'); process.stdout.write(message); }) .catch(function(e) { message += chalk.red(strings.action, 'failed.', e); process.stderr.write(message); process.exit(1); }) .finally(function() { db.disconnect(); }); }
[ "function", "(", "action", ",", "azulfile", ",", "options", ",", "strings", ")", "{", "var", "db", "=", "Database", ".", "create", "(", "azulfile", "[", "env", "]", ")", ";", "var", "migrator", "=", "db", ".", "migrator", "(", "path", ".", "resolve", "(", "options", ".", "migrations", ")", ")", ";", "var", "message", "=", "''", ";", "var", "batches", "=", "''", ";", "return", "migrator", "[", "action", "]", "(", ")", ".", "tap", "(", "function", "(", "migrations", ")", "{", "batches", "=", "_", "(", "migrations", ")", ".", "pluck", "(", "'batch'", ")", ".", "unique", "(", ")", ".", "join", "(", "', '", ")", ";", "}", ")", ".", "then", "(", "function", "(", "migrations", ")", "{", "message", "+=", "migrations", ".", "length", "?", "chalk", ".", "magenta", "(", "strings", ".", "intro", ",", "'migrations, batch'", ",", "batches", ",", "'\\n'", ")", ":", "\\n", ";", "chalk", ".", "magenta", "(", "strings", ".", "none", ",", "'\\n'", ")", "\\n", "migrations", ".", "forEach", "(", "function", "(", "migration", ")", "{", "message", "+=", "chalk", ".", "cyan", "(", "migration", ".", "name", ",", "'\\n'", ")", ";", "}", ")", ";", "}", ")", ".", "\\n", "message", "+=", "chalk", ".", "gray", "(", "_", ".", "capitalize", "(", "env", ")", ",", "'environment\\n'", ")", ";", ".", "\\n", "process", ".", "stdout", ".", "write", "(", "message", ")", ";", ";", "}" ]
Run the migrator. @private @function runMigrator @param {String} action Either `migrate` or `rollback`. @param {Object} azulfile Configuration object. @param {Object} options @param {String} options.migrations @param {Object} strings The output format strings to use. @return {Promise}
[ "Run", "the", "migrator", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/cli/actions.js#L23-L49
train
Synerzip/loopback-connector-sqlite
lib/sqlite3db.js
function(sqlite3, dbSettings) { if (!(this instanceof SQLiteDB)) { return new SQLiteDB(sqlite3, dbSettings); } this.constructor.super_.call(this, NAME, dbSettings); this.name = NAME; this.settings = dbSettings; this.sqlite3 = sqlite3; this.debug = dbSettings.debug; this.current_order = []; this.file_name = dbSettings.file_name; if (this.debug) { debug('Settings %j', dbSettings); } }
javascript
function(sqlite3, dbSettings) { if (!(this instanceof SQLiteDB)) { return new SQLiteDB(sqlite3, dbSettings); } this.constructor.super_.call(this, NAME, dbSettings); this.name = NAME; this.settings = dbSettings; this.sqlite3 = sqlite3; this.debug = dbSettings.debug; this.current_order = []; this.file_name = dbSettings.file_name; if (this.debug) { debug('Settings %j', dbSettings); } }
[ "function", "(", "sqlite3", ",", "dbSettings", ")", "{", "if", "(", "!", "(", "this", "instanceof", "SQLiteDB", ")", ")", "{", "return", "new", "SQLiteDB", "(", "sqlite3", ",", "dbSettings", ")", ";", "}", "this", ".", "constructor", ".", "super_", ".", "call", "(", "this", ",", "NAME", ",", "dbSettings", ")", ";", "this", ".", "name", "=", "NAME", ";", "this", ".", "settings", "=", "dbSettings", ";", "this", ".", "sqlite3", "=", "sqlite3", ";", "this", ".", "debug", "=", "dbSettings", ".", "debug", ";", "this", ".", "current_order", "=", "[", "]", ";", "this", ".", "file_name", "=", "dbSettings", ".", "file_name", ";", "if", "(", "this", ".", "debug", ")", "{", "debug", "(", "'Settings %j'", ",", "dbSettings", ")", ";", "}", "}" ]
Constructor for SQLite connector @param {Object} settings The settings object @param {DataSource} dataSource The data source instance @constructor
[ "Constructor", "for", "SQLite", "connector" ]
78b8ffb50396311565e93d17b2f0686ec2326190
https://github.com/Synerzip/loopback-connector-sqlite/blob/78b8ffb50396311565e93d17b2f0686ec2326190/lib/sqlite3db.js#L45-L62
train
pulseshift/ui5-cache-buster
index.js
_getUi5AppHash
function _getUi5AppHash(sResolvedModulePath, sPreloadPath, oOptions) { // read relevant resources for hash generation const oPreloadFileContent = fs.readFileSync(sPreloadPath, 'utf8') // some resources will be requested additionally to 'Component-preload.js' // fortunately they 'should' be listed in manifest.json, therefore, we will look them up there const sManifestPath = path.resolve(sResolvedModulePath, 'manifest.json') const oManifestFileContent = fs.existsSync(sManifestPath) ? fs.readFileSync(sManifestPath, 'utf8') : null const oManifestJSON = oManifestFileContent ? JSON.parse(oManifestFileContent) : { 'sap.ui5': {} } const aResourceKeys = oManifestJSON['sap.ui5'].resources ? Object.keys(oManifestJSON['sap.ui5'].resources) : [] const aDependedResourceContents = aResourceKeys.reduce( (aContentsList, sResourceKey) => { return aContentsList.concat( oManifestJSON['sap.ui5'].resources[sResourceKey].map(oResource => fs.readFileSync( path.resolve(sResolvedModulePath, oResource.uri), 'utf8' ) ) ) }, [] ) // generate hash based on resource contents of the app const aBufferList = aDependedResourceContents .concat(oPreloadFileContent ? oPreloadFileContent : []) .map(oContent => new Buffer(oContent)) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
javascript
function _getUi5AppHash(sResolvedModulePath, sPreloadPath, oOptions) { // read relevant resources for hash generation const oPreloadFileContent = fs.readFileSync(sPreloadPath, 'utf8') // some resources will be requested additionally to 'Component-preload.js' // fortunately they 'should' be listed in manifest.json, therefore, we will look them up there const sManifestPath = path.resolve(sResolvedModulePath, 'manifest.json') const oManifestFileContent = fs.existsSync(sManifestPath) ? fs.readFileSync(sManifestPath, 'utf8') : null const oManifestJSON = oManifestFileContent ? JSON.parse(oManifestFileContent) : { 'sap.ui5': {} } const aResourceKeys = oManifestJSON['sap.ui5'].resources ? Object.keys(oManifestJSON['sap.ui5'].resources) : [] const aDependedResourceContents = aResourceKeys.reduce( (aContentsList, sResourceKey) => { return aContentsList.concat( oManifestJSON['sap.ui5'].resources[sResourceKey].map(oResource => fs.readFileSync( path.resolve(sResolvedModulePath, oResource.uri), 'utf8' ) ) ) }, [] ) // generate hash based on resource contents of the app const aBufferList = aDependedResourceContents .concat(oPreloadFileContent ? oPreloadFileContent : []) .map(oContent => new Buffer(oContent)) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
[ "function", "_getUi5AppHash", "(", "sResolvedModulePath", ",", "sPreloadPath", ",", "oOptions", ")", "{", "const", "oPreloadFileContent", "=", "fs", ".", "readFileSync", "(", "sPreloadPath", ",", "'utf8'", ")", "const", "sManifestPath", "=", "path", ".", "resolve", "(", "sResolvedModulePath", ",", "'manifest.json'", ")", "const", "oManifestFileContent", "=", "fs", ".", "existsSync", "(", "sManifestPath", ")", "?", "fs", ".", "readFileSync", "(", "sManifestPath", ",", "'utf8'", ")", ":", "null", "const", "oManifestJSON", "=", "oManifestFileContent", "?", "JSON", ".", "parse", "(", "oManifestFileContent", ")", ":", "{", "'sap.ui5'", ":", "{", "}", "}", "const", "aResourceKeys", "=", "oManifestJSON", "[", "'sap.ui5'", "]", ".", "resources", "?", "Object", ".", "keys", "(", "oManifestJSON", "[", "'sap.ui5'", "]", ".", "resources", ")", ":", "[", "]", "const", "aDependedResourceContents", "=", "aResourceKeys", ".", "reduce", "(", "(", "aContentsList", ",", "sResourceKey", ")", "=>", "{", "return", "aContentsList", ".", "concat", "(", "oManifestJSON", "[", "'sap.ui5'", "]", ".", "resources", "[", "sResourceKey", "]", ".", "map", "(", "oResource", "=>", "fs", ".", "readFileSync", "(", "path", ".", "resolve", "(", "sResolvedModulePath", ",", "oResource", ".", "uri", ")", ",", "'utf8'", ")", ")", ")", "}", ",", "[", "]", ")", "const", "aBufferList", "=", "aDependedResourceContents", ".", "concat", "(", "oPreloadFileContent", "?", "oPreloadFileContent", ":", "[", "]", ")", ".", "map", "(", "oContent", "=>", "new", "Buffer", "(", "oContent", ")", ")", "const", "sNewHash", "=", "_createHash", "(", "aBufferList", ",", "oOptions", ")", "return", "sNewHash", "}" ]
Generate hash for UI5 app component. @param {string} [sResolvedModulePath] Module path. @param {string} [sPreloadPath] Path to Component-preload.js. @param {Object} [oOptions] Cach buster options. @param {Object} [oOptions.hash] Hash generation options. @param {string} [oOptions.HASH_TYPE] Hash type. @param {string} [oOptions.DIGEST_TYPE] Digest type. @param {number} [oOptions.MAX_LENGTH] Maximum hash length. @returns {string|null} Generated hash.
[ "Generate", "hash", "for", "UI5", "app", "component", "." ]
55147d25bed7754fee2de69269f78c61079e1167
https://github.com/pulseshift/ui5-cache-buster/blob/55147d25bed7754fee2de69269f78c61079e1167/index.js#L269-L306
train
pulseshift/ui5-cache-buster
index.js
_getUi5LibHash
function _getUi5LibHash(sResolvedModulePath, sLibPreloadPath, oOptions) { // read relevant resources for hash generation const oLibPreloadFileContent = fs.readFileSync(sLibPreloadPath, 'utf8') // generate hash based on resource contents of the library const aBufferList = [oLibPreloadFileContent].map( oContent => new Buffer(oContent) ) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
javascript
function _getUi5LibHash(sResolvedModulePath, sLibPreloadPath, oOptions) { // read relevant resources for hash generation const oLibPreloadFileContent = fs.readFileSync(sLibPreloadPath, 'utf8') // generate hash based on resource contents of the library const aBufferList = [oLibPreloadFileContent].map( oContent => new Buffer(oContent) ) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
[ "function", "_getUi5LibHash", "(", "sResolvedModulePath", ",", "sLibPreloadPath", ",", "oOptions", ")", "{", "const", "oLibPreloadFileContent", "=", "fs", ".", "readFileSync", "(", "sLibPreloadPath", ",", "'utf8'", ")", "const", "aBufferList", "=", "[", "oLibPreloadFileContent", "]", ".", "map", "(", "oContent", "=>", "new", "Buffer", "(", "oContent", ")", ")", "const", "sNewHash", "=", "_createHash", "(", "aBufferList", ",", "oOptions", ")", "return", "sNewHash", "}" ]
Generate hash for UI5 control library. @param {string} [sResolvedModulePath] Module path. @param {string} [sLibPreloadPath] Path to library-preload.js. @param {Object} [oOptions] Cach buster options. @param {Object} [oOptions.hash] Hash generation options. @param {string} [oOptions.HASH_TYPE] Hash type. @param {string} [oOptions.DIGEST_TYPE] Digest type. @param {number} [oOptions.MAX_LENGTH] Maximum hash length. @returns {string|null} Generated hash.
[ "Generate", "hash", "for", "UI5", "control", "library", "." ]
55147d25bed7754fee2de69269f78c61079e1167
https://github.com/pulseshift/ui5-cache-buster/blob/55147d25bed7754fee2de69269f78c61079e1167/index.js#L319-L330
train
pulseshift/ui5-cache-buster
index.js
_getThemeRootHash
function _getThemeRootHash(sThemeRootPath, sThemeName, oOptions) { // read relevant resources for hash generation const aAssetContents = _readAllFiles(sThemeRootPath) // generate hash based on library CSS files in theme root const aBufferList = aAssetContents.map(oContent => new Buffer(oContent)) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
javascript
function _getThemeRootHash(sThemeRootPath, sThemeName, oOptions) { // read relevant resources for hash generation const aAssetContents = _readAllFiles(sThemeRootPath) // generate hash based on library CSS files in theme root const aBufferList = aAssetContents.map(oContent => new Buffer(oContent)) const sNewHash = _createHash(aBufferList, oOptions) return sNewHash }
[ "function", "_getThemeRootHash", "(", "sThemeRootPath", ",", "sThemeName", ",", "oOptions", ")", "{", "const", "aAssetContents", "=", "_readAllFiles", "(", "sThemeRootPath", ")", "const", "aBufferList", "=", "aAssetContents", ".", "map", "(", "oContent", "=>", "new", "Buffer", "(", "oContent", ")", ")", "const", "sNewHash", "=", "_createHash", "(", "aBufferList", ",", "oOptions", ")", "return", "sNewHash", "}" ]
Generate hash for theme roots directory. @param {string} [sThemeRootPath] Theme root path. @param {string} [sThemeName] Theme name. @param {Object} [oOptions] Cach buster options. @param {Object} [oOptions.hash] Hash generation options. @param {string} [oOptions.HASH_TYPE] Hash type. @param {string} [oOptions.DIGEST_TYPE] Digest type. @param {number} [oOptions.MAX_LENGTH] Maximum hash length. @returns {string|null} Generated hash.
[ "Generate", "hash", "for", "theme", "roots", "directory", "." ]
55147d25bed7754fee2de69269f78c61079e1167
https://github.com/pulseshift/ui5-cache-buster/blob/55147d25bed7754fee2de69269f78c61079e1167/index.js#L364-L373
train
pulseshift/ui5-cache-buster
index.js
_readAllFiles
function _readAllFiles(sDir = '', aWhitelist = []) { // read all files in current directory const aFiles = fs.readdirSync(sDir) // loop at all files const aContents = aFiles.reduce((aContents, sFileName) => { // get file stats const oFile = fs.statSync(`${sDir}/${sFileName}`) if (oFile.isDirectory()) { // append files of directory to list return aContents.concat(_readAllFiles(`${sDir}/${sFileName}`)) } // append file content to list (if contained in whitelist) return aWhitelist.length === 0 || aWhitelist.indexOf(sFileName) !== -1 ? aContents.concat(fs.readFileSync(`${sDir}/${sFileName}`, 'utf8')) : aContents }, []) return aContents }
javascript
function _readAllFiles(sDir = '', aWhitelist = []) { // read all files in current directory const aFiles = fs.readdirSync(sDir) // loop at all files const aContents = aFiles.reduce((aContents, sFileName) => { // get file stats const oFile = fs.statSync(`${sDir}/${sFileName}`) if (oFile.isDirectory()) { // append files of directory to list return aContents.concat(_readAllFiles(`${sDir}/${sFileName}`)) } // append file content to list (if contained in whitelist) return aWhitelist.length === 0 || aWhitelist.indexOf(sFileName) !== -1 ? aContents.concat(fs.readFileSync(`${sDir}/${sFileName}`, 'utf8')) : aContents }, []) return aContents }
[ "function", "_readAllFiles", "(", "sDir", "=", "''", ",", "aWhitelist", "=", "[", "]", ")", "{", "const", "aFiles", "=", "fs", ".", "readdirSync", "(", "sDir", ")", "const", "aContents", "=", "aFiles", ".", "reduce", "(", "(", "aContents", ",", "sFileName", ")", "=>", "{", "const", "oFile", "=", "fs", ".", "statSync", "(", "`", "${", "sDir", "}", "${", "sFileName", "}", "`", ")", "if", "(", "oFile", ".", "isDirectory", "(", ")", ")", "{", "return", "aContents", ".", "concat", "(", "_readAllFiles", "(", "`", "${", "sDir", "}", "${", "sFileName", "}", "`", ")", ")", "}", "return", "aWhitelist", ".", "length", "===", "0", "||", "aWhitelist", ".", "indexOf", "(", "sFileName", ")", "!==", "-", "1", "?", "aContents", ".", "concat", "(", "fs", ".", "readFileSync", "(", "`", "${", "sDir", "}", "${", "sFileName", "}", "`", ",", "'utf8'", ")", ")", ":", "aContents", "}", ",", "[", "]", ")", "return", "aContents", "}" ]
Helper function to read directories recursively. @param {string} [sDir] Directory. @param {Array.string} [aWhitelist] List of file names as whitelist. @returns {Array.string} List of read file contents.
[ "Helper", "function", "to", "read", "directories", "recursively", "." ]
55147d25bed7754fee2de69269f78c61079e1167
https://github.com/pulseshift/ui5-cache-buster/blob/55147d25bed7754fee2de69269f78c61079e1167/index.js#L381-L401
train
pulseshift/ui5-cache-buster
index.js
_createHash
function _createHash(aBufferList, { HASH_TYPE, DIGEST_TYPE, MAX_LENGTH }) { // very important to sort buffer list before creating hash!! const aSortedBufferList = (aBufferList || []).sort() // create and return hash return aSortedBufferList.length > 0 ? loaderUtils .getHashDigest( Buffer.concat(aSortedBufferList), HASH_TYPE, DIGEST_TYPE, MAX_LENGTH ) // Windows machines are case insensitive while Linux machines are, so we only will use lower case paths .toLowerCase() : null }
javascript
function _createHash(aBufferList, { HASH_TYPE, DIGEST_TYPE, MAX_LENGTH }) { // very important to sort buffer list before creating hash!! const aSortedBufferList = (aBufferList || []).sort() // create and return hash return aSortedBufferList.length > 0 ? loaderUtils .getHashDigest( Buffer.concat(aSortedBufferList), HASH_TYPE, DIGEST_TYPE, MAX_LENGTH ) // Windows machines are case insensitive while Linux machines are, so we only will use lower case paths .toLowerCase() : null }
[ "function", "_createHash", "(", "aBufferList", ",", "{", "HASH_TYPE", ",", "DIGEST_TYPE", ",", "MAX_LENGTH", "}", ")", "{", "const", "aSortedBufferList", "=", "(", "aBufferList", "||", "[", "]", ")", ".", "sort", "(", ")", "return", "aSortedBufferList", ".", "length", ">", "0", "?", "loaderUtils", ".", "getHashDigest", "(", "Buffer", ".", "concat", "(", "aSortedBufferList", ")", ",", "HASH_TYPE", ",", "DIGEST_TYPE", ",", "MAX_LENGTH", ")", ".", "toLowerCase", "(", ")", ":", "null", "}" ]
Generate hash by binary content. @param {Array.Buffer} [aBufferList] Buffer list with binary content. @param {Object} [oOptions] Cach buster options. @param {Object} [oOptions.hash] Hash generation options. @param {string} [oOptions.HASH_TYPE] Hash type. @param {string} [oOptions.DIGEST_TYPE] Digest type. @param {number} [oOptions.MAX_LENGTH] Maximum hash length. @returns {string|null} Generated hash.
[ "Generate", "hash", "by", "binary", "content", "." ]
55147d25bed7754fee2de69269f78c61079e1167
https://github.com/pulseshift/ui5-cache-buster/blob/55147d25bed7754fee2de69269f78c61079e1167/index.js#L413-L429
train
fullstackio/cq
packages/cq/dist/index.js
lineNumberOfCharacterIndex
function lineNumberOfCharacterIndex(code, idx) { var everythingUpUntilTheIndex = code.substring(0, idx); // computer science! return everythingUpUntilTheIndex.split("\n").length; }
javascript
function lineNumberOfCharacterIndex(code, idx) { var everythingUpUntilTheIndex = code.substring(0, idx); // computer science! return everythingUpUntilTheIndex.split("\n").length; }
[ "function", "lineNumberOfCharacterIndex", "(", "code", ",", "idx", ")", "{", "var", "everythingUpUntilTheIndex", "=", "code", ".", "substring", "(", "0", ",", "idx", ")", ";", "return", "everythingUpUntilTheIndex", ".", "split", "(", "\"\\n\"", ")", ".", "\\n", ";", "}" ]
given character index idx in code, returns the 1-indexed line number
[ "given", "character", "index", "idx", "in", "code", "returns", "the", "1", "-", "indexed", "line", "number" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/cq/dist/index.js#L503-L507
train
wbyoung/azul
lib/database.js
function(name, properties) { var className = _.capitalize(_.camelCase(name)); var known = this._modelClasses; var model = known[className]; if (!model) { model = known[className] = this.Model.extend({}, { __name__: className }); } return model.reopen(properties); }
javascript
function(name, properties) { var className = _.capitalize(_.camelCase(name)); var known = this._modelClasses; var model = known[className]; if (!model) { model = known[className] = this.Model.extend({}, { __name__: className }); } return model.reopen(properties); }
[ "function", "(", "name", ",", "properties", ")", "{", "var", "className", "=", "_", ".", "capitalize", "(", "_", ".", "camelCase", "(", "name", ")", ")", ";", "var", "known", "=", "this", ".", "_modelClasses", ";", "var", "model", "=", "known", "[", "className", "]", ";", "if", "(", "!", "model", ")", "{", "model", "=", "known", "[", "className", "]", "=", "this", ".", "Model", ".", "extend", "(", "{", "}", ",", "{", "__name__", ":", "className", "}", ")", ";", "}", "return", "model", ".", "reopen", "(", "properties", ")", ";", "}" ]
Create a new model class or retrieve an existing class. This is the preferred way of creating new model classes as it also stores the model class by name, allowing you to use strings in certain places to refer to classes (i.e. when defining relationships). @param {String} name The name for the class @param {Object} [properties] Properties to add to the class @return {Class} The model class
[ "Create", "a", "new", "model", "class", "or", "retrieve", "an", "existing", "class", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/database.js#L96-L105
train
jwir3/gulp-ssh-deploy
src/index.js
function() { var self = this; if (!self.mHighlightedText) { gulpUtil.log(gulpUtil.colors.yellow('Warning:'), self.mMessage, "You will not be able to deploy."); } else { gulpUtil.log(gulpUtil.colors.yellow('Warning:'), self.mMessage, gulpUtil.colors.cyan(self.mHighlightedText), "You will not be able to deploy."); } }
javascript
function() { var self = this; if (!self.mHighlightedText) { gulpUtil.log(gulpUtil.colors.yellow('Warning:'), self.mMessage, "You will not be able to deploy."); } else { gulpUtil.log(gulpUtil.colors.yellow('Warning:'), self.mMessage, gulpUtil.colors.cyan(self.mHighlightedText), "You will not be able to deploy."); } }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "self", ".", "mHighlightedText", ")", "{", "gulpUtil", ".", "log", "(", "gulpUtil", ".", "colors", ".", "yellow", "(", "'Warning:'", ")", ",", "self", ".", "mMessage", ",", "\"You will not be able to deploy.\"", ")", ";", "}", "else", "{", "gulpUtil", ".", "log", "(", "gulpUtil", ".", "colors", ".", "yellow", "(", "'Warning:'", ")", ",", "self", ".", "mMessage", ",", "gulpUtil", ".", "colors", ".", "cyan", "(", "self", ".", "mHighlightedText", ")", ",", "\"You will not be able to deploy.\"", ")", ";", "}", "}" ]
Print this exception to the gulp log, with some color highlighting.
[ "Print", "this", "exception", "to", "the", "gulp", "log", "with", "some", "color", "highlighting", "." ]
d16f99fe93215b3fdf28796daf1d326154899866
https://github.com/jwir3/gulp-ssh-deploy/blob/d16f99fe93215b3fdf28796daf1d326154899866/src/index.js#L20-L29
train
jwir3/gulp-ssh-deploy
src/index.js
function() { var self = this; if (!self.mPackageJson) { self.mPackageJson = jetpack.read(this.mOptions.package_json_file_path, 'json'); } return self.mPackageJson; }
javascript
function() { var self = this; if (!self.mPackageJson) { self.mPackageJson = jetpack.read(this.mOptions.package_json_file_path, 'json'); } return self.mPackageJson; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "self", ".", "mPackageJson", ")", "{", "self", ".", "mPackageJson", "=", "jetpack", ".", "read", "(", "this", ".", "mOptions", ".", "package_json_file_path", ",", "'json'", ")", ";", "}", "return", "self", ".", "mPackageJson", ";", "}" ]
Retrieve the package.json file, as a JSON object. @return {object} The object containing the contents of the package.json file specified in the options structure.
[ "Retrieve", "the", "package", ".", "json", "file", "as", "a", "JSON", "object", "." ]
d16f99fe93215b3fdf28796daf1d326154899866
https://github.com/jwir3/gulp-ssh-deploy/blob/d16f99fe93215b3fdf28796daf1d326154899866/src/index.js#L124-L131
train
wbyoung/azul
lib/relations/base.js
function(baseTable, joinTable) { var jk = [baseTable, this.joinKeyAttr].join('.'); var ik = [joinTable, this.inverseKeyAttr].join('.'); var parts = [jk, ik]; // for readability, we like to keep the foreign key first in the join // condition, so if the join key is the primary key, swap the order of the // condition. if (this.joinKey === this.primaryKey) { parts.reverse(); } return parts.join('='); }
javascript
function(baseTable, joinTable) { var jk = [baseTable, this.joinKeyAttr].join('.'); var ik = [joinTable, this.inverseKeyAttr].join('.'); var parts = [jk, ik]; // for readability, we like to keep the foreign key first in the join // condition, so if the join key is the primary key, swap the order of the // condition. if (this.joinKey === this.primaryKey) { parts.reverse(); } return parts.join('='); }
[ "function", "(", "baseTable", ",", "joinTable", ")", "{", "var", "jk", "=", "[", "baseTable", ",", "this", ".", "joinKeyAttr", "]", ".", "join", "(", "'.'", ")", ";", "var", "ik", "=", "[", "joinTable", ",", "this", ".", "inverseKeyAttr", "]", ".", "join", "(", "'.'", ")", ";", "var", "parts", "=", "[", "jk", ",", "ik", "]", ";", "if", "(", "this", ".", "joinKey", "===", "this", ".", "primaryKey", ")", "{", "parts", ".", "reverse", "(", ")", ";", "}", "return", "parts", ".", "join", "(", "'='", ")", ";", "}" ]
Join support for a relation. This method joins a table, `baseTable` to `joinTable` using {@link BaseRelation#joinKey} as the attribute on the `baseTable` and {@link BaseRelation#inverseKey} as the attribute on `joinTable`. It also ensures that the foreign key will come first in the resulting condition (for readability, it's generally a little more understandable to see the foreign key first). @method @protected @param {String} baseTable The table name/alias of the existing table. @param {String} relatedTable The table name/alias being joined. @return {String} A string that represents the appropriate join condition.
[ "Join", "support", "for", "a", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/base.js#L223-L236
train
jpommerening/node-lazystream
lib/lazystream.js
beforeFirstCall
function beforeFirstCall(instance, method, callback) { instance[method] = function() { delete instance[method]; callback.apply(this, arguments); return this[method].apply(this, arguments); }; }
javascript
function beforeFirstCall(instance, method, callback) { instance[method] = function() { delete instance[method]; callback.apply(this, arguments); return this[method].apply(this, arguments); }; }
[ "function", "beforeFirstCall", "(", "instance", ",", "method", ",", "callback", ")", "{", "instance", "[", "method", "]", "=", "function", "(", ")", "{", "delete", "instance", "[", "method", "]", ";", "callback", ".", "apply", "(", "this", ",", "arguments", ")", ";", "return", "this", "[", "method", "]", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ";", "}" ]
Patch the given method of instance so that the callback is executed once, before the actual method is called the first time.
[ "Patch", "the", "given", "method", "of", "instance", "so", "that", "the", "callback", "is", "executed", "once", "before", "the", "actual", "method", "is", "called", "the", "first", "time", "." ]
f1f047c1957c75d39da6d4c21bb1d5196427d6c6
https://github.com/jpommerening/node-lazystream/blob/f1f047c1957c75d39da6d4c21bb1d5196427d6c6/lib/lazystream.js#L15-L21
train
wbyoung/azul
lib/cli/index.js
function(env, action) { if (!env.modulePath) { console.log(chalk.red('Local azul not found in'), chalk.magenta(tildify(env.cwd))); console.log(chalk.red('Try running: npm install azul')); process.exit(1); } if (!env.configPath && action.azulfile) { console.log(chalk.red('No azulfile found')); process.exit(1); } }
javascript
function(env, action) { if (!env.modulePath) { console.log(chalk.red('Local azul not found in'), chalk.magenta(tildify(env.cwd))); console.log(chalk.red('Try running: npm install azul')); process.exit(1); } if (!env.configPath && action.azulfile) { console.log(chalk.red('No azulfile found')); process.exit(1); } }
[ "function", "(", "env", ",", "action", ")", "{", "if", "(", "!", "env", ".", "modulePath", ")", "{", "console", ".", "log", "(", "chalk", ".", "red", "(", "'Local azul not found in'", ")", ",", "chalk", ".", "magenta", "(", "tildify", "(", "env", ".", "cwd", ")", ")", ")", ";", "console", ".", "log", "(", "chalk", ".", "red", "(", "'Try running: npm install azul'", ")", ")", ";", "process", ".", "exit", "(", "1", ")", ";", "}", "if", "(", "!", "env", ".", "configPath", "&&", "action", ".", "azulfile", ")", "{", "console", ".", "log", "(", "chalk", ".", "red", "(", "'No azulfile found'", ")", ")", ";", "process", ".", "exit", "(", "1", ")", ";", "}", "}" ]
Verify the Liftoff environment and exit the program if we are not in a suitable environment to operate. @private @function cli.verifyEnvironment @param {Object} env The liftoff environment.
[ "Verify", "the", "Liftoff", "environment", "and", "exit", "the", "program", "if", "we", "are", "not", "in", "a", "suitable", "environment", "to", "operate", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/cli/index.js#L47-L59
train
wbyoung/azul
lib/cli/index.js
function(program) { return program .version(require('../../package.json').version) .usage('[options] command') .option('--cwd <cwd>', 'change the current working directory') .option('--azulfile <azulfile>', 'use a specific config file') .option('--require <require>', 'require external module') .option('--completion <value>', 'a method to handle shell completions'); }
javascript
function(program) { return program .version(require('../../package.json').version) .usage('[options] command') .option('--cwd <cwd>', 'change the current working directory') .option('--azulfile <azulfile>', 'use a specific config file') .option('--require <require>', 'require external module') .option('--completion <value>', 'a method to handle shell completions'); }
[ "function", "(", "program", ")", "{", "return", "program", ".", "version", "(", "require", "(", "'../../package.json'", ")", ".", "version", ")", ".", "usage", "(", "'[options] command'", ")", ".", "option", "(", "'--cwd <cwd>'", ",", "'change the current working directory'", ")", ".", "option", "(", "'--azulfile <azulfile>'", ",", "'use a specific config file'", ")", ".", "option", "(", "'--require <require>'", ",", "'require external module'", ")", ".", "option", "(", "'--completion <value>'", ",", "'a method to handle shell completions'", ")", ";", "}" ]
Setup program. @private @function
[ "Setup", "program", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/cli/index.js#L76-L84
train
wbyoung/azul
lib/cli/index.js
function(details) { return function() { var args = _.toArray(arguments); var options = _.last(args); action.options = options; action.name = options.name(); action.args = args; action = _.defaults(action, details, { azulfile: true }); }; }
javascript
function(details) { return function() { var args = _.toArray(arguments); var options = _.last(args); action.options = options; action.name = options.name(); action.args = args; action = _.defaults(action, details, { azulfile: true }); }; }
[ "function", "(", "details", ")", "{", "return", "function", "(", ")", "{", "var", "args", "=", "_", ".", "toArray", "(", "arguments", ")", ";", "var", "options", "=", "_", ".", "last", "(", "args", ")", ";", "action", ".", "options", "=", "options", ";", "action", ".", "name", "=", "options", ".", "name", "(", ")", ";", "action", ".", "args", "=", "args", ";", "action", "=", "_", ".", "defaults", "(", "action", ",", "details", ",", "{", "azulfile", ":", "true", "}", ")", ";", "}", ";", "}" ]
We need capture the requested action & execute it after checking that all required values are set on env. this allows the cli to still run things like help when azul is not installed locally or is missing a configuration file. @function cli~capture @private
[ "We", "need", "capture", "the", "requested", "action", "&", "execute", "it", "after", "checking", "that", "all", "required", "values", "are", "set", "on", "env", ".", "this", "allows", "the", "cli", "to", "still", "run", "things", "like", "help", "when", "azul", "is", "not", "installed", "locally", "or", "is", "missing", "a", "configuration", "file", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/cli/index.js#L160-L169
train
fullstackio/cq
packages/react-cq-demo/src/jquery.highlight-within-textarea.js
function(instance) { let type = typeof instance; if (!instance) { return "falsey"; } else if (Array.isArray(instance)) { if ( instance.length === 2 && typeof instance[0] === "number" && typeof instance[1] === "number" ) { return "range"; } else { return "array"; } } else if (type === "object") { if (instance instanceof RegExp) { return "regexp"; } else if (instance.hasOwnProperty("highlight")) { return "custom"; } } else if (type === "function" || type === "string") { return type; } return "other"; }
javascript
function(instance) { let type = typeof instance; if (!instance) { return "falsey"; } else if (Array.isArray(instance)) { if ( instance.length === 2 && typeof instance[0] === "number" && typeof instance[1] === "number" ) { return "range"; } else { return "array"; } } else if (type === "object") { if (instance instanceof RegExp) { return "regexp"; } else if (instance.hasOwnProperty("highlight")) { return "custom"; } } else if (type === "function" || type === "string") { return type; } return "other"; }
[ "function", "(", "instance", ")", "{", "let", "type", "=", "typeof", "instance", ";", "if", "(", "!", "instance", ")", "{", "return", "\"falsey\"", ";", "}", "else", "if", "(", "Array", ".", "isArray", "(", "instance", ")", ")", "{", "if", "(", "instance", ".", "length", "===", "2", "&&", "typeof", "instance", "[", "0", "]", "===", "\"number\"", "&&", "typeof", "instance", "[", "1", "]", "===", "\"number\"", ")", "{", "return", "\"range\"", ";", "}", "else", "{", "return", "\"array\"", ";", "}", "}", "else", "if", "(", "type", "===", "\"object\"", ")", "{", "if", "(", "instance", "instanceof", "RegExp", ")", "{", "return", "\"regexp\"", ";", "}", "else", "if", "(", "instance", ".", "hasOwnProperty", "(", "\"highlight\"", ")", ")", "{", "return", "\"custom\"", ";", "}", "}", "else", "if", "(", "type", "===", "\"function\"", "||", "type", "===", "\"string\"", ")", "{", "return", "type", ";", "}", "return", "\"other\"", ";", "}" ]
returns identifier strings that aren't necessarily "real" JavaScript types
[ "returns", "identifier", "strings", "that", "aren", "t", "necessarily", "real", "JavaScript", "types" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/react-cq-demo/src/jquery.highlight-within-textarea.js#L33-L58
train
fullstackio/cq
packages/react-cq-demo/src/jquery.highlight-within-textarea.js
function() { let ua = window.navigator.userAgent.toLowerCase(); if (ua.indexOf("firefox") !== -1) { return "firefox"; } else if (!!ua.match(/msie|trident\/7|edge/)) { return "ie"; } else if ( !!ua.match(/ipad|iphone|ipod/) && ua.indexOf("windows phone") === -1 ) { // Windows Phone flags itself as "like iPhone", thus the extra check return "ios"; } else { return "other"; } }
javascript
function() { let ua = window.navigator.userAgent.toLowerCase(); if (ua.indexOf("firefox") !== -1) { return "firefox"; } else if (!!ua.match(/msie|trident\/7|edge/)) { return "ie"; } else if ( !!ua.match(/ipad|iphone|ipod/) && ua.indexOf("windows phone") === -1 ) { // Windows Phone flags itself as "like iPhone", thus the extra check return "ios"; } else { return "other"; } }
[ "function", "(", ")", "{", "let", "ua", "=", "window", ".", "navigator", ".", "userAgent", ".", "toLowerCase", "(", ")", ";", "if", "(", "ua", ".", "indexOf", "(", "\"firefox\"", ")", "!==", "-", "1", ")", "{", "return", "\"firefox\"", ";", "}", "else", "if", "(", "!", "!", "ua", ".", "match", "(", "/", "msie|trident\\/7|edge", "/", ")", ")", "{", "return", "\"ie\"", ";", "}", "else", "if", "(", "!", "!", "ua", ".", "match", "(", "/", "ipad|iphone|ipod", "/", ")", "&&", "ua", ".", "indexOf", "(", "\"windows phone\"", ")", "===", "-", "1", ")", "{", "return", "\"ios\"", ";", "}", "else", "{", "return", "\"other\"", ";", "}", "}" ]
browser sniffing sucks, but there are browser-specific quirks to handle that are not a matter of feature detection
[ "browser", "sniffing", "sucks", "but", "there", "are", "browser", "-", "specific", "quirks", "to", "handle", "that", "are", "not", "a", "matter", "of", "feature", "detection" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/react-cq-demo/src/jquery.highlight-within-textarea.js#L98-L113
train
fullstackio/cq
packages/react-cq-demo/src/jquery.highlight-within-textarea.js
function() { // take padding and border pixels from highlights div let padding = this.$highlights.css([ "padding-top", "padding-right", "padding-bottom", "padding-left" ]); let border = this.$highlights.css([ "border-top-width", "border-right-width", "border-bottom-width", "border-left-width" ]); this.$highlights.css({ padding: "0", "border-width": "0" }); this.$backdrop .css({ // give padding pixels to backdrop div "margin-top": "+=" + padding["padding-top"], "margin-right": "+=" + padding["padding-right"], "margin-bottom": "+=" + padding["padding-bottom"], "margin-left": "+=" + padding["padding-left"] }) .css({ // give border pixels to backdrop div "margin-top": "+=" + border["border-top-width"], "margin-right": "+=" + border["border-right-width"], "margin-bottom": "+=" + border["border-bottom-width"], "margin-left": "+=" + border["border-left-width"] }); }
javascript
function() { // take padding and border pixels from highlights div let padding = this.$highlights.css([ "padding-top", "padding-right", "padding-bottom", "padding-left" ]); let border = this.$highlights.css([ "border-top-width", "border-right-width", "border-bottom-width", "border-left-width" ]); this.$highlights.css({ padding: "0", "border-width": "0" }); this.$backdrop .css({ // give padding pixels to backdrop div "margin-top": "+=" + padding["padding-top"], "margin-right": "+=" + padding["padding-right"], "margin-bottom": "+=" + padding["padding-bottom"], "margin-left": "+=" + padding["padding-left"] }) .css({ // give border pixels to backdrop div "margin-top": "+=" + border["border-top-width"], "margin-right": "+=" + border["border-right-width"], "margin-bottom": "+=" + border["border-bottom-width"], "margin-left": "+=" + border["border-left-width"] }); }
[ "function", "(", ")", "{", "let", "padding", "=", "this", ".", "$highlights", ".", "css", "(", "[", "\"padding-top\"", ",", "\"padding-right\"", ",", "\"padding-bottom\"", ",", "\"padding-left\"", "]", ")", ";", "let", "border", "=", "this", ".", "$highlights", ".", "css", "(", "[", "\"border-top-width\"", ",", "\"border-right-width\"", ",", "\"border-bottom-width\"", ",", "\"border-left-width\"", "]", ")", ";", "this", ".", "$highlights", ".", "css", "(", "{", "padding", ":", "\"0\"", ",", "\"border-width\"", ":", "\"0\"", "}", ")", ";", "this", ".", "$backdrop", ".", "css", "(", "{", "\"margin-top\"", ":", "\"+=\"", "+", "padding", "[", "\"padding-top\"", "]", ",", "\"margin-right\"", ":", "\"+=\"", "+", "padding", "[", "\"padding-right\"", "]", ",", "\"margin-bottom\"", ":", "\"+=\"", "+", "padding", "[", "\"padding-bottom\"", "]", ",", "\"margin-left\"", ":", "\"+=\"", "+", "padding", "[", "\"padding-left\"", "]", "}", ")", ".", "css", "(", "{", "\"margin-top\"", ":", "\"+=\"", "+", "border", "[", "\"border-top-width\"", "]", ",", "\"margin-right\"", ":", "\"+=\"", "+", "border", "[", "\"border-right-width\"", "]", ",", "\"margin-bottom\"", ":", "\"+=\"", "+", "border", "[", "\"border-bottom-width\"", "]", ",", "\"margin-left\"", ":", "\"+=\"", "+", "border", "[", "\"border-left-width\"", "]", "}", ")", ";", "}" ]
Firefox doesn't show text that scrolls into the padding of a textarea, so rearrange a couple box models to make highlights behave the same way
[ "Firefox", "doesn", "t", "show", "text", "that", "scrolls", "into", "the", "padding", "of", "a", "textarea", "so", "rearrange", "a", "couple", "box", "models", "to", "make", "highlights", "behave", "the", "same", "way" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/react-cq-demo/src/jquery.highlight-within-textarea.js#L117-L151
train
fullstackio/cq
packages/remark-cq/index.js
locateCodeImport
function locateCodeImport(value, fromIndex) { var index = value.indexOf(C_NEWLINE, fromIndex); if (value.charAt(index + 1) !== "<" && value.charAt(index + 2) !== "<") { return; } return index; }
javascript
function locateCodeImport(value, fromIndex) { var index = value.indexOf(C_NEWLINE, fromIndex); if (value.charAt(index + 1) !== "<" && value.charAt(index + 2) !== "<") { return; } return index; }
[ "function", "locateCodeImport", "(", "value", ",", "fromIndex", ")", "{", "var", "index", "=", "value", ".", "indexOf", "(", "C_NEWLINE", ",", "fromIndex", ")", ";", "if", "(", "value", ".", "charAt", "(", "index", "+", "1", ")", "!==", "\"<\"", "&&", "value", ".", "charAt", "(", "index", "+", "2", ")", "!==", "\"<\"", ")", "{", "return", ";", "}", "return", "index", ";", "}" ]
Find a possible Code Imports @example locateCodeImport('foo \n<<[my-file.js](my-file.js)'); // 4 @param {string} value - Value to search. @param {number} fromIndex - Index to start searching at. @return {number} - Location of possible mention sequence.
[ "Find", "a", "possible", "Code", "Imports" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/remark-cq/index.js#L54-L62
train
fullstackio/cq
packages/remark-cq/index.js
codeImportBlock
function codeImportBlock(eat, value, silent) { var index = -1; var length = value.length + 1; var subvalue = EMPTY; var character; var marker; var markerCount; var queue; // eat initial spacing while (++index < length) { character = value.charAt(index); if (character !== C_TAB && character !== C_SPACE) { break; } subvalue += character; } if (value.charAt(index) !== "<") { return; } // require << if (value.charAt(index + 1) !== "<") { return; } marker = character; subvalue += character; markerCount = 1; queue = EMPTY; while (++index < length) { character = value.charAt(index); if (character !== C_RIGHT_PAREN) { markerCount++; subvalue += queue + character; queue = EMPTY; } else if (character === C_RIGHT_PAREN) { subvalue += queue + C_RIGHT_PAREN; break; } } var match = /^(<<.*?)\s*$/m.exec(subvalue); if (!match) return; var fileMatches = /<<\[(.*)\]\((.*)\)/.exec(match[0]); var statedFilename = fileMatches[1]; var actualFilename = fileMatches[2]; var cqOpts = { ...__options }; if (__lastBlockAttributes["undent"]) { cqOpts.undent = true; } if (__lastBlockAttributes["root"]) { cqOpts.root = __lastBlockAttributes["root"]; } if (__lastBlockAttributes["meta"]) { cqOpts.meta = __lastBlockAttributes["meta"]; } let newNode = { type: "cq", lang: null, statedFilename, actualFilename, query: null, cropStartLine: null, cropEndLine: null, options: cqOpts }; if (__lastBlockAttributes["lang"]) { newNode.lang = __lastBlockAttributes["lang"].toLowerCase(); } if (__lastBlockAttributes["crop-query"]) { newNode.query = __lastBlockAttributes["crop-query"]; } if (__lastBlockAttributes["crop-start-line"]) { newNode.cropStartLine = parseInt(__lastBlockAttributes["crop-start-line"]); } if (__lastBlockAttributes["crop-end-line"]) { newNode.cropEndLine = parseInt(__lastBlockAttributes["crop-end-line"]); } // meta: `{ info=string filename="foo/bar/baz.js" githubUrl="https://github.com/foo/bar"}` return eat(subvalue)(newNode); }
javascript
function codeImportBlock(eat, value, silent) { var index = -1; var length = value.length + 1; var subvalue = EMPTY; var character; var marker; var markerCount; var queue; // eat initial spacing while (++index < length) { character = value.charAt(index); if (character !== C_TAB && character !== C_SPACE) { break; } subvalue += character; } if (value.charAt(index) !== "<") { return; } // require << if (value.charAt(index + 1) !== "<") { return; } marker = character; subvalue += character; markerCount = 1; queue = EMPTY; while (++index < length) { character = value.charAt(index); if (character !== C_RIGHT_PAREN) { markerCount++; subvalue += queue + character; queue = EMPTY; } else if (character === C_RIGHT_PAREN) { subvalue += queue + C_RIGHT_PAREN; break; } } var match = /^(<<.*?)\s*$/m.exec(subvalue); if (!match) return; var fileMatches = /<<\[(.*)\]\((.*)\)/.exec(match[0]); var statedFilename = fileMatches[1]; var actualFilename = fileMatches[2]; var cqOpts = { ...__options }; if (__lastBlockAttributes["undent"]) { cqOpts.undent = true; } if (__lastBlockAttributes["root"]) { cqOpts.root = __lastBlockAttributes["root"]; } if (__lastBlockAttributes["meta"]) { cqOpts.meta = __lastBlockAttributes["meta"]; } let newNode = { type: "cq", lang: null, statedFilename, actualFilename, query: null, cropStartLine: null, cropEndLine: null, options: cqOpts }; if (__lastBlockAttributes["lang"]) { newNode.lang = __lastBlockAttributes["lang"].toLowerCase(); } if (__lastBlockAttributes["crop-query"]) { newNode.query = __lastBlockAttributes["crop-query"]; } if (__lastBlockAttributes["crop-start-line"]) { newNode.cropStartLine = parseInt(__lastBlockAttributes["crop-start-line"]); } if (__lastBlockAttributes["crop-end-line"]) { newNode.cropEndLine = parseInt(__lastBlockAttributes["crop-end-line"]); } // meta: `{ info=string filename="foo/bar/baz.js" githubUrl="https://github.com/foo/bar"}` return eat(subvalue)(newNode); }
[ "function", "codeImportBlock", "(", "eat", ",", "value", ",", "silent", ")", "{", "var", "index", "=", "-", "1", ";", "var", "length", "=", "value", ".", "length", "+", "1", ";", "var", "subvalue", "=", "EMPTY", ";", "var", "character", ";", "var", "marker", ";", "var", "markerCount", ";", "var", "queue", ";", "while", "(", "++", "index", "<", "length", ")", "{", "character", "=", "value", ".", "charAt", "(", "index", ")", ";", "if", "(", "character", "!==", "C_TAB", "&&", "character", "!==", "C_SPACE", ")", "{", "break", ";", "}", "subvalue", "+=", "character", ";", "}", "if", "(", "value", ".", "charAt", "(", "index", ")", "!==", "\"<\"", ")", "{", "return", ";", "}", "if", "(", "value", ".", "charAt", "(", "index", "+", "1", ")", "!==", "\"<\"", ")", "{", "return", ";", "}", "marker", "=", "character", ";", "subvalue", "+=", "character", ";", "markerCount", "=", "1", ";", "queue", "=", "EMPTY", ";", "while", "(", "++", "index", "<", "length", ")", "{", "character", "=", "value", ".", "charAt", "(", "index", ")", ";", "if", "(", "character", "!==", "C_RIGHT_PAREN", ")", "{", "markerCount", "++", ";", "subvalue", "+=", "queue", "+", "character", ";", "queue", "=", "EMPTY", ";", "}", "else", "if", "(", "character", "===", "C_RIGHT_PAREN", ")", "{", "subvalue", "+=", "queue", "+", "C_RIGHT_PAREN", ";", "break", ";", "}", "}", "var", "match", "=", "/", "^(<<.*?)\\s*$", "/", "m", ".", "exec", "(", "subvalue", ")", ";", "if", "(", "!", "match", ")", "return", ";", "var", "fileMatches", "=", "/", "<<\\[(.*)\\]\\((.*)\\)", "/", ".", "exec", "(", "match", "[", "0", "]", ")", ";", "var", "statedFilename", "=", "fileMatches", "[", "1", "]", ";", "var", "actualFilename", "=", "fileMatches", "[", "2", "]", ";", "var", "cqOpts", "=", "{", "...", "__options", "}", ";", "if", "(", "__lastBlockAttributes", "[", "\"undent\"", "]", ")", "{", "cqOpts", ".", "undent", "=", "true", ";", "}", "if", "(", "__lastBlockAttributes", "[", "\"root\"", "]", ")", "{", "cqOpts", ".", "root", "=", "__lastBlockAttributes", "[", "\"root\"", "]", ";", "}", "if", "(", "__lastBlockAttributes", "[", "\"meta\"", "]", ")", "{", "cqOpts", ".", "meta", "=", "__lastBlockAttributes", "[", "\"meta\"", "]", ";", "}", "let", "newNode", "=", "{", "type", ":", "\"cq\"", ",", "lang", ":", "null", ",", "statedFilename", ",", "actualFilename", ",", "query", ":", "null", ",", "cropStartLine", ":", "null", ",", "cropEndLine", ":", "null", ",", "options", ":", "cqOpts", "}", ";", "if", "(", "__lastBlockAttributes", "[", "\"lang\"", "]", ")", "{", "newNode", ".", "lang", "=", "__lastBlockAttributes", "[", "\"lang\"", "]", ".", "toLowerCase", "(", ")", ";", "}", "if", "(", "__lastBlockAttributes", "[", "\"crop-query\"", "]", ")", "{", "newNode", ".", "query", "=", "__lastBlockAttributes", "[", "\"crop-query\"", "]", ";", "}", "if", "(", "__lastBlockAttributes", "[", "\"crop-start-line\"", "]", ")", "{", "newNode", ".", "cropStartLine", "=", "parseInt", "(", "__lastBlockAttributes", "[", "\"crop-start-line\"", "]", ")", ";", "}", "if", "(", "__lastBlockAttributes", "[", "\"crop-end-line\"", "]", ")", "{", "newNode", ".", "cropEndLine", "=", "parseInt", "(", "__lastBlockAttributes", "[", "\"crop-end-line\"", "]", ")", ";", "}", "return", "eat", "(", "subvalue", ")", "(", "newNode", ")", ";", "}" ]
Tokenize a code import @example codeImportBlock(eat, '\n<<[my-file.js](my-file.js)'); @property {Function} locator - Mention locator. @param {function(string)} eat - Eater. @param {string} value - Rest of content. @param {boolean?} [silent] - Whether this is a dry run. @return {Node?|boolean} - `delete` node.
[ "Tokenize", "a", "code", "import" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/remark-cq/index.js#L77-L173
train
fullstackio/cq
packages/remark-cq/index.js
tokenizeBlockInlineAttributeList
function tokenizeBlockInlineAttributeList(eat, value, silent) { var self = this; var index = -1; var length = value.length + 1; var subvalue = EMPTY; var character; var marker; var markerCount; var queue; // eat initial spacing while (++index < length) { character = value.charAt(index); if (character !== C_TAB && character !== C_SPACE) { break; } subvalue += character; } if (value.charAt(index) !== C_LEFT_BRACE) { return; } // ignore {{ thing }} if (value.charAt(index + 1) === C_LEFT_BRACE) { return; } // ignore {% thing %} if (value.charAt(index + 1) === C_PERCENT) { return; } marker = character; subvalue += character; markerCount = 1; queue = EMPTY; while (++index < length) { character = value.charAt(index); if (character !== C_RIGHT_BRACE) { // no newlines allowed in the attribute blocks if (character === C_NEWLINE) { return; } markerCount++; subvalue += queue + character; queue = EMPTY; } else if (character === C_RIGHT_BRACE) { subvalue += queue + C_RIGHT_BRACE; // eat trailing spacing because we don't even want this block to leave a linebreak in the output while (++index < length) { character = value.charAt(index); if ( character !== C_TAB && character !== C_SPACE && character !== C_NEWLINE ) { break; } subvalue += character; } function parseBlockAttributes(attrString) { // e.g. {lang='JavaScript',starting-line=4,crop-start-line=4,crop-end-line=26} var matches = /{(.*?)}/.exec(attrString); var blockAttrs = {}; if (!matches || !matches[1]) { console.log("WARNING: remark-cq unknown attrString", attrString); // hmm... return blockAttrs; } var pairs = splitNoParen(matches[1]); pairs.forEach(function(pair) { var kv = pair.split(/=\s*/); blockAttrs[kv[0]] = kv[1]; }); return blockAttrs; } __lastBlockAttributes = parseBlockAttributes(subvalue); if (__options.preserveEmptyLines) { return eat(subvalue)({ type: T_BREAK }); } else { return eat(subvalue); } } else { return; } } }
javascript
function tokenizeBlockInlineAttributeList(eat, value, silent) { var self = this; var index = -1; var length = value.length + 1; var subvalue = EMPTY; var character; var marker; var markerCount; var queue; // eat initial spacing while (++index < length) { character = value.charAt(index); if (character !== C_TAB && character !== C_SPACE) { break; } subvalue += character; } if (value.charAt(index) !== C_LEFT_BRACE) { return; } // ignore {{ thing }} if (value.charAt(index + 1) === C_LEFT_BRACE) { return; } // ignore {% thing %} if (value.charAt(index + 1) === C_PERCENT) { return; } marker = character; subvalue += character; markerCount = 1; queue = EMPTY; while (++index < length) { character = value.charAt(index); if (character !== C_RIGHT_BRACE) { // no newlines allowed in the attribute blocks if (character === C_NEWLINE) { return; } markerCount++; subvalue += queue + character; queue = EMPTY; } else if (character === C_RIGHT_BRACE) { subvalue += queue + C_RIGHT_BRACE; // eat trailing spacing because we don't even want this block to leave a linebreak in the output while (++index < length) { character = value.charAt(index); if ( character !== C_TAB && character !== C_SPACE && character !== C_NEWLINE ) { break; } subvalue += character; } function parseBlockAttributes(attrString) { // e.g. {lang='JavaScript',starting-line=4,crop-start-line=4,crop-end-line=26} var matches = /{(.*?)}/.exec(attrString); var blockAttrs = {}; if (!matches || !matches[1]) { console.log("WARNING: remark-cq unknown attrString", attrString); // hmm... return blockAttrs; } var pairs = splitNoParen(matches[1]); pairs.forEach(function(pair) { var kv = pair.split(/=\s*/); blockAttrs[kv[0]] = kv[1]; }); return blockAttrs; } __lastBlockAttributes = parseBlockAttributes(subvalue); if (__options.preserveEmptyLines) { return eat(subvalue)({ type: T_BREAK }); } else { return eat(subvalue); } } else { return; } } }
[ "function", "tokenizeBlockInlineAttributeList", "(", "eat", ",", "value", ",", "silent", ")", "{", "var", "self", "=", "this", ";", "var", "index", "=", "-", "1", ";", "var", "length", "=", "value", ".", "length", "+", "1", ";", "var", "subvalue", "=", "EMPTY", ";", "var", "character", ";", "var", "marker", ";", "var", "markerCount", ";", "var", "queue", ";", "while", "(", "++", "index", "<", "length", ")", "{", "character", "=", "value", ".", "charAt", "(", "index", ")", ";", "if", "(", "character", "!==", "C_TAB", "&&", "character", "!==", "C_SPACE", ")", "{", "break", ";", "}", "subvalue", "+=", "character", ";", "}", "if", "(", "value", ".", "charAt", "(", "index", ")", "!==", "C_LEFT_BRACE", ")", "{", "return", ";", "}", "if", "(", "value", ".", "charAt", "(", "index", "+", "1", ")", "===", "C_LEFT_BRACE", ")", "{", "return", ";", "}", "if", "(", "value", ".", "charAt", "(", "index", "+", "1", ")", "===", "C_PERCENT", ")", "{", "return", ";", "}", "marker", "=", "character", ";", "subvalue", "+=", "character", ";", "markerCount", "=", "1", ";", "queue", "=", "EMPTY", ";", "while", "(", "++", "index", "<", "length", ")", "{", "character", "=", "value", ".", "charAt", "(", "index", ")", ";", "if", "(", "character", "!==", "C_RIGHT_BRACE", ")", "{", "if", "(", "character", "===", "C_NEWLINE", ")", "{", "return", ";", "}", "markerCount", "++", ";", "subvalue", "+=", "queue", "+", "character", ";", "queue", "=", "EMPTY", ";", "}", "else", "if", "(", "character", "===", "C_RIGHT_BRACE", ")", "{", "subvalue", "+=", "queue", "+", "C_RIGHT_BRACE", ";", "while", "(", "++", "index", "<", "length", ")", "{", "character", "=", "value", ".", "charAt", "(", "index", ")", ";", "if", "(", "character", "!==", "C_TAB", "&&", "character", "!==", "C_SPACE", "&&", "character", "!==", "C_NEWLINE", ")", "{", "break", ";", "}", "subvalue", "+=", "character", ";", "}", "function", "parseBlockAttributes", "(", "attrString", ")", "{", "var", "matches", "=", "/", "{(.*?)}", "/", ".", "exec", "(", "attrString", ")", ";", "var", "blockAttrs", "=", "{", "}", ";", "if", "(", "!", "matches", "||", "!", "matches", "[", "1", "]", ")", "{", "console", ".", "log", "(", "\"WARNING: remark-cq unknown attrString\"", ",", "attrString", ")", ";", "return", "blockAttrs", ";", "}", "var", "pairs", "=", "splitNoParen", "(", "matches", "[", "1", "]", ")", ";", "pairs", ".", "forEach", "(", "function", "(", "pair", ")", "{", "var", "kv", "=", "pair", ".", "split", "(", "/", "=\\s*", "/", ")", ";", "blockAttrs", "[", "kv", "[", "0", "]", "]", "=", "kv", "[", "1", "]", ";", "}", ")", ";", "return", "blockAttrs", ";", "}", "__lastBlockAttributes", "=", "parseBlockAttributes", "(", "subvalue", ")", ";", "if", "(", "__options", ".", "preserveEmptyLines", ")", "{", "return", "eat", "(", "subvalue", ")", "(", "{", "type", ":", "T_BREAK", "}", ")", ";", "}", "else", "{", "return", "eat", "(", "subvalue", ")", ";", "}", "}", "else", "{", "return", ";", "}", "}", "}" ]
Tokenise a block inline attribute list @example tokenizeBlockInlineAttributeList(eat, '{lang=javascript}'); @param {function(string)} eat - Eater. @param {string} value - Rest of content. @param {boolean?} [silent] - Whether this is a dry run. @return {Node?|boolean} - `thematicBreak` node.
[ "Tokenise", "a", "block", "inline", "attribute", "list" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/remark-cq/index.js#L232-L333
train
fullstackio/cq
packages/cq/dist/engines/util.js
rangeExtents
function rangeExtents(ranges) { var start = Number.MAX_VALUE; var end = Number.MIN_VALUE; ranges.map(function (_ref) { var rs = _ref.start, re = _ref.end; start = Math.min(start, rs); end = Math.max(end, re); }); return { start: start, end: end }; }
javascript
function rangeExtents(ranges) { var start = Number.MAX_VALUE; var end = Number.MIN_VALUE; ranges.map(function (_ref) { var rs = _ref.start, re = _ref.end; start = Math.min(start, rs); end = Math.max(end, re); }); return { start: start, end: end }; }
[ "function", "rangeExtents", "(", "ranges", ")", "{", "var", "start", "=", "Number", ".", "MAX_VALUE", ";", "var", "end", "=", "Number", ".", "MIN_VALUE", ";", "ranges", ".", "map", "(", "function", "(", "_ref", ")", "{", "var", "rs", "=", "_ref", ".", "start", ",", "re", "=", "_ref", ".", "end", ";", "start", "=", "Math", ".", "min", "(", "start", ",", "rs", ")", ";", "end", "=", "Math", ".", "max", "(", "end", ",", "re", ")", ";", "}", ")", ";", "return", "{", "start", ":", "start", ",", "end", ":", "end", "}", ";", "}" ]
cq Engine Util Utility functions
[ "cq", "Engine", "Util" ]
a9425c677b558f92f73a15d38ad39ac1d2deb189
https://github.com/fullstackio/cq/blob/a9425c677b558f92f73a15d38ad39ac1d2deb189/packages/cq/dist/engines/util.js#L14-L25
train
alawatthe/MathLib
build/es6/Functn.js
function (f, a, b, fa, fc, fb, options) { var h = b - a, c = (a + b) / 2, fd = f((a + c) / 2), fe = f((c + b) / 2), Q1 = (h / 6) * (fa + 4 * fc + fb), Q2 = (h / 12) * (fa + 4 * fd + 2 * fc + 4 * fe + fb), Q = Q2 + (Q2 - Q1) / 15; options.calls = options.calls + 2; // Infinite or Not-a-Number function value encountered if (!isFinite(Q)) { options.warn = Math.max(options.warn, 3); return Q; } // Maximum function count exceeded; singularity likely if (options.calls > options.maxCalls) { options.warn = Math.max(options.warn, 2); return Q; } // Accuracy over this subinterval is acceptable if (Math.abs(Q2 - Q) <= options.tolerance) { return Q; } // Minimum step size reached; singularity possible if (Math.abs(h) < options.minStep || c === a || c === b) { options.warn = Math.max(options.warn, 1); return Q; } // Otherwise, divide the interval into two subintervals return quadstep(f, a, c, fa, fd, fc, options) + quadstep(f, c, b, fc, fe, fb, options); }
javascript
function (f, a, b, fa, fc, fb, options) { var h = b - a, c = (a + b) / 2, fd = f((a + c) / 2), fe = f((c + b) / 2), Q1 = (h / 6) * (fa + 4 * fc + fb), Q2 = (h / 12) * (fa + 4 * fd + 2 * fc + 4 * fe + fb), Q = Q2 + (Q2 - Q1) / 15; options.calls = options.calls + 2; // Infinite or Not-a-Number function value encountered if (!isFinite(Q)) { options.warn = Math.max(options.warn, 3); return Q; } // Maximum function count exceeded; singularity likely if (options.calls > options.maxCalls) { options.warn = Math.max(options.warn, 2); return Q; } // Accuracy over this subinterval is acceptable if (Math.abs(Q2 - Q) <= options.tolerance) { return Q; } // Minimum step size reached; singularity possible if (Math.abs(h) < options.minStep || c === a || c === b) { options.warn = Math.max(options.warn, 1); return Q; } // Otherwise, divide the interval into two subintervals return quadstep(f, a, c, fa, fd, fc, options) + quadstep(f, c, b, fc, fe, fb, options); }
[ "function", "(", "f", ",", "a", ",", "b", ",", "fa", ",", "fc", ",", "fb", ",", "options", ")", "{", "var", "h", "=", "b", "-", "a", ",", "c", "=", "(", "a", "+", "b", ")", "/", "2", ",", "fd", "=", "f", "(", "(", "a", "+", "c", ")", "/", "2", ")", ",", "fe", "=", "f", "(", "(", "c", "+", "b", ")", "/", "2", ")", ",", "Q1", "=", "(", "h", "/", "6", ")", "*", "(", "fa", "+", "4", "*", "fc", "+", "fb", ")", ",", "Q2", "=", "(", "h", "/", "12", ")", "*", "(", "fa", "+", "4", "*", "fd", "+", "2", "*", "fc", "+", "4", "*", "fe", "+", "fb", ")", ",", "Q", "=", "Q2", "+", "(", "Q2", "-", "Q1", ")", "/", "15", ";", "options", ".", "calls", "=", "options", ".", "calls", "+", "2", ";", "if", "(", "!", "isFinite", "(", "Q", ")", ")", "{", "options", ".", "warn", "=", "Math", ".", "max", "(", "options", ".", "warn", ",", "3", ")", ";", "return", "Q", ";", "}", "if", "(", "options", ".", "calls", ">", "options", ".", "maxCalls", ")", "{", "options", ".", "warn", "=", "Math", ".", "max", "(", "options", ".", "warn", ",", "2", ")", ";", "return", "Q", ";", "}", "if", "(", "Math", ".", "abs", "(", "Q2", "-", "Q", ")", "<=", "options", ".", "tolerance", ")", "{", "return", "Q", ";", "}", "if", "(", "Math", ".", "abs", "(", "h", ")", "<", "options", ".", "minStep", "||", "c", "===", "a", "||", "c", "===", "b", ")", "{", "options", ".", "warn", "=", "Math", ".", "max", "(", "options", ".", "warn", ",", "1", ")", ";", "return", "Q", ";", "}", "return", "quadstep", "(", "f", ",", "a", ",", "c", ",", "fa", ",", "fd", ",", "fc", ",", "options", ")", "+", "quadstep", "(", "f", ",", "c", ",", "b", ",", "fc", ",", "fe", ",", "fb", ",", "options", ")", ";", "}" ]
Recursive function for the quad method
[ "Recursive", "function", "for", "the", "quad", "method" ]
43dbd35263da672bd2ca41f93dc447b60da9bdac
https://github.com/alawatthe/MathLib/blob/43dbd35263da672bd2ca41f93dc447b60da9bdac/build/es6/Functn.js#L1120-L1150
train
wbyoung/azul
lib/relations/has_one.js
function() { this._super.apply(this, arguments); if (this._options.through) { this._options.through = inflection.singularize(this._options.through); } }
javascript
function() { this._super.apply(this, arguments); if (this._options.through) { this._options.through = inflection.singularize(this._options.through); } }
[ "function", "(", ")", "{", "this", ".", "_super", ".", "apply", "(", "this", ",", "arguments", ")", ";", "if", "(", "this", ".", "_options", ".", "through", ")", "{", "this", ".", "_options", ".", "through", "=", "inflection", ".", "singularize", "(", "this", ".", "_options", ".", "through", ")", ";", "}", "}" ]
Create a HasOne relation. @protected @constructor HasOne @see {@link Database#hasOne}
[ "Create", "a", "HasOne", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_one.js#L51-L57
train
wbyoung/azul
lib/relations/has_one.js
function(instance, value) { var collection = this._getCollectionCache(instance); var current = collection && collection[0]; if (current) { this.removeObjects(instance, current); } if (value) { this.addObjects(instance, value); } }
javascript
function(instance, value) { var collection = this._getCollectionCache(instance); var current = collection && collection[0]; if (current) { this.removeObjects(instance, current); } if (value) { this.addObjects(instance, value); } }
[ "function", "(", "instance", ",", "value", ")", "{", "var", "collection", "=", "this", ".", "_getCollectionCache", "(", "instance", ")", ";", "var", "current", "=", "collection", "&&", "collection", "[", "0", "]", ";", "if", "(", "current", ")", "{", "this", ".", "removeObjects", "(", "instance", ",", "current", ")", ";", "}", "if", "(", "value", ")", "{", "this", ".", "addObjects", "(", "instance", ",", "value", ")", ";", "}", "}" ]
The item property setter for this relation. This property allows altering the associated object of a specific model in a given relation. It is accessible on an individual model via assignment with `<singular>` and via `set<Singular>`. For instance, a user that has one blog would cause this method to get triggered via `user.blog = '...'` or `user.setBlog`. The naming conventions are set forth in {@link HasOne#overrides}. @method @protected @param {Model} instance The model instance on which to operate. @see {@link BaseRelation#methods}
[ "The", "item", "property", "setter", "for", "this", "relation", "." ]
860197318f9a1ca79970b2d053351e44e810b1ef
https://github.com/wbyoung/azul/blob/860197318f9a1ca79970b2d053351e44e810b1ef/lib/relations/has_one.js#L99-L104
train
DFFR-NT/dffrnt.route
lib/routes.js
AddDocuments
function AddDocuments () { // Create Helpdoc Route HLP .all("/", ReqHandle.Valid(true), GetHelp); API .use('/docs', HLP); }
javascript
function AddDocuments () { // Create Helpdoc Route HLP .all("/", ReqHandle.Valid(true), GetHelp); API .use('/docs', HLP); }
[ "function", "AddDocuments", "(", ")", "{", "HLP", ".", "all", "(", "\"/\"", ",", "ReqHandle", ".", "Valid", "(", "true", ")", ",", "GetHelp", ")", ";", "API", ".", "use", "(", "'/docs'", ",", "HLP", ")", ";", "}" ]
Endpoints for when API documentation is requested or during API errors
[ "Endpoints", "for", "when", "API", "documentation", "is", "requested", "or", "during", "API", "errors" ]
3b0ff9510de0e458a373e9c0e260d5ed6ff8b249
https://github.com/DFFR-NT/dffrnt.route/blob/3b0ff9510de0e458a373e9c0e260d5ed6ff8b249/lib/routes.js#L655-L659
train
bigeasy/procession
splitter.js
Splitter
function Splitter (queue, splits) { this._shifter = queue.shifter() this._map = {} this._array = [] for (var key in splits) { var queue = new Procession var split = { selector: splits[key], queue: queue, shifter: queue.shifter() } this._map[key] = split this._array.push(split) } }
javascript
function Splitter (queue, splits) { this._shifter = queue.shifter() this._map = {} this._array = [] for (var key in splits) { var queue = new Procession var split = { selector: splits[key], queue: queue, shifter: queue.shifter() } this._map[key] = split this._array.push(split) } }
[ "function", "Splitter", "(", "queue", ",", "splits", ")", "{", "this", ".", "_shifter", "=", "queue", ".", "shifter", "(", ")", "this", ".", "_map", "=", "{", "}", "this", ".", "_array", "=", "[", "]", "for", "(", "var", "key", "in", "splits", ")", "{", "var", "queue", "=", "new", "Procession", "var", "split", "=", "{", "selector", ":", "splits", "[", "key", "]", ",", "queue", ":", "queue", ",", "shifter", ":", "queue", ".", "shifter", "(", ")", "}", "this", ".", "_map", "[", "key", "]", "=", "split", "this", ".", "_array", ".", "push", "(", "split", ")", "}", "}" ]
Create a splitter that will split the given queue.
[ "Create", "a", "splitter", "that", "will", "split", "the", "given", "queue", "." ]
c8ea48a72a55cbe8b9b153e23ffcef9902e67038
https://github.com/bigeasy/procession/blob/c8ea48a72a55cbe8b9b153e23ffcef9902e67038/splitter.js#L10-L24
train
LeisureLink/magicbus
lib/subscriber.js
Subscriber
function Subscriber(consumer, eventDispatcher, logger, events) { assert.object(consumer, 'consumer'); assert.object(eventDispatcher, 'eventDispatcher'); assert.object(logger, 'logger'); assert.object(events, 'events'); /** * Internal message handler, passes message to event dispatcher * * @private * @method * @param {Any} data - message payload * @param {Array} messageTypes - message types * @param {Object} msg - raw message */ const internalHandler = (data, messageTypes, msg) => { logger.debug('Subscriber received message with types ' + JSON.stringify(messageTypes) + ', handing off to event dispatcher.'); return eventDispatcher.dispatch(messageTypes, data, msg) .catch(function (err){ events.emit('unhandled-error', { data: data, messageTypes: messageTypes, message: msg, error: err }); logger.error('Error during message dispatch', err); return Promise.reject(err); }) .then(function(executed){ if (!executed){ events.emit('unhandled-event', { data: data, messageTypes: messageTypes, message: msg }); return Promise.reject(new Error('No handler registered for ' + messageTypes)); } return Promise.resolve(); }); }; /** * Subscribe to an event * * @public * @method * @param {String} eventName - name of event (required) * @param {Subscriber.handlerCallback} handler - the handler to be called with the message */ const on = (eventName, handler) => { eventDispatcher.on(eventName, handler); }; /** * Subscribe to an event, for one iteration only * * @public * @method * @param {String} eventName - name of event (required) * @param {Subscriber.handlerCallback} handler - the handler to be called with the message * @returns {Promise} a promise that is fulfilled when the event has been fired - useful for automated testing of handler behavior */ const once = (eventName, handler) => { return eventDispatcher.once(eventName, handler); }; /** * Use a middleware function * * @public * @method * @param {Function} middleware - middleware to run {@see middleware.contract} */ const use = (middleware) => { consumer.use(middleware); }; /** * Start consuming events * * @param {Object} options - details in consuming from the queue * @param {Number} options.limit - the channel prefetch limit * @param {bool} options.noBatch - if true, ack/nack/reject operations will execute immediately and not be batched * @param {bool} options.noAck - if true, the broker won't expect an acknowledgement of messages delivered to this consumer; i.e., it will dequeue messages as soon as they've been sent down the wire. Defaults to false (i.e., you will be expected to acknowledge messages). * @param {String} options.consumerTag - a name which the server will use to distinguish message deliveries for the consumer; mustn't be already in use on the channel. It's usually easier to omit this, in which case the server will create a random name and supply it in the reply. * @param {bool} options.exclusive - if true, the broker won't let anyone else consume from this queue; if there already is a consumer, there goes your channel (so usually only useful if you've made a 'private' queue by letting the server choose its name). * @param {Number} options.priority - gives a priority to the consumer; higher priority consumers get messages in preference to lower priority consumers. See this RabbitMQ extension's documentation * @param {Object} options.arguments - arbitrary arguments. Go to town. * @public * @method */ const startSubscription = (options) => { return consumer.startConsuming(internalHandler, options); }; /** * Gets the route being used for consuming * * @public * @method * @returns {Object} details of the route */ const getRoute = () => { return consumer.getRoute(); }; /** * Purges messages from a route's queue. Useful for testing, to ensure your queue is empty before subscribing * * @public * @method * @returns {Promise} a promise that is fulfilled when the queue has been purged */ const purgeQueue = () => { return consumer.purgeQueue(); }; return { on: on, once: once, use: use, startSubscription: startSubscription, getRoute: getRoute, purgeQueue: purgeQueue }; }
javascript
function Subscriber(consumer, eventDispatcher, logger, events) { assert.object(consumer, 'consumer'); assert.object(eventDispatcher, 'eventDispatcher'); assert.object(logger, 'logger'); assert.object(events, 'events'); /** * Internal message handler, passes message to event dispatcher * * @private * @method * @param {Any} data - message payload * @param {Array} messageTypes - message types * @param {Object} msg - raw message */ const internalHandler = (data, messageTypes, msg) => { logger.debug('Subscriber received message with types ' + JSON.stringify(messageTypes) + ', handing off to event dispatcher.'); return eventDispatcher.dispatch(messageTypes, data, msg) .catch(function (err){ events.emit('unhandled-error', { data: data, messageTypes: messageTypes, message: msg, error: err }); logger.error('Error during message dispatch', err); return Promise.reject(err); }) .then(function(executed){ if (!executed){ events.emit('unhandled-event', { data: data, messageTypes: messageTypes, message: msg }); return Promise.reject(new Error('No handler registered for ' + messageTypes)); } return Promise.resolve(); }); }; /** * Subscribe to an event * * @public * @method * @param {String} eventName - name of event (required) * @param {Subscriber.handlerCallback} handler - the handler to be called with the message */ const on = (eventName, handler) => { eventDispatcher.on(eventName, handler); }; /** * Subscribe to an event, for one iteration only * * @public * @method * @param {String} eventName - name of event (required) * @param {Subscriber.handlerCallback} handler - the handler to be called with the message * @returns {Promise} a promise that is fulfilled when the event has been fired - useful for automated testing of handler behavior */ const once = (eventName, handler) => { return eventDispatcher.once(eventName, handler); }; /** * Use a middleware function * * @public * @method * @param {Function} middleware - middleware to run {@see middleware.contract} */ const use = (middleware) => { consumer.use(middleware); }; /** * Start consuming events * * @param {Object} options - details in consuming from the queue * @param {Number} options.limit - the channel prefetch limit * @param {bool} options.noBatch - if true, ack/nack/reject operations will execute immediately and not be batched * @param {bool} options.noAck - if true, the broker won't expect an acknowledgement of messages delivered to this consumer; i.e., it will dequeue messages as soon as they've been sent down the wire. Defaults to false (i.e., you will be expected to acknowledge messages). * @param {String} options.consumerTag - a name which the server will use to distinguish message deliveries for the consumer; mustn't be already in use on the channel. It's usually easier to omit this, in which case the server will create a random name and supply it in the reply. * @param {bool} options.exclusive - if true, the broker won't let anyone else consume from this queue; if there already is a consumer, there goes your channel (so usually only useful if you've made a 'private' queue by letting the server choose its name). * @param {Number} options.priority - gives a priority to the consumer; higher priority consumers get messages in preference to lower priority consumers. See this RabbitMQ extension's documentation * @param {Object} options.arguments - arbitrary arguments. Go to town. * @public * @method */ const startSubscription = (options) => { return consumer.startConsuming(internalHandler, options); }; /** * Gets the route being used for consuming * * @public * @method * @returns {Object} details of the route */ const getRoute = () => { return consumer.getRoute(); }; /** * Purges messages from a route's queue. Useful for testing, to ensure your queue is empty before subscribing * * @public * @method * @returns {Promise} a promise that is fulfilled when the queue has been purged */ const purgeQueue = () => { return consumer.purgeQueue(); }; return { on: on, once: once, use: use, startSubscription: startSubscription, getRoute: getRoute, purgeQueue: purgeQueue }; }
[ "function", "Subscriber", "(", "consumer", ",", "eventDispatcher", ",", "logger", ",", "events", ")", "{", "assert", ".", "object", "(", "consumer", ",", "'consumer'", ")", ";", "assert", ".", "object", "(", "eventDispatcher", ",", "'eventDispatcher'", ")", ";", "assert", ".", "object", "(", "logger", ",", "'logger'", ")", ";", "assert", ".", "object", "(", "events", ",", "'events'", ")", ";", "const", "internalHandler", "=", "(", "data", ",", "messageTypes", ",", "msg", ")", "=>", "{", "logger", ".", "debug", "(", "'Subscriber received message with types '", "+", "JSON", ".", "stringify", "(", "messageTypes", ")", "+", "', handing off to event dispatcher.'", ")", ";", "return", "eventDispatcher", ".", "dispatch", "(", "messageTypes", ",", "data", ",", "msg", ")", ".", "catch", "(", "function", "(", "err", ")", "{", "events", ".", "emit", "(", "'unhandled-error'", ",", "{", "data", ":", "data", ",", "messageTypes", ":", "messageTypes", ",", "message", ":", "msg", ",", "error", ":", "err", "}", ")", ";", "logger", ".", "error", "(", "'Error during message dispatch'", ",", "err", ")", ";", "return", "Promise", ".", "reject", "(", "err", ")", ";", "}", ")", ".", "then", "(", "function", "(", "executed", ")", "{", "if", "(", "!", "executed", ")", "{", "events", ".", "emit", "(", "'unhandled-event'", ",", "{", "data", ":", "data", ",", "messageTypes", ":", "messageTypes", ",", "message", ":", "msg", "}", ")", ";", "return", "Promise", ".", "reject", "(", "new", "Error", "(", "'No handler registered for '", "+", "messageTypes", ")", ")", ";", "}", "return", "Promise", ".", "resolve", "(", ")", ";", "}", ")", ";", "}", ";", "const", "on", "=", "(", "eventName", ",", "handler", ")", "=>", "{", "eventDispatcher", ".", "on", "(", "eventName", ",", "handler", ")", ";", "}", ";", "const", "once", "=", "(", "eventName", ",", "handler", ")", "=>", "{", "return", "eventDispatcher", ".", "once", "(", "eventName", ",", "handler", ")", ";", "}", ";", "const", "use", "=", "(", "middleware", ")", "=>", "{", "consumer", ".", "use", "(", "middleware", ")", ";", "}", ";", "const", "startSubscription", "=", "(", "options", ")", "=>", "{", "return", "consumer", ".", "startConsuming", "(", "internalHandler", ",", "options", ")", ";", "}", ";", "const", "getRoute", "=", "(", ")", "=>", "{", "return", "consumer", ".", "getRoute", "(", ")", ";", "}", ";", "const", "purgeQueue", "=", "(", ")", "=>", "{", "return", "consumer", ".", "purgeQueue", "(", ")", ";", "}", ";", "return", "{", "on", ":", "on", ",", "once", ":", "once", ",", "use", ":", "use", ",", "startSubscription", ":", "startSubscription", ",", "getRoute", ":", "getRoute", ",", "purgeQueue", ":", "purgeQueue", "}", ";", "}" ]
Handles consumption of event messages from the bus @public @constructor @param {Object} consumer - instance of the {@link Consumer} class @param {Object} eventDispatcher - instance of the {@link EventDispatcher} class @param {Object} logger - the logger @param {EventEmitter} events - the event emitter for unhandled exception events
[ "Handles", "consumption", "of", "event", "messages", "from", "the", "bus" ]
0370c38ebb8c7917cfd3894263d734aefc2d3d29
https://github.com/LeisureLink/magicbus/blob/0370c38ebb8c7917cfd3894263d734aefc2d3d29/lib/subscriber.js#L16-L142
train
whitfin/dep-validate
lib/dep-validate.js
format
function format(results) { if (_isFormatted(results)) { return results; } var dependencyErrors = results.dependencies || []; var devDependencyErrors = results.devDependencies || []; var formattedErrors = { }; formattedErrors.dependencies = dependencyErrors.length ? _formatErrors('Dependencies', dependencyErrors) : dependencyErrors; formattedErrors.devDependencies = devDependencyErrors.length ? _formatErrors('Dev Dependencies', devDependencyErrors) : devDependencyErrors; return formattedErrors; }
javascript
function format(results) { if (_isFormatted(results)) { return results; } var dependencyErrors = results.dependencies || []; var devDependencyErrors = results.devDependencies || []; var formattedErrors = { }; formattedErrors.dependencies = dependencyErrors.length ? _formatErrors('Dependencies', dependencyErrors) : dependencyErrors; formattedErrors.devDependencies = devDependencyErrors.length ? _formatErrors('Dev Dependencies', devDependencyErrors) : devDependencyErrors; return formattedErrors; }
[ "function", "format", "(", "results", ")", "{", "if", "(", "_isFormatted", "(", "results", ")", ")", "{", "return", "results", ";", "}", "var", "dependencyErrors", "=", "results", ".", "dependencies", "||", "[", "]", ";", "var", "devDependencyErrors", "=", "results", ".", "devDependencies", "||", "[", "]", ";", "var", "formattedErrors", "=", "{", "}", ";", "formattedErrors", ".", "dependencies", "=", "dependencyErrors", ".", "length", "?", "_formatErrors", "(", "'Dependencies'", ",", "dependencyErrors", ")", ":", "dependencyErrors", ";", "formattedErrors", ".", "devDependencies", "=", "devDependencyErrors", ".", "length", "?", "_formatErrors", "(", "'Dev Dependencies'", ",", "devDependencyErrors", ")", ":", "devDependencyErrors", ";", "return", "formattedErrors", ";", "}" ]
Formats an Object of results. The Object should be of the same form as the result of calling #validate, as the formatter expects the values to be piped straight through. @param results our Object containing validation results. @returns {{dependencies: Array, devDependencies: Array}}.
[ "Formats", "an", "Object", "of", "results", "." ]
2f334d1c0a6e9f93429ce34ca165e28c1c072c1b
https://github.com/whitfin/dep-validate/blob/2f334d1c0a6e9f93429ce34ca165e28c1c072c1b/lib/dep-validate.js#L62-L81
train
whitfin/dep-validate
lib/dep-validate.js
hasErrors
function hasErrors(results) { return (results.dependencies && results.dependencies.length) || (results.devDependencies && results.devDependencies.length) }
javascript
function hasErrors(results) { return (results.dependencies && results.dependencies.length) || (results.devDependencies && results.devDependencies.length) }
[ "function", "hasErrors", "(", "results", ")", "{", "return", "(", "results", ".", "dependencies", "&&", "results", ".", "dependencies", ".", "length", ")", "||", "(", "results", ".", "devDependencies", "&&", "results", ".", "devDependencies", ".", "length", ")", "}" ]
Detects if a results Object contains any errors. @param results our Object containing validation results. @returns true if errors are contained in the results.
[ "Detects", "if", "a", "results", "Object", "contains", "any", "errors", "." ]
2f334d1c0a6e9f93429ce34ca165e28c1c072c1b
https://github.com/whitfin/dep-validate/blob/2f334d1c0a6e9f93429ce34ca165e28c1c072c1b/lib/dep-validate.js#L89-L92
train
whitfin/dep-validate
lib/dep-validate.js
gulp
function gulp(opts) { opts = opts || {}; var failOnError = opts['failOnError'] || false; var interimFiles = []; var failedValidations = []; return Through( function (file) { interimFiles.push(file.path); this.queue(file); }, function () { var baseFile = opts.packageFile; interimFiles.forEach(function (file) { opts.packageFile = file; var results = validate(opts); if (hasErrors(results)) { failedValidations.push(file); log(results); } }); opts.packageFile = baseFile; if (failOnError && failedValidations.length) { this.emit('error', new PluginError('dep-validate', 'Unable to validate dependencies')); } else { this.emit('end'); } } ); }
javascript
function gulp(opts) { opts = opts || {}; var failOnError = opts['failOnError'] || false; var interimFiles = []; var failedValidations = []; return Through( function (file) { interimFiles.push(file.path); this.queue(file); }, function () { var baseFile = opts.packageFile; interimFiles.forEach(function (file) { opts.packageFile = file; var results = validate(opts); if (hasErrors(results)) { failedValidations.push(file); log(results); } }); opts.packageFile = baseFile; if (failOnError && failedValidations.length) { this.emit('error', new PluginError('dep-validate', 'Unable to validate dependencies')); } else { this.emit('end'); } } ); }
[ "function", "gulp", "(", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "var", "failOnError", "=", "opts", "[", "'failOnError'", "]", "||", "false", ";", "var", "interimFiles", "=", "[", "]", ";", "var", "failedValidations", "=", "[", "]", ";", "return", "Through", "(", "function", "(", "file", ")", "{", "interimFiles", ".", "push", "(", "file", ".", "path", ")", ";", "this", ".", "queue", "(", "file", ")", ";", "}", ",", "function", "(", ")", "{", "var", "baseFile", "=", "opts", ".", "packageFile", ";", "interimFiles", ".", "forEach", "(", "function", "(", "file", ")", "{", "opts", ".", "packageFile", "=", "file", ";", "var", "results", "=", "validate", "(", "opts", ")", ";", "if", "(", "hasErrors", "(", "results", ")", ")", "{", "failedValidations", ".", "push", "(", "file", ")", ";", "log", "(", "results", ")", ";", "}", "}", ")", ";", "opts", ".", "packageFile", "=", "baseFile", ";", "if", "(", "failOnError", "&&", "failedValidations", ".", "length", ")", "{", "this", ".", "emit", "(", "'error'", ",", "new", "PluginError", "(", "'dep-validate'", ",", "'Unable to validate dependencies'", ")", ")", ";", "}", "else", "{", "this", ".", "emit", "(", "'end'", ")", ";", "}", "}", ")", ";", "}" ]
Returns a Transform Stream for use with Gulp. @param opts an options Object (see README.md). @returns a Stream instance for Gulp use.
[ "Returns", "a", "Transform", "Stream", "for", "use", "with", "Gulp", "." ]
2f334d1c0a6e9f93429ce34ca165e28c1c072c1b
https://github.com/whitfin/dep-validate/blob/2f334d1c0a6e9f93429ce34ca165e28c1c072c1b/lib/dep-validate.js#L100-L135
train
whitfin/dep-validate
lib/dep-validate.js
log
function log(results, stream) { stream = stream || process.stdout; if (results instanceof Error) { results = results.meta; } if (!_isFormatted(results)) { results = format(results); } stream.write(_join(results)); }
javascript
function log(results, stream) { stream = stream || process.stdout; if (results instanceof Error) { results = results.meta; } if (!_isFormatted(results)) { results = format(results); } stream.write(_join(results)); }
[ "function", "log", "(", "results", ",", "stream", ")", "{", "stream", "=", "stream", "||", "process", ".", "stdout", ";", "if", "(", "results", "instanceof", "Error", ")", "{", "results", "=", "results", ".", "meta", ";", "}", "if", "(", "!", "_isFormatted", "(", "results", ")", ")", "{", "results", "=", "format", "(", "results", ")", ";", "}", "stream", ".", "write", "(", "_join", "(", "results", ")", ")", ";", "}" ]
Logs a results Object out to a given write stream. The stream defaults to `process.stdout`, and results will be formatted on-demand if needed. @param results our Object containing validation results. @param stream a write stream to write the log to.
[ "Logs", "a", "results", "Object", "out", "to", "a", "given", "write", "stream", "." ]
2f334d1c0a6e9f93429ce34ca165e28c1c072c1b
https://github.com/whitfin/dep-validate/blob/2f334d1c0a6e9f93429ce34ca165e28c1c072c1b/lib/dep-validate.js#L146-L158
train
ofidj/fidj
.todo/miapp.tools.array.js
removeKeyFromList
function removeKeyFromList(list, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list.splice(i, 1); // remove from array } } return false; }
javascript
function removeKeyFromList(list, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list.splice(i, 1); // remove from array } } return false; }
[ "function", "removeKeyFromList", "(", "list", ",", "key", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "[", "key", "]", "==", "value", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ")", ";", "}", "}", "return", "false", ";", "}" ]
Remove from list the last object having the same key attribute as value @param list Array of objects having key attribute comparable to value @param {string} key @param value @return {*} Array of deleted item or false
[ "Remove", "from", "list", "the", "last", "object", "having", "the", "same", "key", "attribute", "as", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L146-L153
train
ofidj/fidj
.todo/miapp.tools.array.js
replaceKeyFromList
function replaceKeyFromList(list, key, value, object) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list.splice(i, 1, object); // remove from array and replace by the new object } } return false; }
javascript
function replaceKeyFromList(list, key, value, object) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list.splice(i, 1, object); // remove from array and replace by the new object } } return false; }
[ "function", "replaceKeyFromList", "(", "list", ",", "key", ",", "value", ",", "object", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "[", "key", "]", "==", "value", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ",", "object", ")", ";", "}", "}", "return", "false", ";", "}" ]
Replace in list the last object having the same key attribute as value @param list Array of objects having key attribute comparable to value @param {string} key @param value @param object New object replacing the old one @return {*} Array of replaced item or false
[ "Replace", "in", "list", "the", "last", "object", "having", "the", "same", "key", "attribute", "as", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L164-L171
train
ofidj/fidj
.todo/miapp.tools.array.js
addKeyToList
function addKeyToList(list, key, object) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == object[key]) { return false; } } list.push(object); return true; }
javascript
function addKeyToList(list, key, object) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == object[key]) { return false; } } list.push(object); return true; }
[ "function", "addKeyToList", "(", "list", ",", "key", ",", "object", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "[", "key", "]", "==", "object", "[", "key", "]", ")", "{", "return", "false", ";", "}", "}", "list", ".", "push", "(", "object", ")", ";", "return", "true", ";", "}" ]
Add in list the argument object if none has the same key attribute @param list Array of objects having key attribute @param {string} key @param object New object to add @return {boolean} True if added or false if already exists in list
[ "Add", "in", "list", "the", "argument", "object", "if", "none", "has", "the", "same", "key", "attribute" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L181-L189
train
ofidj/fidj
.todo/miapp.tools.array.js
getKeyFromList
function getKeyFromList(list, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list[i]; } } return false; }
javascript
function getKeyFromList(list, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i][key] == value) { return list[i]; } } return false; }
[ "function", "getKeyFromList", "(", "list", ",", "key", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "[", "key", "]", "==", "value", ")", "{", "return", "list", "[", "i", "]", ";", "}", "}", "return", "false", ";", "}" ]
Check if one object in list has the same key attribute as value and return it @param list Array of objects having key attribute comparable to value @param {string} key @param value @return {*} Object if exists or false if none exists in list
[ "Check", "if", "one", "object", "in", "list", "has", "the", "same", "key", "attribute", "as", "value", "and", "return", "it" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L199-L206
train
ofidj/fidj
.todo/miapp.tools.array.js
removeSubKeyFromList
function removeSubKeyFromList(list, sub, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list.splice(i, 1); // remove from array } } return false; }
javascript
function removeSubKeyFromList(list, sub, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list.splice(i, 1); // remove from array } } return false; }
[ "function", "removeSubKeyFromList", "(", "list", ",", "sub", ",", "key", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "a4p", ".", "isDefined", "(", "list", "[", "i", "]", "[", "sub", "]", ")", "&&", "(", "list", "[", "i", "]", "[", "sub", "]", "[", "key", "]", "==", "value", ")", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ")", ";", "}", "}", "return", "false", ";", "}" ]
Remove from list the last object having the same sub.key attribute as value @param list Array of objects having sub.key attribute comparable to value @param {string} sub @param {string} key @param value @return {*} Array of deleted item or false
[ "Remove", "from", "list", "the", "last", "object", "having", "the", "same", "sub", ".", "key", "attribute", "as", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L217-L224
train
ofidj/fidj
.todo/miapp.tools.array.js
replaceSubKeyFromList
function replaceSubKeyFromList(list, sub, key, value, object) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list.splice(i, 1, object); // remove from array and replace by the new object } } return false; }
javascript
function replaceSubKeyFromList(list, sub, key, value, object) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list.splice(i, 1, object); // remove from array and replace by the new object } } return false; }
[ "function", "replaceSubKeyFromList", "(", "list", ",", "sub", ",", "key", ",", "value", ",", "object", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "a4p", ".", "isDefined", "(", "list", "[", "i", "]", "[", "sub", "]", ")", "&&", "(", "list", "[", "i", "]", "[", "sub", "]", "[", "key", "]", "==", "value", ")", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ",", "object", ")", ";", "}", "}", "return", "false", ";", "}" ]
Replace in list the last object having the same sub.key attribute as value @param list Array of objects having sub.key attribute comparable to value @param {string} sub @param {string} key @param value @param object New object replacing the old one @return {*} Array of replaced item or false
[ "Replace", "in", "list", "the", "last", "object", "having", "the", "same", "sub", ".", "key", "attribute", "as", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L236-L243
train
ofidj/fidj
.todo/miapp.tools.array.js
addSubKeyToList
function addSubKeyToList(list, sub, key, object) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == object[sub][key])) { return false; } } list.push(object); return true; }
javascript
function addSubKeyToList(list, sub, key, object) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == object[sub][key])) { return false; } } list.push(object); return true; }
[ "function", "addSubKeyToList", "(", "list", ",", "sub", ",", "key", ",", "object", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "a4p", ".", "isDefined", "(", "list", "[", "i", "]", "[", "sub", "]", ")", "&&", "(", "list", "[", "i", "]", "[", "sub", "]", "[", "key", "]", "==", "object", "[", "sub", "]", "[", "key", "]", ")", ")", "{", "return", "false", ";", "}", "}", "list", ".", "push", "(", "object", ")", ";", "return", "true", ";", "}" ]
Add in list the argument object if none has the same sub.key attribute @param list Array of objects having sub.key attribute @param {string} sub @param {string} key @param object New object to add @return {boolean} True if added or false if already exists in list
[ "Add", "in", "list", "the", "argument", "object", "if", "none", "has", "the", "same", "sub", ".", "key", "attribute" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L254-L262
train
ofidj/fidj
.todo/miapp.tools.array.js
getSubKeyFromList
function getSubKeyFromList(list, sub, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list[i]; } } return false; }
javascript
function getSubKeyFromList(list, sub, key, value) { for (var i = list.length - 1; i >= 0; i--) { if (a4p.isDefined(list[i][sub]) && (list[i][sub][key] == value)) { return list[i]; } } return false; }
[ "function", "getSubKeyFromList", "(", "list", ",", "sub", ",", "key", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "a4p", ".", "isDefined", "(", "list", "[", "i", "]", "[", "sub", "]", ")", "&&", "(", "list", "[", "i", "]", "[", "sub", "]", "[", "key", "]", "==", "value", ")", ")", "{", "return", "list", "[", "i", "]", ";", "}", "}", "return", "false", ";", "}" ]
Check if one object in list has the same sub.key attribute as value and return it @param list Array of objects having sub.key attribute comparable to value @param {string} sub @param {string} key @param value @return {*} Object if exists or false if none exists in list
[ "Check", "if", "one", "object", "in", "list", "has", "the", "same", "sub", ".", "key", "attribute", "as", "value", "and", "return", "it" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L273-L280
train
ofidj/fidj
.todo/miapp.tools.array.js
removeValueFromList
function removeValueFromList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return list.splice(i, 1); // remove from array } } return false; }
javascript
function removeValueFromList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return list.splice(i, 1); // remove from array } } return false; }
[ "function", "removeValueFromList", "(", "list", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "==", "value", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ")", ";", "}", "}", "return", "false", ";", "}" ]
Remove from list the last object being equal to value @param list Array of objects comparable to value @param value @return {*} Array of deleted item or false
[ "Remove", "from", "list", "the", "last", "object", "being", "equal", "to", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L289-L296
train
ofidj/fidj
.todo/miapp.tools.array.js
replaceValueFromList
function replaceValueFromList(list, oldValue, newValue) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == oldValue) { return list.splice(i, 1, newValue); // remove from array and replace by the new object } } return false; }
javascript
function replaceValueFromList(list, oldValue, newValue) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == oldValue) { return list.splice(i, 1, newValue); // remove from array and replace by the new object } } return false; }
[ "function", "replaceValueFromList", "(", "list", ",", "oldValue", ",", "newValue", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "==", "oldValue", ")", "{", "return", "list", ".", "splice", "(", "i", ",", "1", ",", "newValue", ")", ";", "}", "}", "return", "false", ";", "}" ]
Replace in list the last object being equal to oldValue. Beware, this can insert duplicates in the list ! @param list Array of objects comparable to oldValue @param oldValue @param newValue New object replacing the old one @return {*} Array of replaced item or false
[ "Replace", "in", "list", "the", "last", "object", "being", "equal", "to", "oldValue", ".", "Beware", "this", "can", "insert", "duplicates", "in", "the", "list", "!" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L307-L314
train
ofidj/fidj
.todo/miapp.tools.array.js
addValueToList
function addValueToList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return false; } } list.push(value); return true; }
javascript
function addValueToList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return false; } } list.push(value); return true; }
[ "function", "addValueToList", "(", "list", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "==", "value", ")", "{", "return", "false", ";", "}", "}", "list", ".", "push", "(", "value", ")", ";", "return", "true", ";", "}" ]
Add in list the value if none equals value @param list Array of objects comparable to value @param value New value to add @return {boolean} True if added or false if already exists in list
[ "Add", "in", "list", "the", "value", "if", "none", "equals", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L323-L331
train
ofidj/fidj
.todo/miapp.tools.array.js
isValueInList
function isValueInList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return true; } } return false; }
javascript
function isValueInList(list, value) { for (var i = list.length - 1; i >= 0; i--) { if (list[i] == value) { return true; } } return false; }
[ "function", "isValueInList", "(", "list", ",", "value", ")", "{", "for", "(", "var", "i", "=", "list", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "list", "[", "i", "]", "==", "value", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if one value in list has the same value @param list Array of objects comparable to value @param value @return {boolean} True if exists or false if none exists in list
[ "Check", "if", "one", "value", "in", "list", "has", "the", "same", "value" ]
e57ebece54ee68211d43802a8e0feeef098d3e36
https://github.com/ofidj/fidj/blob/e57ebece54ee68211d43802a8e0feeef098d3e36/.todo/miapp.tools.array.js#L340-L347
train
urturn/urturn-expression-api
lib/expression-api/PublicCollection.js
function(oldItem, newItem) { if(data.operations) { for(var i = 0; i < data.operations.length; i++) { var operation = data.operations[i]; if(newItem && newItem[operation.field] !== undefined || oldItem && oldItem[operation.field] !== undefined) { opsToolbox[operation.operation].recompute(operations[operation.field], operation, oldItem, newItem); } } } }
javascript
function(oldItem, newItem) { if(data.operations) { for(var i = 0; i < data.operations.length; i++) { var operation = data.operations[i]; if(newItem && newItem[operation.field] !== undefined || oldItem && oldItem[operation.field] !== undefined) { opsToolbox[operation.operation].recompute(operations[operation.field], operation, oldItem, newItem); } } } }
[ "function", "(", "oldItem", ",", "newItem", ")", "{", "if", "(", "data", ".", "operations", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "data", ".", "operations", ".", "length", ";", "i", "++", ")", "{", "var", "operation", "=", "data", ".", "operations", "[", "i", "]", ";", "if", "(", "newItem", "&&", "newItem", "[", "operation", ".", "field", "]", "!==", "undefined", "||", "oldItem", "&&", "oldItem", "[", "operation", ".", "field", "]", "!==", "undefined", ")", "{", "opsToolbox", "[", "operation", ".", "operation", "]", ".", "recompute", "(", "operations", "[", "operation", ".", "field", "]", ",", "operation", ",", "oldItem", ",", "newItem", ")", ";", "}", "}", "}", "}" ]
PRIVATE Methods Recompute the operations results
[ "PRIVATE", "Methods", "Recompute", "the", "operations", "results" ]
009a272ee670dbbe5eefb5c070ed827dd778bb07
https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/lib/expression-api/PublicCollection.js#L289-L298
train
jonschlinkert/lookup-deps
index.js
Lookup
function Lookup(options) { this.options = options || {}; this.cwd = this.options.cwd || process.cwd(); this.limit = this.options.limit || 25; this.versions = {}; this.history = {}; this.parents = {}; this.cache = {}; this._paths = []; this.init(options); }
javascript
function Lookup(options) { this.options = options || {}; this.cwd = this.options.cwd || process.cwd(); this.limit = this.options.limit || 25; this.versions = {}; this.history = {}; this.parents = {}; this.cache = {}; this._paths = []; this.init(options); }
[ "function", "Lookup", "(", "options", ")", "{", "this", ".", "options", "=", "options", "||", "{", "}", ";", "this", ".", "cwd", "=", "this", ".", "options", ".", "cwd", "||", "process", ".", "cwd", "(", ")", ";", "this", ".", "limit", "=", "this", ".", "options", ".", "limit", "||", "25", ";", "this", ".", "versions", "=", "{", "}", ";", "this", ".", "history", "=", "{", "}", ";", "this", ".", "parents", "=", "{", "}", ";", "this", ".", "cache", "=", "{", "}", ";", "this", ".", "_paths", "=", "[", "]", ";", "this", ".", "init", "(", "options", ")", ";", "}" ]
Create a new instance of `Lookup`. ```js var Lookup = require('lookup-deps'); var deps = new Lookup(); ``` @param {Object} `config` Optionally pass a default config object instead of `package.json` For now there is no reason to do this. @param {Object} `options` @api public
[ "Create", "a", "new", "instance", "of", "Lookup", "." ]
fd9ca05abdaf543b954bfb170896ac6a4bf3fe07
https://github.com/jonschlinkert/lookup-deps/blob/fd9ca05abdaf543b954bfb170896ac6a4bf3fe07/index.js#L46-L56
train
Mammut-FE/nejm
src/util/dispatcher/dsp/group.js
function(_node){ var _module; _node = _node._$getParent(); while(!!_node){ _module = _node._$getData().module; if (_t2._$isModule(_module)){ return _module._$getExportData(); } _node = _node._$getParent(); } return null; }
javascript
function(_node){ var _module; _node = _node._$getParent(); while(!!_node){ _module = _node._$getData().module; if (_t2._$isModule(_module)){ return _module._$getExportData(); } _node = _node._$getParent(); } return null; }
[ "function", "(", "_node", ")", "{", "var", "_module", ";", "_node", "=", "_node", ".", "_$getParent", "(", ")", ";", "while", "(", "!", "!", "_node", ")", "{", "_module", "=", "_node", ".", "_$getData", "(", ")", ".", "module", ";", "if", "(", "_t2", ".", "_$isModule", "(", "_module", ")", ")", "{", "return", "_module", ".", "_$getExportData", "(", ")", ";", "}", "_node", "=", "_node", ".", "_$getParent", "(", ")", ";", "}", "return", "null", ";", "}" ]
get nearest parent export data
[ "get", "nearest", "parent", "export", "data" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/dispatcher/dsp/group.js#L203-L214
train
Mammut-FE/nejm
src/util/dispatcher/dsp/group.js
function (module, config) { var ret = { url: (config.root||'')+module, version: (config.ver||_o)[module] }; // convert xxx.html to xxx_ver.html if (!!config.mode&&!!ret.version){ ret.url = ret.url.replace( /(\.[^.\/]*?)$/, '_'+ret.version+'$1' ); ret.version = null; } return ret; }
javascript
function (module, config) { var ret = { url: (config.root||'')+module, version: (config.ver||_o)[module] }; // convert xxx.html to xxx_ver.html if (!!config.mode&&!!ret.version){ ret.url = ret.url.replace( /(\.[^.\/]*?)$/, '_'+ret.version+'$1' ); ret.version = null; } return ret; }
[ "function", "(", "module", ",", "config", ")", "{", "var", "ret", "=", "{", "url", ":", "(", "config", ".", "root", "||", "''", ")", "+", "module", ",", "version", ":", "(", "config", ".", "ver", "||", "_o", ")", "[", "module", "]", "}", ";", "if", "(", "!", "!", "config", ".", "mode", "&&", "!", "!", "ret", ".", "version", ")", "{", "ret", ".", "url", "=", "ret", ".", "url", ".", "replace", "(", "/", "(\\.[^.\\/]*?)$", "/", ",", "'_'", "+", "ret", ".", "version", "+", "'$1'", ")", ";", "ret", ".", "version", "=", "null", ";", "}", "return", "ret", ";", "}" ]
parse module url config - ver,root,mode
[ "parse", "module", "url", "config", "-", "ver", "root", "mode" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/dispatcher/dsp/group.js#L217-L231
train
zazuko/trifid-core
plugins/locals.js
locals
function locals (router) { router.use((req, res, next) => { absoluteUrl.attach(req) // requested resource res.locals.iri = req.iri // requested resource parsed into URL object res.locals.url = url.parse(res.locals.iri) // dummy translation res.locals.t = res.locals.t || ((x) => { return x.substring(x.indexOf(':') + 1) }) next() }) }
javascript
function locals (router) { router.use((req, res, next) => { absoluteUrl.attach(req) // requested resource res.locals.iri = req.iri // requested resource parsed into URL object res.locals.url = url.parse(res.locals.iri) // dummy translation res.locals.t = res.locals.t || ((x) => { return x.substring(x.indexOf(':') + 1) }) next() }) }
[ "function", "locals", "(", "router", ")", "{", "router", ".", "use", "(", "(", "req", ",", "res", ",", "next", ")", "=>", "{", "absoluteUrl", ".", "attach", "(", "req", ")", "res", ".", "locals", ".", "iri", "=", "req", ".", "iri", "res", ".", "locals", ".", "url", "=", "url", ".", "parse", "(", "res", ".", "locals", ".", "iri", ")", "res", ".", "locals", ".", "t", "=", "res", ".", "locals", ".", "t", "||", "(", "(", "x", ")", "=>", "{", "return", "x", ".", "substring", "(", "x", ".", "indexOf", "(", "':'", ")", "+", "1", ")", "}", ")", "next", "(", ")", "}", ")", "}" ]
Adds router and request locals variables @param router
[ "Adds", "router", "and", "request", "locals", "variables" ]
47068ef508971f562e35768d829e15699ce3e19c
https://github.com/zazuko/trifid-core/blob/47068ef508971f562e35768d829e15699ce3e19c/plugins/locals.js#L8-L25
train
jmjuanes/stattic
index.js
function (res, errorCode, errorMessage) { res.writeHead(errorCode, {"Content-Type": "text/html"}); //Read the local error file return fs.readFile(options.error, "utf8", function (error, content) { //Check the error if (error) { return res.end("<" + "h1>Error</h1><p>" + errorMessage + "</p>"); } let data = {code: errorCode, message: errorMessage}; content = content.replace(/{{([^{}]+)}}/g, function(match, found) { found = found.trim(); if(typeof data[found] !== "undefined") { return data[found].toString(); } else { return match; } }); return res.end(content); }); }
javascript
function (res, errorCode, errorMessage) { res.writeHead(errorCode, {"Content-Type": "text/html"}); //Read the local error file return fs.readFile(options.error, "utf8", function (error, content) { //Check the error if (error) { return res.end("<" + "h1>Error</h1><p>" + errorMessage + "</p>"); } let data = {code: errorCode, message: errorMessage}; content = content.replace(/{{([^{}]+)}}/g, function(match, found) { found = found.trim(); if(typeof data[found] !== "undefined") { return data[found].toString(); } else { return match; } }); return res.end(content); }); }
[ "function", "(", "res", ",", "errorCode", ",", "errorMessage", ")", "{", "res", ".", "writeHead", "(", "errorCode", ",", "{", "\"Content-Type\"", ":", "\"text/html\"", "}", ")", ";", "return", "fs", ".", "readFile", "(", "options", ".", "error", ",", "\"utf8\"", ",", "function", "(", "error", ",", "content", ")", "{", "if", "(", "error", ")", "{", "return", "res", ".", "end", "(", "\"<\"", "+", "\"h1>Error</h1><p>\"", "+", "errorMessage", "+", "\"</p>\"", ")", ";", "}", "let", "data", "=", "{", "code", ":", "errorCode", ",", "message", ":", "errorMessage", "}", ";", "content", "=", "content", ".", "replace", "(", "/", "{{([^{}]+)}}", "/", "g", ",", "function", "(", "match", ",", "found", ")", "{", "found", "=", "found", ".", "trim", "(", ")", ";", "if", "(", "typeof", "data", "[", "found", "]", "!==", "\"undefined\"", ")", "{", "return", "data", "[", "found", "]", ".", "toString", "(", ")", ";", "}", "else", "{", "return", "match", ";", "}", "}", ")", ";", "return", "res", ".", "end", "(", "content", ")", ";", "}", ")", ";", "}" ]
Display an error page
[ "Display", "an", "error", "page" ]
b7930953f235690f1458de0b95c0c759aa9da7f3
https://github.com/jmjuanes/stattic/blob/b7930953f235690f1458de0b95c0c759aa9da7f3/index.js#L113-L133
train
veo-labs/openveo-api
lib/controllers/SocketController.js
SocketController
function SocketController(namespace) { SocketController.super_.call(this); Object.defineProperties(this, { /** * Socket's namespace associated to the controller. * * @property namespace * @type SocketNamespace * @final */ namespace: {value: namespace}, /** * An emitter to emits clients' messages. * * @property emitter * @type AdvancedEmitter * @final */ emitter: {value: new AdvancedEmitter()} }); }
javascript
function SocketController(namespace) { SocketController.super_.call(this); Object.defineProperties(this, { /** * Socket's namespace associated to the controller. * * @property namespace * @type SocketNamespace * @final */ namespace: {value: namespace}, /** * An emitter to emits clients' messages. * * @property emitter * @type AdvancedEmitter * @final */ emitter: {value: new AdvancedEmitter()} }); }
[ "function", "SocketController", "(", "namespace", ")", "{", "SocketController", ".", "super_", ".", "call", "(", "this", ")", ";", "Object", ".", "defineProperties", "(", "this", ",", "{", "namespace", ":", "{", "value", ":", "namespace", "}", ",", "emitter", ":", "{", "value", ":", "new", "AdvancedEmitter", "(", ")", "}", "}", ")", ";", "}" ]
Defines base controller for all controllers which need to handle socket messages. A SocketController is associated to a namespace to be able to emit a message to the whole socket namespace. A SocketController is also associated to an emitter to emit socket's clients' messages to pilots. // Implement a SocketController : "CustomSocketController" var util = require('util'); var openVeoApi = require('@openveo/api'); function CustomSocketController(namespace) { CustomSocketController.super_.call(this, namespace); } util.inherits(CustomSocketController, openVeoApi.controllers.SocketController); @class SocketController @extends Controller @constructor @param {SocketNamespace} namespace The socket namespace associated to the controller
[ "Defines", "base", "controller", "for", "all", "controllers", "which", "need", "to", "handle", "socket", "messages", "." ]
493a811e9a5ba4d3e14910facaa7452caba1ab38
https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/controllers/SocketController.js#L34-L58
train
Bartvds/ministyle
lib/flow.js
toggle
function toggle(main, alt) { var mw = core.base(); mw.enabled = true; mw.main = main; mw.alt = (alt || common.plain()); mw.active = mw.main; mw.swap = function () { mw.active = (mw.active !== mw.main ? mw.main : mw.alt); }; mw.error = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.error(str); } return str; }; mw.warning = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.warning(str); } return str; }; mw.success = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.error(str); } return str; }; mw.accent = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.accent(str); } return str; }; mw.signal = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.signal(str); } return str; }; mw.muted = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.muted(str); } return str; }; mw.plain = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.plain(str); } return str; }; mw.toString = function () { return '<ministyle-toggle>'; }; return mw; }
javascript
function toggle(main, alt) { var mw = core.base(); mw.enabled = true; mw.main = main; mw.alt = (alt || common.plain()); mw.active = mw.main; mw.swap = function () { mw.active = (mw.active !== mw.main ? mw.main : mw.alt); }; mw.error = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.error(str); } return str; }; mw.warning = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.warning(str); } return str; }; mw.success = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.error(str); } return str; }; mw.accent = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.accent(str); } return str; }; mw.signal = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.signal(str); } return str; }; mw.muted = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.muted(str); } return str; }; mw.plain = function (str) { str = String(str); if (mw.enabled && mw.active) { return mw.active.plain(str); } return str; }; mw.toString = function () { return '<ministyle-toggle>'; }; return mw; }
[ "function", "toggle", "(", "main", ",", "alt", ")", "{", "var", "mw", "=", "core", ".", "base", "(", ")", ";", "mw", ".", "enabled", "=", "true", ";", "mw", ".", "main", "=", "main", ";", "mw", ".", "alt", "=", "(", "alt", "||", "common", ".", "plain", "(", ")", ")", ";", "mw", ".", "active", "=", "mw", ".", "main", ";", "mw", ".", "swap", "=", "function", "(", ")", "{", "mw", ".", "active", "=", "(", "mw", ".", "active", "!==", "mw", ".", "main", "?", "mw", ".", "main", ":", "mw", ".", "alt", ")", ";", "}", ";", "mw", ".", "error", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "error", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "warning", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "warning", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "success", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "error", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "accent", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "accent", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "signal", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "signal", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "muted", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "muted", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "plain", "=", "function", "(", "str", ")", "{", "str", "=", "String", "(", "str", ")", ";", "if", "(", "mw", ".", "enabled", "&&", "mw", ".", "active", ")", "{", "return", "mw", ".", "active", ".", "plain", "(", "str", ")", ";", "}", "return", "str", ";", "}", ";", "mw", ".", "toString", "=", "function", "(", ")", "{", "return", "'<ministyle-toggle>'", ";", "}", ";", "return", "mw", ";", "}" ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - toggle flow
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "toggle", "flow" ]
92681e81d4c93faddd4e5d1d6edf44990b3a9e68
https://github.com/Bartvds/ministyle/blob/92681e81d4c93faddd4e5d1d6edf44990b3a9e68/lib/flow.js#L50-L113
train
atsid/circuits-js
js/NativeXhrDataProvider.js
function (url) { var ret = true, xhr; try { // try the lowest footprint synchronous request to specific url. xhr = new XMLHttpRequest(); xhr.open("HEAD", url, false); xhr.send(); } catch (e) { ret = false; } return ret; }
javascript
function (url) { var ret = true, xhr; try { // try the lowest footprint synchronous request to specific url. xhr = new XMLHttpRequest(); xhr.open("HEAD", url, false); xhr.send(); } catch (e) { ret = false; } return ret; }
[ "function", "(", "url", ")", "{", "var", "ret", "=", "true", ",", "xhr", ";", "try", "{", "xhr", "=", "new", "XMLHttpRequest", "(", ")", ";", "xhr", ".", "open", "(", "\"HEAD\"", ",", "url", ",", "false", ")", ";", "xhr", ".", "send", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "ret", "=", "false", ";", "}", "return", "ret", ";", "}" ]
test - do a network test with a synchronous call. @param url to test.
[ "test", "-", "do", "a", "network", "test", "with", "a", "synchronous", "call", "." ]
f1fa5e98d406b3b9f577dd8995782c7115d6b346
https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/NativeXhrDataProvider.js#L38-L49
train
atsid/circuits-js
js/NativeXhrDataProvider.js
function (params) { var xhr = new XMLHttpRequest(), async = typeof (params.asynchronous) === "boolean" ? params.asynchronous : this.asynchronous, readystatechange = function () { if (params.onreadystatechange) { params.onreadystatechange.call(this); } else { if (this.readyState === this.DONE) { if (!this.loadcalled) { // prevent multiple done calls from xhr. var resp; if (!xhr.timedOut) { resp = this.response || this.responseText; } this.loadcalled = true; if (resp && !this.responseType && params.responseType === "json") { try { resp = JSON.parse(resp); } catch (e) { logger.debug('Unable to parse JSON: ' + resp + '\n' + e); } } params.handler.call(this, (xhr.timedOut) ? -1 : this.status, resp, params); } } } }; // setup pre-open parameters params.xhr = xhr; if (params.responseType && typeof (xhr.responseType) === 'string') { // types for level 2 are still draft. Don't attempt to set until // support is more universal. // // xhr.responseType = params.responseType; logger.debug("Ignoring responseType on XHR until fully supported."); } xhr.open(params.method, params.url, async); Object.keys((params.headers || {})).forEach(function (val) { if (!(val === "Content-Type" && params.headers[val] === "multipart/form-data")) { xhr.setRequestHeader(val, params.headers[val]); } }); // If level 2, then attach the handlers directly. if (xhr.upload) { Object.keys(params).forEach(function (key) { if (key.indexOf("on") === 0 && typeof (params[key]) === 'function') { if (typeof (xhr[key]) !== 'undefined') { xhr[key] = params[key]; } if (typeof (xhr.upload[key]) !== 'undefined') { xhr.upload[key] = params[key]; } } }); } // still support readystate event. if (params.handler || params.onreadystatechange) { xhr.onreadystatechange = readystatechange; } if (params.timeout && typeof (params.timeout) === 'number') { xhr.timeout = params.timeout; xhr.ontimeout = function () { xhr.timedOut = true; xhr.abort(); }; setTimeout(function () { /* vs. xhr.timeout */ this.response = {}; if (xhr.readyState < 4 && !xhr.timedOut) { xhr.ontimeout(); } }, xhr.timeout); } xhr.send(params.payload); }
javascript
function (params) { var xhr = new XMLHttpRequest(), async = typeof (params.asynchronous) === "boolean" ? params.asynchronous : this.asynchronous, readystatechange = function () { if (params.onreadystatechange) { params.onreadystatechange.call(this); } else { if (this.readyState === this.DONE) { if (!this.loadcalled) { // prevent multiple done calls from xhr. var resp; if (!xhr.timedOut) { resp = this.response || this.responseText; } this.loadcalled = true; if (resp && !this.responseType && params.responseType === "json") { try { resp = JSON.parse(resp); } catch (e) { logger.debug('Unable to parse JSON: ' + resp + '\n' + e); } } params.handler.call(this, (xhr.timedOut) ? -1 : this.status, resp, params); } } } }; // setup pre-open parameters params.xhr = xhr; if (params.responseType && typeof (xhr.responseType) === 'string') { // types for level 2 are still draft. Don't attempt to set until // support is more universal. // // xhr.responseType = params.responseType; logger.debug("Ignoring responseType on XHR until fully supported."); } xhr.open(params.method, params.url, async); Object.keys((params.headers || {})).forEach(function (val) { if (!(val === "Content-Type" && params.headers[val] === "multipart/form-data")) { xhr.setRequestHeader(val, params.headers[val]); } }); // If level 2, then attach the handlers directly. if (xhr.upload) { Object.keys(params).forEach(function (key) { if (key.indexOf("on") === 0 && typeof (params[key]) === 'function') { if (typeof (xhr[key]) !== 'undefined') { xhr[key] = params[key]; } if (typeof (xhr.upload[key]) !== 'undefined') { xhr.upload[key] = params[key]; } } }); } // still support readystate event. if (params.handler || params.onreadystatechange) { xhr.onreadystatechange = readystatechange; } if (params.timeout && typeof (params.timeout) === 'number') { xhr.timeout = params.timeout; xhr.ontimeout = function () { xhr.timedOut = true; xhr.abort(); }; setTimeout(function () { /* vs. xhr.timeout */ this.response = {}; if (xhr.readyState < 4 && !xhr.timedOut) { xhr.ontimeout(); } }, xhr.timeout); } xhr.send(params.payload); }
[ "function", "(", "params", ")", "{", "var", "xhr", "=", "new", "XMLHttpRequest", "(", ")", ",", "async", "=", "typeof", "(", "params", ".", "asynchronous", ")", "===", "\"boolean\"", "?", "params", ".", "asynchronous", ":", "this", ".", "asynchronous", ",", "readystatechange", "=", "function", "(", ")", "{", "if", "(", "params", ".", "onreadystatechange", ")", "{", "params", ".", "onreadystatechange", ".", "call", "(", "this", ")", ";", "}", "else", "{", "if", "(", "this", ".", "readyState", "===", "this", ".", "DONE", ")", "{", "if", "(", "!", "this", ".", "loadcalled", ")", "{", "var", "resp", ";", "if", "(", "!", "xhr", ".", "timedOut", ")", "{", "resp", "=", "this", ".", "response", "||", "this", ".", "responseText", ";", "}", "this", ".", "loadcalled", "=", "true", ";", "if", "(", "resp", "&&", "!", "this", ".", "responseType", "&&", "params", ".", "responseType", "===", "\"json\"", ")", "{", "try", "{", "resp", "=", "JSON", ".", "parse", "(", "resp", ")", ";", "}", "catch", "(", "e", ")", "{", "logger", ".", "debug", "(", "'Unable to parse JSON: '", "+", "resp", "+", "'\\n'", "+", "\\n", ")", ";", "}", "}", "e", "}", "}", "}", "}", ";", "params", ".", "handler", ".", "call", "(", "this", ",", "(", "xhr", ".", "timedOut", ")", "?", "-", "1", ":", "this", ".", "status", ",", "resp", ",", "params", ")", ";", "params", ".", "xhr", "=", "xhr", ";", "if", "(", "params", ".", "responseType", "&&", "typeof", "(", "xhr", ".", "responseType", ")", "===", "'string'", ")", "{", "logger", ".", "debug", "(", "\"Ignoring responseType on XHR until fully supported.\"", ")", ";", "}", "xhr", ".", "open", "(", "params", ".", "method", ",", "params", ".", "url", ",", "async", ")", ";", "Object", ".", "keys", "(", "(", "params", ".", "headers", "||", "{", "}", ")", ")", ".", "forEach", "(", "function", "(", "val", ")", "{", "if", "(", "!", "(", "val", "===", "\"Content-Type\"", "&&", "params", ".", "headers", "[", "val", "]", "===", "\"multipart/form-data\"", ")", ")", "{", "xhr", ".", "setRequestHeader", "(", "val", ",", "params", ".", "headers", "[", "val", "]", ")", ";", "}", "}", ")", ";", "if", "(", "xhr", ".", "upload", ")", "{", "Object", ".", "keys", "(", "params", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "key", ".", "indexOf", "(", "\"on\"", ")", "===", "0", "&&", "typeof", "(", "params", "[", "key", "]", ")", "===", "'function'", ")", "{", "if", "(", "typeof", "(", "xhr", "[", "key", "]", ")", "!==", "'undefined'", ")", "{", "xhr", "[", "key", "]", "=", "params", "[", "key", "]", ";", "}", "if", "(", "typeof", "(", "xhr", ".", "upload", "[", "key", "]", ")", "!==", "'undefined'", ")", "{", "xhr", ".", "upload", "[", "key", "]", "=", "params", "[", "key", "]", ";", "}", "}", "}", ")", ";", "}", "if", "(", "params", ".", "handler", "||", "params", ".", "onreadystatechange", ")", "{", "xhr", ".", "onreadystatechange", "=", "readystatechange", ";", "}", "if", "(", "params", ".", "timeout", "&&", "typeof", "(", "params", ".", "timeout", ")", "===", "'number'", ")", "{", "xhr", ".", "timeout", "=", "params", ".", "timeout", ";", "xhr", ".", "ontimeout", "=", "function", "(", ")", "{", "xhr", ".", "timedOut", "=", "true", ";", "xhr", ".", "abort", "(", ")", ";", "}", ";", "setTimeout", "(", "function", "(", ")", "{", "this", ".", "response", "=", "{", "}", ";", "if", "(", "xhr", ".", "readyState", "<", "4", "&&", "!", "xhr", ".", "timedOut", ")", "{", "xhr", ".", "ontimeout", "(", ")", ";", "}", "}", ",", "xhr", ".", "timeout", ")", ";", "}", "}" ]
Perform the actual XMLHttpRequest call, interpreting the params as necessary. Although this method accepts the bulk of the parameters that can be set on XMLHttpRequest 2, only a few are passed through from the upstream calls. @param params - object of the form: { onprogress {function} onloadstart {function} onabort {function} ontimeout {function} onloadend {function} onreadystatechange {function} asynchronous {boolean} method {String} headers {Object} payload {Object} url {String} timeout {Number} responseType {String} handler {function} }
[ "Perform", "the", "actual", "XMLHttpRequest", "call", "interpreting", "the", "params", "as", "necessary", ".", "Although", "this", "method", "accepts", "the", "bulk", "of", "the", "parameters", "that", "can", "be", "set", "on", "XMLHttpRequest", "2", "only", "a", "few", "are", "passed", "through", "from", "the", "upstream", "calls", "." ]
f1fa5e98d406b3b9f577dd8995782c7115d6b346
https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/NativeXhrDataProvider.js#L183-L263
train
chip-js/observations-js
src/observer.js
function(value) { if (!this.context) return; if (this.setter === false) return; if (!this.setter) { try { this.setter = typeof this.expression === 'string' ? expressions.parseSetter(this.expression, this.observations.globals, this.observations.formatters) : false; } catch (e) { this.setter = false; } if (!this.setter) return; } try { var result = this.setter.call(this.context, value); } catch(e) { return; } // We can't expect code in fragments outside Observer to be aware of "sync" since observer can be replaced by other // types (e.g. one without a `sync()` method, such as one that uses `Object.observe`) in other systems. this.sync(); this.observations.sync(); return result; }
javascript
function(value) { if (!this.context) return; if (this.setter === false) return; if (!this.setter) { try { this.setter = typeof this.expression === 'string' ? expressions.parseSetter(this.expression, this.observations.globals, this.observations.formatters) : false; } catch (e) { this.setter = false; } if (!this.setter) return; } try { var result = this.setter.call(this.context, value); } catch(e) { return; } // We can't expect code in fragments outside Observer to be aware of "sync" since observer can be replaced by other // types (e.g. one without a `sync()` method, such as one that uses `Object.observe`) in other systems. this.sync(); this.observations.sync(); return result; }
[ "function", "(", "value", ")", "{", "if", "(", "!", "this", ".", "context", ")", "return", ";", "if", "(", "this", ".", "setter", "===", "false", ")", "return", ";", "if", "(", "!", "this", ".", "setter", ")", "{", "try", "{", "this", ".", "setter", "=", "typeof", "this", ".", "expression", "===", "'string'", "?", "expressions", ".", "parseSetter", "(", "this", ".", "expression", ",", "this", ".", "observations", ".", "globals", ",", "this", ".", "observations", ".", "formatters", ")", ":", "false", ";", "}", "catch", "(", "e", ")", "{", "this", ".", "setter", "=", "false", ";", "}", "if", "(", "!", "this", ".", "setter", ")", "return", ";", "}", "try", "{", "var", "result", "=", "this", ".", "setter", ".", "call", "(", "this", ".", "context", ",", "value", ")", ";", "}", "catch", "(", "e", ")", "{", "return", ";", "}", "this", ".", "sync", "(", ")", ";", "this", ".", "observations", ".", "sync", "(", ")", ";", "return", "result", ";", "}" ]
Sets the value of this expression
[ "Sets", "the", "value", "of", "this", "expression" ]
a48b32a648089bc86b502712d78cd0b3f8317d50
https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observer.js#L77-L102
train
chip-js/observations-js
src/observer.js
function() { var value = this.get(); // Don't call the callback if `skipNextSync` was called on the observer if (this.skip || !this.callback) { this.skip = false; if (this.getChangeRecords) { // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters // in bind-each) this.oldValue = diff.clone(value); } else { this.oldValue = value; } } else { var change; var useCompareBy = this.getChangeRecords && this.compareBy && Array.isArray(value) && Array.isArray(this.oldValue); if (useCompareBy) { var compareExpression = this.compareBy; var name = this.compareByName; var index = this.compareByIndex || '__index__'; var ctx = this.context; var globals = this.observations.globals; var formatters = this.observations.formatters; var oldValue = this.oldValue; if (!name) { name = '__item__'; // Turn "id" into "__item__.id" compareExpression = name + '.' + compareExpression; } var getCompareValue = expressions.parse(compareExpression, globals, formatters, name, index); changed = diff.values(value.map(getCompareValue, ctx), oldValue.map(getCompareValue, ctx)); } else if (this.getChangeRecords) { changed = diff.values(value, this.oldValue); } else { changed = diff.basic(value, this.oldValue); } var oldValue = this.oldValue; if (this.getChangeRecords) { // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters // in bind-each) this.oldValue = diff.clone(value); } else { this.oldValue = value; } // If an array has changed calculate the splices and call the callback. if (!changed && !this.forceUpdateNextSync) return; this.forceUpdateNextSync = false; if (Array.isArray(changed)) { this.callback.call(this.callbackContext, value, oldValue, changed); } else { this.callback.call(this.callbackContext, value, oldValue); } } }
javascript
function() { var value = this.get(); // Don't call the callback if `skipNextSync` was called on the observer if (this.skip || !this.callback) { this.skip = false; if (this.getChangeRecords) { // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters // in bind-each) this.oldValue = diff.clone(value); } else { this.oldValue = value; } } else { var change; var useCompareBy = this.getChangeRecords && this.compareBy && Array.isArray(value) && Array.isArray(this.oldValue); if (useCompareBy) { var compareExpression = this.compareBy; var name = this.compareByName; var index = this.compareByIndex || '__index__'; var ctx = this.context; var globals = this.observations.globals; var formatters = this.observations.formatters; var oldValue = this.oldValue; if (!name) { name = '__item__'; // Turn "id" into "__item__.id" compareExpression = name + '.' + compareExpression; } var getCompareValue = expressions.parse(compareExpression, globals, formatters, name, index); changed = diff.values(value.map(getCompareValue, ctx), oldValue.map(getCompareValue, ctx)); } else if (this.getChangeRecords) { changed = diff.values(value, this.oldValue); } else { changed = diff.basic(value, this.oldValue); } var oldValue = this.oldValue; if (this.getChangeRecords) { // Store an immutable version of the value, allowing for arrays and objects to change instance but not content and // still refrain from dispatching callbacks (e.g. when using an object in bind-class or when using array formatters // in bind-each) this.oldValue = diff.clone(value); } else { this.oldValue = value; } // If an array has changed calculate the splices and call the callback. if (!changed && !this.forceUpdateNextSync) return; this.forceUpdateNextSync = false; if (Array.isArray(changed)) { this.callback.call(this.callbackContext, value, oldValue, changed); } else { this.callback.call(this.callbackContext, value, oldValue); } } }
[ "function", "(", ")", "{", "var", "value", "=", "this", ".", "get", "(", ")", ";", "if", "(", "this", ".", "skip", "||", "!", "this", ".", "callback", ")", "{", "this", ".", "skip", "=", "false", ";", "if", "(", "this", ".", "getChangeRecords", ")", "{", "this", ".", "oldValue", "=", "diff", ".", "clone", "(", "value", ")", ";", "}", "else", "{", "this", ".", "oldValue", "=", "value", ";", "}", "}", "else", "{", "var", "change", ";", "var", "useCompareBy", "=", "this", ".", "getChangeRecords", "&&", "this", ".", "compareBy", "&&", "Array", ".", "isArray", "(", "value", ")", "&&", "Array", ".", "isArray", "(", "this", ".", "oldValue", ")", ";", "if", "(", "useCompareBy", ")", "{", "var", "compareExpression", "=", "this", ".", "compareBy", ";", "var", "name", "=", "this", ".", "compareByName", ";", "var", "index", "=", "this", ".", "compareByIndex", "||", "'__index__'", ";", "var", "ctx", "=", "this", ".", "context", ";", "var", "globals", "=", "this", ".", "observations", ".", "globals", ";", "var", "formatters", "=", "this", ".", "observations", ".", "formatters", ";", "var", "oldValue", "=", "this", ".", "oldValue", ";", "if", "(", "!", "name", ")", "{", "name", "=", "'__item__'", ";", "compareExpression", "=", "name", "+", "'.'", "+", "compareExpression", ";", "}", "var", "getCompareValue", "=", "expressions", ".", "parse", "(", "compareExpression", ",", "globals", ",", "formatters", ",", "name", ",", "index", ")", ";", "changed", "=", "diff", ".", "values", "(", "value", ".", "map", "(", "getCompareValue", ",", "ctx", ")", ",", "oldValue", ".", "map", "(", "getCompareValue", ",", "ctx", ")", ")", ";", "}", "else", "if", "(", "this", ".", "getChangeRecords", ")", "{", "changed", "=", "diff", ".", "values", "(", "value", ",", "this", ".", "oldValue", ")", ";", "}", "else", "{", "changed", "=", "diff", ".", "basic", "(", "value", ",", "this", ".", "oldValue", ")", ";", "}", "var", "oldValue", "=", "this", ".", "oldValue", ";", "if", "(", "this", ".", "getChangeRecords", ")", "{", "this", ".", "oldValue", "=", "diff", ".", "clone", "(", "value", ")", ";", "}", "else", "{", "this", ".", "oldValue", "=", "value", ";", "}", "if", "(", "!", "changed", "&&", "!", "this", ".", "forceUpdateNextSync", ")", "return", ";", "this", ".", "forceUpdateNextSync", "=", "false", ";", "if", "(", "Array", ".", "isArray", "(", "changed", ")", ")", "{", "this", ".", "callback", ".", "call", "(", "this", ".", "callbackContext", ",", "value", ",", "oldValue", ",", "changed", ")", ";", "}", "else", "{", "this", ".", "callback", ".", "call", "(", "this", ".", "callbackContext", ",", "value", ",", "oldValue", ")", ";", "}", "}", "}" ]
Syncs this observer now, calling the callback immediately if there have been changes
[ "Syncs", "this", "observer", "now", "calling", "the", "callback", "immediately", "if", "there", "have", "been", "changes" ]
a48b32a648089bc86b502712d78cd0b3f8317d50
https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/observer.js#L112-L176
train
Mammut-FE/nejm
src/util/focus/platform/focus.js
function(_clazz,_event){ var _element = _v._$getElement(_event); if (!_element.value) _e._$delClassName(_element,_clazz); }
javascript
function(_clazz,_event){ var _element = _v._$getElement(_event); if (!_element.value) _e._$delClassName(_element,_clazz); }
[ "function", "(", "_clazz", ",", "_event", ")", "{", "var", "_element", "=", "_v", ".", "_$getElement", "(", "_event", ")", ";", "if", "(", "!", "_element", ".", "value", ")", "_e", ".", "_$delClassName", "(", "_element", ",", "_clazz", ")", ";", "}" ]
do blur check
[ "do", "blur", "check" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/focus/platform/focus.js#L21-L25
train
Mammut-FE/nejm
src/util/ajax/rest.js
function(_headers,_key,_default){ var _value = _headers[_key]|| _headers[_key.toLowerCase()]; if (!_value){ _value = _default; _headers[_key] = _value; } return _value; }
javascript
function(_headers,_key,_default){ var _value = _headers[_key]|| _headers[_key.toLowerCase()]; if (!_value){ _value = _default; _headers[_key] = _value; } return _value; }
[ "function", "(", "_headers", ",", "_key", ",", "_default", ")", "{", "var", "_value", "=", "_headers", "[", "_key", "]", "||", "_headers", "[", "_key", ".", "toLowerCase", "(", ")", "]", ";", "if", "(", "!", "_value", ")", "{", "_value", "=", "_default", ";", "_headers", "[", "_key", "]", "=", "_value", ";", "}", "return", "_value", ";", "}" ]
check default headers
[ "check", "default", "headers" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/ajax/rest.js#L132-L140
train
Mammut-FE/nejm
src/util/ajax/rest.js
function(_data,_key,_map){ if (_u._$isArray(_data)){ _map[_key] = JSON.stringify(_data); } }
javascript
function(_data,_key,_map){ if (_u._$isArray(_data)){ _map[_key] = JSON.stringify(_data); } }
[ "function", "(", "_data", ",", "_key", ",", "_map", ")", "{", "if", "(", "_u", ".", "_$isArray", "(", "_data", ")", ")", "{", "_map", "[", "_key", "]", "=", "JSON", ".", "stringify", "(", "_data", ")", ";", "}", "}" ]
pre convert array
[ "pre", "convert", "array" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/ajax/rest.js#L142-L146
train
urturn/urturn-expression-api
lib/modules/antiscroll.costum.js
Antiscroll
function Antiscroll (el, opts) { this.el = $(el); this.options = opts || {}; // CUSTOM // this.x = (false !== this.options.x) || this.options.forceHorizontal; this.x = false; // Always hide horizontal scroll this.y = (false !== this.options.y) || this.options.forceVertical; this.autoHide = false !== this.options.autoHide; this.padding = undefined === this.options.padding ? 2 : this.options.padding; this.inner = this.el.find('.antiscroll-inner'); /* CUSTOM */ /* Don't add space to hide scrollbar multiple times */ if (this.inner.outerWidth() <= this.el.outerWidth()) { this.inner.css({ 'width': '+=' + (this.y ? scrollbarSize() : 0) // 'height': '+=' + (this.x ? scrollbarSize() : 0) }); } var cssMap = {}; if (this.x) cssMap.width = '+=' + scrollbarSize(); // if (this.y) cssMap.height = '+=' + scrollbarSize(); this.inner.css(cssMap); this.refresh(); }
javascript
function Antiscroll (el, opts) { this.el = $(el); this.options = opts || {}; // CUSTOM // this.x = (false !== this.options.x) || this.options.forceHorizontal; this.x = false; // Always hide horizontal scroll this.y = (false !== this.options.y) || this.options.forceVertical; this.autoHide = false !== this.options.autoHide; this.padding = undefined === this.options.padding ? 2 : this.options.padding; this.inner = this.el.find('.antiscroll-inner'); /* CUSTOM */ /* Don't add space to hide scrollbar multiple times */ if (this.inner.outerWidth() <= this.el.outerWidth()) { this.inner.css({ 'width': '+=' + (this.y ? scrollbarSize() : 0) // 'height': '+=' + (this.x ? scrollbarSize() : 0) }); } var cssMap = {}; if (this.x) cssMap.width = '+=' + scrollbarSize(); // if (this.y) cssMap.height = '+=' + scrollbarSize(); this.inner.css(cssMap); this.refresh(); }
[ "function", "Antiscroll", "(", "el", ",", "opts", ")", "{", "this", ".", "el", "=", "$", "(", "el", ")", ";", "this", ".", "options", "=", "opts", "||", "{", "}", ";", "this", ".", "x", "=", "false", ";", "this", ".", "y", "=", "(", "false", "!==", "this", ".", "options", ".", "y", ")", "||", "this", ".", "options", ".", "forceVertical", ";", "this", ".", "autoHide", "=", "false", "!==", "this", ".", "options", ".", "autoHide", ";", "this", ".", "padding", "=", "undefined", "===", "this", ".", "options", ".", "padding", "?", "2", ":", "this", ".", "options", ".", "padding", ";", "this", ".", "inner", "=", "this", ".", "el", ".", "find", "(", "'.antiscroll-inner'", ")", ";", "if", "(", "this", ".", "inner", ".", "outerWidth", "(", ")", "<=", "this", ".", "el", ".", "outerWidth", "(", ")", ")", "{", "this", ".", "inner", ".", "css", "(", "{", "'width'", ":", "'+='", "+", "(", "this", ".", "y", "?", "scrollbarSize", "(", ")", ":", "0", ")", "}", ")", ";", "}", "var", "cssMap", "=", "{", "}", ";", "if", "(", "this", ".", "x", ")", "cssMap", ".", "width", "=", "'+='", "+", "scrollbarSize", "(", ")", ";", "this", ".", "inner", ".", "css", "(", "cssMap", ")", ";", "this", ".", "refresh", "(", ")", ";", "}" ]
Antiscroll pane constructor. @param {Element|jQuery} main pane @parma {Object} options @api public
[ "Antiscroll", "pane", "constructor", "." ]
009a272ee670dbbe5eefb5c070ed827dd778bb07
https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/lib/modules/antiscroll.costum.js#L46-L73
train
urturn/urturn-expression-api
lib/modules/antiscroll.costum.js
Scrollbar
function Scrollbar (pane) { this.pane = pane; this.pane.el.append(this.el); this.innerEl = this.pane.inner.get(0); this.dragging = false; this.enter = false; this.shown = false; // hovering this.pane.el.mouseenter($.proxy(this, 'mouseenter')); this.pane.el.mouseleave($.proxy(this, 'mouseleave')); // dragging this.el.mousedown($.proxy(this, 'mousedown')); // scrolling this.innerPaneScrollListener = $.proxy(this, 'scroll'); this.pane.inner.scroll(this.innerPaneScrollListener); // wheel -optional- this.innerPaneMouseWheelListener = $.proxy(this, 'mousewheel'); this.pane.inner.bind('mousewheel', this.innerPaneMouseWheelListener); // show var initialDisplay = this.pane.options.initialDisplay; if (initialDisplay !== false) { this.show(); if (this.pane.autoHide) { this.hiding = setTimeout($.proxy(this, 'hide'), parseInt(initialDisplay, 10) || 3000); } } }
javascript
function Scrollbar (pane) { this.pane = pane; this.pane.el.append(this.el); this.innerEl = this.pane.inner.get(0); this.dragging = false; this.enter = false; this.shown = false; // hovering this.pane.el.mouseenter($.proxy(this, 'mouseenter')); this.pane.el.mouseleave($.proxy(this, 'mouseleave')); // dragging this.el.mousedown($.proxy(this, 'mousedown')); // scrolling this.innerPaneScrollListener = $.proxy(this, 'scroll'); this.pane.inner.scroll(this.innerPaneScrollListener); // wheel -optional- this.innerPaneMouseWheelListener = $.proxy(this, 'mousewheel'); this.pane.inner.bind('mousewheel', this.innerPaneMouseWheelListener); // show var initialDisplay = this.pane.options.initialDisplay; if (initialDisplay !== false) { this.show(); if (this.pane.autoHide) { this.hiding = setTimeout($.proxy(this, 'hide'), parseInt(initialDisplay, 10) || 3000); } } }
[ "function", "Scrollbar", "(", "pane", ")", "{", "this", ".", "pane", "=", "pane", ";", "this", ".", "pane", ".", "el", ".", "append", "(", "this", ".", "el", ")", ";", "this", ".", "innerEl", "=", "this", ".", "pane", ".", "inner", ".", "get", "(", "0", ")", ";", "this", ".", "dragging", "=", "false", ";", "this", ".", "enter", "=", "false", ";", "this", ".", "shown", "=", "false", ";", "this", ".", "pane", ".", "el", ".", "mouseenter", "(", "$", ".", "proxy", "(", "this", ",", "'mouseenter'", ")", ")", ";", "this", ".", "pane", ".", "el", ".", "mouseleave", "(", "$", ".", "proxy", "(", "this", ",", "'mouseleave'", ")", ")", ";", "this", ".", "el", ".", "mousedown", "(", "$", ".", "proxy", "(", "this", ",", "'mousedown'", ")", ")", ";", "this", ".", "innerPaneScrollListener", "=", "$", ".", "proxy", "(", "this", ",", "'scroll'", ")", ";", "this", ".", "pane", ".", "inner", ".", "scroll", "(", "this", ".", "innerPaneScrollListener", ")", ";", "this", ".", "innerPaneMouseWheelListener", "=", "$", ".", "proxy", "(", "this", ",", "'mousewheel'", ")", ";", "this", ".", "pane", ".", "inner", ".", "bind", "(", "'mousewheel'", ",", "this", ".", "innerPaneMouseWheelListener", ")", ";", "var", "initialDisplay", "=", "this", ".", "pane", ".", "options", ".", "initialDisplay", ";", "if", "(", "initialDisplay", "!==", "false", ")", "{", "this", ".", "show", "(", ")", ";", "if", "(", "this", ".", "pane", ".", "autoHide", ")", "{", "this", ".", "hiding", "=", "setTimeout", "(", "$", ".", "proxy", "(", "this", ",", "'hide'", ")", ",", "parseInt", "(", "initialDisplay", ",", "10", ")", "||", "3000", ")", ";", "}", "}", "}" ]
Scrollbar constructor. @param {Element|jQuery} element @api public
[ "Scrollbar", "constructor", "." ]
009a272ee670dbbe5eefb5c070ed827dd778bb07
https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/lib/modules/antiscroll.costum.js#L149-L182
train
urturn/urturn-expression-api
lib/modules/antiscroll.costum.js
inherits
function inherits (ctorA, ctorB) { function f() {} f.prototype = ctorB.prototype; ctorA.prototype = new f(); }
javascript
function inherits (ctorA, ctorB) { function f() {} f.prototype = ctorB.prototype; ctorA.prototype = new f(); }
[ "function", "inherits", "(", "ctorA", ",", "ctorB", ")", "{", "function", "f", "(", ")", "{", "}", "f", ".", "prototype", "=", "ctorB", ".", "prototype", ";", "ctorA", ".", "prototype", "=", "new", "f", "(", ")", ";", "}" ]
Cross-browser inheritance. @param {Function} constructor @param {Function} constructor we inherit from @api private
[ "Cross", "-", "browser", "inheritance", "." ]
009a272ee670dbbe5eefb5c070ed827dd778bb07
https://github.com/urturn/urturn-expression-api/blob/009a272ee670dbbe5eefb5c070ed827dd778bb07/lib/modules/antiscroll.costum.js#L461-L465
train
emeryrose/coalescent
lib/middleware/router.js
Router
function Router(socket, options) { stream.Transform.call(this, { objectMode: true }); this.options = merge(Object.create(Router.DEFAULTS), options || {}); this.socket = socket; }
javascript
function Router(socket, options) { stream.Transform.call(this, { objectMode: true }); this.options = merge(Object.create(Router.DEFAULTS), options || {}); this.socket = socket; }
[ "function", "Router", "(", "socket", ",", "options", ")", "{", "stream", ".", "Transform", ".", "call", "(", "this", ",", "{", "objectMode", ":", "true", "}", ")", ";", "this", ".", "options", "=", "merge", "(", "Object", ".", "create", "(", "Router", ".", "DEFAULTS", ")", ",", "options", "||", "{", "}", ")", ";", "this", ".", "socket", "=", "socket", ";", "}" ]
Routes messages parsed with courier to defined handlers by `type` @constructor @param {object} socket @param {object} options
[ "Routes", "messages", "parsed", "with", "courier", "to", "defined", "handlers", "by", "type" ]
5e722d4e1c16b9a9e959b281f6bb07713c60c46a
https://github.com/emeryrose/coalescent/blob/5e722d4e1c16b9a9e959b281f6bb07713c60c46a/lib/middleware/router.js#L23-L28
train
tmarshall/Google-Plus-API
google-plus-api.js
makeRequest
function makeRequest(apiKey, path, opts, callback) { var key, req, dataStr = ''; if(callback === undefined) { throw 'No callback defined'; return; } path = '/plus/v1/' + path + '?key=' + apiKey; for(key in opts) { path += '&' + key + '=' + opts[key]; } req = https.request({ host: 'www.googleapis.com', port: 443, path: path, method: 'GET' }, function(res) { res.on('data', function(data) { dataStr += data; }); res.on('end', function() { if(opts.alt === undefined || opts.alt.toLowerCase() == 'json') { try { callback(null, JSON.parse(dataStr)); } catch(err) { callback(null, dataStr); } } else { callback(null, dataStr); } }); res.on('close', function () { res.emit('end'); }); }); req.end(); req.on('error', function(err) { callback(err); }); return req; }
javascript
function makeRequest(apiKey, path, opts, callback) { var key, req, dataStr = ''; if(callback === undefined) { throw 'No callback defined'; return; } path = '/plus/v1/' + path + '?key=' + apiKey; for(key in opts) { path += '&' + key + '=' + opts[key]; } req = https.request({ host: 'www.googleapis.com', port: 443, path: path, method: 'GET' }, function(res) { res.on('data', function(data) { dataStr += data; }); res.on('end', function() { if(opts.alt === undefined || opts.alt.toLowerCase() == 'json') { try { callback(null, JSON.parse(dataStr)); } catch(err) { callback(null, dataStr); } } else { callback(null, dataStr); } }); res.on('close', function () { res.emit('end'); }); }); req.end(); req.on('error', function(err) { callback(err); }); return req; }
[ "function", "makeRequest", "(", "apiKey", ",", "path", ",", "opts", ",", "callback", ")", "{", "var", "key", ",", "req", ",", "dataStr", "=", "''", ";", "if", "(", "callback", "===", "undefined", ")", "{", "throw", "'No callback defined'", ";", "return", ";", "}", "path", "=", "'/plus/v1/'", "+", "path", "+", "'?key='", "+", "apiKey", ";", "for", "(", "key", "in", "opts", ")", "{", "path", "+=", "'&'", "+", "key", "+", "'='", "+", "opts", "[", "key", "]", ";", "}", "req", "=", "https", ".", "request", "(", "{", "host", ":", "'www.googleapis.com'", ",", "port", ":", "443", ",", "path", ":", "path", ",", "method", ":", "'GET'", "}", ",", "function", "(", "res", ")", "{", "res", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "dataStr", "+=", "data", ";", "}", ")", ";", "res", ".", "on", "(", "'end'", ",", "function", "(", ")", "{", "if", "(", "opts", ".", "alt", "===", "undefined", "||", "opts", ".", "alt", ".", "toLowerCase", "(", ")", "==", "'json'", ")", "{", "try", "{", "callback", "(", "null", ",", "JSON", ".", "parse", "(", "dataStr", ")", ")", ";", "}", "catch", "(", "err", ")", "{", "callback", "(", "null", ",", "dataStr", ")", ";", "}", "}", "else", "{", "callback", "(", "null", ",", "dataStr", ")", ";", "}", "}", ")", ";", "res", ".", "on", "(", "'close'", ",", "function", "(", ")", "{", "res", ".", "emit", "(", "'end'", ")", ";", "}", ")", ";", "}", ")", ";", "req", ".", "end", "(", ")", ";", "req", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "callback", "(", "err", ")", ";", "}", ")", ";", "return", "req", ";", "}" ]
Private function, used to make requests to G+ Takes the path, any options (becomes query params) & a callback Returns the HTTP request instance
[ "Private", "function", "used", "to", "make", "requests", "to", "G", "+" ]
27f8593072910c1fbcd926ffe689e497337a8834
https://github.com/tmarshall/Google-Plus-API/blob/27f8593072910c1fbcd926ffe689e497337a8834/google-plus-api.js#L175-L225
train
atsid/circuits-js
js/plugins/DataProviderPlugin.js
function (args) { this.type = "mixin"; this.fn = function (service) { service.create = service[this.create]; service.read = service[this.read]; service.update = service[this.update]; service.remove = service[this.remove]; }; }
javascript
function (args) { this.type = "mixin"; this.fn = function (service) { service.create = service[this.create]; service.read = service[this.read]; service.update = service[this.update]; service.remove = service[this.remove]; }; }
[ "function", "(", "args", ")", "{", "this", ".", "type", "=", "\"mixin\"", ";", "this", ".", "fn", "=", "function", "(", "service", ")", "{", "service", ".", "create", "=", "service", "[", "this", ".", "create", "]", ";", "service", ".", "read", "=", "service", "[", "this", ".", "read", "]", ";", "service", ".", "update", "=", "service", "[", "this", ".", "update", "]", ";", "service", ".", "remove", "=", "service", "[", "this", ".", "remove", "]", ";", "}", ";", "}" ]
Maps simple CRUD operations to actual service methods. @param {Object} args should consist of 4 key/value pairs: create, read, update and remove Each value should be the equivalent operation on the service.
[ "Maps", "simple", "CRUD", "operations", "to", "actual", "service", "methods", "." ]
f1fa5e98d406b3b9f577dd8995782c7115d6b346
https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/plugins/DataProviderPlugin.js#L17-L25
train
chip-js/observations-js
src/computed-properties/map.js
MapProperty
function MapProperty(sourceExpression, keyExpression, resultExpression, removeExpression) { var parts = sourceExpression.split(/\s+in\s+/); this.sourceExpression = parts.pop(); this.itemName = parts.pop(); this.keyExpression = keyExpression; this.resultExpression = resultExpression; this.removeExpression = removeExpression; }
javascript
function MapProperty(sourceExpression, keyExpression, resultExpression, removeExpression) { var parts = sourceExpression.split(/\s+in\s+/); this.sourceExpression = parts.pop(); this.itemName = parts.pop(); this.keyExpression = keyExpression; this.resultExpression = resultExpression; this.removeExpression = removeExpression; }
[ "function", "MapProperty", "(", "sourceExpression", ",", "keyExpression", ",", "resultExpression", ",", "removeExpression", ")", "{", "var", "parts", "=", "sourceExpression", ".", "split", "(", "/", "\\s+in\\s+", "/", ")", ";", "this", ".", "sourceExpression", "=", "parts", ".", "pop", "(", ")", ";", "this", ".", "itemName", "=", "parts", ".", "pop", "(", ")", ";", "this", ".", "keyExpression", "=", "keyExpression", ";", "this", ".", "resultExpression", "=", "resultExpression", ";", "this", ".", "removeExpression", "=", "removeExpression", ";", "}" ]
Creates an object hash with the key being the value of the `key` property of each item in `sourceExpression` and the value being the result of `expression`. `key` is optional, defaulting to "id" when not provided. `sourceExpression` can resolve to an array or an object hash. @param {Array|Object} sourceExpression An array or object whose members will be added to the map. @param {String} keyExpression The name of the property to key against as values are added to the map. @param {String} resultExpression [Optional] The expression evaluated against the array/object member whose value is added to the map. If not provided, the member will be added. @return {Object} The object map of key=>value
[ "Creates", "an", "object", "hash", "with", "the", "key", "being", "the", "value", "of", "the", "key", "property", "of", "each", "item", "in", "sourceExpression", "and", "the", "value", "being", "the", "result", "of", "expression", ".", "key", "is", "optional", "defaulting", "to", "id", "when", "not", "provided", ".", "sourceExpression", "can", "resolve", "to", "an", "array", "or", "an", "object", "hash", "." ]
a48b32a648089bc86b502712d78cd0b3f8317d50
https://github.com/chip-js/observations-js/blob/a48b32a648089bc86b502712d78cd0b3f8317d50/src/computed-properties/map.js#L14-L21
train
vesln/hydro
lib/suite/index.js
Suite
function Suite(title) { this.title = _.title(title); this.parent = null; this.runnables = []; this.events = { pre: 'pre:suite', post: 'post:suite' }; }
javascript
function Suite(title) { this.title = _.title(title); this.parent = null; this.runnables = []; this.events = { pre: 'pre:suite', post: 'post:suite' }; }
[ "function", "Suite", "(", "title", ")", "{", "this", ".", "title", "=", "_", ".", "title", "(", "title", ")", ";", "this", ".", "parent", "=", "null", ";", "this", ".", "runnables", "=", "[", "]", ";", "this", ".", "events", "=", "{", "pre", ":", "'pre:suite'", ",", "post", ":", "'post:suite'", "}", ";", "}" ]
Test suite. @param {String} title @constructor
[ "Test", "suite", "." ]
3f4d2e4926f913976187376e82f1496514c39890
https://github.com/vesln/hydro/blob/3f4d2e4926f913976187376e82f1496514c39890/lib/suite/index.js#L16-L24
train
atsid/circuits-js
js/Request.js
function () { var that = this, paramHandler = this.params.handler, params = util.mixin({}, this.params); //wrap the handler callbacks in a cancel check function handler(responseCode, data, ioArgs) { that.xhr = ioArgs.xhr; that.statusCode = that.xhr && !that.xhr.timedOut && that.xhr.status || 0; if (that.canceled) { logger.debug("Request [" + that.id + "] was canceled, not calling handler"); } else { that.pending = false; that.complete = true; paramHandler(responseCode, data, ioArgs); } } if (this.canceled) { logger.debug("Request [" + that.id + "] was canceled, not executing"); } else { this.pending = true; this.fn(util.mixin(params, { handler: handler })); } }
javascript
function () { var that = this, paramHandler = this.params.handler, params = util.mixin({}, this.params); //wrap the handler callbacks in a cancel check function handler(responseCode, data, ioArgs) { that.xhr = ioArgs.xhr; that.statusCode = that.xhr && !that.xhr.timedOut && that.xhr.status || 0; if (that.canceled) { logger.debug("Request [" + that.id + "] was canceled, not calling handler"); } else { that.pending = false; that.complete = true; paramHandler(responseCode, data, ioArgs); } } if (this.canceled) { logger.debug("Request [" + that.id + "] was canceled, not executing"); } else { this.pending = true; this.fn(util.mixin(params, { handler: handler })); } }
[ "function", "(", ")", "{", "var", "that", "=", "this", ",", "paramHandler", "=", "this", ".", "params", ".", "handler", ",", "params", "=", "util", ".", "mixin", "(", "{", "}", ",", "this", ".", "params", ")", ";", "function", "handler", "(", "responseCode", ",", "data", ",", "ioArgs", ")", "{", "that", ".", "xhr", "=", "ioArgs", ".", "xhr", ";", "that", ".", "statusCode", "=", "that", ".", "xhr", "&&", "!", "that", ".", "xhr", ".", "timedOut", "&&", "that", ".", "xhr", ".", "status", "||", "0", ";", "if", "(", "that", ".", "canceled", ")", "{", "logger", ".", "debug", "(", "\"Request [\"", "+", "that", ".", "id", "+", "\"] was canceled, not calling handler\"", ")", ";", "}", "else", "{", "that", ".", "pending", "=", "false", ";", "that", ".", "complete", "=", "true", ";", "paramHandler", "(", "responseCode", ",", "data", ",", "ioArgs", ")", ";", "}", "}", "if", "(", "this", ".", "canceled", ")", "{", "logger", ".", "debug", "(", "\"Request [\"", "+", "that", ".", "id", "+", "\"] was canceled, not executing\"", ")", ";", "}", "else", "{", "this", ".", "pending", "=", "true", ";", "this", ".", "fn", "(", "util", ".", "mixin", "(", "params", ",", "{", "handler", ":", "handler", "}", ")", ")", ";", "}", "}" ]
Calls the specified data function, passing in the params. This allows us to wrap these calls with a cancellation check. Note that scope is ignored - the ultimate callback scope is defined wherever the provider method is ultimately called.
[ "Calls", "the", "specified", "data", "function", "passing", "in", "the", "params", ".", "This", "allows", "us", "to", "wrap", "these", "calls", "with", "a", "cancellation", "check", ".", "Note", "that", "scope", "is", "ignored", "-", "the", "ultimate", "callback", "scope", "is", "defined", "wherever", "the", "provider", "method", "is", "ultimately", "called", "." ]
f1fa5e98d406b3b9f577dd8995782c7115d6b346
https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/Request.js#L45-L72
train
atsid/circuits-js
js/Request.js
handler
function handler(responseCode, data, ioArgs) { that.xhr = ioArgs.xhr; that.statusCode = that.xhr && !that.xhr.timedOut && that.xhr.status || 0; if (that.canceled) { logger.debug("Request [" + that.id + "] was canceled, not calling handler"); } else { that.pending = false; that.complete = true; paramHandler(responseCode, data, ioArgs); } }
javascript
function handler(responseCode, data, ioArgs) { that.xhr = ioArgs.xhr; that.statusCode = that.xhr && !that.xhr.timedOut && that.xhr.status || 0; if (that.canceled) { logger.debug("Request [" + that.id + "] was canceled, not calling handler"); } else { that.pending = false; that.complete = true; paramHandler(responseCode, data, ioArgs); } }
[ "function", "handler", "(", "responseCode", ",", "data", ",", "ioArgs", ")", "{", "that", ".", "xhr", "=", "ioArgs", ".", "xhr", ";", "that", ".", "statusCode", "=", "that", ".", "xhr", "&&", "!", "that", ".", "xhr", ".", "timedOut", "&&", "that", ".", "xhr", ".", "status", "||", "0", ";", "if", "(", "that", ".", "canceled", ")", "{", "logger", ".", "debug", "(", "\"Request [\"", "+", "that", ".", "id", "+", "\"] was canceled, not calling handler\"", ")", ";", "}", "else", "{", "that", ".", "pending", "=", "false", ";", "that", ".", "complete", "=", "true", ";", "paramHandler", "(", "responseCode", ",", "data", ",", "ioArgs", ")", ";", "}", "}" ]
wrap the handler callbacks in a cancel check
[ "wrap", "the", "handler", "callbacks", "in", "a", "cancel", "check" ]
f1fa5e98d406b3b9f577dd8995782c7115d6b346
https://github.com/atsid/circuits-js/blob/f1fa5e98d406b3b9f577dd8995782c7115d6b346/js/Request.js#L52-L62
train
Mammut-FE/nejm
src/util/ajax/xdr.js
function(_options){ var _upload = _isUpload(_options.headers); if (!_isXDomain(_options.url)&&!_upload) return _t._$$ProxyXHR._$allocate(_options); return _h.__getProxyByMode(_options.mode,_upload,_options); }
javascript
function(_options){ var _upload = _isUpload(_options.headers); if (!_isXDomain(_options.url)&&!_upload) return _t._$$ProxyXHR._$allocate(_options); return _h.__getProxyByMode(_options.mode,_upload,_options); }
[ "function", "(", "_options", ")", "{", "var", "_upload", "=", "_isUpload", "(", "_options", ".", "headers", ")", ";", "if", "(", "!", "_isXDomain", "(", "_options", ".", "url", ")", "&&", "!", "_upload", ")", "return", "_t", ".", "_$$ProxyXHR", ".", "_$allocate", "(", "_options", ")", ";", "return", "_h", ".", "__getProxyByMode", "(", "_options", ".", "mode", ",", "_upload", ",", "_options", ")", ";", "}" ]
get ajax proxy
[ "get", "ajax", "proxy" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/ajax/xdr.js#L208-L213
train
Mammut-FE/nejm
src/util/ajax/xdr.js
function(_cache,_result){ var _data = { data:_result }; // parse ext headers var _keys = _cache.result.headers; if (!!_keys){ _data.headers = _cache.req._$header(_keys); } // TODO parse other ext data return _data; }
javascript
function(_cache,_result){ var _data = { data:_result }; // parse ext headers var _keys = _cache.result.headers; if (!!_keys){ _data.headers = _cache.req._$header(_keys); } // TODO parse other ext data return _data; }
[ "function", "(", "_cache", ",", "_result", ")", "{", "var", "_data", "=", "{", "data", ":", "_result", "}", ";", "var", "_keys", "=", "_cache", ".", "result", ".", "headers", ";", "if", "(", "!", "!", "_keys", ")", "{", "_data", ".", "headers", "=", "_cache", ".", "req", ".", "_$header", "(", "_keys", ")", ";", "}", "return", "_data", ";", "}" ]
parse ext result
[ "parse", "ext", "result" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/ajax/xdr.js#L215-L226
train
Mammut-FE/nejm
src/util/ajax/xdr.js
function(_url,_data){ var _sep = _url.indexOf('?')<0?'?':'&', _data = _data||''; if (_u._$isObject(_data)) _data = _u._$object2query(_data); if (!!_data) _url += _sep+_data; return _url; }
javascript
function(_url,_data){ var _sep = _url.indexOf('?')<0?'?':'&', _data = _data||''; if (_u._$isObject(_data)) _data = _u._$object2query(_data); if (!!_data) _url += _sep+_data; return _url; }
[ "function", "(", "_url", ",", "_data", ")", "{", "var", "_sep", "=", "_url", ".", "indexOf", "(", "'?'", ")", "<", "0", "?", "'?'", ":", "'&'", ",", "_data", "=", "_data", "||", "''", ";", "if", "(", "_u", ".", "_$isObject", "(", "_data", ")", ")", "_data", "=", "_u", ".", "_$object2query", "(", "_data", ")", ";", "if", "(", "!", "!", "_data", ")", "_url", "+=", "_sep", "+", "_data", ";", "return", "_url", ";", "}" ]
check data for get method
[ "check", "data", "for", "get", "method" ]
dfc09ac66a8d67620a7aea65e34d8a179976b3fb
https://github.com/Mammut-FE/nejm/blob/dfc09ac66a8d67620a7aea65e34d8a179976b3fb/src/util/ajax/xdr.js#L262-L269
train
veo-labs/openveo-api
lib/errors/StorageError.js
StorageError
function StorageError(message, code) { Error.captureStackTrace(this, this.constructor); Object.defineProperties(this, { /** * The error code. * * @property code * @type Number * @final */ code: {value: code}, /** * Error message. * * @property message * @type String * @final */ message: {value: 'A storage error occurred with code "' + code + '"', writable: true}, /** * The error name. * * @property name * @type String * @final */ name: {value: 'StorageError', writable: true} }); if (message) this.message = message; }
javascript
function StorageError(message, code) { Error.captureStackTrace(this, this.constructor); Object.defineProperties(this, { /** * The error code. * * @property code * @type Number * @final */ code: {value: code}, /** * Error message. * * @property message * @type String * @final */ message: {value: 'A storage error occurred with code "' + code + '"', writable: true}, /** * The error name. * * @property name * @type String * @final */ name: {value: 'StorageError', writable: true} }); if (message) this.message = message; }
[ "function", "StorageError", "(", "message", ",", "code", ")", "{", "Error", ".", "captureStackTrace", "(", "this", ",", "this", ".", "constructor", ")", ";", "Object", ".", "defineProperties", "(", "this", ",", "{", "code", ":", "{", "value", ":", "code", "}", ",", "message", ":", "{", "value", ":", "'A storage error occurred with code \"'", "+", "code", "+", "'\"'", ",", "writable", ":", "true", "}", ",", "name", ":", "{", "value", ":", "'StorageError'", ",", "writable", ":", "true", "}", "}", ")", ";", "if", "(", "message", ")", "this", ".", "message", "=", "message", ";", "}" ]
Defines a StorageError to be thrown when a storage error occurred. var openVeoApi = require('@openveo/api'); throw new openVeoApi.errors.StorageError(42); @class StorageError @extends Error @constructor @param {String} message The error message @param {Number} code The code corresponding to the error
[ "Defines", "a", "StorageError", "to", "be", "thrown", "when", "a", "storage", "error", "occurred", "." ]
493a811e9a5ba4d3e14910facaa7452caba1ab38
https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/errors/StorageError.js#L21-L56
train
larvit/larvitfs
index.js
searchPathsRec
function searchPathsRec(thisPath, pathsToIgnore) { const subLogPrefix = logPrefix + 'searchPathsRec() - '; let result = []; let thisPaths; if (! pathsToIgnore) pathsToIgnore = []; try { if (that.fs.existsSync(thisPath + '/' + target) && result.indexOf(path.normalize(thisPath + '/' + target)) === - 1 && pathsToIgnore.indexOf(thisPath) === - 1) { result.push(path.normalize(thisPath + '/' + target)); } if (! that.fs.existsSync(thisPath)) { return result; } thisPaths = that.fs.readdirSync(thisPath); } catch (err) { that.log.error(subLogPrefix + 'throwed fs error: ' + err.message); return result; } for (let i = 0; thisPaths[i] !== undefined; i ++) { try { const subStat = that.fs.statSync(thisPath + '/' + thisPaths[i]); if (subStat.isDirectory()) { if (thisPaths[i] !== target && pathsToIgnore.indexOf(thisPaths[i]) === - 1) { // If we've found a target dir, we do not wish to scan it result = result.concat(searchPathsRec(thisPath + '/' + thisPaths[i], pathsToIgnore)); } } } catch (err) { that.log.error(subLogPrefix + 'Could not read "' + thisPaths[i] + '": ' + err.message); } } return result; }
javascript
function searchPathsRec(thisPath, pathsToIgnore) { const subLogPrefix = logPrefix + 'searchPathsRec() - '; let result = []; let thisPaths; if (! pathsToIgnore) pathsToIgnore = []; try { if (that.fs.existsSync(thisPath + '/' + target) && result.indexOf(path.normalize(thisPath + '/' + target)) === - 1 && pathsToIgnore.indexOf(thisPath) === - 1) { result.push(path.normalize(thisPath + '/' + target)); } if (! that.fs.existsSync(thisPath)) { return result; } thisPaths = that.fs.readdirSync(thisPath); } catch (err) { that.log.error(subLogPrefix + 'throwed fs error: ' + err.message); return result; } for (let i = 0; thisPaths[i] !== undefined; i ++) { try { const subStat = that.fs.statSync(thisPath + '/' + thisPaths[i]); if (subStat.isDirectory()) { if (thisPaths[i] !== target && pathsToIgnore.indexOf(thisPaths[i]) === - 1) { // If we've found a target dir, we do not wish to scan it result = result.concat(searchPathsRec(thisPath + '/' + thisPaths[i], pathsToIgnore)); } } } catch (err) { that.log.error(subLogPrefix + 'Could not read "' + thisPaths[i] + '": ' + err.message); } } return result; }
[ "function", "searchPathsRec", "(", "thisPath", ",", "pathsToIgnore", ")", "{", "const", "subLogPrefix", "=", "logPrefix", "+", "'searchPathsRec() - '", ";", "let", "result", "=", "[", "]", ";", "let", "thisPaths", ";", "if", "(", "!", "pathsToIgnore", ")", "pathsToIgnore", "=", "[", "]", ";", "try", "{", "if", "(", "that", ".", "fs", ".", "existsSync", "(", "thisPath", "+", "'/'", "+", "target", ")", "&&", "result", ".", "indexOf", "(", "path", ".", "normalize", "(", "thisPath", "+", "'/'", "+", "target", ")", ")", "===", "-", "1", "&&", "pathsToIgnore", ".", "indexOf", "(", "thisPath", ")", "===", "-", "1", ")", "{", "result", ".", "push", "(", "path", ".", "normalize", "(", "thisPath", "+", "'/'", "+", "target", ")", ")", ";", "}", "if", "(", "!", "that", ".", "fs", ".", "existsSync", "(", "thisPath", ")", ")", "{", "return", "result", ";", "}", "thisPaths", "=", "that", ".", "fs", ".", "readdirSync", "(", "thisPath", ")", ";", "}", "catch", "(", "err", ")", "{", "that", ".", "log", ".", "error", "(", "subLogPrefix", "+", "'throwed fs error: '", "+", "err", ".", "message", ")", ";", "return", "result", ";", "}", "for", "(", "let", "i", "=", "0", ";", "thisPaths", "[", "i", "]", "!==", "undefined", ";", "i", "++", ")", "{", "try", "{", "const", "subStat", "=", "that", ".", "fs", ".", "statSync", "(", "thisPath", "+", "'/'", "+", "thisPaths", "[", "i", "]", ")", ";", "if", "(", "subStat", ".", "isDirectory", "(", ")", ")", "{", "if", "(", "thisPaths", "[", "i", "]", "!==", "target", "&&", "pathsToIgnore", ".", "indexOf", "(", "thisPaths", "[", "i", "]", ")", "===", "-", "1", ")", "{", "result", "=", "result", ".", "concat", "(", "searchPathsRec", "(", "thisPath", "+", "'/'", "+", "thisPaths", "[", "i", "]", ",", "pathsToIgnore", ")", ")", ";", "}", "}", "}", "catch", "(", "err", ")", "{", "that", ".", "log", ".", "error", "(", "subLogPrefix", "+", "'Could not read \"'", "+", "thisPaths", "[", "i", "]", "+", "'\": '", "+", "err", ".", "message", ")", ";", "}", "}", "return", "result", ";", "}" ]
Search for paths recursively @param {str} thisPath - the path to search for @param {arr} pathsToIgnore - array of paths to ignore @returns {str} - absolute path
[ "Search", "for", "paths", "recursively" ]
3e0169577c2844b60f210a4e59a3d4f41821713c
https://github.com/larvit/larvitfs/blob/3e0169577c2844b60f210a4e59a3d4f41821713c/index.js#L128-L168
train
larvit/larvitfs
index.js
loadPathsRec
function loadPathsRec(thisPath) { const subLogPrefix = logPrefix + 'loadPathsRec() - '; let thisPaths; if (that.paths.indexOf(thisPath) === - 1) { that.log.debug(subLogPrefix + 'Adding ' + path.basename(thisPath) + ' to paths with full path ' + thisPath); that.paths.push(thisPath); } thisPaths = that.fs.readdirSync(thisPath + '/node_modules'); for (let i = 0; thisPaths[i] !== undefined; i ++) { try { const subStat = that.fs.statSync(thisPath + '/node_modules/' + thisPaths[i]); if (subStat.isDirectory()) { loadPathsRec(thisPath + '/node_modules/' + thisPaths[i]); } } catch (err) { that.log.silly(subLogPrefix + 'Could not read "' + thisPaths[i] + '": ' + err.message); } } }
javascript
function loadPathsRec(thisPath) { const subLogPrefix = logPrefix + 'loadPathsRec() - '; let thisPaths; if (that.paths.indexOf(thisPath) === - 1) { that.log.debug(subLogPrefix + 'Adding ' + path.basename(thisPath) + ' to paths with full path ' + thisPath); that.paths.push(thisPath); } thisPaths = that.fs.readdirSync(thisPath + '/node_modules'); for (let i = 0; thisPaths[i] !== undefined; i ++) { try { const subStat = that.fs.statSync(thisPath + '/node_modules/' + thisPaths[i]); if (subStat.isDirectory()) { loadPathsRec(thisPath + '/node_modules/' + thisPaths[i]); } } catch (err) { that.log.silly(subLogPrefix + 'Could not read "' + thisPaths[i] + '": ' + err.message); } } }
[ "function", "loadPathsRec", "(", "thisPath", ")", "{", "const", "subLogPrefix", "=", "logPrefix", "+", "'loadPathsRec() - '", ";", "let", "thisPaths", ";", "if", "(", "that", ".", "paths", ".", "indexOf", "(", "thisPath", ")", "===", "-", "1", ")", "{", "that", ".", "log", ".", "debug", "(", "subLogPrefix", "+", "'Adding '", "+", "path", ".", "basename", "(", "thisPath", ")", "+", "' to paths with full path '", "+", "thisPath", ")", ";", "that", ".", "paths", ".", "push", "(", "thisPath", ")", ";", "}", "thisPaths", "=", "that", ".", "fs", ".", "readdirSync", "(", "thisPath", "+", "'/node_modules'", ")", ";", "for", "(", "let", "i", "=", "0", ";", "thisPaths", "[", "i", "]", "!==", "undefined", ";", "i", "++", ")", "{", "try", "{", "const", "subStat", "=", "that", ".", "fs", ".", "statSync", "(", "thisPath", "+", "'/node_modules/'", "+", "thisPaths", "[", "i", "]", ")", ";", "if", "(", "subStat", ".", "isDirectory", "(", ")", ")", "{", "loadPathsRec", "(", "thisPath", "+", "'/node_modules/'", "+", "thisPaths", "[", "i", "]", ")", ";", "}", "}", "catch", "(", "err", ")", "{", "that", ".", "log", ".", "silly", "(", "subLogPrefix", "+", "'Could not read \"'", "+", "thisPaths", "[", "i", "]", "+", "'\": '", "+", "err", ".", "message", ")", ";", "}", "}", "}" ]
Add all other paths, recursively @param {str} thisPath - the path to search for
[ "Add", "all", "other", "paths", "recursively" ]
3e0169577c2844b60f210a4e59a3d4f41821713c
https://github.com/larvit/larvitfs/blob/3e0169577c2844b60f210a4e59a3d4f41821713c/index.js#L239-L262
train
donejs/ir-reattach
src/reattach.js
depth
function depth(root) { let i = 0; let walker = document.createTreeWalker(root, 0xFFFFFFFF, { acceptNode: function(node){ let nt = node.nodeType; return nt === 1 || nt === 3; } }); while(walker.nextNode()) { i++; } return i; }
javascript
function depth(root) { let i = 0; let walker = document.createTreeWalker(root, 0xFFFFFFFF, { acceptNode: function(node){ let nt = node.nodeType; return nt === 1 || nt === 3; } }); while(walker.nextNode()) { i++; } return i; }
[ "function", "depth", "(", "root", ")", "{", "let", "i", "=", "0", ";", "let", "walker", "=", "document", ".", "createTreeWalker", "(", "root", ",", "0xFFFFFFFF", ",", "{", "acceptNode", ":", "function", "(", "node", ")", "{", "let", "nt", "=", "node", ".", "nodeType", ";", "return", "nt", "===", "1", "||", "nt", "===", "3", ";", "}", "}", ")", ";", "while", "(", "walker", ".", "nextNode", "(", ")", ")", "{", "i", "++", ";", "}", "return", "i", ";", "}" ]
Get the depth of a Node
[ "Get", "the", "depth", "of", "a", "Node" ]
0440d4ed090982103d90347aa0b960f35a7e0628
https://github.com/donejs/ir-reattach/blob/0440d4ed090982103d90347aa0b960f35a7e0628/src/reattach.js#L4-L17
train
Bartvds/grunt-run-grunt
lib/runGruntfile.js
writeShell
function writeShell(grunt, options, src, cwd, argArr) { let dir = options.writeShell; if (grunt.file.isFile(options.writeShell)) { dir = path.dirname(options.writeShell); } const gf = path.basename(src.toLowerCase(), path.extname(src)); const base = path.join(dir, options.target + '__' + gf); const _ = grunt.util._; const gruntCli = (_.isUndefined(options.gruntCli) || _.isNull(options.gruntCli)) ? 'grunt' : options.gruntCli; // beh const shPath = base + '.sh'; const shContent = [ '#!/bin/bash', '', 'cd ' + path.resolve(cwd), gruntCli + ' ' + argArr.join(' '), '' ].join('\n'); grunt.file.write(shPath, shContent); //TODO chmod the shell-script? // semi broken const batPath = base + '.bat'; const batContent = [ 'set PWD=%~dp0', 'cd ' + path.resolve(cwd), gruntCli + ' ' + argArr.join(' '), 'cd "%PWD%"', '' ].join('\r\n'); grunt.file.write(batPath, batContent); console.log('argArr: ' + argArr.join(' ')); }
javascript
function writeShell(grunt, options, src, cwd, argArr) { let dir = options.writeShell; if (grunt.file.isFile(options.writeShell)) { dir = path.dirname(options.writeShell); } const gf = path.basename(src.toLowerCase(), path.extname(src)); const base = path.join(dir, options.target + '__' + gf); const _ = grunt.util._; const gruntCli = (_.isUndefined(options.gruntCli) || _.isNull(options.gruntCli)) ? 'grunt' : options.gruntCli; // beh const shPath = base + '.sh'; const shContent = [ '#!/bin/bash', '', 'cd ' + path.resolve(cwd), gruntCli + ' ' + argArr.join(' '), '' ].join('\n'); grunt.file.write(shPath, shContent); //TODO chmod the shell-script? // semi broken const batPath = base + '.bat'; const batContent = [ 'set PWD=%~dp0', 'cd ' + path.resolve(cwd), gruntCli + ' ' + argArr.join(' '), 'cd "%PWD%"', '' ].join('\r\n'); grunt.file.write(batPath, batContent); console.log('argArr: ' + argArr.join(' ')); }
[ "function", "writeShell", "(", "grunt", ",", "options", ",", "src", ",", "cwd", ",", "argArr", ")", "{", "let", "dir", "=", "options", ".", "writeShell", ";", "if", "(", "grunt", ".", "file", ".", "isFile", "(", "options", ".", "writeShell", ")", ")", "{", "dir", "=", "path", ".", "dirname", "(", "options", ".", "writeShell", ")", ";", "}", "const", "gf", "=", "path", ".", "basename", "(", "src", ".", "toLowerCase", "(", ")", ",", "path", ".", "extname", "(", "src", ")", ")", ";", "const", "base", "=", "path", ".", "join", "(", "dir", ",", "options", ".", "target", "+", "'__'", "+", "gf", ")", ";", "const", "_", "=", "grunt", ".", "util", ".", "_", ";", "const", "gruntCli", "=", "(", "_", ".", "isUndefined", "(", "options", ".", "gruntCli", ")", "||", "_", ".", "isNull", "(", "options", ".", "gruntCli", ")", ")", "?", "'grunt'", ":", "options", ".", "gruntCli", ";", "const", "shPath", "=", "base", "+", "'.sh'", ";", "const", "shContent", "=", "[", "'#!/bin/bash'", ",", "''", ",", "'cd '", "+", "path", ".", "resolve", "(", "cwd", ")", ",", "gruntCli", "+", "' '", "+", "argArr", ".", "join", "(", "' '", ")", ",", "''", "]", ".", "join", "(", "'\\n'", ")", ";", "\\n", "grunt", ".", "file", ".", "write", "(", "shPath", ",", "shContent", ")", ";", "const", "batPath", "=", "base", "+", "'.bat'", ";", "const", "batContent", "=", "[", "'set PWD=%~dp0'", ",", "'cd '", "+", "path", ".", "resolve", "(", "cwd", ")", ",", "gruntCli", "+", "' '", "+", "argArr", ".", "join", "(", "' '", ")", ",", "'cd \"%PWD%\"'", ",", "''", "]", ".", "join", "(", "'\\r\\n'", ")", ";", "\\r", "}" ]
write shell scripts
[ "write", "shell", "scripts" ]
e347fe8e5a9e2e1b16c8e84fbbad2df884e84643
https://github.com/Bartvds/grunt-run-grunt/blob/e347fe8e5a9e2e1b16c8e84fbbad2df884e84643/lib/runGruntfile.js#L10-L48
train
veo-labs/openveo-api
lib/socket/Pilot.js
Pilot
function Pilot(clientEmitter, namespace) { Pilot.super_.call(this); Object.defineProperties(this, { /** * The list of actually connected clients. * * @property clients * @type Array * @final */ clients: {value: []}, /** * The emitter to receive sockets' messages from clients. * * @property clientEmitter * @type AdvancedEmitter * @final */ clientEmitter: {value: clientEmitter}, /** * The sockets' namespace to communicate with clients. * * @property namespace * @type SocketNamespace * @final */ namespace: {value: namespace} }); }
javascript
function Pilot(clientEmitter, namespace) { Pilot.super_.call(this); Object.defineProperties(this, { /** * The list of actually connected clients. * * @property clients * @type Array * @final */ clients: {value: []}, /** * The emitter to receive sockets' messages from clients. * * @property clientEmitter * @type AdvancedEmitter * @final */ clientEmitter: {value: clientEmitter}, /** * The sockets' namespace to communicate with clients. * * @property namespace * @type SocketNamespace * @final */ namespace: {value: namespace} }); }
[ "function", "Pilot", "(", "clientEmitter", ",", "namespace", ")", "{", "Pilot", ".", "super_", ".", "call", "(", "this", ")", ";", "Object", ".", "defineProperties", "(", "this", ",", "{", "clients", ":", "{", "value", ":", "[", "]", "}", ",", "clientEmitter", ":", "{", "value", ":", "clientEmitter", "}", ",", "namespace", ":", "{", "value", ":", "namespace", "}", "}", ")", ";", "}" ]
Defines a base pilot for all pilots. A Pilot is designed to interact with sockets' clients. It listens to sockets' messages by listening to its associated client emitter. It sends information to sockets' clients using its associated socket namespace. A Pilot keeps a list of connected clients with associated sockets. @class Pilot @constructor @param {AdvancedEmitter} clientEmitter The clients' emitter @param {SocketNamespace} namespace The clients' namespace
[ "Defines", "a", "base", "pilot", "for", "all", "pilots", "." ]
493a811e9a5ba4d3e14910facaa7452caba1ab38
https://github.com/veo-labs/openveo-api/blob/493a811e9a5ba4d3e14910facaa7452caba1ab38/lib/socket/Pilot.js#L24-L58
train
bigeasy/chaperon
colleagues.js
Colleagues
function Colleagues (options) { this._ua = options.ua this._mingle = options.mingle this._conduit = options.conduit this._colleague = options.colleague }
javascript
function Colleagues (options) { this._ua = options.ua this._mingle = options.mingle this._conduit = options.conduit this._colleague = options.colleague }
[ "function", "Colleagues", "(", "options", ")", "{", "this", ".", "_ua", "=", "options", ".", "ua", "this", ".", "_mingle", "=", "options", ".", "mingle", "this", ".", "_conduit", "=", "options", ".", "conduit", "this", ".", "_colleague", "=", "options", ".", "colleague", "}" ]
Create a client with the given user agent that will query the Mingle end point URL at `mingle`. The `conduit` and `colleague` arguments are string formats used to create the URLs to query the conduit and colleague respectively.
[ "Create", "a", "client", "with", "the", "given", "user", "agent", "that", "will", "query", "the", "Mingle", "end", "point", "URL", "at", "mingle", ".", "The", "conduit", "and", "colleague", "arguments", "are", "string", "formats", "used", "to", "create", "the", "URLs", "to", "query", "the", "conduit", "and", "colleague", "respectively", "." ]
e5285ebbb9dbdb020cd7fe989fd0ffc228482798
https://github.com/bigeasy/chaperon/blob/e5285ebbb9dbdb020cd7fe989fd0ffc228482798/colleagues.js#L25-L30
train