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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
vadr-vr/VR-Analytics-JSCore | index.js | _setParams | function _setParams(params){
if(params){
// set the data collection params
if(params.defaultEvents){
for (let i = 0; i < params.defaultEvents.length; i++){
dataCollector.configureEventCollection(
params.defaultEvents[i].name,
pa... | javascript | function _setParams(params){
if(params){
// set the data collection params
if(params.defaultEvents){
for (let i = 0; i < params.defaultEvents.length; i++){
dataCollector.configureEventCollection(
params.defaultEvents[i].name,
pa... | [
"function",
"_setParams",
"(",
"params",
")",
"{",
"if",
"(",
"params",
")",
"{",
"// set the data collection params",
"if",
"(",
"params",
".",
"defaultEvents",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"params",
".",
"defaultEvents",
"... | set the params for the application
@param {Object} params
@param {Object[]} params.defaultEvents array containing the configuretion for default events
@param {Object[]} params.sessionInfo array containing the meta data for session | [
"set",
"the",
"params",
"for",
"the",
"application"
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/index.js#L46-L88 | train |
vid/SenseBase | lib/auth.js | authedByUsername | function authedByUsername(username) {
return _.first(_.where(context.authed, { username: username}));
} | javascript | function authedByUsername(username) {
return _.first(_.where(context.authed, { username: username}));
} | [
"function",
"authedByUsername",
"(",
"username",
")",
"{",
"return",
"_",
".",
"first",
"(",
"_",
".",
"where",
"(",
"context",
".",
"authed",
",",
"{",
"username",
":",
"username",
"}",
")",
")",
";",
"}"
] | Retrieve a user record by their username. | [
"Retrieve",
"a",
"user",
"record",
"by",
"their",
"username",
"."
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/auth.js#L71-L73 | train |
serg-io/backbone-sdb | backbone-sdb.js | httpRequest | function httpRequest(options, body, callback) {
// The `processResponse` callback should only be called once. The [http docs](http://nodejs.org/api/http.html#http_event_close_1)
// say that a 'close' event can be fired after the 'end' event has been fired. To ensure that the `processResponse` callback
// is calle... | javascript | function httpRequest(options, body, callback) {
// The `processResponse` callback should only be called once. The [http docs](http://nodejs.org/api/http.html#http_event_close_1)
// say that a 'close' event can be fired after the 'end' event has been fired. To ensure that the `processResponse` callback
// is calle... | [
"function",
"httpRequest",
"(",
"options",
",",
"body",
",",
"callback",
")",
"{",
"// The `processResponse` callback should only be called once. The [http docs](http://nodejs.org/api/http.html#http_event_close_1)",
"// say that a 'close' event can be fired after the 'end' event has been fired... | This is the method that send the actual HTTP requests, caches the response, and executes the callback after the response has been received.
@method httpRequest
@private
@param {Object} options The [HTTP options](http://nodejs.org/api/http.html#http_http_request_options_callback) to use when sending the request.
@param... | [
"This",
"is",
"the",
"method",
"that",
"send",
"the",
"actual",
"HTTP",
"requests",
"caches",
"the",
"response",
"and",
"executes",
"the",
"callback",
"after",
"the",
"response",
"has",
"been",
"received",
"."
] | aa43a854470aa28d72d8b4d19c603d91283788b9 | https://github.com/serg-io/backbone-sdb/blob/aa43a854470aa28d72d8b4d19c603d91283788b9/backbone-sdb.js#L513-L535 | train |
serg-io/backbone-sdb | backbone-sdb.js | getEC2IAMRole | function getEC2IAMRole(callback) {
httpRequest({host: EC2_METADATA_HOST, path: SECURITY_CREDENTIALS_RESOURCE}, null, function(error, role, httpResponse) {
callback(error, _.isString(role) ? role.trim() : role, httpResponse);
});
} | javascript | function getEC2IAMRole(callback) {
httpRequest({host: EC2_METADATA_HOST, path: SECURITY_CREDENTIALS_RESOURCE}, null, function(error, role, httpResponse) {
callback(error, _.isString(role) ? role.trim() : role, httpResponse);
});
} | [
"function",
"getEC2IAMRole",
"(",
"callback",
")",
"{",
"httpRequest",
"(",
"{",
"host",
":",
"EC2_METADATA_HOST",
",",
"path",
":",
"SECURITY_CREDENTIALS_RESOURCE",
"}",
",",
"null",
",",
"function",
"(",
"error",
",",
"role",
",",
"httpResponse",
")",
"{",
... | Gets the EC2 IAM role name from the metadata service.
@method getEC2IAMRole
@private
@param {Function} callback Callback function that receives the role returned by the metadata service. | [
"Gets",
"the",
"EC2",
"IAM",
"role",
"name",
"from",
"the",
"metadata",
"service",
"."
] | aa43a854470aa28d72d8b4d19c603d91283788b9 | https://github.com/serg-io/backbone-sdb/blob/aa43a854470aa28d72d8b4d19c603d91283788b9/backbone-sdb.js#L544-L548 | train |
serg-io/backbone-sdb | backbone-sdb.js | getEC2IAMSecurityCredentials | function getEC2IAMSecurityCredentials(role, callback) {
httpRequest({host: EC2_METADATA_HOST, path: SECURITY_CREDENTIALS_RESOURCE + role}, null, function(error, jsonStr, httpResponse) {
var credentials;
try {
credentials = JSON.parse(jsonStr);
} catch (parseError) {
if (!error) error = parseError;
... | javascript | function getEC2IAMSecurityCredentials(role, callback) {
httpRequest({host: EC2_METADATA_HOST, path: SECURITY_CREDENTIALS_RESOURCE + role}, null, function(error, jsonStr, httpResponse) {
var credentials;
try {
credentials = JSON.parse(jsonStr);
} catch (parseError) {
if (!error) error = parseError;
... | [
"function",
"getEC2IAMSecurityCredentials",
"(",
"role",
",",
"callback",
")",
"{",
"httpRequest",
"(",
"{",
"host",
":",
"EC2_METADATA_HOST",
",",
"path",
":",
"SECURITY_CREDENTIALS_RESOURCE",
"+",
"role",
"}",
",",
"null",
",",
"function",
"(",
"error",
",",
... | Gets the security credentials from the metadata service.
@method getEC2IAMSecurityCredentials
@private
@param {String} role IAM role name.
@param {Function} callback Callback function that receives the parsed credentials object returned by the metadata service. | [
"Gets",
"the",
"security",
"credentials",
"from",
"the",
"metadata",
"service",
"."
] | aa43a854470aa28d72d8b4d19c603d91283788b9 | https://github.com/serg-io/backbone-sdb/blob/aa43a854470aa28d72d8b4d19c603d91283788b9/backbone-sdb.js#L558-L569 | train |
serg-io/backbone-sdb | backbone-sdb.js | needsToLoadEC2IAMRoleCredentials | function needsToLoadEC2IAMRoleCredentials() {
if (!accessKey || !secretKey) return true;
if (credentialsExpiration === null) return false;
return (credentialsExpiration.getTime() - Date.now()) < CREDENTIALS_EXPIRATION_THRESHOLD;
} | javascript | function needsToLoadEC2IAMRoleCredentials() {
if (!accessKey || !secretKey) return true;
if (credentialsExpiration === null) return false;
return (credentialsExpiration.getTime() - Date.now()) < CREDENTIALS_EXPIRATION_THRESHOLD;
} | [
"function",
"needsToLoadEC2IAMRoleCredentials",
"(",
")",
"{",
"if",
"(",
"!",
"accessKey",
"||",
"!",
"secretKey",
")",
"return",
"true",
";",
"if",
"(",
"credentialsExpiration",
"===",
"null",
")",
"return",
"false",
";",
"return",
"(",
"credentialsExpiration"... | Helper function that returns `true` if getting the security credentials from the metadata service is needed or `false` otherwise.
@method needsToLoadEC2IAMRoleCredentials
@private | [
"Helper",
"function",
"that",
"returns",
"true",
"if",
"getting",
"the",
"security",
"credentials",
"from",
"the",
"metadata",
"service",
"is",
"needed",
"or",
"false",
"otherwise",
"."
] | aa43a854470aa28d72d8b4d19c603d91283788b9 | https://github.com/serg-io/backbone-sdb/blob/aa43a854470aa28d72d8b4d19c603d91283788b9/backbone-sdb.js#L577-L581 | train |
jriecken/asset-smasher | lib/asset-smasher.js | function (cb) {
this.reset();
var bundle = this.bundle;
var self = this;
async.waterfall([
function (wfCb) {
if (self.noclean) {
wfCb();
} else {
// Remove the output directory if it exists
existsCompat(self.outputTo, function (exists) {
if... | javascript | function (cb) {
this.reset();
var bundle = this.bundle;
var self = this;
async.waterfall([
function (wfCb) {
if (self.noclean) {
wfCb();
} else {
// Remove the output directory if it exists
existsCompat(self.outputTo, function (exists) {
if... | [
"function",
"(",
"cb",
")",
"{",
"this",
".",
"reset",
"(",
")",
";",
"var",
"bundle",
"=",
"this",
".",
"bundle",
";",
"var",
"self",
"=",
"this",
";",
"async",
".",
"waterfall",
"(",
"[",
"function",
"(",
"wfCb",
")",
"{",
"if",
"(",
"self",
... | Compile all the assets according to the options | [
"Compile",
"all",
"the",
"assets",
"according",
"to",
"the",
"options"
] | c627449b01f5da892683895915f74baa9994a475 | https://github.com/jriecken/asset-smasher/blob/c627449b01f5da892683895915f74baa9994a475/lib/asset-smasher.js#L168-L230 | train | |
jriecken/asset-smasher | lib/asset-smasher.js | function (cb) {
this.reset();
var bundle = this.bundle;
var self = this;
async.waterfall([
function (wfCb) {
if (self.verbose) {
console.log('findAssets: starting discovery phase');
}
executePhase(self.phases.discovery, bundle, wfCb);
},
function (b, w... | javascript | function (cb) {
this.reset();
var bundle = this.bundle;
var self = this;
async.waterfall([
function (wfCb) {
if (self.verbose) {
console.log('findAssets: starting discovery phase');
}
executePhase(self.phases.discovery, bundle, wfCb);
},
function (b, w... | [
"function",
"(",
"cb",
")",
"{",
"this",
".",
"reset",
"(",
")",
";",
"var",
"bundle",
"=",
"this",
".",
"bundle",
";",
"var",
"self",
"=",
"this",
";",
"async",
".",
"waterfall",
"(",
"[",
"function",
"(",
"wfCb",
")",
"{",
"if",
"(",
"self",
... | Find, but do not compile all the assets according to the options. | [
"Find",
"but",
"do",
"not",
"compile",
"all",
"the",
"assets",
"according",
"to",
"the",
"options",
"."
] | c627449b01f5da892683895915f74baa9994a475 | https://github.com/jriecken/asset-smasher/blob/c627449b01f5da892683895915f74baa9994a475/lib/asset-smasher.js#L292-L312 | train | |
jriecken/asset-smasher | lib/asset-smasher.js | function () {
var bundle = this.bundle;
var order = bundle.getProcessingOrder();
return order.map(function (file ) {
return bundle.getAsset(file).logicalPath;
});
} | javascript | function () {
var bundle = this.bundle;
var order = bundle.getProcessingOrder();
return order.map(function (file ) {
return bundle.getAsset(file).logicalPath;
});
} | [
"function",
"(",
")",
"{",
"var",
"bundle",
"=",
"this",
".",
"bundle",
";",
"var",
"order",
"=",
"bundle",
".",
"getProcessingOrder",
"(",
")",
";",
"return",
"order",
".",
"map",
"(",
"function",
"(",
"file",
")",
"{",
"return",
"bundle",
".",
"get... | Get a list of logical paths in the order that the assets will be processed in | [
"Get",
"a",
"list",
"of",
"logical",
"paths",
"in",
"the",
"order",
"that",
"the",
"assets",
"will",
"be",
"processed",
"in"
] | c627449b01f5da892683895915f74baa9994a475 | https://github.com/jriecken/asset-smasher/blob/c627449b01f5da892683895915f74baa9994a475/lib/asset-smasher.js#L346-L352 | train | |
binduwavell/generator-alfresco-common | lib/mem-fs-utils.js | function (storeOrEditor, path) {
debug('Checking if ' + path + ' exists in the in-memory store.');
var retv = false;
this.processInMemoryStore(storeOrEditor, file => {
debug('Evaluating ' + file.path + ' in state ' + file.state + ' with content length ' + (file && file.contents ? file.contents.length ... | javascript | function (storeOrEditor, path) {
debug('Checking if ' + path + ' exists in the in-memory store.');
var retv = false;
this.processInMemoryStore(storeOrEditor, file => {
debug('Evaluating ' + file.path + ' in state ' + file.state + ' with content length ' + (file && file.contents ? file.contents.length ... | [
"function",
"(",
"storeOrEditor",
",",
"path",
")",
"{",
"debug",
"(",
"'Checking if '",
"+",
"path",
"+",
"' exists in the in-memory store.'",
")",
";",
"var",
"retv",
"=",
"false",
";",
"this",
".",
"processInMemoryStore",
"(",
"storeOrEditor",
",",
"file",
... | Check if a path exists in the provided memfs Store.
As memfs only stores files (and not paths) we simply make sure we find at least one valid file
with the provided path as a prefix (or complete match). I'm not aware of
@param {!Store|!EditionInterface} storeOrEditor
@param {string} file path or folder path | [
"Check",
"if",
"a",
"path",
"exists",
"in",
"the",
"provided",
"memfs",
"Store",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/mem-fs-utils.js#L16-L28 | train | |
binduwavell/generator-alfresco-common | lib/mem-fs-utils.js | function (storeOrEditor, from, to) {
debug('Performing inMemoryCopy from ' + from + ' to ' + to + '.');
var fromLen = from.length;
this.processInMemoryStore(storeOrEditor, (file, store) => {
var idx = file.path.indexOf(from);
if (idx === 0 && file.contents !== null && file.state !== 'deleted') {... | javascript | function (storeOrEditor, from, to) {
debug('Performing inMemoryCopy from ' + from + ' to ' + to + '.');
var fromLen = from.length;
this.processInMemoryStore(storeOrEditor, (file, store) => {
var idx = file.path.indexOf(from);
if (idx === 0 && file.contents !== null && file.state !== 'deleted') {... | [
"function",
"(",
"storeOrEditor",
",",
"from",
",",
"to",
")",
"{",
"debug",
"(",
"'Performing inMemoryCopy from '",
"+",
"from",
"+",
"' to '",
"+",
"to",
"+",
"'.'",
")",
";",
"var",
"fromLen",
"=",
"from",
".",
"length",
";",
"this",
".",
"processInMe... | Given the path for a virtual file or folder and a destination path perform a copy
completely within mem-fs.
@param {!Store|!EditionInterface} storeOrEditor
@param {string} from - file path or folder path
@param {string} to - folder path | [
"Given",
"the",
"path",
"for",
"a",
"virtual",
"file",
"or",
"folder",
"and",
"a",
"destination",
"path",
"perform",
"a",
"copy",
"completely",
"within",
"mem",
"-",
"fs",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/mem-fs-utils.js#L38-L56 | train | |
binduwavell/generator-alfresco-common | lib/mem-fs-utils.js | function (storeOrEditor, from, to) {
debug('Performing inMemoryMove from ' + from + ' to ' + to);
var store = (storeOrEditor && storeOrEditor.store ? storeOrEditor.store : storeOrEditor);
var memFsEditor = require('mem-fs-editor').create(store);
var fromLen = from.length;
store.each(function (file) ... | javascript | function (storeOrEditor, from, to) {
debug('Performing inMemoryMove from ' + from + ' to ' + to);
var store = (storeOrEditor && storeOrEditor.store ? storeOrEditor.store : storeOrEditor);
var memFsEditor = require('mem-fs-editor').create(store);
var fromLen = from.length;
store.each(function (file) ... | [
"function",
"(",
"storeOrEditor",
",",
"from",
",",
"to",
")",
"{",
"debug",
"(",
"'Performing inMemoryMove from '",
"+",
"from",
"+",
"' to '",
"+",
"to",
")",
";",
"var",
"store",
"=",
"(",
"storeOrEditor",
"&&",
"storeOrEditor",
".",
"store",
"?",
"stor... | Given the path for a virtual file or folder and a destination path perform a move
completely within mem-fs.
@param {!Store|!EditionInterface} storeOrEditor
@param {string} from - file path or folder path
@param {string} to - folder path | [
"Given",
"the",
"path",
"for",
"a",
"virtual",
"file",
"or",
"folder",
"and",
"a",
"destination",
"path",
"perform",
"a",
"move",
"completely",
"within",
"mem",
"-",
"fs",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/mem-fs-utils.js#L66-L83 | train | |
binduwavell/generator-alfresco-common | lib/mem-fs-utils.js | function (storeOrEditor, logFn) {
debug('Dumping contents of in-memory store.');
var logFunc = logFn || console.log;
this.processInMemoryStore(storeOrEditor, file => {
logFunc.call(this, file.path + ' [STATE:' + file.state + ']');
/*
logFunc.call(this, JSON.stringify(file, function (k, v)... | javascript | function (storeOrEditor, logFn) {
debug('Dumping contents of in-memory store.');
var logFunc = logFn || console.log;
this.processInMemoryStore(storeOrEditor, file => {
logFunc.call(this, file.path + ' [STATE:' + file.state + ']');
/*
logFunc.call(this, JSON.stringify(file, function (k, v)... | [
"function",
"(",
"storeOrEditor",
",",
"logFn",
")",
"{",
"debug",
"(",
"'Dumping contents of in-memory store.'",
")",
";",
"var",
"logFunc",
"=",
"logFn",
"||",
"console",
".",
"log",
";",
"this",
".",
"processInMemoryStore",
"(",
"storeOrEditor",
",",
"file",
... | Log file path and sate information via a log function or console.log if not provided.
@param {!Store|!EditionInterface} storeOrEditor
@param {(Function|undefined)} logFn | [
"Log",
"file",
"path",
"and",
"sate",
"information",
"via",
"a",
"log",
"function",
"or",
"console",
".",
"log",
"if",
"not",
"provided",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/mem-fs-utils.js#L91-L107 | train | |
vid/SenseBase | web/dashboard/dashboard.js | processReconcile | function processReconcile(field, toSet, setSep, reconcileSet) {
// process validated updates
if (reconcileSet) {
reconcileSet.forEach(function(t) {
var s = { uri: t.uri };
s[toSet] = t.setVal;
context.pubsub.item.save(s);
});
return;
}
} | javascript | function processReconcile(field, toSet, setSep, reconcileSet) {
// process validated updates
if (reconcileSet) {
reconcileSet.forEach(function(t) {
var s = { uri: t.uri };
s[toSet] = t.setVal;
context.pubsub.item.save(s);
});
return;
}
} | [
"function",
"processReconcile",
"(",
"field",
",",
"toSet",
",",
"setSep",
",",
"reconcileSet",
")",
"{",
"// process validated updates",
"if",
"(",
"reconcileSet",
")",
"{",
"reconcileSet",
".",
"forEach",
"(",
"function",
"(",
"t",
")",
"{",
"var",
"s",
"=... | process validated updates | [
"process",
"validated",
"updates"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/dashboard/dashboard.js#L190-L200 | train |
jonschlinkert/question-cache | index.js | Questions | function Questions(options) {
if (!(this instanceof Questions)) {
return new Questions(options);
}
debug('initializing from <%s>', __filename);
Options.call(this, utils.omitEmpty(options || {}));
use(this);
this.initQuestions(this.options);
} | javascript | function Questions(options) {
if (!(this instanceof Questions)) {
return new Questions(options);
}
debug('initializing from <%s>', __filename);
Options.call(this, utils.omitEmpty(options || {}));
use(this);
this.initQuestions(this.options);
} | [
"function",
"Questions",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Questions",
")",
")",
"{",
"return",
"new",
"Questions",
"(",
"options",
")",
";",
"}",
"debug",
"(",
"'initializing from <%s>'",
",",
"__filename",
")",
";",
... | Create an instance of `Questions` with the given `options`.
```js
var Questions = new Questions(options);
```
@param {Object} `options` question cache options
@api public | [
"Create",
"an",
"instance",
"of",
"Questions",
"with",
"the",
"given",
"options",
"."
] | 85e4f1e00be1f230c435101f70c5da4227ce51ff | https://github.com/jonschlinkert/question-cache/blob/85e4f1e00be1f230c435101f70c5da4227ce51ff/index.js#L27-L35 | train |
usecanvas/share-js-stream | index.js | ShareJSStream | function ShareJSStream(ws, options) {
options = options || {};
options.keepAlive = options.keepAlive !== undefined ?
options.keepAlive : KEEP_ALIVE;
this.debug = options.debug === true;
this.ws = ws;
this.headers = this.ws.upgradeReq.headers;
this.remoteAddress = this.ws.upgrad... | javascript | function ShareJSStream(ws, options) {
options = options || {};
options.keepAlive = options.keepAlive !== undefined ?
options.keepAlive : KEEP_ALIVE;
this.debug = options.debug === true;
this.ws = ws;
this.headers = this.ws.upgradeReq.headers;
this.remoteAddress = this.ws.upgrad... | [
"function",
"ShareJSStream",
"(",
"ws",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"keepAlive",
"=",
"options",
".",
"keepAlive",
"!==",
"undefined",
"?",
"options",
".",
"keepAlive",
":",
"KEEP_ALIVE",
";",
... | A Stream for managing communication between a ShareJS client and a ws client
var ShareJSStream = require('share-js-stream');
var WsServer = require('ws').Server;
var http = require('http');
var livedb = require('livedb');
var shareServer = require('share').server.createClient({
backend: livedb.c... | [
"A",
"Stream",
"for",
"managing",
"communication",
"between",
"a",
"ShareJS",
"client",
"and",
"a",
"ws",
"client"
] | 6fae58dcbab7d15b22efe0e19c7f510b48de231c | https://github.com/usecanvas/share-js-stream/blob/6fae58dcbab7d15b22efe0e19c7f510b48de231c/index.js#L41-L151 | train |
tombenke/datafile | dist/schemas/index.js | loadSchema | function loadSchema(schemaBasePath, fullSchemaFileName) {
var scfPath = fullSchemaFileName.split('/');
var schemaFileName = scfPath[scfPath.length - 1];
var mainSchema = null;
// First, register() the main schemas you plan to use.
try {
mainSchema = _jsYaml2.default.load(_fs2.default.readFi... | javascript | function loadSchema(schemaBasePath, fullSchemaFileName) {
var scfPath = fullSchemaFileName.split('/');
var schemaFileName = scfPath[scfPath.length - 1];
var mainSchema = null;
// First, register() the main schemas you plan to use.
try {
mainSchema = _jsYaml2.default.load(_fs2.default.readFi... | [
"function",
"loadSchema",
"(",
"schemaBasePath",
",",
"fullSchemaFileName",
")",
"{",
"var",
"scfPath",
"=",
"fullSchemaFileName",
".",
"split",
"(",
"'/'",
")",
";",
"var",
"schemaFileName",
"=",
"scfPath",
"[",
"scfPath",
".",
"length",
"-",
"1",
"]",
";",... | Load the named JSON schema
@arg {String} schemaFileName - The name of the schema file
@return {Object} - The loaded schema
@function
Load the JSON schema validator module and create a validator object | [
"Load",
"the",
"named",
"JSON",
"schema"
] | 658a02142a9f80cc889e5074e91fc19d5ffc6f1a | https://github.com/tombenke/datafile/blob/658a02142a9f80cc889e5074e91fc19d5ffc6f1a/dist/schemas/index.js#L44-L63 | train |
briancsparks/serverassist | ra-scripts/models/partner.js | function(argv, context, callback) {
return MongoClient.connect(mongoHost, function(err, db) {
if (err) { return sg.die(err, callback, 'upsertPartner.MongoClient.connect'); }
var partnersDb = db.collection('partners');
var partnerId = argvGet(argv, 'partner-id,partner');
var item = {};
_.each... | javascript | function(argv, context, callback) {
return MongoClient.connect(mongoHost, function(err, db) {
if (err) { return sg.die(err, callback, 'upsertPartner.MongoClient.connect'); }
var partnersDb = db.collection('partners');
var partnerId = argvGet(argv, 'partner-id,partner');
var item = {};
_.each... | [
"function",
"(",
"argv",
",",
"context",
",",
"callback",
")",
"{",
"return",
"MongoClient",
".",
"connect",
"(",
"mongoHost",
",",
"function",
"(",
"err",
",",
"db",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"sg",
".",
"die",
"(",
"err",
","... | Just insert one partner without any intelligence on inserting a project | [
"Just",
"insert",
"one",
"partner",
"without",
"any",
"intelligence",
"on",
"inserting",
"a",
"project"
] | f966832aae287f502cce53a71f5129b962ada8a3 | https://github.com/briancsparks/serverassist/blob/f966832aae287f502cce53a71f5129b962ada8a3/ra-scripts/models/partner.js#L26-L47 | train | |
chapmanu/hb | lib/services/instagram/stream.js | function(service, credentials, accounts, keywords) {
Stream.call(this, service, credentials, accounts, keywords);
// Set up instagram-node-lib
Insta.set('client_id', credentials.client_id);
Insta.set('client_secret', credentials.client_secret);
// Set api endpoint URL for subscriber
this.api_end... | javascript | function(service, credentials, accounts, keywords) {
Stream.call(this, service, credentials, accounts, keywords);
// Set up instagram-node-lib
Insta.set('client_id', credentials.client_id);
Insta.set('client_secret', credentials.client_secret);
// Set api endpoint URL for subscriber
this.api_end... | [
"function",
"(",
"service",
",",
"credentials",
",",
"accounts",
",",
"keywords",
")",
"{",
"Stream",
".",
"call",
"(",
"this",
",",
"service",
",",
"credentials",
",",
"accounts",
",",
"keywords",
")",
";",
"// Set up instagram-node-lib",
"Insta",
".",
"set... | Manages the streaming connection to Instagram
@constructor
@extends Stream | [
"Manages",
"the",
"streaming",
"connection",
"to",
"Instagram"
] | 5edd8de89c7c5fdffc3df0c627513889220f7d51 | https://github.com/chapmanu/hb/blob/5edd8de89c7c5fdffc3df0c627513889220f7d51/lib/services/instagram/stream.js#L16-L37 | train | |
brianbrunner/yowl | lib/bot.js | logError | function logError(message, err, context, event) {
var current_err = err;
while (current_err) {
var next_err = current_err._previous;
delete current_err._previous;
if (current_err.stack) {
console.error(current_err.stack);
} else {
console.error(current_err);
}
current_err = next_... | javascript | function logError(message, err, context, event) {
var current_err = err;
while (current_err) {
var next_err = current_err._previous;
delete current_err._previous;
if (current_err.stack) {
console.error(current_err.stack);
} else {
console.error(current_err);
}
current_err = next_... | [
"function",
"logError",
"(",
"message",
",",
"err",
",",
"context",
",",
"event",
")",
"{",
"var",
"current_err",
"=",
"err",
";",
"while",
"(",
"current_err",
")",
"{",
"var",
"next_err",
"=",
"current_err",
".",
"_previous",
";",
"delete",
"current_err",... | Log Errors With Some Textual Context | [
"Log",
"Errors",
"With",
"Some",
"Textual",
"Context"
] | 35d6764f4cc6c4a3487eca18a12fd8ca567d4293 | https://github.com/brianbrunner/yowl/blob/35d6764f4cc6c4a3487eca18a12fd8ca567d4293/lib/bot.js#L192-L205 | train |
mchalapuk/hyper-text-slider | lib/polyfills/dom-token-list.js | Polyfill | function Polyfill(object, key) {
nodsl.check(typeof object === 'object', 'object must be an object; got ', object);
nodsl.check(typeof key === 'string', 'key must be a string; got ', key);
nodsl.check(typeof object[key] === 'string', 'object.', key, ' must be a string; got ', object[key]);
var that = this;
... | javascript | function Polyfill(object, key) {
nodsl.check(typeof object === 'object', 'object must be an object; got ', object);
nodsl.check(typeof key === 'string', 'key must be a string; got ', key);
nodsl.check(typeof object[key] === 'string', 'object.', key, ' must be a string; got ', object[key]);
var that = this;
... | [
"function",
"Polyfill",
"(",
"object",
",",
"key",
")",
"{",
"nodsl",
".",
"check",
"(",
"typeof",
"object",
"===",
"'object'",
",",
"'object must be an object; got '",
",",
"object",
")",
";",
"nodsl",
".",
"check",
"(",
"typeof",
"key",
"===",
"'string'",
... | Constructs Polyfill of DOMTokenList.
The list will be represented as a string located in given **object**
under property of name **key**.
@see https://developer.mozilla.org/pl/docs/Web/API/DOMTokenList | [
"Constructs",
"Polyfill",
"of",
"DOMTokenList",
"."
] | 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/polyfills/dom-token-list.js#L34-L63 | train |
onechiporenko/jsonium | index.js | _isArrayOfObjects | function _isArrayOfObjects(value) {
if (!Array.isArray(value)) {
return false;
}
var l = value.length;
var _type, cond;
for (var i = 0; i < l; i++) {
_type = typeof value[i];
cond = _type === 'function' || _type === 'object' && !!value[i];
if (!cond) {
return false;
}
}
return tr... | javascript | function _isArrayOfObjects(value) {
if (!Array.isArray(value)) {
return false;
}
var l = value.length;
var _type, cond;
for (var i = 0; i < l; i++) {
_type = typeof value[i];
cond = _type === 'function' || _type === 'object' && !!value[i];
if (!cond) {
return false;
}
}
return tr... | [
"function",
"_isArrayOfObjects",
"(",
"value",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"l",
"=",
"value",
".",
"length",
";",
"var",
"_type",
",",
"cond",
";",
"for",
"(",
... | Check if value is an array of objects
@param {*} value
@returns {boolean}
@private | [
"Check",
"if",
"value",
"is",
"an",
"array",
"of",
"objects"
] | 50059570f58fecebb9e139b4766d03064416a4c4 | https://github.com/onechiporenko/jsonium/blob/50059570f58fecebb9e139b4766d03064416a4c4/index.js#L20-L34 | train |
onechiporenko/jsonium | index.js | _get | function _get(obj, path) {
var subpathes = path.split('.');
while (subpathes.length) {
var subpath = subpathes.shift();
obj = obj[subpath];
if (!obj) {
return obj;
}
}
return obj;
} | javascript | function _get(obj, path) {
var subpathes = path.split('.');
while (subpathes.length) {
var subpath = subpathes.shift();
obj = obj[subpath];
if (!obj) {
return obj;
}
}
return obj;
} | [
"function",
"_get",
"(",
"obj",
",",
"path",
")",
"{",
"var",
"subpathes",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
";",
"while",
"(",
"subpathes",
".",
"length",
")",
"{",
"var",
"subpath",
"=",
"subpathes",
".",
"shift",
"(",
")",
";",
"obj",
... | Get object's value by provided nested path
@param {object} obj
@param {string} path
@returns {*}
@private | [
"Get",
"object",
"s",
"value",
"by",
"provided",
"nested",
"path"
] | 50059570f58fecebb9e139b4766d03064416a4c4 | https://github.com/onechiporenko/jsonium/blob/50059570f58fecebb9e139b4766d03064416a4c4/index.js#L44-L54 | train |
onechiporenko/jsonium | index.js | _set | function _set(obj, path, value) {
var subpathes = path.split('.');
while (subpathes.length - 1) {
obj = obj[subpathes.shift()];
}
obj[subpathes.shift()] = value;
} | javascript | function _set(obj, path, value) {
var subpathes = path.split('.');
while (subpathes.length - 1) {
obj = obj[subpathes.shift()];
}
obj[subpathes.shift()] = value;
} | [
"function",
"_set",
"(",
"obj",
",",
"path",
",",
"value",
")",
"{",
"var",
"subpathes",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
";",
"while",
"(",
"subpathes",
".",
"length",
"-",
"1",
")",
"{",
"obj",
"=",
"obj",
"[",
"subpathes",
".",
"shi... | Set object's value by provided nested path
@param {object} obj
@param {string} path
@param {*} value
@private | [
"Set",
"object",
"s",
"value",
"by",
"provided",
"nested",
"path"
] | 50059570f58fecebb9e139b4766d03064416a4c4 | https://github.com/onechiporenko/jsonium/blob/50059570f58fecebb9e139b4766d03064416a4c4/index.js#L64-L70 | train |
onechiporenko/jsonium | index.js | _has | function _has(obj, path) {
var subpathes = path.split('.');
while (subpathes.length) {
var subpath = subpathes.shift();
if (!obj.hasOwnProperty(subpath)) {
return false;
}
obj = obj[subpath];
}
return true;
} | javascript | function _has(obj, path) {
var subpathes = path.split('.');
while (subpathes.length) {
var subpath = subpathes.shift();
if (!obj.hasOwnProperty(subpath)) {
return false;
}
obj = obj[subpath];
}
return true;
} | [
"function",
"_has",
"(",
"obj",
",",
"path",
")",
"{",
"var",
"subpathes",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
";",
"while",
"(",
"subpathes",
".",
"length",
")",
"{",
"var",
"subpath",
"=",
"subpathes",
".",
"shift",
"(",
")",
";",
"if",
... | Check if object has provided nested path
@param {object} obj
@param {string} path
@returns {boolean}
@private | [
"Check",
"if",
"object",
"has",
"provided",
"nested",
"path"
] | 50059570f58fecebb9e139b4766d03064416a4c4 | https://github.com/onechiporenko/jsonium/blob/50059570f58fecebb9e139b4766d03064416a4c4/index.js#L80-L90 | train |
cliffano/couchpenter | lib/cli.js | exec | function exec() {
// NOTE: pardon this cli target to Couchpenter methods mapping,
// needed to preserve backward compatibility w/ v0.1.x
const FUNCTIONS = {
setup: 'setUp',
'setup-db': 'setUpDatabases',
'setup-doc': 'setUpDocuments',
'setup-doc-overwrite': 'setUpDocumentsOverwrite',
teardown:... | javascript | function exec() {
// NOTE: pardon this cli target to Couchpenter methods mapping,
// needed to preserve backward compatibility w/ v0.1.x
const FUNCTIONS = {
setup: 'setUp',
'setup-db': 'setUpDatabases',
'setup-doc': 'setUpDocuments',
'setup-doc-overwrite': 'setUpDocumentsOverwrite',
teardown:... | [
"function",
"exec",
"(",
")",
"{",
"// NOTE: pardon this cli target to Couchpenter methods mapping,",
"// needed to preserve backward compatibility w/ v0.1.x",
"const",
"FUNCTIONS",
"=",
"{",
"setup",
":",
"'setUp'",
",",
"'setup-db'",
":",
"'setUpDatabases'",
",",
"'setup-doc'... | Execute Couchpenter CLI. | [
"Execute",
"Couchpenter",
"CLI",
"."
] | 00cce387da2f39e4b276b27b0bacb073caa80453 | https://github.com/cliffano/couchpenter/blob/00cce387da2f39e4b276b27b0bacb073caa80453/lib/cli.js#L30-L62 | train |
nodejitsu/contour | pagelets/pagelet.js | use | function use(brand) {
return function branding(file) {
var branded = file.replace('{{brand}}', brand);
return fs.existsSync(branded) ? branded : file.replace('{{brand}}', 'nodejitsu');
};
} | javascript | function use(brand) {
return function branding(file) {
var branded = file.replace('{{brand}}', brand);
return fs.existsSync(branded) ? branded : file.replace('{{brand}}', 'nodejitsu');
};
} | [
"function",
"use",
"(",
"brand",
")",
"{",
"return",
"function",
"branding",
"(",
"file",
")",
"{",
"var",
"branded",
"=",
"file",
".",
"replace",
"(",
"'{{brand}}'",
",",
"brand",
")",
";",
"return",
"fs",
".",
"existsSync",
"(",
"branded",
")",
"?",
... | Return a mapping function with preset brand, will default to nodejitsu files if
the requested branded file does not exist.
@param {String} brand
@returns {Function} mapper
@api private | [
"Return",
"a",
"mapping",
"function",
"with",
"preset",
"brand",
"will",
"default",
"to",
"nodejitsu",
"files",
"if",
"the",
"requested",
"branded",
"file",
"does",
"not",
"exist",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/pagelet.js#L18-L23 | train |
nodejitsu/contour | pagelets/pagelet.js | get | function get(done) {
this.define();
done(undefined, this.mixin({}, this.defaults, this.data, this.merge(
this.data,
this.queue.discharge(this.name)
)));
} | javascript | function get(done) {
this.define();
done(undefined, this.mixin({}, this.defaults, this.data, this.merge(
this.data,
this.queue.discharge(this.name)
)));
} | [
"function",
"get",
"(",
"done",
")",
"{",
"this",
".",
"define",
"(",
")",
";",
"done",
"(",
"undefined",
",",
"this",
".",
"mixin",
"(",
"{",
"}",
",",
"this",
".",
"defaults",
",",
"this",
".",
"data",
",",
"this",
".",
"merge",
"(",
"this",
... | Provide data to the template render method. Can be called sync and async.
@param {Function} done completion callback
@api private | [
"Provide",
"data",
"to",
"the",
"template",
"render",
"method",
".",
"Can",
"be",
"called",
"sync",
"and",
"async",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/pagelet.js#L154-L160 | train |
nodejitsu/contour | pagelets/pagelet.js | use | function use(namespace, name, fn) {
name = name || this.name;
this.temper.require('handlebars').registerHelper(
namespace + '-' + name,
fn
);
return this;
} | javascript | function use(namespace, name, fn) {
name = name || this.name;
this.temper.require('handlebars').registerHelper(
namespace + '-' + name,
fn
);
return this;
} | [
"function",
"use",
"(",
"namespace",
",",
"name",
",",
"fn",
")",
"{",
"name",
"=",
"name",
"||",
"this",
".",
"name",
";",
"this",
".",
"temper",
".",
"require",
"(",
"'handlebars'",
")",
".",
"registerHelper",
"(",
"namespace",
"+",
"'-'",
"+",
"na... | Register provided helper with handlebars.
@param {String} namespace Name of the Pagelet the helper was registered from.
@param {String} name Registered name
@param {Function} fn Handlebars helper
@api public | [
"Register",
"provided",
"helper",
"with",
"handlebars",
"."
] | 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/pagelets/pagelet.js#L170-L178 | train |
taskrjs/fly-util | src/bind.js | reduce | function reduce (m) {
if (Array.isArray(m)) {
try {
const module = m[0].module ? m[0].module : m[0]
_("register bind %o", module)
return require(module)
} catch (_) { return reduce(m.slice(1)) }
} else return reduce([m])
} | javascript | function reduce (m) {
if (Array.isArray(m)) {
try {
const module = m[0].module ? m[0].module : m[0]
_("register bind %o", module)
return require(module)
} catch (_) { return reduce(m.slice(1)) }
} else return reduce([m])
} | [
"function",
"reduce",
"(",
"m",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"m",
")",
")",
"{",
"try",
"{",
"const",
"module",
"=",
"m",
"[",
"0",
"]",
".",
"module",
"?",
"m",
"[",
"0",
"]",
".",
"module",
":",
"m",
"[",
"0",
"]",
... | Try require each module until we don't error.
@param {String} module name | [
"Try",
"require",
"each",
"module",
"until",
"we",
"don",
"t",
"error",
"."
] | 976c0fbec697b2c3de7b2b90b75f2eb66a83de24 | https://github.com/taskrjs/fly-util/blob/976c0fbec697b2c3de7b2b90b75f2eb66a83de24/src/bind.js#L21-L29 | train |
stealjs/live-reload | live.js | teardown | function teardown(moduleName, e, moduleNames) {
var moduleNames = moduleNames || {};
if(disposeModule(moduleName, e, moduleNames)) {
// Delete the module and call teardown on its parents as well.
var parents = loader.getDependants(moduleName);
for(var i = 0, len = parents.length; i < len; i++) {
teardown(p... | javascript | function teardown(moduleName, e, moduleNames) {
var moduleNames = moduleNames || {};
if(disposeModule(moduleName, e, moduleNames)) {
// Delete the module and call teardown on its parents as well.
var parents = loader.getDependants(moduleName);
for(var i = 0, len = parents.length; i < len; i++) {
teardown(p... | [
"function",
"teardown",
"(",
"moduleName",
",",
"e",
",",
"moduleNames",
")",
"{",
"var",
"moduleNames",
"=",
"moduleNames",
"||",
"{",
"}",
";",
"if",
"(",
"disposeModule",
"(",
"moduleName",
",",
"e",
",",
"moduleNames",
")",
")",
"{",
"// Delete the mod... | Teardown a module name by deleting it and all of its parent modules. | [
"Teardown",
"a",
"module",
"name",
"by",
"deleting",
"it",
"and",
"all",
"of",
"its",
"parent",
"modules",
"."
] | 904f929ddbf5f1d4346c5ef13e61b9cbb7b71d52 | https://github.com/stealjs/live-reload/blob/904f929ddbf5f1d4346c5ef13e61b9cbb7b71d52/live.js#L116-L129 | train |
rasouli100/twimap | lib/twimap.js | config_mail_box | function config_mail_box(config) {
imap = new Imap({
user:config.user,
password:config.password,
host:config.host,
port:config.port,
secure:config.secure
});
} | javascript | function config_mail_box(config) {
imap = new Imap({
user:config.user,
password:config.password,
host:config.host,
port:config.port,
secure:config.secure
});
} | [
"function",
"config_mail_box",
"(",
"config",
")",
"{",
"imap",
"=",
"new",
"Imap",
"(",
"{",
"user",
":",
"config",
".",
"user",
",",
"password",
":",
"config",
".",
"password",
",",
"host",
":",
"config",
".",
"host",
",",
"port",
":",
"config",
".... | Configs imap account from which must fetch the twitter e-mails
@param config object containing information of imap account (user, password, host, port, secure boolean flag) | [
"Configs",
"imap",
"account",
"from",
"which",
"must",
"fetch",
"the",
"twitter",
"e",
"-",
"mails"
] | 90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7 | https://github.com/rasouli100/twimap/blob/90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7/lib/twimap.js#L21-L30 | train |
rasouli100/twimap | lib/twimap.js | get_new_followers | function get_new_followers(since, cb, cberr) {
get_inbox(since);
_callback = cb;
_callback_err = cberr;
} | javascript | function get_new_followers(since, cb, cberr) {
get_inbox(since);
_callback = cb;
_callback_err = cberr;
} | [
"function",
"get_new_followers",
"(",
"since",
",",
"cb",
",",
"cberr",
")",
"{",
"get_inbox",
"(",
"since",
")",
";",
"_callback",
"=",
"cb",
";",
"_callback_err",
"=",
"cberr",
";",
"}"
] | returns followers asynchronously
@param since date from which to look for followers e-mails
@param cb callback function when there is a result
@param cberr callback function on error | [
"returns",
"followers",
"asynchronously"
] | 90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7 | https://github.com/rasouli100/twimap/blob/90a93fda604ab3af6b25bddcfe3dd71dc19ac1f7/lib/twimap.js#L40-L44 | train |
MiguelCastillo/bit-loader | example/bundler/src/bundler.js | bundlerFactory | function bundlerFactory(loader, options) {
function bundlerDelegate(modules) {
return bundler(loader, options || {}, modules);
}
bundlerDelegate.bundle = function(names) {
return loader.fetch(names).then(bundlerDelegate);
};
return bundlerDelegate;
} | javascript | function bundlerFactory(loader, options) {
function bundlerDelegate(modules) {
return bundler(loader, options || {}, modules);
}
bundlerDelegate.bundle = function(names) {
return loader.fetch(names).then(bundlerDelegate);
};
return bundlerDelegate;
} | [
"function",
"bundlerFactory",
"(",
"loader",
",",
"options",
")",
"{",
"function",
"bundlerDelegate",
"(",
"modules",
")",
"{",
"return",
"bundler",
"(",
"loader",
",",
"options",
"||",
"{",
"}",
",",
"modules",
")",
";",
"}",
"bundlerDelegate",
".",
"bund... | Convenience factory for specifying the instance of bit loader to bundle up | [
"Convenience",
"factory",
"for",
"specifying",
"the",
"instance",
"of",
"bit",
"loader",
"to",
"bundle",
"up"
] | da9d18952d87014fdb09e7a8320a24cbf1c2b436 | https://github.com/MiguelCastillo/bit-loader/blob/da9d18952d87014fdb09e7a8320a24cbf1c2b436/example/bundler/src/bundler.js#L8-L18 | train |
MiguelCastillo/bit-loader | example/bundler/src/bundler.js | bundler | function bundler(loader, options, modules) {
var stack = modules.slice(0);
var mods = [];
var finished = {};
function processModule(mod) {
if (finished.hasOwnProperty(mod.id)) {
return;
}
mod = loader.getModule(mod.id);
// browser pack chunk
var browserpack = {
id :... | javascript | function bundler(loader, options, modules) {
var stack = modules.slice(0);
var mods = [];
var finished = {};
function processModule(mod) {
if (finished.hasOwnProperty(mod.id)) {
return;
}
mod = loader.getModule(mod.id);
// browser pack chunk
var browserpack = {
id :... | [
"function",
"bundler",
"(",
"loader",
",",
"options",
",",
"modules",
")",
"{",
"var",
"stack",
"=",
"modules",
".",
"slice",
"(",
"0",
")",
";",
"var",
"mods",
"=",
"[",
"]",
";",
"var",
"finished",
"=",
"{",
"}",
";",
"function",
"processModule",
... | Bundles up incoming modules. This will process all dependencies and will create
a bundle using browser-pack.
@returns {Promise} When resolve, the full bundle buffer is returned | [
"Bundles",
"up",
"incoming",
"modules",
".",
"This",
"will",
"process",
"all",
"dependencies",
"and",
"will",
"create",
"a",
"bundle",
"using",
"browser",
"-",
"pack",
"."
] | da9d18952d87014fdb09e7a8320a24cbf1c2b436 | https://github.com/MiguelCastillo/bit-loader/blob/da9d18952d87014fdb09e7a8320a24cbf1c2b436/example/bundler/src/bundler.js#L27-L68 | train |
binduwavell/generator-alfresco-common | lib/java-properties.js | isCommentLine | function isCommentLine (line) {
var isCmnt = commentRE.test(line);
if (isCmnt) {
debug('removing comment: %s', line);
}
return !isCmnt;
} | javascript | function isCommentLine (line) {
var isCmnt = commentRE.test(line);
if (isCmnt) {
debug('removing comment: %s', line);
}
return !isCmnt;
} | [
"function",
"isCommentLine",
"(",
"line",
")",
"{",
"var",
"isCmnt",
"=",
"commentRE",
".",
"test",
"(",
"line",
")",
";",
"if",
"(",
"isCmnt",
")",
"{",
"debug",
"(",
"'removing comment: %s'",
",",
"line",
")",
";",
"}",
"return",
"!",
"isCmnt",
";",
... | Detects if a line is a comment.
@param {string} line
@returns {boolean} | [
"Detects",
"if",
"a",
"line",
"is",
"a",
"comment",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/java-properties.js#L61-L67 | train |
binduwavell/generator-alfresco-common | lib/java-properties.js | extractKeyValue | function extractKeyValue (line) {
var kv = {
key: undefined,
value: undefined,
};
var matches = kvRE.exec(line);
if (matches !== null && matches.length === 3) {
kv.key = matches[1];
kv.value = matches[2];
}
return kv;
} | javascript | function extractKeyValue (line) {
var kv = {
key: undefined,
value: undefined,
};
var matches = kvRE.exec(line);
if (matches !== null && matches.length === 3) {
kv.key = matches[1];
kv.value = matches[2];
}
return kv;
} | [
"function",
"extractKeyValue",
"(",
"line",
")",
"{",
"var",
"kv",
"=",
"{",
"key",
":",
"undefined",
",",
"value",
":",
"undefined",
",",
"}",
";",
"var",
"matches",
"=",
"kvRE",
".",
"exec",
"(",
"line",
")",
";",
"if",
"(",
"matches",
"!==",
"nu... | Uses a regular expression to extract a key
and value from the line.
@param {string} line
@returns {{key: undefined, value: undefined}} | [
"Uses",
"a",
"regular",
"expression",
"to",
"extract",
"a",
"key",
"and",
"value",
"from",
"the",
"line",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/java-properties.js#L76-L89 | train |
binduwavell/generator-alfresco-common | lib/java-properties.js | processLine | function processLine (instance, acc, line) {
debug('processing: %s', line);
// if previous line was continued then capture this line verbatim
// of course we need to handle if this is also a continuation too
if (instance.key) {
var hasCont = hasNewlineContinuation(line);
if (hasCont) {
debug('remo... | javascript | function processLine (instance, acc, line) {
debug('processing: %s', line);
// if previous line was continued then capture this line verbatim
// of course we need to handle if this is also a continuation too
if (instance.key) {
var hasCont = hasNewlineContinuation(line);
if (hasCont) {
debug('remo... | [
"function",
"processLine",
"(",
"instance",
",",
"acc",
",",
"line",
")",
"{",
"debug",
"(",
"'processing: %s'",
",",
"line",
")",
";",
"// if previous line was continued then capture this line verbatim",
"// of course we need to handle if this is also a continuation too",
"if"... | This method is called with each non-blank and non-comment
line from the properties file. It builds up the object
representation of the properties data in the accumulator.
It uses instance object to store state when lines are
being continued.
@param {Object} instance
@param {Object} acc
@param {string} line
@returns {O... | [
"This",
"method",
"is",
"called",
"with",
"each",
"non",
"-",
"blank",
"and",
"non",
"-",
"comment",
"line",
"from",
"the",
"properties",
"file",
".",
"It",
"builds",
"up",
"the",
"object",
"representation",
"of",
"the",
"properties",
"data",
"in",
"the",
... | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/java-properties.js#L113-L142 | train |
binduwavell/generator-alfresco-common | lib/java-properties.js | unescape | function unescape (line) {
var retv = _.replace(line, propEscapeRE, '$1');
retv = _.replace(line, unicodeEscapeRE, function (m) {
return String.fromCharCode(parseInt(m, 16));
});
if (retv !== line) {
debug('removed escapes from: %s => %s', line, retv);
}
return retv;
} | javascript | function unescape (line) {
var retv = _.replace(line, propEscapeRE, '$1');
retv = _.replace(line, unicodeEscapeRE, function (m) {
return String.fromCharCode(parseInt(m, 16));
});
if (retv !== line) {
debug('removed escapes from: %s => %s', line, retv);
}
return retv;
} | [
"function",
"unescape",
"(",
"line",
")",
"{",
"var",
"retv",
"=",
"_",
".",
"replace",
"(",
"line",
",",
"propEscapeRE",
",",
"'$1'",
")",
";",
"retv",
"=",
"_",
".",
"replace",
"(",
"line",
",",
"unicodeEscapeRE",
",",
"function",
"(",
"m",
")",
... | Resolve property esacpe sequences in a line.
Also resolves unicode escapes.
@param {string} line
@returns {string} | [
"Resolve",
"property",
"esacpe",
"sequences",
"in",
"a",
"line",
".",
"Also",
"resolves",
"unicode",
"escapes",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/java-properties.js#L183-L192 | train |
feedhenry/fh-mbaas-client | index.js | function(environment, mbaasConfig) {
if (!client) {
client = new MbaasClient(environment, mbaasConfig);
}
//Deprecated
module.exports.app = client.app;
module.exports.admin = client.admin;
} | javascript | function(environment, mbaasConfig) {
if (!client) {
client = new MbaasClient(environment, mbaasConfig);
}
//Deprecated
module.exports.app = client.app;
module.exports.admin = client.admin;
} | [
"function",
"(",
"environment",
",",
"mbaasConfig",
")",
"{",
"if",
"(",
"!",
"client",
")",
"{",
"client",
"=",
"new",
"MbaasClient",
"(",
"environment",
",",
"mbaasConfig",
")",
";",
"}",
"//Deprecated",
"module",
".",
"exports",
".",
"app",
"=",
"clie... | Deprecated, try not to use it. Use MbaasClient instead. | [
"Deprecated",
"try",
"not",
"to",
"use",
"it",
".",
"Use",
"MbaasClient",
"instead",
"."
] | 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/index.js#L9-L16 | train | |
edappy/seneca-context | index.js | getContext | function getContext(seneca) {
var transactionId = seneca.fixedargs.tx$;
var context = seneca.fixedargs.context$;
if (typeof context === 'undefined') {
try {
context = seneca.fixedargs.context$ = JSON.parse(URLSafeBase64.decode(transactionId).toString('utf8'));
debug('context loaded from tx$ and c... | javascript | function getContext(seneca) {
var transactionId = seneca.fixedargs.tx$;
var context = seneca.fixedargs.context$;
if (typeof context === 'undefined') {
try {
context = seneca.fixedargs.context$ = JSON.parse(URLSafeBase64.decode(transactionId).toString('utf8'));
debug('context loaded from tx$ and c... | [
"function",
"getContext",
"(",
"seneca",
")",
"{",
"var",
"transactionId",
"=",
"seneca",
".",
"fixedargs",
".",
"tx$",
";",
"var",
"context",
"=",
"seneca",
".",
"fixedargs",
".",
"context$",
";",
"if",
"(",
"typeof",
"context",
"===",
"'undefined'",
")",... | Loads the context from the seneca transaction ID.
@param {seneca} seneca The seneca object, which is the context of a running action.
@returns {Object} A context object | [
"Loads",
"the",
"context",
"from",
"the",
"seneca",
"transaction",
"ID",
"."
] | 1e0c8d36c5be4b661b062754c01f064de47873c4 | https://github.com/edappy/seneca-context/blob/1e0c8d36c5be4b661b062754c01f064de47873c4/index.js#L17-L34 | train |
edappy/seneca-context | index.js | setContext | function setContext(seneca, context) {
seneca.fixedargs.tx$ = URLSafeBase64.encode(new Buffer(JSON.stringify(context)));
seneca.fixedargs.context$ = context;
debug('context saved', seneca.fixedargs.tx$, context);
} | javascript | function setContext(seneca, context) {
seneca.fixedargs.tx$ = URLSafeBase64.encode(new Buffer(JSON.stringify(context)));
seneca.fixedargs.context$ = context;
debug('context saved', seneca.fixedargs.tx$, context);
} | [
"function",
"setContext",
"(",
"seneca",
",",
"context",
")",
"{",
"seneca",
".",
"fixedargs",
".",
"tx$",
"=",
"URLSafeBase64",
".",
"encode",
"(",
"new",
"Buffer",
"(",
"JSON",
".",
"stringify",
"(",
"context",
")",
")",
")",
";",
"seneca",
".",
"fix... | Saves the specified context inside the seneca transaction ID.
@param {seneca} seneca The seneca object, which is the context of a running action.
@param {Object} context A context object | [
"Saves",
"the",
"specified",
"context",
"inside",
"the",
"seneca",
"transaction",
"ID",
"."
] | 1e0c8d36c5be4b661b062754c01f064de47873c4 | https://github.com/edappy/seneca-context/blob/1e0c8d36c5be4b661b062754c01f064de47873c4/index.js#L42-L46 | train |
cfpb/AtomicComponent | src/utilities/transition/BaseTransition.js | setElement | function setElement( targetElement ) {
// If the element has already been set,
// clear the transition classes from the old element.
if ( _dom ) {
remove();
animateOn();
}
_dom = targetElement;
_dom.classList.add( _classes.BASE_CLASS );
_transitionEndEvent = _getTransitionEndEven... | javascript | function setElement( targetElement ) {
// If the element has already been set,
// clear the transition classes from the old element.
if ( _dom ) {
remove();
animateOn();
}
_dom = targetElement;
_dom.classList.add( _classes.BASE_CLASS );
_transitionEndEvent = _getTransitionEndEven... | [
"function",
"setElement",
"(",
"targetElement",
")",
"{",
"// If the element has already been set,",
"// clear the transition classes from the old element.",
"if",
"(",
"_dom",
")",
"{",
"remove",
"(",
")",
";",
"animateOn",
"(",
")",
";",
"}",
"_dom",
"=",
"targetEle... | Set the HTML element target of this transition.
@param {HTMLNode} targetElement - The target of the transition. | [
"Set",
"the",
"HTML",
"element",
"target",
"of",
"this",
"transition",
"."
] | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/transition/BaseTransition.js#L47-L57 | train |
cfpb/AtomicComponent | src/utilities/transition/BaseTransition.js | halt | function halt() {
if ( !_isAnimating ) { return; }
_dom.style.webkitTransitionDuration = '0';
_dom.style.mozTransitionDuration = '0';
_dom.style.oTransitionDuration = '0';
_dom.style.transitionDuration = '0';
_dom.removeEventListener( _transitionEndEvent,
_transitio... | javascript | function halt() {
if ( !_isAnimating ) { return; }
_dom.style.webkitTransitionDuration = '0';
_dom.style.mozTransitionDuration = '0';
_dom.style.oTransitionDuration = '0';
_dom.style.transitionDuration = '0';
_dom.removeEventListener( _transitionEndEvent,
_transitio... | [
"function",
"halt",
"(",
")",
"{",
"if",
"(",
"!",
"_isAnimating",
")",
"{",
"return",
";",
"}",
"_dom",
".",
"style",
".",
"webkitTransitionDuration",
"=",
"'0'",
";",
"_dom",
".",
"style",
".",
"mozTransitionDuration",
"=",
"'0'",
";",
"_dom",
".",
"... | Halt an in-progress animation and call the complete event immediately. | [
"Halt",
"an",
"in",
"-",
"progress",
"animation",
"and",
"call",
"the",
"complete",
"event",
"immediately",
"."
] | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/transition/BaseTransition.js#L93-L106 | train |
cfpb/AtomicComponent | src/utilities/transition/BaseTransition.js | _addEventListener | function _addEventListener() {
_isAnimating = true;
// If transition is not supported, call handler directly (IE9/OperaMini).
if ( _transitionEndEvent ) {
_dom.addEventListener( _transitionEndEvent,
_transitionCompleteBinded );
this.trigger( BaseTransition.BEGIN_EVEN... | javascript | function _addEventListener() {
_isAnimating = true;
// If transition is not supported, call handler directly (IE9/OperaMini).
if ( _transitionEndEvent ) {
_dom.addEventListener( _transitionEndEvent,
_transitionCompleteBinded );
this.trigger( BaseTransition.BEGIN_EVEN... | [
"function",
"_addEventListener",
"(",
")",
"{",
"_isAnimating",
"=",
"true",
";",
"// If transition is not supported, call handler directly (IE9/OperaMini).",
"if",
"(",
"_transitionEndEvent",
")",
"{",
"_dom",
".",
"addEventListener",
"(",
"_transitionEndEvent",
",",
"_tra... | Add an event listener to the transition, or call the transition
complete handler immediately if transition not supported. | [
"Add",
"an",
"event",
"listener",
"to",
"the",
"transition",
"or",
"call",
"the",
"transition",
"complete",
"handler",
"immediately",
"if",
"transition",
"not",
"supported",
"."
] | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/transition/BaseTransition.js#L112-L123 | train |
cfpb/AtomicComponent | src/utilities/transition/BaseTransition.js | _flush | function _flush() {
for ( const prop in _classes ) {
if ( _classes.hasOwnProperty( prop ) &&
_classes[prop] !== _classes.BASE_CLASS &&
_dom.classList.contains( _classes[prop] ) ) {
_dom.classList.remove( _classes[prop] );
}
}
} | javascript | function _flush() {
for ( const prop in _classes ) {
if ( _classes.hasOwnProperty( prop ) &&
_classes[prop] !== _classes.BASE_CLASS &&
_dom.classList.contains( _classes[prop] ) ) {
_dom.classList.remove( _classes[prop] );
}
}
} | [
"function",
"_flush",
"(",
")",
"{",
"for",
"(",
"const",
"prop",
"in",
"_classes",
")",
"{",
"if",
"(",
"_classes",
".",
"hasOwnProperty",
"(",
"prop",
")",
"&&",
"_classes",
"[",
"prop",
"]",
"!==",
"_classes",
".",
"BASE_CLASS",
"&&",
"_dom",
".",
... | Search for and remove initial BaseTransition classes that have
already been applied to this BaseTransition's target element. | [
"Search",
"for",
"and",
"remove",
"initial",
"BaseTransition",
"classes",
"that",
"have",
"already",
"been",
"applied",
"to",
"this",
"BaseTransition",
"s",
"target",
"element",
"."
] | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/transition/BaseTransition.js#L145-L153 | train |
cfpb/AtomicComponent | src/utilities/transition/BaseTransition.js | remove | function remove() {
if ( _dom ) {
halt();
_dom.classList.remove( _classes.BASE_CLASS );
_flush();
return true;
}
return false;
} | javascript | function remove() {
if ( _dom ) {
halt();
_dom.classList.remove( _classes.BASE_CLASS );
_flush();
return true;
}
return false;
} | [
"function",
"remove",
"(",
")",
"{",
"if",
"(",
"_dom",
")",
"{",
"halt",
"(",
")",
";",
"_dom",
".",
"classList",
".",
"remove",
"(",
"_classes",
".",
"BASE_CLASS",
")",
";",
"_flush",
"(",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
... | Remove all transition classes, if transition is initialized.
@returns {boolean}
True, if the element's CSS classes were touched, false otherwise. | [
"Remove",
"all",
"transition",
"classes",
"if",
"transition",
"is",
"initialized",
"."
] | f45d7ded6687672c8b701c9910ddfe90c7ede742 | https://github.com/cfpb/AtomicComponent/blob/f45d7ded6687672c8b701c9910ddfe90c7ede742/src/utilities/transition/BaseTransition.js#L160-L169 | train |
henrytseng/angular-state-router | src/services/queue-handler.js | function(handler, priority) {
if(handler && handler.constructor === Array) {
handler.forEach(function(layer) {
layer.priority = typeof layer.priority === 'undefined' ? 1 : layer.priority;
});
_list = _list.concat(handler);
} else {
handler.priority = p... | javascript | function(handler, priority) {
if(handler && handler.constructor === Array) {
handler.forEach(function(layer) {
layer.priority = typeof layer.priority === 'undefined' ? 1 : layer.priority;
});
_list = _list.concat(handler);
} else {
handler.priority = p... | [
"function",
"(",
"handler",
",",
"priority",
")",
"{",
"if",
"(",
"handler",
"&&",
"handler",
".",
"constructor",
"===",
"Array",
")",
"{",
"handler",
".",
"forEach",
"(",
"function",
"(",
"layer",
")",
"{",
"layer",
".",
"priority",
"=",
"typeof",
"la... | Add a handler
@param {Mixed} handler A Function or an Array of Functions to add to the queue
@return {Queue} Itself; chainable | [
"Add",
"a",
"handler"
] | 5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b | https://github.com/henrytseng/angular-state-router/blob/5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b/src/services/queue-handler.js#L20-L31 | train | |
henrytseng/angular-state-router | src/services/queue-handler.js | function(callback) {
var nextHandler;
var executionList = _list.slice(0).sort(function(a, b) {
return Math.max(-1, Math.min(1, b.priority - a.priority));
});
nextHandler = function() {
$rootScope.$evalAsync(function() {
var handler = executionList.shift()... | javascript | function(callback) {
var nextHandler;
var executionList = _list.slice(0).sort(function(a, b) {
return Math.max(-1, Math.min(1, b.priority - a.priority));
});
nextHandler = function() {
$rootScope.$evalAsync(function() {
var handler = executionList.shift()... | [
"function",
"(",
"callback",
")",
"{",
"var",
"nextHandler",
";",
"var",
"executionList",
"=",
"_list",
".",
"slice",
"(",
"0",
")",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"Math",
".",
"max",
"(",
"-",
"1",
",",
"Ma... | Begin execution and trigger callback at the end
@param {Function} callback A callback, function(err)
@return {Queue} Itself; chainable | [
"Begin",
"execution",
"and",
"trigger",
"callback",
"at",
"the",
"end"
] | 5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b | https://github.com/henrytseng/angular-state-router/blob/5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b/src/services/queue-handler.js#L50-L82 | train | |
glaunay/ms-jobmanager | build/index.js | isSpecs | function isSpecs(opt) {
//logger.debug('???');
//logger.debug(`${opt.cacheDir}`);
//let b:any = opt.cacheDir instanceof(String)
if (!path.isAbsolute(opt.cacheDir)) {
logger.error('cacheDir parameter must be an absolute path');
return false;
}
if ('cacheDir' in opt && 'tcp' in opt... | javascript | function isSpecs(opt) {
//logger.debug('???');
//logger.debug(`${opt.cacheDir}`);
//let b:any = opt.cacheDir instanceof(String)
if (!path.isAbsolute(opt.cacheDir)) {
logger.error('cacheDir parameter must be an absolute path');
return false;
}
if ('cacheDir' in opt && 'tcp' in opt... | [
"function",
"isSpecs",
"(",
"opt",
")",
"{",
"//logger.debug('???');",
"//logger.debug(`${opt.cacheDir}`);",
"//let b:any = opt.cacheDir instanceof(String)",
"if",
"(",
"!",
"path",
".",
"isAbsolute",
"(",
"opt",
".",
"cacheDir",
")",
")",
"{",
"logger",
".",
"error",... | VR change typeguard to warehouse | [
"VR",
"change",
"typeguard",
"to",
"warehouse"
] | 997d4fb25fd1d2b41acfae1dd576b33f2c92bd15 | https://github.com/glaunay/ms-jobmanager/blob/997d4fb25fd1d2b41acfae1dd576b33f2c92bd15/build/index.js#L50-L63 | train |
glaunay/ms-jobmanager | build/index.js | pushMS | function pushMS(data, socket) {
logger.debug(`newJob Packet arrived w/ ${util.format(data)}`);
logger.silly(` Memory size vs nWorker :: ${liveMemory.size()} <<>> ${nWorker}`);
if (liveMemory.size("notBound") >= nWorker) {
logger.debug("must refuse packet, max pool size reached");
jmServer.bo... | javascript | function pushMS(data, socket) {
logger.debug(`newJob Packet arrived w/ ${util.format(data)}`);
logger.silly(` Memory size vs nWorker :: ${liveMemory.size()} <<>> ${nWorker}`);
if (liveMemory.size("notBound") >= nWorker) {
logger.debug("must refuse packet, max pool size reached");
jmServer.bo... | [
"function",
"pushMS",
"(",
"data",
",",
"socket",
")",
"{",
"logger",
".",
"debug",
"(",
"`",
"${",
"util",
".",
"format",
"(",
"data",
")",
"}",
"`",
")",
";",
"logger",
".",
"silly",
"(",
"`",
"${",
"liveMemory",
".",
"size",
"(",
")",
"}",
"... | New job packet arrived on MS socket, 1st arg is streamMap, 2nd the socket | [
"New",
"job",
"packet",
"arrived",
"on",
"MS",
"socket",
"1st",
"arg",
"is",
"streamMap",
"2nd",
"the",
"socket"
] | 997d4fb25fd1d2b41acfae1dd576b33f2c92bd15 | https://github.com/glaunay/ms-jobmanager/blob/997d4fb25fd1d2b41acfae1dd576b33f2c92bd15/build/index.js#L271-L289 | train |
jrmerz/node-ckan | index.js | addFileResource | function addFileResource(cmd, file, params, callback) {
if( !file ) return callback({error:true,message:"no file provided"});
if( !fs.existsSync(file) ) return callback({error:true,message:"no file found: "+file});
if( !fs.statSync(file).isFile() ) return callback({error:true,message:"not a file: "+file});
... | javascript | function addFileResource(cmd, file, params, callback) {
if( !file ) return callback({error:true,message:"no file provided"});
if( !fs.existsSync(file) ) return callback({error:true,message:"no file found: "+file});
if( !fs.statSync(file).isFile() ) return callback({error:true,message:"not a file: "+file});
... | [
"function",
"addFileResource",
"(",
"cmd",
",",
"file",
",",
"params",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"file",
")",
"return",
"callback",
"(",
"{",
"error",
":",
"true",
",",
"message",
":",
"\"no file provided\"",
"}",
")",
";",
"if",
"(",
... | todo, check for read access | [
"todo",
"check",
"for",
"read",
"access"
] | 55f6bb1ece7f57ccd5ba57be7888e4d3941bc659 | https://github.com/jrmerz/node-ckan/blob/55f6bb1ece7f57ccd5ba57be7888e4d3941bc659/index.js#L112-L154 | train |
rBurgett/simple-sort | src/main.js | function(locale) {
this.intCol = (Intl && Intl.Collator) ? new Intl.Collator(locale) : new CollatorPolyfill(locale);
} | javascript | function(locale) {
this.intCol = (Intl && Intl.Collator) ? new Intl.Collator(locale) : new CollatorPolyfill(locale);
} | [
"function",
"(",
"locale",
")",
"{",
"this",
".",
"intCol",
"=",
"(",
"Intl",
"&&",
"Intl",
".",
"Collator",
")",
"?",
"new",
"Intl",
".",
"Collator",
"(",
"locale",
")",
":",
"new",
"CollatorPolyfill",
"(",
"locale",
")",
";",
"}"
] | Constructs a sorter instance.
@constructor Sorter
@param {string} [locale] - the locale to sort by (e.g. 'en-US') | [
"Constructs",
"a",
"sorter",
"instance",
"."
] | 1c27912b3dce1e581b2817dbe599fdfe7b8d1781 | https://github.com/rBurgett/simple-sort/blob/1c27912b3dce1e581b2817dbe599fdfe7b8d1781/src/main.js#L13-L15 | train | |
ryb73/dealers-choice-meta | packages/server/lib/game-managers/choice-provider/handle-bidding.js | giveAnswer | function giveAnswer(answeringPlayer, answer) {
if(answeringPlayer === seller) return;
if(answer <= currentBid) return;
buyer = answeringPlayer;
currentBid = answer;
resetTimer();
notify(false);
} | javascript | function giveAnswer(answeringPlayer, answer) {
if(answeringPlayer === seller) return;
if(answer <= currentBid) return;
buyer = answeringPlayer;
currentBid = answer;
resetTimer();
notify(false);
} | [
"function",
"giveAnswer",
"(",
"answeringPlayer",
",",
"answer",
")",
"{",
"if",
"(",
"answeringPlayer",
"===",
"seller",
")",
"return",
";",
"if",
"(",
"answer",
"<=",
"currentBid",
")",
"return",
";",
"buyer",
"=",
"answeringPlayer",
";",
"currentBid",
"="... | answer is the bid amount | [
"answer",
"is",
"the",
"bid",
"amount"
] | 4632e8897c832b01d944a340cf87d5c807809925 | https://github.com/ryb73/dealers-choice-meta/blob/4632e8897c832b01d944a340cf87d5c807809925/packages/server/lib/game-managers/choice-provider/handle-bidding.js#L74-L83 | train |
sham-ui/sham-ui | src/options/decorator.js | hoistingOptions | function hoistingOptions( target ) {
if ( !target.hasOwnProperty( '_options' ) ) {
let options;
if ( undefined === target._options ) {
options = {};
} else {
// Create copy with descriptors
options = Object.create(
null,
Ob... | javascript | function hoistingOptions( target ) {
if ( !target.hasOwnProperty( '_options' ) ) {
let options;
if ( undefined === target._options ) {
options = {};
} else {
// Create copy with descriptors
options = Object.create(
null,
Ob... | [
"function",
"hoistingOptions",
"(",
"target",
")",
"{",
"if",
"(",
"!",
"target",
".",
"hasOwnProperty",
"(",
"'_options'",
")",
")",
"{",
"let",
"options",
";",
"if",
"(",
"undefined",
"===",
"target",
".",
"_options",
")",
"{",
"options",
"=",
"{",
"... | Hoisting options in prototype chain
@param {Object} target | [
"Hoisting",
"options",
"in",
"prototype",
"chain"
] | d4a1a43deac246575557c5cca86fc5a7e7a1dd9f | https://github.com/sham-ui/sham-ui/blob/d4a1a43deac246575557c5cca86fc5a7e7a1dd9f/src/options/decorator.js#L5-L24 | train |
mikolalysenko/overlay-pslg | overlay-pslg.js | markCells | function markCells(cells, adj, edges) {
//Initialize active/next queues and flags
var flags = new Array(cells.length)
var constraint = new Array(3*cells.length)
for(var i=0; i<3*cells.length; ++i) {
constraint[i] = false
}
var active = []
var next = []
for(var i=0; i<cells.length; ++i) {
var ... | javascript | function markCells(cells, adj, edges) {
//Initialize active/next queues and flags
var flags = new Array(cells.length)
var constraint = new Array(3*cells.length)
for(var i=0; i<3*cells.length; ++i) {
constraint[i] = false
}
var active = []
var next = []
for(var i=0; i<cells.length; ++i) {
var ... | [
"function",
"markCells",
"(",
"cells",
",",
"adj",
",",
"edges",
")",
"{",
"//Initialize active/next queues and flags",
"var",
"flags",
"=",
"new",
"Array",
"(",
"cells",
".",
"length",
")",
"var",
"constraint",
"=",
"new",
"Array",
"(",
"3",
"*",
"cells",
... | Classify all cells within boundary | [
"Classify",
"all",
"cells",
"within",
"boundary"
] | 7f6490b5c44ecf2078dc17cbce252a190b734cbc | https://github.com/mikolalysenko/overlay-pslg/blob/7f6490b5c44ecf2078dc17cbce252a190b734cbc/overlay-pslg.js#L108-L169 | train |
writetome51/array-has | dist/privy/arrayHasAny.js | arrayHasAny | function arrayHasAny(values, array) {
error_if_not_array_1.errorIfNotArray(values);
var i = -1;
while (++i < values.length) {
if (arrayHas_1.arrayHas(values[i], array))
return true;
}
return false;
} | javascript | function arrayHasAny(values, array) {
error_if_not_array_1.errorIfNotArray(values);
var i = -1;
while (++i < values.length) {
if (arrayHas_1.arrayHas(values[i], array))
return true;
}
return false;
} | [
"function",
"arrayHasAny",
"(",
"values",
",",
"array",
")",
"{",
"error_if_not_array_1",
".",
"errorIfNotArray",
"(",
"values",
")",
";",
"var",
"i",
"=",
"-",
"1",
";",
"while",
"(",
"++",
"i",
"<",
"values",
".",
"length",
")",
"{",
"if",
"(",
"ar... | values cannot contain object. | [
"values",
"cannot",
"contain",
"object",
"."
] | 8ced3fda5818940b814bbcdc37e03c65f285a965 | https://github.com/writetome51/array-has/blob/8ced3fda5818940b814bbcdc37e03c65f285a965/dist/privy/arrayHasAny.js#L6-L14 | train |
RainBirdAi/rainbird-linter | report.js | setJSHint | function setJSHint(path, done) {
var opts = JSON.parse(fs.readFileSync(path, 'utf8'));
jsHintOptions.config = opts;
done();
} | javascript | function setJSHint(path, done) {
var opts = JSON.parse(fs.readFileSync(path, 'utf8'));
jsHintOptions.config = opts;
done();
} | [
"function",
"setJSHint",
"(",
"path",
",",
"done",
")",
"{",
"var",
"opts",
"=",
"JSON",
".",
"parse",
"(",
"fs",
".",
"readFileSync",
"(",
"path",
",",
"'utf8'",
")",
")",
";",
"jsHintOptions",
".",
"config",
"=",
"opts",
";",
"done",
"(",
")",
";... | Plato uses the `jshintrc` as is, whereas JSHint-Build needs the options inserted into its own options. | [
"Plato",
"uses",
"the",
"jshintrc",
"as",
"is",
"whereas",
"JSHint",
"-",
"Build",
"needs",
"the",
"options",
"inserted",
"into",
"its",
"own",
"options",
"."
] | 2831a0286bfe3fb956b5188f0508752c6d16a4de | https://github.com/RainBirdAi/rainbird-linter/blob/2831a0286bfe3fb956b5188f0508752c6d16a4de/report.js#L50-L55 | train |
RainBirdAi/rainbird-linter | report.js | checkJSHint | function checkJSHint(done) {
if(!options.jshint) {
options.jshint = path.join(__dirname, '.jshintrc');
}
checkPath(options.jshint, setJSHint, done);
} | javascript | function checkJSHint(done) {
if(!options.jshint) {
options.jshint = path.join(__dirname, '.jshintrc');
}
checkPath(options.jshint, setJSHint, done);
} | [
"function",
"checkJSHint",
"(",
"done",
")",
"{",
"if",
"(",
"!",
"options",
".",
"jshint",
")",
"{",
"options",
".",
"jshint",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'.jshintrc'",
")",
";",
"}",
"checkPath",
"(",
"options",
".",
"jshint",
... | The default `jshintrc` from the linter package can be overridden with the `jshint` option. The provided file is checked to ensure it exists before it's used. | [
"The",
"default",
"jshintrc",
"from",
"the",
"linter",
"package",
"can",
"be",
"overridden",
"with",
"the",
"jshint",
"option",
".",
"The",
"provided",
"file",
"is",
"checked",
"to",
"ensure",
"it",
"exists",
"before",
"it",
"s",
"used",
"."
] | 2831a0286bfe3fb956b5188f0508752c6d16a4de | https://github.com/RainBirdAi/rainbird-linter/blob/2831a0286bfe3fb956b5188f0508752c6d16a4de/report.js#L61-L67 | train |
RainBirdAi/rainbird-linter | report.js | setFilesets | function setFilesets(path, done) {
var config = JSON.parse(fs.readFileSync(path, 'utf8'));
/* jshint sub: true */
var includeFiles = config['includeFiles'];
var excludeFiles = config['excludeFiles'];
var filterFiles = config['lintOnly'];
/* jshint sub: false */
if (filterFiles && !Array.is... | javascript | function setFilesets(path, done) {
var config = JSON.parse(fs.readFileSync(path, 'utf8'));
/* jshint sub: true */
var includeFiles = config['includeFiles'];
var excludeFiles = config['excludeFiles'];
var filterFiles = config['lintOnly'];
/* jshint sub: false */
if (filterFiles && !Array.is... | [
"function",
"setFilesets",
"(",
"path",
",",
"done",
")",
"{",
"var",
"config",
"=",
"JSON",
".",
"parse",
"(",
"fs",
".",
"readFileSync",
"(",
"path",
",",
"'utf8'",
")",
")",
";",
"/* jshint sub: true */",
"var",
"includeFiles",
"=",
"config",
"[",
"'i... | Set the filesets from those defined in the provided configuration file. If a given fileset isn't defined then a warning will be output. The `lintOnly` fileset is an optional fileset that will be excluded from the Plato fileset. | [
"Set",
"the",
"filesets",
"from",
"those",
"defined",
"in",
"the",
"provided",
"configuration",
"file",
".",
"If",
"a",
"given",
"fileset",
"isn",
"t",
"defined",
"then",
"a",
"warning",
"will",
"be",
"output",
".",
"The",
"lintOnly",
"fileset",
"is",
"an"... | 2831a0286bfe3fb956b5188f0508752c6d16a4de | https://github.com/RainBirdAi/rainbird-linter/blob/2831a0286bfe3fb956b5188f0508752c6d16a4de/report.js#L73-L100 | train |
RainBirdAi/rainbird-linter | report.js | runReports | function runReports(err) {
if (err) { console.log(chalk.red('Error running reports: %s'), err); }
var excludes = filesets.platoExcludes();
if (excludes) {
platoOptions.exclude = excludes;
}
jsHintOptions.ignore = filesets.jshintExcludes();
jsHintOptions.reporter = reporter.reporter;
... | javascript | function runReports(err) {
if (err) { console.log(chalk.red('Error running reports: %s'), err); }
var excludes = filesets.platoExcludes();
if (excludes) {
platoOptions.exclude = excludes;
}
jsHintOptions.ignore = filesets.jshintExcludes();
jsHintOptions.reporter = reporter.reporter;
... | [
"function",
"runReports",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"chalk",
".",
"red",
"(",
"'Error running reports: %s'",
")",
",",
"err",
")",
";",
"}",
"var",
"excludes",
"=",
"filesets",
".",
"platoExcludes",
"... | Run the actual reports. The plato reports are run first, then the JSHint report. The output is annotated with headers and details on where the reports are stored. | [
"Run",
"the",
"actual",
"reports",
".",
"The",
"plato",
"reports",
"are",
"run",
"first",
"then",
"the",
"JSHint",
"report",
".",
"The",
"output",
"is",
"annotated",
"with",
"headers",
"and",
"details",
"on",
"where",
"the",
"reports",
"are",
"stored",
"."... | 2831a0286bfe3fb956b5188f0508752c6d16a4de | https://github.com/RainBirdAi/rainbird-linter/blob/2831a0286bfe3fb956b5188f0508752c6d16a4de/report.js#L120-L145 | train |
gabmontes/node-coindesk-api | lib/index.js | getHistoricalClosePrices | function getHistoricalClosePrices(options = {}) {
const { index, currency, start, end, yesterday } = options
return request(`/historical/close.json`, {
index,
currency,
start: start && end && formatDate(start) || undefined,
end: start && end && formatDate(end) || undefined,
for: yesterday ? 'ye... | javascript | function getHistoricalClosePrices(options = {}) {
const { index, currency, start, end, yesterday } = options
return request(`/historical/close.json`, {
index,
currency,
start: start && end && formatDate(start) || undefined,
end: start && end && formatDate(end) || undefined,
for: yesterday ? 'ye... | [
"function",
"getHistoricalClosePrices",
"(",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"{",
"index",
",",
"currency",
",",
"start",
",",
"end",
",",
"yesterday",
"}",
"=",
"options",
"return",
"request",
"(",
"`",
"`",
",",
"{",
"index",
",",
"curre... | memoize 1' TTL 15" | [
"memoize",
"1",
"TTL",
"15"
] | 9f7a54c24d6edb493723bf52cd5db54952f62125 | https://github.com/gabmontes/node-coindesk-api/blob/9f7a54c24d6edb493723bf52cd5db54952f62125/lib/index.js#L23-L33 | train |
MiguelCastillo/bit-loader | example/asyncfile/src/fileReader.js | fileReader | function fileReader(moduleMeta) {
// Read file from disk and return a module meta
return pstream(readFile(moduleMeta.path))
.then(function(text) {
return {
source: text
};
}, log2console);
} | javascript | function fileReader(moduleMeta) {
// Read file from disk and return a module meta
return pstream(readFile(moduleMeta.path))
.then(function(text) {
return {
source: text
};
}, log2console);
} | [
"function",
"fileReader",
"(",
"moduleMeta",
")",
"{",
"// Read file from disk and return a module meta",
"return",
"pstream",
"(",
"readFile",
"(",
"moduleMeta",
".",
"path",
")",
")",
".",
"then",
"(",
"function",
"(",
"text",
")",
"{",
"return",
"{",
"source"... | Function that reads file from disk
@param {object} moduleMeta - Module meta with information about the module being loaded | [
"Function",
"that",
"reads",
"file",
"from",
"disk"
] | da9d18952d87014fdb09e7a8320a24cbf1c2b436 | https://github.com/MiguelCastillo/bit-loader/blob/da9d18952d87014fdb09e7a8320a24cbf1c2b436/example/asyncfile/src/fileReader.js#L11-L19 | train |
briancsparks/serverassist | lib/helpers.js | function(guess, filename) {
var ct = guess;
// Someone else just defaulted to octet-stream?
if (!ct || ct === 'application/octet-stream') {
ct = sg.mimeType(filename) || ct;
}
return ct || 'application/octet-stream';
} | javascript | function(guess, filename) {
var ct = guess;
// Someone else just defaulted to octet-stream?
if (!ct || ct === 'application/octet-stream') {
ct = sg.mimeType(filename) || ct;
}
return ct || 'application/octet-stream';
} | [
"function",
"(",
"guess",
",",
"filename",
")",
"{",
"var",
"ct",
"=",
"guess",
";",
"// Someone else just defaulted to octet-stream?",
"if",
"(",
"!",
"ct",
"||",
"ct",
"===",
"'application/octet-stream'",
")",
"{",
"ct",
"=",
"sg",
".",
"mimeType",
"(",
"f... | Returns the Content-Type. | [
"Returns",
"the",
"Content",
"-",
"Type",
"."
] | f966832aae287f502cce53a71f5129b962ada8a3 | https://github.com/briancsparks/serverassist/blob/f966832aae287f502cce53a71f5129b962ada8a3/lib/helpers.js#L222-L231 | train | |
MiguelCastillo/bit-loader | src/module.js | Module | function Module(options) {
options = options || {};
if (types.isString(options)) {
options = {
name: options
};
}
if (!types.isString(options.name) && !types.isString(options.source)) {
throw new TypeError("Must provide a name or source for the module");
}
this.deps = options.deps ? opt... | javascript | function Module(options) {
options = options || {};
if (types.isString(options)) {
options = {
name: options
};
}
if (!types.isString(options.name) && !types.isString(options.source)) {
throw new TypeError("Must provide a name or source for the module");
}
this.deps = options.deps ? opt... | [
"function",
"Module",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"types",
".",
"isString",
"(",
"options",
")",
")",
"{",
"options",
"=",
"{",
"name",
":",
"options",
"}",
";",
"}",
"if",
"(",
"!",
"types... | Intermediate representation of a Module which contains the information that is processed
in the different pipelines in order to generate a Module instance.
@class
@memberof Module
@property {string} id - Module id
@property {string} name - Module name
@property {string[]} deps - Array of module dependencies
@property... | [
"Intermediate",
"representation",
"of",
"a",
"Module",
"which",
"contains",
"the",
"information",
"that",
"is",
"processed",
"in",
"the",
"different",
"pipelines",
"in",
"order",
"to",
"generate",
"a",
"Module",
"instance",
"."
] | da9d18952d87014fdb09e7a8320a24cbf1c2b436 | https://github.com/MiguelCastillo/bit-loader/blob/da9d18952d87014fdb09e7a8320a24cbf1c2b436/src/module.js#L106-L122 | train |
onecommons/base | lib/utils.js | function(doRecentCheck, req, res, next) {
var app = req.app;
var config = app.loadConfig('auth');
var failed = !req.isAuthenticated();
if (!failed && doRecentCheck && !req.session.impersonated) {
//skip recent check if login is impersonated
//note: loginTime maybe a string since sessions are serialized... | javascript | function(doRecentCheck, req, res, next) {
var app = req.app;
var config = app.loadConfig('auth');
var failed = !req.isAuthenticated();
if (!failed && doRecentCheck && !req.session.impersonated) {
//skip recent check if login is impersonated
//note: loginTime maybe a string since sessions are serialized... | [
"function",
"(",
"doRecentCheck",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"app",
"=",
"req",
".",
"app",
";",
"var",
"config",
"=",
"app",
".",
"loadConfig",
"(",
"'auth'",
")",
";",
"var",
"failed",
"=",
"!",
"req",
".",
"isAuthentic... | route middleware to make sure a user is logged in | [
"route",
"middleware",
"to",
"make",
"sure",
"a",
"user",
"is",
"logged",
"in"
] | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/lib/utils.js#L34-L73 | train | |
styonsk/elmongoose | lib/sync.js | function (next) {
// index creation options
var body = {
settings: {
number_of_shards : 3,
number_of_replicas : 2,
analysis: {
// analyzer definitions go here
analyzer: {
... | javascript | function (next) {
// index creation options
var body = {
settings: {
number_of_shards : 3,
number_of_replicas : 2,
analysis: {
// analyzer definitions go here
analyzer: {
... | [
"function",
"(",
"next",
")",
"{",
"// index creation options",
"var",
"body",
"=",
"{",
"settings",
":",
"{",
"number_of_shards",
":",
"3",
",",
"number_of_replicas",
":",
"2",
",",
"analysis",
":",
"{",
"// analyzer definitions go here",
"analyzer",
":",
"{",
... | create an elasticsearch index, versioned with the current timestamp | [
"create",
"an",
"elasticsearch",
"index",
"versioned",
"with",
"the",
"current",
"timestamp"
] | b83f7dd67330c7288e7f17866d3e67f12a2adc1d | https://github.com/styonsk/elmongoose/blob/b83f7dd67330c7288e7f17866d3e67f12a2adc1d/lib/sync.js#L45-L139 | train | |
styonsk/elmongoose | lib/sync.js | function (next) {
self.count().exec(function (err, count) {
if (err) {
return next(err)
}
docsToIndex = count
return next()
})
} | javascript | function (next) {
self.count().exec(function (err, count) {
if (err) {
return next(err)
}
docsToIndex = count
return next()
})
} | [
"function",
"(",
"next",
")",
"{",
"self",
".",
"count",
"(",
")",
".",
"exec",
"(",
"function",
"(",
"err",
",",
"count",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"next",
"(",
"err",
")",
"}",
"docsToIndex",
"=",
"count",
"return",
"next"... | get a count of how many documents we have to index | [
"get",
"a",
"count",
"of",
"how",
"many",
"documents",
"we",
"have",
"to",
"index"
] | b83f7dd67330c7288e7f17866d3e67f12a2adc1d | https://github.com/styonsk/elmongoose/blob/b83f7dd67330c7288e7f17866d3e67f12a2adc1d/lib/sync.js#L141-L151 | train | |
styonsk/elmongoose | lib/sync.js | function (next) {
// if no documents to index, skip population
if (!docsToIndex) {
return next()
}
// stream docs - and upload in batches of size BATCH_SIZE
var docStream = self.find().stream()
// elasticsearch commands to perform... | javascript | function (next) {
// if no documents to index, skip population
if (!docsToIndex) {
return next()
}
// stream docs - and upload in batches of size BATCH_SIZE
var docStream = self.find().stream()
// elasticsearch commands to perform... | [
"function",
"(",
"next",
")",
"{",
"// if no documents to index, skip population",
"if",
"(",
"!",
"docsToIndex",
")",
"{",
"return",
"next",
"(",
")",
"}",
"// stream docs - and upload in batches of size BATCH_SIZE",
"var",
"docStream",
"=",
"self",
".",
"find",
"(",... | populate the newly created index with this collection's documents | [
"populate",
"the",
"newly",
"created",
"index",
"with",
"this",
"collection",
"s",
"documents"
] | b83f7dd67330c7288e7f17866d3e67f12a2adc1d | https://github.com/styonsk/elmongoose/blob/b83f7dd67330c7288e7f17866d3e67f12a2adc1d/lib/sync.js#L153-L227 | train | |
styonsk/elmongoose | lib/sync.js | function (next) {
var reqOpts = {
method: 'GET',
url: helpers.makeAliasUri(options)
}
if(options.auth) {
reqOpts.auth = {
user: options.auth.user,
pass: options.auth.password,
... | javascript | function (next) {
var reqOpts = {
method: 'GET',
url: helpers.makeAliasUri(options)
}
if(options.auth) {
reqOpts.auth = {
user: options.auth.user,
pass: options.auth.password,
... | [
"function",
"(",
"next",
")",
"{",
"var",
"reqOpts",
"=",
"{",
"method",
":",
"'GET'",
",",
"url",
":",
"helpers",
".",
"makeAliasUri",
"(",
"options",
")",
"}",
"if",
"(",
"options",
".",
"auth",
")",
"{",
"reqOpts",
".",
"auth",
"=",
"{",
"user",... | atomically replace existing aliases for this collection with the new one we just created | [
"atomically",
"replace",
"existing",
"aliases",
"for",
"this",
"collection",
"with",
"the",
"new",
"one",
"we",
"just",
"created"
] | b83f7dd67330c7288e7f17866d3e67f12a2adc1d | https://github.com/styonsk/elmongoose/blob/b83f7dd67330c7288e7f17866d3e67f12a2adc1d/lib/sync.js#L259-L345 | train | |
ryb73/dealers-choice-meta | packages/server/lib/game-managers/pending-game-manager.js | addPlayer | function addPlayer(userId, callbacks) {
let player = factory.addPlayer();
if(!player) return null;
self._callbacks.set(player, callbacks);
// If the game didn't have an owner, it does now
// This should only happen when the game is first created
// and the initial playe... | javascript | function addPlayer(userId, callbacks) {
let player = factory.addPlayer();
if(!player) return null;
self._callbacks.set(player, callbacks);
// If the game didn't have an owner, it does now
// This should only happen when the game is first created
// and the initial playe... | [
"function",
"addPlayer",
"(",
"userId",
",",
"callbacks",
")",
"{",
"let",
"player",
"=",
"factory",
".",
"addPlayer",
"(",
")",
";",
"if",
"(",
"!",
"player",
")",
"return",
"null",
";",
"self",
".",
"_callbacks",
".",
"set",
"(",
"player",
",",
"ca... | callback is used to send messages to the players in the game | [
"callback",
"is",
"used",
"to",
"send",
"messages",
"to",
"the",
"players",
"in",
"the",
"game"
] | 4632e8897c832b01d944a340cf87d5c807809925 | https://github.com/ryb73/dealers-choice-meta/blob/4632e8897c832b01d944a340cf87d5c807809925/packages/server/lib/game-managers/pending-game-manager.js#L39-L54 | train |
uvworkspace/uvwlib | lib/utils/slice.js | slice | function slice (args, start, end) {
var len = args.length;
start = start > 0 ? start : 0;
end = end >= 0 && end < len ? end : len;
var n = end - start;
if (n <= 0) return [];
var ret = new Array(n);
for (var i = 0; i < n; ++i) {
ret[i] = args[i + start];
}
return ret;
} | javascript | function slice (args, start, end) {
var len = args.length;
start = start > 0 ? start : 0;
end = end >= 0 && end < len ? end : len;
var n = end - start;
if (n <= 0) return [];
var ret = new Array(n);
for (var i = 0; i < n; ++i) {
ret[i] = args[i + start];
}
return ret;
} | [
"function",
"slice",
"(",
"args",
",",
"start",
",",
"end",
")",
"{",
"var",
"len",
"=",
"args",
".",
"length",
";",
"start",
"=",
"start",
">",
"0",
"?",
"start",
":",
"0",
";",
"end",
"=",
"end",
">=",
"0",
"&&",
"end",
"<",
"len",
"?",
"en... | force copying to avoid leaking arguments | [
"force",
"copying",
"to",
"avoid",
"leaking",
"arguments"
] | ef1893e0c9cdcaa321186dd5dc17fc2c9bd9e641 | https://github.com/uvworkspace/uvwlib/blob/ef1893e0c9cdcaa321186dd5dc17fc2c9bd9e641/lib/utils/slice.js#L4-L17 | train |
aheckmann/mongodb-schema-miner | lib/index.js | read | function read (stream, opts, db, cb) {
var schema = new exports.Schema;
if (opts.onType) {
schema.onType = opts.onType;
}
stream.once('error', function (err) {
debug('aborting with error: ' + err);
db.close(cb.bind(err));
});
stream.on('data', function (doc) {
var err = schema.consume(doc... | javascript | function read (stream, opts, db, cb) {
var schema = new exports.Schema;
if (opts.onType) {
schema.onType = opts.onType;
}
stream.once('error', function (err) {
debug('aborting with error: ' + err);
db.close(cb.bind(err));
});
stream.on('data', function (doc) {
var err = schema.consume(doc... | [
"function",
"read",
"(",
"stream",
",",
"opts",
",",
"db",
",",
"cb",
")",
"{",
"var",
"schema",
"=",
"new",
"exports",
".",
"Schema",
";",
"if",
"(",
"opts",
".",
"onType",
")",
"{",
"schema",
".",
"onType",
"=",
"opts",
".",
"onType",
";",
"}",... | process documents from the stream | [
"process",
"documents",
"from",
"the",
"stream"
] | c56220bd527d82f6a1712f90b45f10828290961f | https://github.com/aheckmann/mongodb-schema-miner/blob/c56220bd527d82f6a1712f90b45f10828290961f/lib/index.js#L38-L62 | train |
aheckmann/mongodb-schema-miner | lib/index.js | abort | function abort (err, stream, db, cb) {
debug('aborting with error: ' + err);
stream.destroy();
db.close(function () {
cb(err);
})
} | javascript | function abort (err, stream, db, cb) {
debug('aborting with error: ' + err);
stream.destroy();
db.close(function () {
cb(err);
})
} | [
"function",
"abort",
"(",
"err",
",",
"stream",
",",
"db",
",",
"cb",
")",
"{",
"debug",
"(",
"'aborting with error: '",
"+",
"err",
")",
";",
"stream",
".",
"destroy",
"(",
")",
";",
"db",
".",
"close",
"(",
"function",
"(",
")",
"{",
"cb",
"(",
... | abort the stream | [
"abort",
"the",
"stream"
] | c56220bd527d82f6a1712f90b45f10828290961f | https://github.com/aheckmann/mongodb-schema-miner/blob/c56220bd527d82f6a1712f90b45f10828290961f/lib/index.js#L68-L74 | train |
aheckmann/mongodb-schema-miner | lib/index.js | validate | function validate (uri, collection, cb) {
if ('function' != typeof cb) {
throw new TypeError('cb must be a function');
}
if ('string' != typeof collection) {
throw new TypeError('collection must be a string');
}
if ('string' != typeof uri) {
throw new TypeError('uri must be a string');
}
} | javascript | function validate (uri, collection, cb) {
if ('function' != typeof cb) {
throw new TypeError('cb must be a function');
}
if ('string' != typeof collection) {
throw new TypeError('collection must be a string');
}
if ('string' != typeof uri) {
throw new TypeError('uri must be a string');
}
} | [
"function",
"validate",
"(",
"uri",
",",
"collection",
",",
"cb",
")",
"{",
"if",
"(",
"'function'",
"!=",
"typeof",
"cb",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'cb must be a function'",
")",
";",
"}",
"if",
"(",
"'string'",
"!=",
"typeof",
"colle... | validate "miner" arguments | [
"validate",
"miner",
"arguments"
] | c56220bd527d82f6a1712f90b45f10828290961f | https://github.com/aheckmann/mongodb-schema-miner/blob/c56220bd527d82f6a1712f90b45f10828290961f/lib/index.js#L80-L92 | train |
gavagai-corp/gavagai-node | lib/tonality.js | function (texts, options, callback) {
if (typeof(options) === 'function') {
callback = options;
options = {};
}
if (Array.isArray(texts)) {
texts = texts.map(function (text, i) {
return textObj(text, i);
});
} else if (typ... | javascript | function (texts, options, callback) {
if (typeof(options) === 'function') {
callback = options;
options = {};
}
if (Array.isArray(texts)) {
texts = texts.map(function (text, i) {
return textObj(text, i);
});
} else if (typ... | [
"function",
"(",
"texts",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"(",
"options",
")",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"... | Given a set of documents, return their tonality based on lexical analysis in multiple dimensions.
The tonality is calculated on a document level, that is, the response will return the tonality of
each document.
@param {Array|string} texts - an array of document objects or strings to be analyzed.
@param {object} [optio... | [
"Given",
"a",
"set",
"of",
"documents",
"return",
"their",
"tonality",
"based",
"on",
"lexical",
"analysis",
"in",
"multiple",
"dimensions",
".",
"The",
"tonality",
"is",
"calculated",
"on",
"a",
"document",
"level",
"that",
"is",
"the",
"response",
"will",
... | d3f5e3f59f25d9c3ebbf6fd3a3ecb70b3a4047eb | https://github.com/gavagai-corp/gavagai-node/blob/d3f5e3f59f25d9c3ebbf6fd3a3ecb70b3a4047eb/lib/tonality.js#L18-L51 | train | |
theboyWhoCriedWoolf/transition-manager | example/example.js | clickRegion | function clickRegion( e ) {
let pos = {
x : e.clientX,
y : e.clientY
},
region = '',
dividant = 4,
right = window.innerWidth - (window.innerWidth / dividant),
left = (window.innerWidth / dividant),
top = (window.innerHeight / dividant),
bottom = window.innerHeight - (window.innerHeight /... | javascript | function clickRegion( e ) {
let pos = {
x : e.clientX,
y : e.clientY
},
region = '',
dividant = 4,
right = window.innerWidth - (window.innerWidth / dividant),
left = (window.innerWidth / dividant),
top = (window.innerHeight / dividant),
bottom = window.innerHeight - (window.innerHeight /... | [
"function",
"clickRegion",
"(",
"e",
")",
"{",
"let",
"pos",
"=",
"{",
"x",
":",
"e",
".",
"clientX",
",",
"y",
":",
"e",
".",
"clientY",
"}",
",",
"region",
"=",
"''",
",",
"dividant",
"=",
"4",
",",
"right",
"=",
"window",
".",
"innerWidth",
... | get click quadrant based on mouse position | [
"get",
"click",
"quadrant",
"based",
"on",
"mouse",
"position"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/example/example.js#L54-L74 | train |
edappy/seneca-context | plugins/getContext.js | getContextPlugin | function getContextPlugin(options) {
var seneca = this;
var plugin = 'get-context';
seneca.wrap(options.pin, function (message, done) {
var seneca = this;
message.context$ = getContext(seneca);
seneca.prior(message, done);
});
return {name: plugin};
} | javascript | function getContextPlugin(options) {
var seneca = this;
var plugin = 'get-context';
seneca.wrap(options.pin, function (message, done) {
var seneca = this;
message.context$ = getContext(seneca);
seneca.prior(message, done);
});
return {name: plugin};
} | [
"function",
"getContextPlugin",
"(",
"options",
")",
"{",
"var",
"seneca",
"=",
"this",
";",
"var",
"plugin",
"=",
"'get-context'",
";",
"seneca",
".",
"wrap",
"(",
"options",
".",
"pin",
",",
"function",
"(",
"message",
",",
"done",
")",
"{",
"var",
"... | A seneca plugin, which automatically exposes the context as a property of the incoming message.
@param {{
pin: string|Object // a seneca pattern to which this plugin should be applied
}} options | [
"A",
"seneca",
"plugin",
"which",
"automatically",
"exposes",
"the",
"context",
"as",
"a",
"property",
"of",
"the",
"incoming",
"message",
"."
] | 1e0c8d36c5be4b661b062754c01f064de47873c4 | https://github.com/edappy/seneca-context/blob/1e0c8d36c5be4b661b062754c01f064de47873c4/plugins/getContext.js#L14-L25 | train |
fknussel/custom-scripts | scripts/build.js | build | function build() {
console.log('Creating an optimized production build...\n');
webpack(config)
.run((err, stats) => {
if (err) {
printErrors('Failed to compile.', [err]);
process.exit(1);
}
if (stats.compilation.errors.length) {
printErrors('Failed to compile.', stats... | javascript | function build() {
console.log('Creating an optimized production build...\n');
webpack(config)
.run((err, stats) => {
if (err) {
printErrors('Failed to compile.', [err]);
process.exit(1);
}
if (stats.compilation.errors.length) {
printErrors('Failed to compile.', stats... | [
"function",
"build",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'Creating an optimized production build...\\n'",
")",
";",
"webpack",
"(",
"config",
")",
".",
"run",
"(",
"(",
"err",
",",
"stats",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"printErrors... | Create a production build | [
"Create",
"a",
"production",
"build"
] | 801ad6f42bcde265e317d427b7ee0f371eeb0e9b | https://github.com/fknussel/custom-scripts/blob/801ad6f42bcde265e317d427b7ee0f371eeb0e9b/scripts/build.js#L26-L53 | train |
onecommons/base | routes/crud.js | addToFooter | function addToFooter(schema, path, unwind) {
Object.keys(schema).forEach(function(name) {
if (name.slice(0,2) == '__')
return true;
if (!path && (name == 'id' || name == '_id'))
return;
if (model.schema.nested[path+name]) {
addToFooter(schema[name], path+name+'.', '')
... | javascript | function addToFooter(schema, path, unwind) {
Object.keys(schema).forEach(function(name) {
if (name.slice(0,2) == '__')
return true;
if (!path && (name == 'id' || name == '_id'))
return;
if (model.schema.nested[path+name]) {
addToFooter(schema[name], path+name+'.', '')
... | [
"function",
"addToFooter",
"(",
"schema",
",",
"path",
",",
"unwind",
")",
"{",
"Object",
".",
"keys",
"(",
"schema",
")",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"if",
"(",
"name",
".",
"slice",
"(",
"0",
",",
"2",
")",
"==",
"'_... | only include leaves | [
"only",
"include",
"leaves"
] | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/routes/crud.js#L514-L539 | train |
vid/SenseBase | lib/content.js | diffContentItems | function diffContentItems(lhs, rhs) {
var d = diff(lhs, rhs, function(key, value) {
return value === 'visitors' || value === 'headers';
});
return d;
} | javascript | function diffContentItems(lhs, rhs) {
var d = diff(lhs, rhs, function(key, value) {
return value === 'visitors' || value === 'headers';
});
return d;
} | [
"function",
"diffContentItems",
"(",
"lhs",
",",
"rhs",
")",
"{",
"var",
"d",
"=",
"diff",
"(",
"lhs",
",",
"rhs",
",",
"function",
"(",
"key",
",",
"value",
")",
"{",
"return",
"value",
"===",
"'visitors'",
"||",
"value",
"===",
"'headers'",
";",
"}... | Compare two content items, returning any difference | [
"Compare",
"two",
"content",
"items",
"returning",
"any",
"difference"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/content.js#L247-L252 | train |
vid/SenseBase | lib/content.js | extractContent | function extractContent(desc) {
/*
// search all possible matches, returning first find
var founds = sites.findMatch(desc.uri);
if (founds.length) {
var $ = cheerio.load(desc.content);
// use first found extractor
founds.forEach(function(found) {
if ($(found.selector)) {
var content = $... | javascript | function extractContent(desc) {
/*
// search all possible matches, returning first find
var founds = sites.findMatch(desc.uri);
if (founds.length) {
var $ = cheerio.load(desc.content);
// use first found extractor
founds.forEach(function(found) {
if ($(found.selector)) {
var content = $... | [
"function",
"extractContent",
"(",
"desc",
")",
"{",
"/*\n // search all possible matches, returning first find\n var founds = sites.findMatch(desc.uri);\n\n if (founds.length) {\n var $ = cheerio.load(desc.content);\n // use first found extractor\n founds.forEach(function(found) {\n if (... | find finer content areas if available extract content based on site definitions | [
"find",
"finer",
"content",
"areas",
"if",
"available",
"extract",
"content",
"based",
"on",
"site",
"definitions"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/content.js#L348-L370 | train |
vid/SenseBase | lib/content.js | getTitle | function getTitle(content, tag) {
if (!content) {
return;
}
var ts = content.indexOf(tag);
if (ts < 0) {
return;
}
var te = content.indexOf('>', ts);
var cs = content.indexOf('<', te + 1);
var title = content.substring(te + 1, cs);
return title.trim();
} | javascript | function getTitle(content, tag) {
if (!content) {
return;
}
var ts = content.indexOf(tag);
if (ts < 0) {
return;
}
var te = content.indexOf('>', ts);
var cs = content.indexOf('<', te + 1);
var title = content.substring(te + 1, cs);
return title.trim();
} | [
"function",
"getTitle",
"(",
"content",
",",
"tag",
")",
"{",
"if",
"(",
"!",
"content",
")",
"{",
"return",
";",
"}",
"var",
"ts",
"=",
"content",
".",
"indexOf",
"(",
"tag",
")",
";",
"if",
"(",
"ts",
"<",
"0",
")",
"{",
"return",
";",
"}",
... | Get an HTML title the old-fashioned way. | [
"Get",
"an",
"HTML",
"title",
"the",
"old",
"-",
"fashioned",
"way",
"."
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/content.js#L373-L385 | train |
henrytseng/angular-state-router | example/app.js | function() {
var i = Math.floor(_listing.length-1 * Math.random());
return $q.when(_listing[i]);
} | javascript | function() {
var i = Math.floor(_listing.length-1 * Math.random());
return $q.when(_listing[i]);
} | [
"function",
"(",
")",
"{",
"var",
"i",
"=",
"Math",
".",
"floor",
"(",
"_listing",
".",
"length",
"-",
"1",
"*",
"Math",
".",
"random",
"(",
")",
")",
";",
"return",
"$q",
".",
"when",
"(",
"_listing",
"[",
"i",
"]",
")",
";",
"}"
] | Get random item | [
"Get",
"random",
"item"
] | 5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b | https://github.com/henrytseng/angular-state-router/blob/5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b/example/app.js#L299-L302 | train | |
henrytseng/angular-state-router | example/app.js | function(criteria) {
var results = [];
criteria = angular.isArray(criteria) ? criteria : [criteria];
// Search through each
criteria.forEach(function(q) {
if(q && q !== '') {
_listing.forEach(function(item) {
for(var name in item) {
... | javascript | function(criteria) {
var results = [];
criteria = angular.isArray(criteria) ? criteria : [criteria];
// Search through each
criteria.forEach(function(q) {
if(q && q !== '') {
_listing.forEach(function(item) {
for(var name in item) {
... | [
"function",
"(",
"criteria",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"criteria",
"=",
"angular",
".",
"isArray",
"(",
"criteria",
")",
"?",
"criteria",
":",
"[",
"criteria",
"]",
";",
"// Search through each",
"criteria",
".",
"forEach",
"(",
"fu... | Search for a product | [
"Search",
"for",
"a",
"product"
] | 5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b | https://github.com/henrytseng/angular-state-router/blob/5b8147d5f5fe8a8e8453dddf61fe0b01fe5b5e9b/example/app.js#L305-L325 | train | |
benaston/partial-application | dist/partial-application.js | partialWithArityOfOne | function partialWithArityOfOne(fn) {
var args = arguments;
return function(a) {
return partial.apply(this, args).apply(this, arguments);
};
} | javascript | function partialWithArityOfOne(fn) {
var args = arguments;
return function(a) {
return partial.apply(this, args).apply(this, arguments);
};
} | [
"function",
"partialWithArityOfOne",
"(",
"fn",
")",
"{",
"var",
"args",
"=",
"arguments",
";",
"return",
"function",
"(",
"a",
")",
"{",
"return",
"partial",
".",
"apply",
"(",
"this",
",",
"args",
")",
".",
"apply",
"(",
"this",
",",
"arguments",
")"... | Partially apply a function, but ensure the returned function has an arity of one.
@param {Function} fn The function to partially apply.
@return {Function} The partially applied function. | [
"Partially",
"apply",
"a",
"function",
"but",
"ensure",
"the",
"returned",
"function",
"has",
"an",
"arity",
"of",
"one",
"."
] | bfb79abc7d6a81f2ad5c237bc618c261051692d3 | https://github.com/benaston/partial-application/blob/bfb79abc7d6a81f2ad5c237bc618c261051692d3/dist/partial-application.js#L39-L45 | train |
binduwavell/generator-alfresco-common | lib/maven-archetype-metadata.js | _getFileSet | function _getFileSet (fileSetElement) {
var filtered = utils.toBoolean(fileSetElement.getAttribute('filtered'), false);
var packaged = utils.toBoolean(fileSetElement.getAttribute('packaged'), false);
var encoding = fileSetElement.getAttribute('encoding');
var directory = domutils.getChild(fileSetElement... | javascript | function _getFileSet (fileSetElement) {
var filtered = utils.toBoolean(fileSetElement.getAttribute('filtered'), false);
var packaged = utils.toBoolean(fileSetElement.getAttribute('packaged'), false);
var encoding = fileSetElement.getAttribute('encoding');
var directory = domutils.getChild(fileSetElement... | [
"function",
"_getFileSet",
"(",
"fileSetElement",
")",
"{",
"var",
"filtered",
"=",
"utils",
".",
"toBoolean",
"(",
"fileSetElement",
".",
"getAttribute",
"(",
"'filtered'",
")",
",",
"false",
")",
";",
"var",
"packaged",
"=",
"utils",
".",
"toBoolean",
"(",... | Produces a JavaScript object representing a fileSet.
@param {Element} fileSetElement
@returns {{filtered: (boolean|undefined), packaged: (boolean|undefined), encoding: (string|*), directory, includes: Array, excludes: Array}}
@private | [
"Produces",
"a",
"JavaScript",
"object",
"representing",
"a",
"fileSet",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/maven-archetype-metadata.js#L91-L108 | train |
binduwavell/generator-alfresco-common | lib/maven-archetype-metadata.js | _getModule | function _getModule (moduleElement) {
var id = moduleElement.getAttribute('id');
var dir = moduleElement.getAttribute('dir');
var name = moduleElement.getAttribute('name');
var fileSets = domutils.getChild(moduleElement, 'desc', 'fileSets');
var modules = domutils.getChild(moduleElement, 'desc', 'mo... | javascript | function _getModule (moduleElement) {
var id = moduleElement.getAttribute('id');
var dir = moduleElement.getAttribute('dir');
var name = moduleElement.getAttribute('name');
var fileSets = domutils.getChild(moduleElement, 'desc', 'fileSets');
var modules = domutils.getChild(moduleElement, 'desc', 'mo... | [
"function",
"_getModule",
"(",
"moduleElement",
")",
"{",
"var",
"id",
"=",
"moduleElement",
".",
"getAttribute",
"(",
"'id'",
")",
";",
"var",
"dir",
"=",
"moduleElement",
".",
"getAttribute",
"(",
"'dir'",
")",
";",
"var",
"name",
"=",
"moduleElement",
"... | Produces a JavaScript object representing a module.
@param {!Element} moduleElement
@returns {{id: (string|*), dir: (string|*), name: (string|*), fileSets: Array, modules: Array}}
@private | [
"Produces",
"a",
"JavaScript",
"object",
"representing",
"a",
"module",
"."
] | d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/maven-archetype-metadata.js#L134-L156 | train |
jldec/pub-generator | generator.js | unload | function unload() {
u.each(opts.sources, function(source) {
if (source.src && source.src.unref) { source.src.unref(); }
if (source.cache && source.cache.unref) { source.cache.unref(); }
});
u.each(opts.outputs, function(output) {
if (output.output && output.output.cancel) { output.output.c... | javascript | function unload() {
u.each(opts.sources, function(source) {
if (source.src && source.src.unref) { source.src.unref(); }
if (source.cache && source.cache.unref) { source.cache.unref(); }
});
u.each(opts.outputs, function(output) {
if (output.output && output.output.cancel) { output.output.c... | [
"function",
"unload",
"(",
")",
"{",
"u",
".",
"each",
"(",
"opts",
".",
"sources",
",",
"function",
"(",
"source",
")",
"{",
"if",
"(",
"source",
".",
"src",
"&&",
"source",
".",
"src",
".",
"unref",
")",
"{",
"source",
".",
"src",
".",
"unref",... | disconnect all sources and cancel all throttled functions | [
"disconnect",
"all",
"sources",
"and",
"cancel",
"all",
"throttled",
"functions"
] | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/generator.js#L140-L150 | train |
jldec/pub-generator | generator.js | redirect | function redirect(url) {
var path = u.urlPath(url);
var params = u.urlParams(url);
var pg = generator.aliase$[path];
if (pg) return { status:301, url:pg._href + params };
pg = generator.redirect$[path];
if (pg) return { status:302, url:pg._href + params };
// customRedirects return params... | javascript | function redirect(url) {
var path = u.urlPath(url);
var params = u.urlParams(url);
var pg = generator.aliase$[path];
if (pg) return { status:301, url:pg._href + params };
pg = generator.redirect$[path];
if (pg) return { status:302, url:pg._href + params };
// customRedirects return params... | [
"function",
"redirect",
"(",
"url",
")",
"{",
"var",
"path",
"=",
"u",
".",
"urlPath",
"(",
"url",
")",
";",
"var",
"params",
"=",
"u",
".",
"urlParams",
"(",
"url",
")",
";",
"var",
"pg",
"=",
"generator",
".",
"aliase$",
"[",
"path",
"]",
";",
... | compute alias or custom redirect for a url - returns falsy if none 302 redirects are temporary - browsers won't try to remember them 301 redirects are permanent - browsers will cache and avoid re-requesting | [
"compute",
"alias",
"or",
"custom",
"redirect",
"for",
"a",
"url",
"-",
"returns",
"falsy",
"if",
"none",
"302",
"redirects",
"are",
"temporary",
"-",
"browsers",
"won",
"t",
"try",
"to",
"remember",
"them",
"301",
"redirects",
"are",
"permanent",
"-",
"br... | 524081509921ac8cb897753142324d61e10afdf3 | https://github.com/jldec/pub-generator/blob/524081509921ac8cb897753142324d61e10afdf3/generator.js#L238-L251 | train |
UNLOQIO/unloq-node-client | lib/api.js | UnloqApi | function UnloqApi(authObj) {
if(typeof authObj !== 'object' || authObj === null) {
throw new Error('Unloq.Api: First constructor argument must be an instance of unloq.Auth');
}
// If we receive only the object with configuration, we try and create the auth object.
if(authObj.__type !== 'auth') {
... | javascript | function UnloqApi(authObj) {
if(typeof authObj !== 'object' || authObj === null) {
throw new Error('Unloq.Api: First constructor argument must be an instance of unloq.Auth');
}
// If we receive only the object with configuration, we try and create the auth object.
if(authObj.__type !== 'auth') {
... | [
"function",
"UnloqApi",
"(",
"authObj",
")",
"{",
"if",
"(",
"typeof",
"authObj",
"!==",
"'object'",
"||",
"authObj",
"===",
"null",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Unloq.Api: First constructor argument must be an instance of unloq.Auth'",
")",
";",
"}",
... | this is an unloq.Auth instance. | [
"this",
"is",
"an",
"unloq",
".",
"Auth",
"instance",
"."
] | f88adeb7f0d3c729c6b578bff4aa5f548b84133b | https://github.com/UNLOQIO/unloq-node-client/blob/f88adeb7f0d3c729c6b578bff4aa5f548b84133b/lib/api.js#L12-L22 | train |
DScheglov/merest | lib/middlewares/register-api.js | registerApi | function registerApi(isApp, apiObject) {
if (isApp) {
return function (req, res, next) {
res.__api = apiObject;
return next();
};
};
return function (req, res, next) {
res.__modelAPI = apiObject;
return next();
};
} | javascript | function registerApi(isApp, apiObject) {
if (isApp) {
return function (req, res, next) {
res.__api = apiObject;
return next();
};
};
return function (req, res, next) {
res.__modelAPI = apiObject;
return next();
};
} | [
"function",
"registerApi",
"(",
"isApp",
",",
"apiObject",
")",
"{",
"if",
"(",
"isApp",
")",
"{",
"return",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"res",
".",
"__api",
"=",
"apiObject",
";",
"return",
"next",
"(",
")",
";",
"}"... | registerApi - the factory for middleware that registers api in response object
@param {ModelAPIRouter|ModelAPIExpress} apiObject the ModelAPIRouter or ModelAPIRouter
@return {Function} description | [
"registerApi",
"-",
"the",
"factory",
"for",
"middleware",
"that",
"registers",
"api",
"in",
"response",
"object"
] | d39e7ef0d56236247773467e9bfe83cb128ebc01 | https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/middlewares/register-api.js#L10-L23 | train |
vadr-vr/VR-Analytics-JSCore | js/timeManager.js | init | function init(){
frameUnixTime = utils.getUnixTimeInMilliseconds();
frameDuration = 0;
frameDurationClone = 0;
timeSinceStart = 0;
playTimeSinceStart = 0;
appActive = true;
appPlaying = true;
videoDuration = 0;
videoPlaying = false;
} | javascript | function init(){
frameUnixTime = utils.getUnixTimeInMilliseconds();
frameDuration = 0;
frameDurationClone = 0;
timeSinceStart = 0;
playTimeSinceStart = 0;
appActive = true;
appPlaying = true;
videoDuration = 0;
videoPlaying = false;
} | [
"function",
"init",
"(",
")",
"{",
"frameUnixTime",
"=",
"utils",
".",
"getUnixTimeInMilliseconds",
"(",
")",
";",
"frameDuration",
"=",
"0",
";",
"frameDurationClone",
"=",
"0",
";",
"timeSinceStart",
"=",
"0",
";",
"playTimeSinceStart",
"=",
"0",
";",
"app... | Init the time manager, sets frameUnixTime to current value
@memberof TimeManager | [
"Init",
"the",
"time",
"manager",
"sets",
"frameUnixTime",
"to",
"current",
"value"
] | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/timeManager.js#L30-L42 | train |
vadr-vr/VR-Analytics-JSCore | js/timeManager.js | tick | function tick(frameTime){
let newFrameUnixTime = utils.getUnixTimeInMilliseconds();
if (frameTime)
frameDuration = frameTime;
else
frameDuration = newFrameUnixTime - frameUnixTime;
// dont consider frame duration if app is not active
frameDurationClone = appActive ? frameDurat... | javascript | function tick(frameTime){
let newFrameUnixTime = utils.getUnixTimeInMilliseconds();
if (frameTime)
frameDuration = frameTime;
else
frameDuration = newFrameUnixTime - frameUnixTime;
// dont consider frame duration if app is not active
frameDurationClone = appActive ? frameDurat... | [
"function",
"tick",
"(",
"frameTime",
")",
"{",
"let",
"newFrameUnixTime",
"=",
"utils",
".",
"getUnixTimeInMilliseconds",
"(",
")",
";",
"if",
"(",
"frameTime",
")",
"frameDuration",
"=",
"frameTime",
";",
"else",
"frameDuration",
"=",
"newFrameUnixTime",
"-",
... | Updates the application timings.
Calculates frameTime as the difference of current
frame time and the previous frame time. In case app was not active the previous frame,
sets the frame time to 0. Correspondingly calculates timeSinceStart and
playTimeSinceStart
@memberof TimeManager
@param {number} frameTime specify the... | [
"Updates",
"the",
"application",
"timings",
".",
"Calculates",
"frameTime",
"as",
"the",
"difference",
"of",
"current",
"frame",
"time",
"and",
"the",
"previous",
"frame",
"time",
".",
"In",
"case",
"app",
"was",
"not",
"active",
"the",
"previous",
"frame",
... | 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/timeManager.js#L53-L80 | train |
OpenSmartEnvironment/ose | lib/field/wrap.js | init | function init(owner, field, layout, val, children) { // {{{2
/**
* Field wrapper constructor
*
* @param owner {Object} Owning wrap list
* @param field {Object} Field description object
* @param layout {Object} Layout
* @param val {*} Field value
*
* @method constructor
*/
this.owner = owner;
owner.fields... | javascript | function init(owner, field, layout, val, children) { // {{{2
/**
* Field wrapper constructor
*
* @param owner {Object} Owning wrap list
* @param field {Object} Field description object
* @param layout {Object} Layout
* @param val {*} Field value
*
* @method constructor
*/
this.owner = owner;
owner.fields... | [
"function",
"init",
"(",
"owner",
",",
"field",
",",
"layout",
",",
"val",
",",
"children",
")",
"{",
"// {{{2",
"/**\n * Field wrapper constructor\n *\n * @param owner {Object} Owning wrap list\n * @param field {Object} Field description object\n * @param layout {Object} Layout\n * @p... | Optional error returned from field.unformat
@property editError
@type Object
Public {{{1 | [
"Optional",
"error",
"returned",
"from",
"field",
".",
"unformat"
] | 2ab051d9db6e77341c40abb9cbdae6ce586917e0 | https://github.com/OpenSmartEnvironment/ose/blob/2ab051d9db6e77341c40abb9cbdae6ce586917e0/lib/field/wrap.js#L88-L108 | train |
primus/condenseify | index.js | condenseify | function condenseify(file, options) {
if (/\.json$/.test(file)) return through();
var appendNewLine = true
, regex = /^[ \t]+$/
, isBlank = false
, eol ='\n';
options = options || {};
function transform(line, encoding, next) {
if (!line.length) {
isBlank = true;
return next();
... | javascript | function condenseify(file, options) {
if (/\.json$/.test(file)) return through();
var appendNewLine = true
, regex = /^[ \t]+$/
, isBlank = false
, eol ='\n';
options = options || {};
function transform(line, encoding, next) {
if (!line.length) {
isBlank = true;
return next();
... | [
"function",
"condenseify",
"(",
"file",
",",
"options",
")",
"{",
"if",
"(",
"/",
"\\.json$",
"/",
".",
"test",
"(",
"file",
")",
")",
"return",
"through",
"(",
")",
";",
"var",
"appendNewLine",
"=",
"true",
",",
"regex",
"=",
"/",
"^[ \\t]+$",
"/",
... | Browserify transform to condense multiple blank lines
into a single blank line.
@param {String} file File name
@param {Object} [options] Options object
@returns {Stream} Transform stream
@api public | [
"Browserify",
"transform",
"to",
"condense",
"multiple",
"blank",
"lines",
"into",
"a",
"single",
"blank",
"line",
"."
] | 1330ead68f7d5cdbcf4f08ad8fc4138920eb4c54 | https://github.com/primus/condenseify/blob/1330ead68f7d5cdbcf4f08ad8fc4138920eb4c54/index.js#L21-L55 | train |
sembaye/numberconverter | index.js | removezeros | function removezeros(bin){
var i = 0;
while((i < bin.length) && (!bin[i])){i++;}
if(i == bin.length){
return filledarray(false, 1);
}else{
return bin.slice(i);
}
} | javascript | function removezeros(bin){
var i = 0;
while((i < bin.length) && (!bin[i])){i++;}
if(i == bin.length){
return filledarray(false, 1);
}else{
return bin.slice(i);
}
} | [
"function",
"removezeros",
"(",
"bin",
")",
"{",
"var",
"i",
"=",
"0",
";",
"while",
"(",
"(",
"i",
"<",
"bin",
".",
"length",
")",
"&&",
"(",
"!",
"bin",
"[",
"i",
"]",
")",
")",
"{",
"i",
"++",
";",
"}",
"if",
"(",
"i",
"==",
"bin",
"."... | Removes all prefixing zeros from the binary array. | [
"Removes",
"all",
"prefixing",
"zeros",
"from",
"the",
"binary",
"array",
"."
] | c3cd4c0c567e520354e0e4fb60a669fd5f07877a | https://github.com/sembaye/numberconverter/blob/c3cd4c0c567e520354e0e4fb60a669fd5f07877a/index.js#L4-L12 | train |
sembaye/numberconverter | index.js | decinputtobin | function decinputtobin(decinput){
var len = decinput.length;
if(len == 0){return filledarray(false, 1);}
var bin = new Array();
var digit = new Array(4);
for (var i = 0; i < len; i++){
switch (decinput[i]){
case '0': digit[0] = false; digit[1] = false; digit[2] = false; digit[3] = false; break;
ca... | javascript | function decinputtobin(decinput){
var len = decinput.length;
if(len == 0){return filledarray(false, 1);}
var bin = new Array();
var digit = new Array(4);
for (var i = 0; i < len; i++){
switch (decinput[i]){
case '0': digit[0] = false; digit[1] = false; digit[2] = false; digit[3] = false; break;
ca... | [
"function",
"decinputtobin",
"(",
"decinput",
")",
"{",
"var",
"len",
"=",
"decinput",
".",
"length",
";",
"if",
"(",
"len",
"==",
"0",
")",
"{",
"return",
"filledarray",
"(",
"false",
",",
"1",
")",
";",
"}",
"var",
"bin",
"=",
"new",
"Array",
"("... | Computes a binary array out of a decimal input string | [
"Computes",
"a",
"binary",
"array",
"out",
"of",
"a",
"decimal",
"input",
"string"
] | c3cd4c0c567e520354e0e4fb60a669fd5f07877a | https://github.com/sembaye/numberconverter/blob/c3cd4c0c567e520354e0e4fb60a669fd5f07877a/index.js#L15-L37 | train |
sembaye/numberconverter | index.js | bininputtobin | function bininputtobin(bininput){
var len = bininput.length;
if(len == 0){return filledarray(false, 1);}
var bin = new Array(len);
var j = 0;
for (var i = 0; i < len; i++){
switch (bininput[i]){
case '0': bin[j++] = false; break;
case '1': bin[j++] = true; break;
default: break;
}
}
re... | javascript | function bininputtobin(bininput){
var len = bininput.length;
if(len == 0){return filledarray(false, 1);}
var bin = new Array(len);
var j = 0;
for (var i = 0; i < len; i++){
switch (bininput[i]){
case '0': bin[j++] = false; break;
case '1': bin[j++] = true; break;
default: break;
}
}
re... | [
"function",
"bininputtobin",
"(",
"bininput",
")",
"{",
"var",
"len",
"=",
"bininput",
".",
"length",
";",
"if",
"(",
"len",
"==",
"0",
")",
"{",
"return",
"filledarray",
"(",
"false",
",",
"1",
")",
";",
"}",
"var",
"bin",
"=",
"new",
"Array",
"("... | Computes a binary array out of a binary input string | [
"Computes",
"a",
"binary",
"array",
"out",
"of",
"a",
"binary",
"input",
"string"
] | c3cd4c0c567e520354e0e4fb60a669fd5f07877a | https://github.com/sembaye/numberconverter/blob/c3cd4c0c567e520354e0e4fb60a669fd5f07877a/index.js#L70-L83 | train |
sembaye/numberconverter | index.js | octinputtobin | function octinputtobin(octinput){
var len = octinput.length;
if(len == 0){return filledarray(false, 1);}
var bin = new Array(len * 3);
var j = 0;
for (var i = 0; i < len; i++){
switch (octinput[i]){
case '0': bin[j+0] = false; bin[j+1] = false; bin[j+2] = false; j+=3; break;
case '1': bin[j+0] = f... | javascript | function octinputtobin(octinput){
var len = octinput.length;
if(len == 0){return filledarray(false, 1);}
var bin = new Array(len * 3);
var j = 0;
for (var i = 0; i < len; i++){
switch (octinput[i]){
case '0': bin[j+0] = false; bin[j+1] = false; bin[j+2] = false; j+=3; break;
case '1': bin[j+0] = f... | [
"function",
"octinputtobin",
"(",
"octinput",
")",
"{",
"var",
"len",
"=",
"octinput",
".",
"length",
";",
"if",
"(",
"len",
"==",
"0",
")",
"{",
"return",
"filledarray",
"(",
"false",
",",
"1",
")",
";",
"}",
"var",
"bin",
"=",
"new",
"Array",
"("... | Computes a binary array out of an octal input string | [
"Computes",
"a",
"binary",
"array",
"out",
"of",
"an",
"octal",
"input",
"string"
] | c3cd4c0c567e520354e0e4fb60a669fd5f07877a | https://github.com/sembaye/numberconverter/blob/c3cd4c0c567e520354e0e4fb60a669fd5f07877a/index.js#L86-L105 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.