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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
quantumpayments/media | lib/qpm_media.js | getTopImages | function getTopImages(params, config, conn) {
// defaults
config = config || require('../config/config.js')
var limit = 10
if (!isNaN(params.limit)) {
limit = params.limit
}
// main
return new Promise((resolve, reject) => {
if (!conn) {
var conn = wc_db.getConnection(config.db)
}
... | javascript | function getTopImages(params, config, conn) {
// defaults
config = config || require('../config/config.js')
var limit = 10
if (!isNaN(params.limit)) {
limit = params.limit
}
// main
return new Promise((resolve, reject) => {
if (!conn) {
var conn = wc_db.getConnection(config.db)
}
... | [
"function",
"getTopImages",
"(",
"params",
",",
"config",
",",
"conn",
")",
"{",
"// defaults",
"config",
"=",
"config",
"||",
"require",
"(",
"'../config/config.js'",
")",
"var",
"limit",
"=",
"10",
"if",
"(",
"!",
"isNaN",
"(",
"params",
".",
"limit",
... | Get the top images
@param {Object} rating The rating to add.
@param {Object} config The optional config.
@param {Object} conn The optional db connection.
@return {Object} Promise with success or fail. | [
"Get",
"the",
"top",
"images"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/qpm_media.js#L633-L667 | train |
quantumpayments/media | lib/qpm_media.js | getTags | function getTags(params, config, conn) {
// defaults
config = config || require('../config/config.js')
params.limit = 100
// main
return new Promise((resolve, reject) => {
if (!conn) {
var conn = wc_db.getConnection(config.db)
}
if (params.uri) {
var sql = 'SELECT t.tag from Med... | javascript | function getTags(params, config, conn) {
// defaults
config = config || require('../config/config.js')
params.limit = 100
// main
return new Promise((resolve, reject) => {
if (!conn) {
var conn = wc_db.getConnection(config.db)
}
if (params.uri) {
var sql = 'SELECT t.tag from Med... | [
"function",
"getTags",
"(",
"params",
",",
"config",
",",
"conn",
")",
"{",
"// defaults",
"config",
"=",
"config",
"||",
"require",
"(",
"'../config/config.js'",
")",
"params",
".",
"limit",
"=",
"100",
"// main",
"return",
"new",
"Promise",
"(",
"(",
"re... | Get list of tags
@param {Object} params Info about tags.
@param {Object} config The optional config.
@param {Object} conn The optional db connection.
@return {Object} Promise with success or fail. | [
"Get",
"list",
"of",
"tags"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/qpm_media.js#L677-L708 | train |
quantumpayments/media | lib/qpm_media.js | getRandomUnseenImage | function getRandomUnseenImage(params, config, conn) {
// defaults
config = config || require('../config/config.js')
params = params || {}
var max = config.db.max || 0
var optimization = config.optimization || 0
var offset = Math.floor(Math.random() * max)
params.optimization = optimization
params.of... | javascript | function getRandomUnseenImage(params, config, conn) {
// defaults
config = config || require('../config/config.js')
params = params || {}
var max = config.db.max || 0
var optimization = config.optimization || 0
var offset = Math.floor(Math.random() * max)
params.optimization = optimization
params.of... | [
"function",
"getRandomUnseenImage",
"(",
"params",
",",
"config",
",",
"conn",
")",
"{",
"// defaults",
"config",
"=",
"config",
"||",
"require",
"(",
"'../config/config.js'",
")",
"params",
"=",
"params",
"||",
"{",
"}",
"var",
"max",
"=",
"config",
".",
... | Get a random unseen image
@param {Object} rating The rating to add.
@param {Object} config The optional config.
@param {Object} conn The optional db connection.
@return {Object} Promise with success or fail. | [
"Get",
"a",
"random",
"unseen",
"image"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/qpm_media.js#L861-L909 | train |
quantumpayments/media | lib/qpm_media.js | getLastSeen | function getLastSeen(params, config, conn) {
// defaults
config = config || require('../config/config.js')
params = params || {}
params.webid = params.webid || 'http://melvincarvalho.com/#me'
// main
return new Promise((resolve, reject) => {
if (!conn) {
var conn = wc_db.getConnection(config.d... | javascript | function getLastSeen(params, config, conn) {
// defaults
config = config || require('../config/config.js')
params = params || {}
params.webid = params.webid || 'http://melvincarvalho.com/#me'
// main
return new Promise((resolve, reject) => {
if (!conn) {
var conn = wc_db.getConnection(config.d... | [
"function",
"getLastSeen",
"(",
"params",
",",
"config",
",",
"conn",
")",
"{",
"// defaults",
"config",
"=",
"config",
"||",
"require",
"(",
"'../config/config.js'",
")",
"params",
"=",
"params",
"||",
"{",
"}",
"params",
".",
"webid",
"=",
"params",
".",... | Get get the last seen item
@param {Object} rating The rating to add.
@param {Object} config The optional config.
@param {Object} conn The optional db connection.
@return {Object} Promise with success or fail. | [
"Get",
"get",
"the",
"last",
"seen",
"item"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/qpm_media.js#L1040-L1087 | train |
ljcl/hubot-iss | src/index.js | astroViewer | function astroViewer (options, cb) {
request({
url: 'http://astroviewer-sat2c.appspot.com/predictor',
qs: {
var: 'passesData',
lat: options.lat,
lon: options.lon,
name: options.name
},
headers: {
'User-Agent': 'request'
}
}, function (error, response, body) {
if... | javascript | function astroViewer (options, cb) {
request({
url: 'http://astroviewer-sat2c.appspot.com/predictor',
qs: {
var: 'passesData',
lat: options.lat,
lon: options.lon,
name: options.name
},
headers: {
'User-Agent': 'request'
}
}, function (error, response, body) {
if... | [
"function",
"astroViewer",
"(",
"options",
",",
"cb",
")",
"{",
"request",
"(",
"{",
"url",
":",
"'http://astroviewer-sat2c.appspot.com/predictor'",
",",
"qs",
":",
"{",
"var",
":",
"'passesData'",
",",
"lat",
":",
"options",
".",
"lat",
",",
"lon",
":",
"... | Query astroviewer and dangerously turn the javascript into parsable JSON.
@param {object} options An object containing the latitude, longitude and location name
@param {Function} cb | [
"Query",
"astroviewer",
"and",
"dangerously",
"turn",
"the",
"javascript",
"into",
"parsable",
"JSON",
"."
] | 15103c9e491e417406ae99a09e098d87fa02251f | https://github.com/ljcl/hubot-iss/blob/15103c9e491e417406ae99a09e098d87fa02251f/src/index.js#L27-L51 | train |
ljcl/hubot-iss | src/index.js | listPasses | function listPasses (data, cb) {
var index = 0
var passes = data.passes
var newpasses = ''
if (passes.length === 0) {
newpasses += ':( No results found for **' + data.location.name + '**'
} else {
passes.map(function (obj) {
if (index === 0) {
newpasses += '**' + data.location.name + '**... | javascript | function listPasses (data, cb) {
var index = 0
var passes = data.passes
var newpasses = ''
if (passes.length === 0) {
newpasses += ':( No results found for **' + data.location.name + '**'
} else {
passes.map(function (obj) {
if (index === 0) {
newpasses += '**' + data.location.name + '**... | [
"function",
"listPasses",
"(",
"data",
",",
"cb",
")",
"{",
"var",
"index",
"=",
"0",
"var",
"passes",
"=",
"data",
".",
"passes",
"var",
"newpasses",
"=",
"''",
"if",
"(",
"passes",
".",
"length",
"===",
"0",
")",
"{",
"newpasses",
"+=",
"':( No res... | Build up a string based on the astroViewer data
@param {object} data Return the astroviewer object
@param {Function} cb | [
"Build",
"up",
"a",
"string",
"based",
"on",
"the",
"astroViewer",
"data"
] | 15103c9e491e417406ae99a09e098d87fa02251f | https://github.com/ljcl/hubot-iss/blob/15103c9e491e417406ae99a09e098d87fa02251f/src/index.js#L58-L79 | train |
konstantin24121/grunt-font-loader | tasks/font_loader.js | closeConnection | function closeConnection(errMsg) {
if (ftp) {
ftp.raw.quit(function(err, res) {
if (err) {
grunt.log.error(err);
done(false);
}
ftp.destroy();
grunt.log.ok("FTP connection closed!");
done();
});
} else if (errMsg) {
grunt.log.warn(errMsg);
done(false);
} else {
done();... | javascript | function closeConnection(errMsg) {
if (ftp) {
ftp.raw.quit(function(err, res) {
if (err) {
grunt.log.error(err);
done(false);
}
ftp.destroy();
grunt.log.ok("FTP connection closed!");
done();
});
} else if (errMsg) {
grunt.log.warn(errMsg);
done(false);
} else {
done();... | [
"function",
"closeConnection",
"(",
"errMsg",
")",
"{",
"if",
"(",
"ftp",
")",
"{",
"ftp",
".",
"raw",
".",
"quit",
"(",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"{",
"grunt",
".",
"log",
".",
"error",
"(",
"err",
")... | Close the connection and end the asynchronous task | [
"Close",
"the",
"connection",
"and",
"end",
"the",
"asynchronous",
"task"
] | 624d93efd6bdd6b52bfe24b28db715d065600661 | https://github.com/konstantin24121/grunt-font-loader/blob/624d93efd6bdd6b52bfe24b28db715d065600661/tasks/font_loader.js#L71-L88 | train |
konstantin24121/grunt-font-loader | tasks/font_loader.js | getNextClar | function getNextClar(params, string, files) {
if (params === 'all') {
files.push(string);
return true;
}
if (Array.isArray(params)){
params.forEach(function(item, i, array) {
files.push(string + '.' + item + '$');
return true;
});
}else if (typeof params === 'object'){
var param;
for (... | javascript | function getNextClar(params, string, files) {
if (params === 'all') {
files.push(string);
return true;
}
if (Array.isArray(params)){
params.forEach(function(item, i, array) {
files.push(string + '.' + item + '$');
return true;
});
}else if (typeof params === 'object'){
var param;
for (... | [
"function",
"getNextClar",
"(",
"params",
",",
"string",
",",
"files",
")",
"{",
"if",
"(",
"params",
"===",
"'all'",
")",
"{",
"files",
".",
"push",
"(",
"string",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"par... | Create regexp massive
@param {array} params massive
@param {string} string regexp
@param {array} files creating massive
@return {boolean} | [
"Create",
"regexp",
"massive"
] | 624d93efd6bdd6b52bfe24b28db715d065600661 | https://github.com/konstantin24121/grunt-font-loader/blob/624d93efd6bdd6b52bfe24b28db715d065600661/tasks/font_loader.js#L97-L125 | train |
konstantin24121/grunt-font-loader | tasks/font_loader.js | createDownloadList | function createDownloadList() {
uploadFiles = [];
files.forEach(function(item, i, arr) {
var preg = new RegExp(item);
var check = false;
serverFonts.forEach(function(item, i, arr) {
if (preg.test(item)) {
uploadFiles.push(item);
check = true;
// serverFonts.remove(item);
}
... | javascript | function createDownloadList() {
uploadFiles = [];
files.forEach(function(item, i, arr) {
var preg = new RegExp(item);
var check = false;
serverFonts.forEach(function(item, i, arr) {
if (preg.test(item)) {
uploadFiles.push(item);
check = true;
// serverFonts.remove(item);
}
... | [
"function",
"createDownloadList",
"(",
")",
"{",
"uploadFiles",
"=",
"[",
"]",
";",
"files",
".",
"forEach",
"(",
"function",
"(",
"item",
",",
"i",
",",
"arr",
")",
"{",
"var",
"preg",
"=",
"new",
"RegExp",
"(",
"item",
")",
";",
"var",
"check",
"... | Create list for downloading | [
"Create",
"list",
"for",
"downloading"
] | 624d93efd6bdd6b52bfe24b28db715d065600661 | https://github.com/konstantin24121/grunt-font-loader/blob/624d93efd6bdd6b52bfe24b28db715d065600661/tasks/font_loader.js#L130-L150 | train |
konstantin24121/grunt-font-loader | tasks/font_loader.js | removeFonts | function removeFonts(files){
var dest = normalizeDir(options.dest);
files.forEach(function(item, i, arr){
grunt.file.delete(dest + item);
grunt.log.warn('File ' + item + ' remove.');
});
} | javascript | function removeFonts(files){
var dest = normalizeDir(options.dest);
files.forEach(function(item, i, arr){
grunt.file.delete(dest + item);
grunt.log.warn('File ' + item + ' remove.');
});
} | [
"function",
"removeFonts",
"(",
"files",
")",
"{",
"var",
"dest",
"=",
"normalizeDir",
"(",
"options",
".",
"dest",
")",
";",
"files",
".",
"forEach",
"(",
"function",
"(",
"item",
",",
"i",
",",
"arr",
")",
"{",
"grunt",
".",
"file",
".",
"delete",
... | Remove unused files
@param {array} files files need to remove | [
"Remove",
"unused",
"files"
] | 624d93efd6bdd6b52bfe24b28db715d065600661 | https://github.com/konstantin24121/grunt-font-loader/blob/624d93efd6bdd6b52bfe24b28db715d065600661/tasks/font_loader.js#L156-L162 | train |
konstantin24121/grunt-font-loader | tasks/font_loader.js | getFilesList | function getFilesList(pattern) {
//If pattern empty return all avaliable fonts
if (pattern === undefined || pattern === '') {
formatingFontsArray(serverFonts);
closeConnection();
return; // We are completed, close connection and end the program
}
var serverFiles = [],
preg = new RegExp('[\\w\\-\\.]... | javascript | function getFilesList(pattern) {
//If pattern empty return all avaliable fonts
if (pattern === undefined || pattern === '') {
formatingFontsArray(serverFonts);
closeConnection();
return; // We are completed, close connection and end the program
}
var serverFiles = [],
preg = new RegExp('[\\w\\-\\.]... | [
"function",
"getFilesList",
"(",
"pattern",
")",
"{",
"//If pattern empty return all avaliable fonts",
"if",
"(",
"pattern",
"===",
"undefined",
"||",
"pattern",
"===",
"''",
")",
"{",
"formatingFontsArray",
"(",
"serverFonts",
")",
";",
"closeConnection",
"(",
")",... | Get list from server
@param {String} pattern pattern for search | [
"Get",
"list",
"from",
"server"
] | 624d93efd6bdd6b52bfe24b28db715d065600661 | https://github.com/konstantin24121/grunt-font-loader/blob/624d93efd6bdd6b52bfe24b28db715d065600661/tasks/font_loader.js#L214-L243 | train |
konstantin24121/grunt-font-loader | tasks/font_loader.js | formatingFontsArray | function formatingFontsArray(array) {
var fileContent = '',
file = [],
buffer = array[0].split('.')[0],
exp = [];
function writeResult() {
var str = buffer + ' [' + exp.join(', ') + ']';
fileContent += str + '\n';
grunt.log.ok(str);
}
array.forEach(function(item, i, arr) {
file = item.spl... | javascript | function formatingFontsArray(array) {
var fileContent = '',
file = [],
buffer = array[0].split('.')[0],
exp = [];
function writeResult() {
var str = buffer + ' [' + exp.join(', ') + ']';
fileContent += str + '\n';
grunt.log.ok(str);
}
array.forEach(function(item, i, arr) {
file = item.spl... | [
"function",
"formatingFontsArray",
"(",
"array",
")",
"{",
"var",
"fileContent",
"=",
"''",
",",
"file",
"=",
"[",
"]",
",",
"buffer",
"=",
"array",
"[",
"0",
"]",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
",",
"exp",
"=",
"[",
"]",
";",
"f... | Formating array with font into better readding
@param {Array} array | [
"Formating",
"array",
"with",
"font",
"into",
"better",
"readding"
] | 624d93efd6bdd6b52bfe24b28db715d065600661 | https://github.com/konstantin24121/grunt-font-loader/blob/624d93efd6bdd6b52bfe24b28db715d065600661/tasks/font_loader.js#L249-L277 | train |
bholloway/browserify-anonymous-labeler | lib/source-replacer.js | sourceReplacer | function sourceReplacer(source, replacements) {
// shared
var getBefore = getField('before');
var getAfter = getField('after');
// split source code into lines, include the delimiter
var lines = source.split(/(\r?\n)/g);
// split each line further by the replacements
for (var i = 0; i < lines.length; ... | javascript | function sourceReplacer(source, replacements) {
// shared
var getBefore = getField('before');
var getAfter = getField('after');
// split source code into lines, include the delimiter
var lines = source.split(/(\r?\n)/g);
// split each line further by the replacements
for (var i = 0; i < lines.length; ... | [
"function",
"sourceReplacer",
"(",
"source",
",",
"replacements",
")",
"{",
"// shared",
"var",
"getBefore",
"=",
"getField",
"(",
"'before'",
")",
";",
"var",
"getAfter",
"=",
"getField",
"(",
"'after'",
")",
";",
"// split source code into lines, include the delim... | Make replacements to the given source code and return a set of methods to utilise it.
@param {string} source Source code text without source-map comment
@param {object} replacements A hash of replacements to make
@returns {{toStringBefore:function, toStringAfter:function, getColumnAfter:function}} A set of methods | [
"Make",
"replacements",
"to",
"the",
"given",
"source",
"code",
"and",
"return",
"a",
"set",
"of",
"methods",
"to",
"utilise",
"it",
"."
] | 651b124eefe8d1a567b2a03a0b8a3dfea87c2703 | https://github.com/bholloway/browserify-anonymous-labeler/blob/651b124eefe8d1a567b2a03a0b8a3dfea87c2703/lib/source-replacer.js#L12-L80 | train |
bholloway/browserify-anonymous-labeler | lib/source-replacer.js | getColumnAfter | function getColumnAfter(lineIndex, columnIndex) {
if (lineIndex in lines) {
var line = lines[lineIndex];
var count = 0;
var offset = 0;
for (var i = 0; i < line.length; i++) {
var widthBefore = getBefore(line[i]).length;
var widthAfter = getAfter(line[i]).length;
... | javascript | function getColumnAfter(lineIndex, columnIndex) {
if (lineIndex in lines) {
var line = lines[lineIndex];
var count = 0;
var offset = 0;
for (var i = 0; i < line.length; i++) {
var widthBefore = getBefore(line[i]).length;
var widthAfter = getAfter(line[i]).length;
... | [
"function",
"getColumnAfter",
"(",
"lineIndex",
",",
"columnIndex",
")",
"{",
"if",
"(",
"lineIndex",
"in",
"lines",
")",
"{",
"var",
"line",
"=",
"lines",
"[",
"lineIndex",
"]",
";",
"var",
"count",
"=",
"0",
";",
"var",
"offset",
"=",
"0",
";",
"fo... | Get a column position delta as at the given line and column that has occured as a result of replacement.
@param {number} lineIndex The line in the original source at which to evaluate the offset
@param {number} columnIndex The column in the original source at which to evaluate the offset
@returns {number} A column offs... | [
"Get",
"a",
"column",
"position",
"delta",
"as",
"at",
"the",
"given",
"line",
"and",
"column",
"that",
"has",
"occured",
"as",
"a",
"result",
"of",
"replacement",
"."
] | 651b124eefe8d1a567b2a03a0b8a3dfea87c2703 | https://github.com/bholloway/browserify-anonymous-labeler/blob/651b124eefe8d1a567b2a03a0b8a3dfea87c2703/lib/source-replacer.js#L59-L79 | train |
vamship/wysknd-test | lib/utils.js | function(args) {
if (!args) {
return [];
}
if (args[0] instanceof Array) {
return args[0];
}
return Array.prototype.slice.call(args, 0);
} | javascript | function(args) {
if (!args) {
return [];
}
if (args[0] instanceof Array) {
return args[0];
}
return Array.prototype.slice.call(args, 0);
} | [
"function",
"(",
"args",
")",
"{",
"if",
"(",
"!",
"args",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"args",
"[",
"0",
"]",
"instanceof",
"Array",
")",
"{",
"return",
"args",
"[",
"0",
"]",
";",
"}",
"return",
"Array",
".",
"prototype"... | Converts input arguments into an addy of args. If the first arg is an
array, it is used as is. If not, all input args are converted into a
single array.
@param {Object} args The arguments object to be converted into an array.
@return {Array} An array representing the parsed arguments. | [
"Converts",
"input",
"arguments",
"into",
"an",
"addy",
"of",
"args",
".",
"If",
"the",
"first",
"arg",
"is",
"an",
"array",
"it",
"is",
"used",
"as",
"is",
".",
"If",
"not",
"all",
"input",
"args",
"are",
"converted",
"into",
"a",
"single",
"array",
... | b7791c42f1c1b36be7738e2c6d24748360634003 | https://github.com/vamship/wysknd-test/blob/b7791c42f1c1b36be7738e2c6d24748360634003/lib/utils.js#L13-L22 | train | |
dalekjs/dalek-reporter-json | index.js | Reporter | function Reporter (opts) {
this.events = opts.events;
this.config = opts.config;
this.data = {};
this.actionQueue = [];
this.data.tests = [];
this.browser = null;
var defaultReportFolder = 'report';
this.dest = this.config.get('json-reporter') && this.config.get('json-reporter').dest ? this.config.get(... | javascript | function Reporter (opts) {
this.events = opts.events;
this.config = opts.config;
this.data = {};
this.actionQueue = [];
this.data.tests = [];
this.browser = null;
var defaultReportFolder = 'report';
this.dest = this.config.get('json-reporter') && this.config.get('json-reporter').dest ? this.config.get(... | [
"function",
"Reporter",
"(",
"opts",
")",
"{",
"this",
".",
"events",
"=",
"opts",
".",
"events",
";",
"this",
".",
"config",
"=",
"opts",
".",
"config",
";",
"this",
".",
"data",
"=",
"{",
"}",
";",
"this",
".",
"actionQueue",
"=",
"[",
"]",
";"... | The JSON reporter can produce a file with the results of your testrun.
The reporter can be installed with the following command:
```
$ npm install dalek-reporter-json --save-dev
```
The file will follow the following format. This is a first draft and will
definitly change in future versions.
```javascript
{
"tests":... | [
"The",
"JSON",
"reporter",
"can",
"produce",
"a",
"file",
"with",
"the",
"results",
"of",
"your",
"testrun",
"."
] | 05c538813fd8e32d45c0aa480a7059df90f8c2c8 | https://github.com/dalekjs/dalek-reporter-json/blob/05c538813fd8e32d45c0aa480a7059df90f8c2c8/index.js#L101-L113 | train |
dalekjs/dalek-reporter-json | index.js | function (data) {
this.data.tests.push({
id: data.id,
name: data.name,
browser: this.browser,
status: data.status,
passedAssertions: data.passedAssertions,
failedAssertions: data.failedAssertions,
actions: this.actionQueue
});
return this;
} | javascript | function (data) {
this.data.tests.push({
id: data.id,
name: data.name,
browser: this.browser,
status: data.status,
passedAssertions: data.passedAssertions,
failedAssertions: data.failedAssertions,
actions: this.actionQueue
});
return this;
} | [
"function",
"(",
"data",
")",
"{",
"this",
".",
"data",
".",
"tests",
".",
"push",
"(",
"{",
"id",
":",
"data",
".",
"id",
",",
"name",
":",
"data",
".",
"name",
",",
"browser",
":",
"this",
".",
"browser",
",",
"status",
":",
"data",
".",
"sta... | Writes data for a finished testcase
@method testFinished
@param {object} data Event data
@chainable | [
"Writes",
"data",
"for",
"a",
"finished",
"testcase"
] | 05c538813fd8e32d45c0aa480a7059df90f8c2c8 | https://github.com/dalekjs/dalek-reporter-json/blob/05c538813fd8e32d45c0aa480a7059df90f8c2c8/index.js#L211-L222 | train | |
dalekjs/dalek-reporter-json | index.js | function (data) {
this.data.elapsedTime = data.elapsedTime;
this.data.status = data.status;
this.data.assertions = data.assertions;
this.data.assertionsFailed = data.assertionsFailed;
this.data.assertionsPassed = data.assertionsPassed;
var contents = JSON.stringify(this.data, false, 4);
if... | javascript | function (data) {
this.data.elapsedTime = data.elapsedTime;
this.data.status = data.status;
this.data.assertions = data.assertions;
this.data.assertionsFailed = data.assertionsFailed;
this.data.assertionsPassed = data.assertionsPassed;
var contents = JSON.stringify(this.data, false, 4);
if... | [
"function",
"(",
"data",
")",
"{",
"this",
".",
"data",
".",
"elapsedTime",
"=",
"data",
".",
"elapsedTime",
";",
"this",
".",
"data",
".",
"status",
"=",
"data",
".",
"status",
";",
"this",
".",
"data",
".",
"assertions",
"=",
"data",
".",
"assertio... | Serializes JSON and writes file to the file system
@method runnerFinished
@param {object} data Event data
@chainable | [
"Serializes",
"JSON",
"and",
"writes",
"file",
"to",
"the",
"file",
"system"
] | 05c538813fd8e32d45c0aa480a7059df90f8c2c8 | https://github.com/dalekjs/dalek-reporter-json/blob/05c538813fd8e32d45c0aa480a7059df90f8c2c8/index.js#L232-L249 | train | |
schwarzkopfb/hand-over | index.js | cloneArray | function cloneArray(a) {
var b = [], i = a.length
while (i--) b[ i ] = a[ i ]
return b
} | javascript | function cloneArray(a) {
var b = [], i = a.length
while (i--) b[ i ] = a[ i ]
return b
} | [
"function",
"cloneArray",
"(",
"a",
")",
"{",
"var",
"b",
"=",
"[",
"]",
",",
"i",
"=",
"a",
".",
"length",
"while",
"(",
"i",
"--",
")",
"b",
"[",
"i",
"]",
"=",
"a",
"[",
"i",
"]",
"return",
"b",
"}"
] | Utility that clones an array.
@param {Array} a
@return {Array} | [
"Utility",
"that",
"clones",
"an",
"array",
"."
] | d09b97e3da8f323df93ad00f10bff32ee8cf8acc | https://github.com/schwarzkopfb/hand-over/blob/d09b97e3da8f323df93ad00f10bff32ee8cf8acc/index.js#L162-L166 | train |
schwarzkopfb/hand-over | index.js | installPlugin | function installPlugin(nameOrPlugin, options) {
assert(nameOrPlugin, 'name or plugin is required')
var plugin,
ctor,
self = this,
parent = module.parent
if (typeof nameOrPlugin === 'string')
try {
// local plugin
if (nameOrPlugin.substring(0, 2) ==... | javascript | function installPlugin(nameOrPlugin, options) {
assert(nameOrPlugin, 'name or plugin is required')
var plugin,
ctor,
self = this,
parent = module.parent
if (typeof nameOrPlugin === 'string')
try {
// local plugin
if (nameOrPlugin.substring(0, 2) ==... | [
"function",
"installPlugin",
"(",
"nameOrPlugin",
",",
"options",
")",
"{",
"assert",
"(",
"nameOrPlugin",
",",
"'name or plugin is required'",
")",
"var",
"plugin",
",",
"ctor",
",",
"self",
"=",
"this",
",",
"parent",
"=",
"module",
".",
"parent",
"if",
"(... | Include and initialize a plugin that handles a notification channel.
@param {string|function|object} nameOrPlugin - Plugin name, constructor or instance to install.
@param {*} [options] - Initialization settings for the plugin.
@returns {Handover} | [
"Include",
"and",
"initialize",
"a",
"plugin",
"that",
"handles",
"a",
"notification",
"channel",
"."
] | d09b97e3da8f323df93ad00f10bff32ee8cf8acc | https://github.com/schwarzkopfb/hand-over/blob/d09b97e3da8f323df93ad00f10bff32ee8cf8acc/index.js#L175-L227 | train |
schwarzkopfb/hand-over | index.js | failed | function failed(err, userId, channel, target) {
if (err && typeof err === 'object') {
err.userId = userId
err.channel = channel
err.target = target
}
errors.push(err)
done()
} | javascript | function failed(err, userId, channel, target) {
if (err && typeof err === 'object') {
err.userId = userId
err.channel = channel
err.target = target
}
errors.push(err)
done()
} | [
"function",
"failed",
"(",
"err",
",",
"userId",
",",
"channel",
",",
"target",
")",
"{",
"if",
"(",
"err",
"&&",
"typeof",
"err",
"===",
"'object'",
")",
"{",
"err",
".",
"userId",
"=",
"userId",
"err",
".",
"channel",
"=",
"channel",
"err",
".",
... | helper for decorating error objects with debug info when possible and storing them to pass back to the caller when we're done | [
"helper",
"for",
"decorating",
"error",
"objects",
"with",
"debug",
"info",
"when",
"possible",
"and",
"storing",
"them",
"to",
"pass",
"back",
"to",
"the",
"caller",
"when",
"we",
"re",
"done"
] | d09b97e3da8f323df93ad00f10bff32ee8cf8acc | https://github.com/schwarzkopfb/hand-over/blob/d09b97e3da8f323df93ad00f10bff32ee8cf8acc/index.js#L250-L259 | train |
schwarzkopfb/hand-over | index.js | done | function done() {
var arg = errors.length ? errors : null
--pending || process.nextTick(callback, arg)
} | javascript | function done() {
var arg = errors.length ? errors : null
--pending || process.nextTick(callback, arg)
} | [
"function",
"done",
"(",
")",
"{",
"var",
"arg",
"=",
"errors",
".",
"length",
"?",
"errors",
":",
"null",
"--",
"pending",
"||",
"process",
".",
"nextTick",
"(",
"callback",
",",
"arg",
")",
"}"
] | helper for counting finished operations and call back when we're done | [
"helper",
"for",
"counting",
"finished",
"operations",
"and",
"call",
"back",
"when",
"we",
"re",
"done"
] | d09b97e3da8f323df93ad00f10bff32ee8cf8acc | https://github.com/schwarzkopfb/hand-over/blob/d09b97e3da8f323df93ad00f10bff32ee8cf8acc/index.js#L262-L265 | train |
schwarzkopfb/hand-over | index.js | registerTarget | function registerTarget(userId, channel, target, callback) {
this.save(userId, channel, target, function (err) {
// ensure that we're firing the callback asynchronously
process.nextTick(callback, err)
})
// make it chainable
return this
} | javascript | function registerTarget(userId, channel, target, callback) {
this.save(userId, channel, target, function (err) {
// ensure that we're firing the callback asynchronously
process.nextTick(callback, err)
})
// make it chainable
return this
} | [
"function",
"registerTarget",
"(",
"userId",
",",
"channel",
",",
"target",
",",
"callback",
")",
"{",
"this",
".",
"save",
"(",
"userId",
",",
"channel",
",",
"target",
",",
"function",
"(",
"err",
")",
"{",
"// ensure that we're firing the callback asynchronou... | Register a new target of a channel.
@param {*} userId - User identifier. Type is mostly string or number but depends on the consumer.
@param {string} channel - Channel name.
@param {*} target - An address to send notifications to. Eg. phone number, email address, push notification token, etc.
@param {function} callbac... | [
"Register",
"a",
"new",
"target",
"of",
"a",
"channel",
"."
] | d09b97e3da8f323df93ad00f10bff32ee8cf8acc | https://github.com/schwarzkopfb/hand-over/blob/d09b97e3da8f323df93ad00f10bff32ee8cf8acc/index.js#L334-L342 | train |
schwarzkopfb/hand-over | index.js | unregisterTargets | function unregisterTargets(userId, channel, targets, callback) {
var self = this
// no target list specified, so we need to load all the targets
// of the supplied channel
if (arguments.length < 4) {
// probably we've got the callback as the third arg
callback = targets
this.lo... | javascript | function unregisterTargets(userId, channel, targets, callback) {
var self = this
// no target list specified, so we need to load all the targets
// of the supplied channel
if (arguments.length < 4) {
// probably we've got the callback as the third arg
callback = targets
this.lo... | [
"function",
"unregisterTargets",
"(",
"userId",
",",
"channel",
",",
"targets",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
"// no target list specified, so we need to load all the targets",
"// of the supplied channel",
"if",
"(",
"arguments",
".",
"length",
... | Remove a previously saved channel or target.
@param {*} userId - User identifier. Type is mostly string or number but depends on the consumer.
@param {string} channel - Channel name.
@param {*|*[]} [targets] - The target or list of targets to remove. If not supplied, then all the targets of the given channel will be r... | [
"Remove",
"a",
"previously",
"saved",
"channel",
"or",
"target",
"."
] | d09b97e3da8f323df93ad00f10bff32ee8cf8acc | https://github.com/schwarzkopfb/hand-over/blob/d09b97e3da8f323df93ad00f10bff32ee8cf8acc/index.js#L353-L394 | train |
schwarzkopfb/hand-over | index.js | removeTargets | function removeTargets(self, userId, channel, targets, callback) {
// dereference the original array,
// because that may not be trustworthy
targets = cloneArray(targets)
var pending = targets.length,
errors = []
if (pending)
targets.forEach(function (target) {
self.re... | javascript | function removeTargets(self, userId, channel, targets, callback) {
// dereference the original array,
// because that may not be trustworthy
targets = cloneArray(targets)
var pending = targets.length,
errors = []
if (pending)
targets.forEach(function (target) {
self.re... | [
"function",
"removeTargets",
"(",
"self",
",",
"userId",
",",
"channel",
",",
"targets",
",",
"callback",
")",
"{",
"// dereference the original array,",
"// because that may not be trustworthy",
"targets",
"=",
"cloneArray",
"(",
"targets",
")",
"var",
"pending",
"="... | Internal func to remove the provided targets. Same as `unregisterTargets` but it assumes that `targets` is an array.
@param {Handover} self - Handover instance to work on.
@param {*} userId
@param {string} channel
@param {*[]} targets
@param {function} callback | [
"Internal",
"func",
"to",
"remove",
"the",
"provided",
"targets",
".",
"Same",
"as",
"unregisterTargets",
"but",
"it",
"assumes",
"that",
"targets",
"is",
"an",
"array",
"."
] | d09b97e3da8f323df93ad00f10bff32ee8cf8acc | https://github.com/schwarzkopfb/hand-over/blob/d09b97e3da8f323df93ad00f10bff32ee8cf8acc/index.js#L405-L438 | train |
schwarzkopfb/hand-over | index.js | unreference | function unreference() {
var plugins = this._plugins
Object.keys(plugins).forEach(function (name) {
var plugin = plugins[ name ]
// `unref()` is preferred
if (typeof plugin.unref === 'function')
plugin.unref()
// if we cannot stop gracefully then destroy open
... | javascript | function unreference() {
var plugins = this._plugins
Object.keys(plugins).forEach(function (name) {
var plugin = plugins[ name ]
// `unref()` is preferred
if (typeof plugin.unref === 'function')
plugin.unref()
// if we cannot stop gracefully then destroy open
... | [
"function",
"unreference",
"(",
")",
"{",
"var",
"plugins",
"=",
"this",
".",
"_plugins",
"Object",
".",
"keys",
"(",
"plugins",
")",
".",
"forEach",
"(",
"function",
"(",
"name",
")",
"{",
"var",
"plugin",
"=",
"plugins",
"[",
"name",
"]",
"// `unref(... | Unreference all the included plugins to let the process exit gracefully.
@returns {Handover} | [
"Unreference",
"all",
"the",
"included",
"plugins",
"to",
"let",
"the",
"process",
"exit",
"gracefully",
"."
] | d09b97e3da8f323df93ad00f10bff32ee8cf8acc | https://github.com/schwarzkopfb/hand-over/blob/d09b97e3da8f323df93ad00f10bff32ee8cf8acc/index.js#L445-L465 | train |
xhochy/node-tomahawkjs | lib/cli/commands.js | function (path, callback) {
fs.stat(path, function (err, stats) {
failOn(err, "Error while reading the resolver path:", err);
if (stats.isFile()) {
TomahawkJS.loadAxe(path, _.partial(statResolver, callback));
} else if (stats.isDirectory()) {
// Load the resolver from... | javascript | function (path, callback) {
fs.stat(path, function (err, stats) {
failOn(err, "Error while reading the resolver path:", err);
if (stats.isFile()) {
TomahawkJS.loadAxe(path, _.partial(statResolver, callback));
} else if (stats.isDirectory()) {
// Load the resolver from... | [
"function",
"(",
"path",
",",
"callback",
")",
"{",
"fs",
".",
"stat",
"(",
"path",
",",
"function",
"(",
"err",
",",
"stats",
")",
"{",
"failOn",
"(",
"err",
",",
"\"Error while reading the resolver path:\"",
",",
"err",
")",
";",
"if",
"(",
"stats",
... | Load an AXE bundle and terminate on errors. | [
"Load",
"an",
"AXE",
"bundle",
"and",
"terminate",
"on",
"errors",
"."
] | 5f3e71a361dcb7a8517807826668332ed5b30303 | https://github.com/xhochy/node-tomahawkjs/blob/5f3e71a361dcb7a8517807826668332ed5b30303/lib/cli/commands.js#L29-L43 | train | |
mnichols/node-event-store | storage/redis/redis-stream.js | concat | function concat (target, data) {
target = target || []
if(Object.prototype.toString.call(data)!=='[object Array]') {
data = [data]
}
Array.prototype.push.apply(target, data)
return target
} | javascript | function concat (target, data) {
target = target || []
if(Object.prototype.toString.call(data)!=='[object Array]') {
data = [data]
}
Array.prototype.push.apply(target, data)
return target
} | [
"function",
"concat",
"(",
"target",
",",
"data",
")",
"{",
"target",
"=",
"target",
"||",
"[",
"]",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"data",
")",
"!==",
"'[object Array]'",
")",
"{",
"data",
"=",
"[",
"data",... | presumably faster than Array.concat | [
"presumably",
"faster",
"than",
"Array",
".",
"concat"
] | 1b03fc39604b100acf4404484a35e3042efddc4a | https://github.com/mnichols/node-event-store/blob/1b03fc39604b100acf4404484a35e3042efddc4a/storage/redis/redis-stream.js#L118-L125 | train |
vkiding/judpack-common | src/util/xml-helpers.js | function(doc, nodes, selector, after) {
var parent = module.exports.resolveParent(doc, selector);
if (!parent) {
//Try to create the parent recursively if necessary
try {
var parentToCreate = et.XML('<' + path.basename(selector) + '>'),
parentS... | javascript | function(doc, nodes, selector, after) {
var parent = module.exports.resolveParent(doc, selector);
if (!parent) {
//Try to create the parent recursively if necessary
try {
var parentToCreate = et.XML('<' + path.basename(selector) + '>'),
parentS... | [
"function",
"(",
"doc",
",",
"nodes",
",",
"selector",
",",
"after",
")",
"{",
"var",
"parent",
"=",
"module",
".",
"exports",
".",
"resolveParent",
"(",
"doc",
",",
"selector",
")",
";",
"if",
"(",
"!",
"parent",
")",
"{",
"//Try to create the parent re... | adds node to doc at selector, creating parent if it doesn't exist | [
"adds",
"node",
"to",
"doc",
"at",
"selector",
"creating",
"parent",
"if",
"it",
"doesn",
"t",
"exist"
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/util/xml-helpers.js#L59-L87 | train | |
vkiding/judpack-common | src/util/xml-helpers.js | function(doc, nodes, selector) {
var parent = module.exports.resolveParent(doc, selector);
if (!parent) return false;
nodes.forEach(function (node) {
var matchingKid = null;
if ((matchingKid = findChild(node, parent)) !== null) {
// stupid elementtree tak... | javascript | function(doc, nodes, selector) {
var parent = module.exports.resolveParent(doc, selector);
if (!parent) return false;
nodes.forEach(function (node) {
var matchingKid = null;
if ((matchingKid = findChild(node, parent)) !== null) {
// stupid elementtree tak... | [
"function",
"(",
"doc",
",",
"nodes",
",",
"selector",
")",
"{",
"var",
"parent",
"=",
"module",
".",
"exports",
".",
"resolveParent",
"(",
"doc",
",",
"selector",
")",
";",
"if",
"(",
"!",
"parent",
")",
"return",
"false",
";",
"nodes",
".",
"forEac... | removes node from doc at selector | [
"removes",
"node",
"from",
"doc",
"at",
"selector"
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/util/xml-helpers.js#L135-L149 | train | |
vkiding/judpack-common | src/util/xml-helpers.js | function(doc, selector, xml) {
var target = module.exports.resolveParent(doc, selector);
if (!target) return false;
if (xml.oldAttrib) {
target.attrib = _.extend({}, xml.oldAttrib);
}
return true;
} | javascript | function(doc, selector, xml) {
var target = module.exports.resolveParent(doc, selector);
if (!target) return false;
if (xml.oldAttrib) {
target.attrib = _.extend({}, xml.oldAttrib);
}
return true;
} | [
"function",
"(",
"doc",
",",
"selector",
",",
"xml",
")",
"{",
"var",
"target",
"=",
"module",
".",
"exports",
".",
"resolveParent",
"(",
"doc",
",",
"selector",
")",
";",
"if",
"(",
"!",
"target",
")",
"return",
"false",
";",
"if",
"(",
"xml",
"."... | restores attributes from doc at selector | [
"restores",
"attributes",
"from",
"doc",
"at",
"selector"
] | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/util/xml-helpers.js#L152-L161 | train | |
vkiding/judpack-common | src/util/xml-helpers.js | findInsertIdx | function findInsertIdx(children, after) {
var childrenTags = children.map(function(child) { return child.tag; });
var afters = after.split(';');
var afterIndexes = afters.map(function(current) { return childrenTags.lastIndexOf(current); });
var foundIndex = _.find(afterIndexes, function(index) { return ... | javascript | function findInsertIdx(children, after) {
var childrenTags = children.map(function(child) { return child.tag; });
var afters = after.split(';');
var afterIndexes = afters.map(function(current) { return childrenTags.lastIndexOf(current); });
var foundIndex = _.find(afterIndexes, function(index) { return ... | [
"function",
"findInsertIdx",
"(",
"children",
",",
"after",
")",
"{",
"var",
"childrenTags",
"=",
"children",
".",
"map",
"(",
"function",
"(",
"child",
")",
"{",
"return",
"child",
".",
"tag",
";",
"}",
")",
";",
"var",
"afters",
"=",
"after",
".",
... | Find the index at which to insert an entry. After is a ;-separated priority list of tags after which the insertion should be made. E.g. If we need to insert an element C, and the rule is that the order of children has to be As, Bs, Cs. After will be equal to "C;B;A". | [
"Find",
"the",
"index",
"at",
"which",
"to",
"insert",
"an",
"entry",
".",
"After",
"is",
"a",
";",
"-",
"separated",
"priority",
"list",
"of",
"tags",
"after",
"which",
"the",
"insertion",
"should",
"be",
"made",
".",
"E",
".",
"g",
".",
"If",
"we",... | 5b87d3f1cb10c2c867243e3a692d39b4bb189dd4 | https://github.com/vkiding/judpack-common/blob/5b87d3f1cb10c2c867243e3a692d39b4bb189dd4/src/util/xml-helpers.js#L247-L255 | train |
gethuman/pancakes-angular | lib/middleware/jng.utils.js | attachToScope | function attachToScope(model, itemsToAttach) {
var me = this;
_.each(itemsToAttach, function (item) {
if (me.pancakes.exists(item, null)) {
model[item] = me.pancakes.cook(item, null);
}
});
} | javascript | function attachToScope(model, itemsToAttach) {
var me = this;
_.each(itemsToAttach, function (item) {
if (me.pancakes.exists(item, null)) {
model[item] = me.pancakes.cook(item, null);
}
});
} | [
"function",
"attachToScope",
"(",
"model",
",",
"itemsToAttach",
")",
"{",
"var",
"me",
"=",
"this",
";",
"_",
".",
"each",
"(",
"itemsToAttach",
",",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"me",
".",
"pancakes",
".",
"exists",
"(",
"item",
",... | Given an array of items, load them and add them to the model
@param model
@param itemsToAttach | [
"Given",
"an",
"array",
"of",
"items",
"load",
"them",
"and",
"add",
"them",
"to",
"the",
"model"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.utils.js#L222-L230 | train |
gethuman/pancakes-angular | lib/middleware/jng.utils.js | getAppFileNames | function getAppFileNames(appName, dir) {
var partialsDir = this.pancakes.getRootDir() + delim + 'app' + delim + appName + delim + dir;
return fs.existsSync(partialsDir) ? fs.readdirSync(partialsDir) : [];
} | javascript | function getAppFileNames(appName, dir) {
var partialsDir = this.pancakes.getRootDir() + delim + 'app' + delim + appName + delim + dir;
return fs.existsSync(partialsDir) ? fs.readdirSync(partialsDir) : [];
} | [
"function",
"getAppFileNames",
"(",
"appName",
",",
"dir",
")",
"{",
"var",
"partialsDir",
"=",
"this",
".",
"pancakes",
".",
"getRootDir",
"(",
")",
"+",
"delim",
"+",
"'app'",
"+",
"delim",
"+",
"appName",
"+",
"delim",
"+",
"dir",
";",
"return",
"fs... | Get all file names in a given app's directory
@param appName
@param dir
@returns {*} | [
"Get",
"all",
"file",
"names",
"in",
"a",
"given",
"app",
"s",
"directory"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.utils.js#L238-L241 | train |
gethuman/pancakes-angular | lib/middleware/jng.utils.js | dotToCamelCase | function dotToCamelCase(name) {
if (!name) { return name; }
if (name.substring(name.length - 3) === '.js') {
name = name.substring(0, name.length - 3);
}
name = name.toLowerCase();
var parts = name.split('.');
name = parts[0];
for (var i = 1; i < parts.length; i++) {
name ... | javascript | function dotToCamelCase(name) {
if (!name) { return name; }
if (name.substring(name.length - 3) === '.js') {
name = name.substring(0, name.length - 3);
}
name = name.toLowerCase();
var parts = name.split('.');
name = parts[0];
for (var i = 1; i < parts.length; i++) {
name ... | [
"function",
"dotToCamelCase",
"(",
"name",
")",
"{",
"if",
"(",
"!",
"name",
")",
"{",
"return",
"name",
";",
"}",
"if",
"(",
"name",
".",
"substring",
"(",
"name",
".",
"length",
"-",
"3",
")",
"===",
"'.js'",
")",
"{",
"name",
"=",
"name",
".",... | Convert a name with dot delim to camel case and remove any .js
@param name | [
"Convert",
"a",
"name",
"with",
"dot",
"delim",
"to",
"camel",
"case",
"and",
"remove",
"any",
".",
"js"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.utils.js#L260-L276 | train |
gethuman/pancakes-angular | lib/middleware/jng.utils.js | registerJytPlugins | function registerJytPlugins() {
var rootDir = this.pancakes.getRootDir();
var pluginDir = path.normalize(rootDir + '/app/common/jyt.plugins');
var me = this;
// if plugin dir doesn't exist, just return
if (!fs.existsSync(pluginDir)) { return; }
// else get all plugin files from the jyt.plugin... | javascript | function registerJytPlugins() {
var rootDir = this.pancakes.getRootDir();
var pluginDir = path.normalize(rootDir + '/app/common/jyt.plugins');
var me = this;
// if plugin dir doesn't exist, just return
if (!fs.existsSync(pluginDir)) { return; }
// else get all plugin files from the jyt.plugin... | [
"function",
"registerJytPlugins",
"(",
")",
"{",
"var",
"rootDir",
"=",
"this",
".",
"pancakes",
".",
"getRootDir",
"(",
")",
";",
"var",
"pluginDir",
"=",
"path",
".",
"normalize",
"(",
"rootDir",
"+",
"'/app/common/jyt.plugins'",
")",
";",
"var",
"me",
"... | Register plugins from the jyt.plugins dir | [
"Register",
"plugins",
"from",
"the",
"jyt",
".",
"plugins",
"dir"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.utils.js#L281-L299 | train |
gethuman/pancakes-angular | lib/middleware/jng.utils.js | isMobileApp | function isMobileApp() {
var isMobile = false;
var appConfigs = this.pancakes.cook('appConfigs', null);
_.each(appConfigs, function (appConfig) {
if (appConfig.isMobile) {
isMobile = true;
}
});
return isMobile;
} | javascript | function isMobileApp() {
var isMobile = false;
var appConfigs = this.pancakes.cook('appConfigs', null);
_.each(appConfigs, function (appConfig) {
if (appConfig.isMobile) {
isMobile = true;
}
});
return isMobile;
} | [
"function",
"isMobileApp",
"(",
")",
"{",
"var",
"isMobile",
"=",
"false",
";",
"var",
"appConfigs",
"=",
"this",
".",
"pancakes",
".",
"cook",
"(",
"'appConfigs'",
",",
"null",
")",
";",
"_",
".",
"each",
"(",
"appConfigs",
",",
"function",
"(",
"appC... | Find out if there is a mobile app in the current project
@returns {boolean} | [
"Find",
"out",
"if",
"there",
"is",
"a",
"mobile",
"app",
"in",
"the",
"current",
"project"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.utils.js#L305-L316 | train |
gethuman/pancakes-angular | lib/middleware/jng.utils.js | doesFileExist | function doesFileExist(filePath) {
if (!fileExistsCache.hasOwnProperty(filePath)) {
fileExistsCache[filePath] = fs.existsSync(filePath);
}
return fileExistsCache[filePath];
} | javascript | function doesFileExist(filePath) {
if (!fileExistsCache.hasOwnProperty(filePath)) {
fileExistsCache[filePath] = fs.existsSync(filePath);
}
return fileExistsCache[filePath];
} | [
"function",
"doesFileExist",
"(",
"filePath",
")",
"{",
"if",
"(",
"!",
"fileExistsCache",
".",
"hasOwnProperty",
"(",
"filePath",
")",
")",
"{",
"fileExistsCache",
"[",
"filePath",
"]",
"=",
"fs",
".",
"existsSync",
"(",
"filePath",
")",
";",
"}",
"return... | Check to see if a particular file exists; cache results
@param filePath
@returns {*} | [
"Check",
"to",
"see",
"if",
"a",
"particular",
"file",
"exists",
";",
"cache",
"results"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.utils.js#L342-L348 | train |
beeblebrox3/super-helpers | src/object/isCyclic.js | isCyclic | function isCyclic(obj) {
let seenObjects = [];
const detect = obj => {
if (obj && typeof obj === "object") {
if (seenObjects.includes(obj)) {
return true;
}
seenObjects.push(obj);
for (const key in obj) {
if (obj.hasOwnPro... | javascript | function isCyclic(obj) {
let seenObjects = [];
const detect = obj => {
if (obj && typeof obj === "object") {
if (seenObjects.includes(obj)) {
return true;
}
seenObjects.push(obj);
for (const key in obj) {
if (obj.hasOwnPro... | [
"function",
"isCyclic",
"(",
"obj",
")",
"{",
"let",
"seenObjects",
"=",
"[",
"]",
";",
"const",
"detect",
"=",
"obj",
"=>",
"{",
"if",
"(",
"obj",
"&&",
"typeof",
"obj",
"===",
"\"object\"",
")",
"{",
"if",
"(",
"seenObjects",
".",
"includes",
"(",
... | Check if any given object has some kind of cyclic reference.
@param {Object} obj the source to be checked
@return {boolean}
@memberof object | [
"Check",
"if",
"any",
"given",
"object",
"has",
"some",
"kind",
"of",
"cyclic",
"reference",
"."
] | 15deaf3509bfe47817e6dd3ecd3e6879743b7dd9 | https://github.com/beeblebrox3/super-helpers/blob/15deaf3509bfe47817e6dd3ecd3e6879743b7dd9/src/object/isCyclic.js#L8-L29 | train |
copress/copress-component-oauth2 | lib/oauth2.js | function (req, res, next) {
if (options.forceAuthorize) {
return next();
}
var userId = req.oauth2.user.id;
var clientId = req.oauth2.client.id;
var scope = req.oauth2.req.scope;
models.Permissions.isAuthorized(clientId, userId, sco... | javascript | function (req, res, next) {
if (options.forceAuthorize) {
return next();
}
var userId = req.oauth2.user.id;
var clientId = req.oauth2.client.id;
var scope = req.oauth2.req.scope;
models.Permissions.isAuthorized(clientId, userId, sco... | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"options",
".",
"forceAuthorize",
")",
"{",
"return",
"next",
"(",
")",
";",
"}",
"var",
"userId",
"=",
"req",
".",
"oauth2",
".",
"user",
".",
"id",
";",
"var",
"clientId",
"=... | Check if the user has granted permissions to the client app | [
"Check",
"if",
"the",
"user",
"has",
"granted",
"permissions",
"to",
"the",
"client",
"app"
] | 4819f379a0d42753bfd51e237c5c3aaddee37544 | https://github.com/copress/copress-component-oauth2/blob/4819f379a0d42753bfd51e237c5c3aaddee37544/lib/oauth2.js#L601-L626 | train | |
copress/copress-component-oauth2 | lib/oauth2.js | function (req, res, next) {
if (options.decisionPage) {
var urlObj = {
pathname: options.decisionPage,
query: {
transactionId: req.oauth2.transactionID,
userId: req.oauth2.user.id,
... | javascript | function (req, res, next) {
if (options.decisionPage) {
var urlObj = {
pathname: options.decisionPage,
query: {
transactionId: req.oauth2.transactionID,
userId: req.oauth2.user.id,
... | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"options",
".",
"decisionPage",
")",
"{",
"var",
"urlObj",
"=",
"{",
"pathname",
":",
"options",
".",
"decisionPage",
",",
"query",
":",
"{",
"transactionId",
":",
"req",
".",
"oau... | Now try to render the dialog to approve client app's request for permissions | [
"Now",
"try",
"to",
"render",
"the",
"dialog",
"to",
"approve",
"client",
"app",
"s",
"request",
"for",
"permissions"
] | 4819f379a0d42753bfd51e237c5c3aaddee37544 | https://github.com/copress/copress-component-oauth2/blob/4819f379a0d42753bfd51e237c5c3aaddee37544/lib/oauth2.js#L628-L649 | train | |
copress/copress-component-oauth2 | lib/oauth2.js | clientLogin | function clientLogin(clientId, clientSecret, done) {
debug('clientLogin: %s', clientId);
clientId = parseInt(clientId);
if (!clientId && clientId !== 0) {
return done(null, false);
}
models.Clients.findByClientId(clientId, function (err, client) {
if (er... | javascript | function clientLogin(clientId, clientSecret, done) {
debug('clientLogin: %s', clientId);
clientId = parseInt(clientId);
if (!clientId && clientId !== 0) {
return done(null, false);
}
models.Clients.findByClientId(clientId, function (err, client) {
if (er... | [
"function",
"clientLogin",
"(",
"clientId",
",",
"clientSecret",
",",
"done",
")",
"{",
"debug",
"(",
"'clientLogin: %s'",
",",
"clientId",
")",
";",
"clientId",
"=",
"parseInt",
"(",
"clientId",
")",
";",
"if",
"(",
"!",
"clientId",
"&&",
"clientId",
"!==... | BasicStrategy & ClientPasswordStrategy
These strategies are used to authenticate registered OAuth clients. They are
employed to protect the `token` endpoint, which consumers use to obtain
access tokens. The OAuth 2.0 specification suggests that clients use the
HTTP Basic scheme to authenticate. Use of the client pa... | [
"BasicStrategy",
"&",
"ClientPasswordStrategy"
] | 4819f379a0d42753bfd51e237c5c3aaddee37544 | https://github.com/copress/copress-component-oauth2/blob/4819f379a0d42753bfd51e237c5c3aaddee37544/lib/oauth2.js#L708-L729 | train |
blueskyfish/bluesky-logger | factory.js | function (namespaces) {
_.forEach(namespaces, function (level, namespace) {
cache.add(namespace, level);
});
return this;
} | javascript | function (namespaces) {
_.forEach(namespaces, function (level, namespace) {
cache.add(namespace, level);
});
return this;
} | [
"function",
"(",
"namespaces",
")",
"{",
"_",
".",
"forEach",
"(",
"namespaces",
",",
"function",
"(",
"level",
",",
"namespace",
")",
"{",
"cache",
".",
"add",
"(",
"namespace",
",",
"level",
")",
";",
"}",
")",
";",
"return",
"this",
";",
"}"
] | set the namespaces configuration.
Config object
```
{
'root': 'all',
'namespace1.namespace2': 'info',
}
```
**root** namespace is for all unknown namespaces.
@param {object} namespaces the map with the namespace and its log level
@return {self} | [
"set",
"the",
"namespaces",
"configuration",
"."
] | 87f7324e19222595fabfe9a8c9c5031f9546e16a | https://github.com/blueskyfish/bluesky-logger/blob/87f7324e19222595fabfe9a8c9c5031f9546e16a/factory.js#L33-L38 | train | |
totorojs/totoro-logger | lib/console.js | function(level, title, format, filters, needstack, args) {
var msg = utils.format.apply(this, args)
var data = {
timestamp : dateFormat(new Date(), _config.dateformat),
message : msg,
title : title,
level : level,
args : args
}
... | javascript | function(level, title, format, filters, needstack, args) {
var msg = utils.format.apply(this, args)
var data = {
timestamp : dateFormat(new Date(), _config.dateformat),
message : msg,
title : title,
level : level,
args : args
}
... | [
"function",
"(",
"level",
",",
"title",
",",
"format",
",",
"filters",
",",
"needstack",
",",
"args",
")",
"{",
"var",
"msg",
"=",
"utils",
".",
"format",
".",
"apply",
"(",
"this",
",",
"args",
")",
"var",
"data",
"=",
"{",
"timestamp",
":",
"date... | main log method | [
"main",
"log",
"method"
] | 1865b681e40bcd4a956226a016bcca4c0339cd6e | https://github.com/totorojs/totoro-logger/blob/1865b681e40bcd4a956226a016bcca4c0339cd6e/lib/console.js#L26-L74 | train | |
dutchenkoOleg/gulp-not-supported-file | index.js | withFilePath | function withFilePath (file, msg) {
if (file && file.path) {
msg += `\n ${file.path}`;
}
return msg;
} | javascript | function withFilePath (file, msg) {
if (file && file.path) {
msg += `\n ${file.path}`;
}
return msg;
} | [
"function",
"withFilePath",
"(",
"file",
",",
"msg",
")",
"{",
"if",
"(",
"file",
"&&",
"file",
".",
"path",
")",
"{",
"msg",
"+=",
"`",
"\\n",
"${",
"file",
".",
"path",
"}",
"`",
";",
"}",
"return",
"msg",
";",
"}"
] | Get msg with file path if exist
@param {File} file
@param {string} msg
@return {string}
@private | [
"Get",
"msg",
"with",
"file",
"path",
"if",
"exist"
] | 6a49c9df53bb3131828524eed71d30b73df36035 | https://github.com/dutchenkoOleg/gulp-not-supported-file/blob/6a49c9df53bb3131828524eed71d30b73df36035/index.js#L35-L40 | train |
feedhenry/fh-mbaas-middleware | lib/middleware/forms.js | _createRequestParams | function _createRequestParams(params){
var resourcePath = params.resourcePath;
resourcePath = resourcePath.replace(":domain", params.domain)
.replace(":projectid", params.projectid)
.replace(":guid", params.appid);
log.logger.debug("Creating Request Params For Core ", params);
var coreHost = params.ap... | javascript | function _createRequestParams(params){
var resourcePath = params.resourcePath;
resourcePath = resourcePath.replace(":domain", params.domain)
.replace(":projectid", params.projectid)
.replace(":guid", params.appid);
log.logger.debug("Creating Request Params For Core ", params);
var coreHost = params.ap... | [
"function",
"_createRequestParams",
"(",
"params",
")",
"{",
"var",
"resourcePath",
"=",
"params",
".",
"resourcePath",
";",
"resourcePath",
"=",
"resourcePath",
".",
"replace",
"(",
"\":domain\"",
",",
"params",
".",
"domain",
")",
".",
"replace",
"(",
"\":pr... | Creating A Request To Supercore. Supercore will authenticate the app request. | [
"Creating",
"A",
"Request",
"To",
"Supercore",
".",
"Supercore",
"will",
"authenticate",
"the",
"app",
"request",
"."
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/forms.js#L7-L29 | train |
feedhenry/fh-mbaas-middleware | lib/middleware/forms.js | _createResponseHandler | function _createResponseHandler(req, next, skipDataResult){
return function(err, httpResponse, responseBody){
log.logger.debug("Performing Core Action ", req.url, err, httpResponse.statusCode, responseBody);
if(err || (httpResponse.statusCode !== 200 && httpResponse.statusCode !== 204)){
return next(er... | javascript | function _createResponseHandler(req, next, skipDataResult){
return function(err, httpResponse, responseBody){
log.logger.debug("Performing Core Action ", req.url, err, httpResponse.statusCode, responseBody);
if(err || (httpResponse.statusCode !== 200 && httpResponse.statusCode !== 204)){
return next(er... | [
"function",
"_createResponseHandler",
"(",
"req",
",",
"next",
",",
"skipDataResult",
")",
"{",
"return",
"function",
"(",
"err",
",",
"httpResponse",
",",
"responseBody",
")",
"{",
"log",
".",
"logger",
".",
"debug",
"(",
"\"Performing Core Action \"",
",",
"... | Utility function for creating response handlers
@param req
@param next
@returns {Function} | [
"Utility",
"function",
"for",
"creating",
"response",
"handlers"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/forms.js#L38-L55 | train |
feedhenry/fh-mbaas-middleware | lib/middleware/forms.js | checkFormAssociation | function checkFormAssociation(req, res, next){
var requestedFormId = req.params.id;
req.appformsResultPayload = req.appformsResultPayload || {};
var formsAssociatedWithProject = req.appformsResultPayload.data || [];
var foundForm = _.find(formsAssociatedWithProject, function(formId){
return requestedFormId... | javascript | function checkFormAssociation(req, res, next){
var requestedFormId = req.params.id;
req.appformsResultPayload = req.appformsResultPayload || {};
var formsAssociatedWithProject = req.appformsResultPayload.data || [];
var foundForm = _.find(formsAssociatedWithProject, function(formId){
return requestedFormId... | [
"function",
"checkFormAssociation",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"requestedFormId",
"=",
"req",
".",
"params",
".",
"id",
";",
"req",
".",
"appformsResultPayload",
"=",
"req",
".",
"appformsResultPayload",
"||",
"{",
"}",
";",
"var... | Middleware To Check That A Requested Form Exists
@param req
@param res
@param next | [
"Middleware",
"To",
"Check",
"That",
"A",
"Requested",
"Form",
"Exists"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/forms.js#L64-L79 | train |
feedhenry/fh-mbaas-middleware | lib/middleware/forms.js | notifySubmissionComplete | function notifySubmissionComplete(req, res, next){
req.appformsResultPayload = req.appformsResultPayload || {};
var completeStatus = req.appformsResultPayload.data;
var submission = completeStatus.formSubmission;
//The Submission Is Not Complete, No need to send a notification.
if("complete" !== completeStat... | javascript | function notifySubmissionComplete(req, res, next){
req.appformsResultPayload = req.appformsResultPayload || {};
var completeStatus = req.appformsResultPayload.data;
var submission = completeStatus.formSubmission;
//The Submission Is Not Complete, No need to send a notification.
if("complete" !== completeStat... | [
"function",
"notifySubmissionComplete",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"req",
".",
"appformsResultPayload",
"=",
"req",
".",
"appformsResultPayload",
"||",
"{",
"}",
";",
"var",
"completeStatus",
"=",
"req",
".",
"appformsResultPayload",
".",
"... | Function To Notify Core Platform That The Submission Is Complete. The core platform will send a mail to any subscribers.
@param req
@param res
@param next | [
"Function",
"To",
"Notify",
"Core",
"Platform",
"That",
"The",
"Submission",
"Is",
"Complete",
".",
"The",
"core",
"platform",
"will",
"send",
"a",
"mail",
"to",
"any",
"subscribers",
"."
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/forms.js#L87-L110 | train |
klovadis/redis-lua-helper | lib/index.js | replaceMacro | function replaceMacro(code) {
if (!re) return getKeys(code);
var match = code.match(re);
if (!match) return getKeys(code);
var includeFile = match[1];
includeFile = path.relative(self.config.root, path.join(path.dirname(fileName), includeFile));
self._parse(includeFile, function (err, includeCode) {
if... | javascript | function replaceMacro(code) {
if (!re) return getKeys(code);
var match = code.match(re);
if (!match) return getKeys(code);
var includeFile = match[1];
includeFile = path.relative(self.config.root, path.join(path.dirname(fileName), includeFile));
self._parse(includeFile, function (err, includeCode) {
if... | [
"function",
"replaceMacro",
"(",
"code",
")",
"{",
"if",
"(",
"!",
"re",
")",
"return",
"getKeys",
"(",
"code",
")",
";",
"var",
"match",
"=",
"code",
".",
"match",
"(",
"re",
")",
";",
"if",
"(",
"!",
"match",
")",
"return",
"getKeys",
"(",
"cod... | get included files | [
"get",
"included",
"files"
] | f23b82054b8ea3c08b7713c6f996fd6f43b55e04 | https://github.com/klovadis/redis-lua-helper/blob/f23b82054b8ea3c08b7713c6f996fd6f43b55e04/lib/index.js#L162-L178 | train |
klovadis/redis-lua-helper | lib/index.js | done | function done(code) {
// calculate shasum and cache info
var shasum = crypto.createHash('sha1');
shasum.update(code);
self._shasums[scriptName] = shasum.digest('hex');
self._scripts[scriptName] = code;
self._files[fileName] = code;
// make dublicate entries for both script and script.lua
if (path.extna... | javascript | function done(code) {
// calculate shasum and cache info
var shasum = crypto.createHash('sha1');
shasum.update(code);
self._shasums[scriptName] = shasum.digest('hex');
self._scripts[scriptName] = code;
self._files[fileName] = code;
// make dublicate entries for both script and script.lua
if (path.extna... | [
"function",
"done",
"(",
"code",
")",
"{",
"// calculate shasum and cache info",
"var",
"shasum",
"=",
"crypto",
".",
"createHash",
"(",
"'sha1'",
")",
";",
"shasum",
".",
"update",
"(",
"code",
")",
";",
"self",
".",
"_shasums",
"[",
"scriptName",
"]",
"=... | file has been loaded | [
"file",
"has",
"been",
"loaded"
] | f23b82054b8ea3c08b7713c6f996fd6f43b55e04 | https://github.com/klovadis/redis-lua-helper/blob/f23b82054b8ea3c08b7713c6f996fd6f43b55e04/lib/index.js#L195-L213 | train |
origin1tech/stiks | dist/exec.js | exec | function exec(cmd, args, options) {
// If true user wants stdout to output value
// instead of using inherit outputting
// to process.stdout stream.
if (options === true)
options = { stdio: 'pipe' };
options = chek_1.extend({}, spawnDefaults, options);
if (chek_1.isString(args))
... | javascript | function exec(cmd, args, options) {
// If true user wants stdout to output value
// instead of using inherit outputting
// to process.stdout stream.
if (options === true)
options = { stdio: 'pipe' };
options = chek_1.extend({}, spawnDefaults, options);
if (chek_1.isString(args))
... | [
"function",
"exec",
"(",
"cmd",
",",
"args",
",",
"options",
")",
"{",
"// If true user wants stdout to output value",
"// instead of using inherit outputting",
"// to process.stdout stream.",
"if",
"(",
"options",
"===",
"true",
")",
"options",
"=",
"{",
"stdio",
":",
... | Exec
Executes command using child process.
@param cmd node, npm or shell command to be executed.
@param args arguments to be passed to command.
@param options the child process spawn options. | [
"Exec",
"Executes",
"command",
"using",
"child",
"process",
"."
] | dca9cd352bb914e53e64e791fc85985aef3d9fb7 | https://github.com/origin1tech/stiks/blob/dca9cd352bb914e53e64e791fc85985aef3d9fb7/dist/exec.js#L54-L75 | train |
SoftwarePlumbers/immutable-base | immutable.js | processArguments | function processArguments(props, args, defaults) {
debug('processArguments',props,args,defaults);
values = Object.assign({}, defaults);
let properties = Object.getOwnPropertyNames(values);
// First execute any single-arg functions to create dynamic defaults
for (property of properties) {
... | javascript | function processArguments(props, args, defaults) {
debug('processArguments',props,args,defaults);
values = Object.assign({}, defaults);
let properties = Object.getOwnPropertyNames(values);
// First execute any single-arg functions to create dynamic defaults
for (property of properties) {
... | [
"function",
"processArguments",
"(",
"props",
",",
"args",
",",
"defaults",
")",
"{",
"debug",
"(",
"'processArguments'",
",",
"props",
",",
"args",
",",
"defaults",
")",
";",
"values",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"defaults",
")",
... | Handle case where we have a single argument containing an object.
Basically, merge properties in args[0] into defaults, iff we have a single argument and it is an object. | [
"Handle",
"case",
"where",
"we",
"have",
"a",
"single",
"argument",
"containing",
"an",
"object",
"."
] | 3975c5e3ca30614916d3df0a262aeef229a1d538 | https://github.com/SoftwarePlumbers/immutable-base/blob/3975c5e3ca30614916d3df0a262aeef229a1d538/immutable.js#L10-L35 | train |
SoftwarePlumbers/immutable-base | immutable.js | create | function create(defaults) {
let props = Object.getOwnPropertyNames(defaults);
/** Immutable class created from defaults.
*
*/
const immutableClass = class {
/** Constructor.
*
* Can take a single object argument, in which case the properties of the object are copied ov... | javascript | function create(defaults) {
let props = Object.getOwnPropertyNames(defaults);
/** Immutable class created from defaults.
*
*/
const immutableClass = class {
/** Constructor.
*
* Can take a single object argument, in which case the properties of the object are copied ov... | [
"function",
"create",
"(",
"defaults",
")",
"{",
"let",
"props",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"defaults",
")",
";",
"/** Immutable class created from defaults.\n *\n */",
"const",
"immutableClass",
"=",
"class",
"{",
"/** Constructor.\n ... | Create an immutable class
The resulting class will have the supplied properties and defaults, a constructor, and setters
which return a copy of the instance they are applied to with the implied update in place.
Passing in { property: undefined } will ensure a setter is created for 'property' without creating a defaul... | [
"Create",
"an",
"immutable",
"class"
] | 3975c5e3ca30614916d3df0a262aeef229a1d538 | https://github.com/SoftwarePlumbers/immutable-base/blob/3975c5e3ca30614916d3df0a262aeef229a1d538/immutable.js#L47-L109 | train |
SoftwarePlumbers/immutable-base | immutable.js | extend | function extend(to_extend, new_defaults = {}) {
let new_default_props = Object.getOwnPropertyNames(new_defaults);
let old_props = to_extend.getImmutablePropertyNames();
let new_props = new_default_props.filter(e => old_props.indexOf(e) < 0);
//let overriden_props = new_default_props.filter(e => old_pro... | javascript | function extend(to_extend, new_defaults = {}) {
let new_default_props = Object.getOwnPropertyNames(new_defaults);
let old_props = to_extend.getImmutablePropertyNames();
let new_props = new_default_props.filter(e => old_props.indexOf(e) < 0);
//let overriden_props = new_default_props.filter(e => old_pro... | [
"function",
"extend",
"(",
"to_extend",
",",
"new_defaults",
"=",
"{",
"}",
")",
"{",
"let",
"new_default_props",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"new_defaults",
")",
";",
"let",
"old_props",
"=",
"to_extend",
".",
"getImmutablePropertyNames",
"(... | Extend an immutable class
The resulting class will have the supplied properties and defaults, a constructor, an additional setters
which return a copy of the instance they are applied to with the implied update in place.
Passing in { property: undefined } will ensure a setter is created for 'property' without creatin... | [
"Extend",
"an",
"immutable",
"class"
] | 3975c5e3ca30614916d3df0a262aeef229a1d538 | https://github.com/SoftwarePlumbers/immutable-base/blob/3975c5e3ca30614916d3df0a262aeef229a1d538/immutable.js#L122-L184 | train |
tkesgar/sharo-next | index.js | withSharo | function withSharo(nextConfig = {}) {
// https://github.com/zeit/next-plugins/issues/320
const withMdx = require('@zeit/next-mdx')({
// Allow regular markdown files (*.md) to be imported.
extension: /\.mdx?$/
})
return (
withSass(withMdx(
Object.assign(
// ==============================... | javascript | function withSharo(nextConfig = {}) {
// https://github.com/zeit/next-plugins/issues/320
const withMdx = require('@zeit/next-mdx')({
// Allow regular markdown files (*.md) to be imported.
extension: /\.mdx?$/
})
return (
withSass(withMdx(
Object.assign(
// ==============================... | [
"function",
"withSharo",
"(",
"nextConfig",
"=",
"{",
"}",
")",
"{",
"// https://github.com/zeit/next-plugins/issues/320",
"const",
"withMdx",
"=",
"require",
"(",
"'@zeit/next-mdx'",
")",
"(",
"{",
"// Allow regular markdown files (*.md) to be imported.",
"extension",
":",... | This function is a Next.js plugin for sharo.
Features:
- Bundle analysis reporter via `@zeit/next-bundle-analyzer`
- MDX support via `@zeit/next-mdx`
- Web Workers transpilation support via `@zeit/next-workers`
- SASS/SCSS support via `@zeit/next-sass`
To generate bundle analysis report, provide `BUNDLE_ANALYZE` envi... | [
"This",
"function",
"is",
"a",
"Next",
".",
"js",
"plugin",
"for",
"sharo",
"."
] | ce4fbd45b418a50599deba5d129286b8691d1f72 | https://github.com/tkesgar/sharo-next/blob/ce4fbd45b418a50599deba5d129286b8691d1f72/index.js#L28-L67 | train |
vmarkdown/vremark-parse | packages/vremark-toc/mdast-util-toc/lib/insert.js | insert | function insert(node, parent, tight) {
var children = parent.children;
var length = children.length;
var last = children[length - 1];
var isLoose = false;
var index;
var item;
if (node.depth === 1) {
item = listItem();
item.children.push({
type: PARAGRAPH,
... | javascript | function insert(node, parent, tight) {
var children = parent.children;
var length = children.length;
var last = children[length - 1];
var isLoose = false;
var index;
var item;
if (node.depth === 1) {
item = listItem();
item.children.push({
type: PARAGRAPH,
... | [
"function",
"insert",
"(",
"node",
",",
"parent",
",",
"tight",
")",
"{",
"var",
"children",
"=",
"parent",
".",
"children",
";",
"var",
"length",
"=",
"children",
".",
"length",
";",
"var",
"last",
"=",
"children",
"[",
"length",
"-",
"1",
"]",
";",... | Insert a `node` into a `parent`.
@param {Object} node - `node` to insert.
@param {Object} parent - Parent of `node`.
@param {boolean?} [tight] - Prefer tight list-items.
@return {undefined} | [
"Insert",
"a",
"node",
"into",
"a",
"parent",
"."
] | d7b353dcb5d021eeceb40f3c505ece893202db7a | https://github.com/vmarkdown/vremark-parse/blob/d7b353dcb5d021eeceb40f3c505ece893202db7a/packages/vremark-toc/mdast-util-toc/lib/insert.js#L31-L123 | train |
molecuel/gridfs-uploader | lib/gfsupload.js | GFSupload | function GFSupload(mongoinst, prefix) {
this.mongo = mongoinst;
this.db = this.mongo.db;
this.Grid = this.mongo.Grid;
this.GridStore = this.mongo.GridStore;
this.ObjectID = this.mongo.ObjectID;
this.prefix = prefix || this.GridStore.DEFAULT_ROOT_COLLECTION;
return this;
} | javascript | function GFSupload(mongoinst, prefix) {
this.mongo = mongoinst;
this.db = this.mongo.db;
this.Grid = this.mongo.Grid;
this.GridStore = this.mongo.GridStore;
this.ObjectID = this.mongo.ObjectID;
this.prefix = prefix || this.GridStore.DEFAULT_ROOT_COLLECTION;
return this;
} | [
"function",
"GFSupload",
"(",
"mongoinst",
",",
"prefix",
")",
"{",
"this",
".",
"mongo",
"=",
"mongoinst",
";",
"this",
".",
"db",
"=",
"this",
".",
"mongo",
".",
"db",
";",
"this",
".",
"Grid",
"=",
"this",
".",
"mongo",
".",
"Grid",
";",
"this",... | This class enables gridfs uploads for all the mongoose users
@constructor
@param {Object} mongoose Mongoose Object from you application
@param {String} prefix Prefix for the database like "imports"
@author "Dominic Böttger" <Dominic.Boettger@inspirationlabs.com>
@return {Object} | [
"This",
"class",
"enables",
"gridfs",
"uploads",
"for",
"all",
"the",
"mongoose",
"users"
] | 3a0a97d70de39e348881f7eca34a99dd7408454f | https://github.com/molecuel/gridfs-uploader/blob/3a0a97d70de39e348881f7eca34a99dd7408454f/lib/gfsupload.js#L66-L74 | train |
TheDustyard/SimplerDiscord | SimplerDiscord/index.js | function (name, guild) {
let emoji = guild.emojis.find('name', name);
if (emoji === undefined || emoji === null)
return name;
return `<:${name}:${emoji.id}>`;
} | javascript | function (name, guild) {
let emoji = guild.emojis.find('name', name);
if (emoji === undefined || emoji === null)
return name;
return `<:${name}:${emoji.id}>`;
} | [
"function",
"(",
"name",
",",
"guild",
")",
"{",
"let",
"emoji",
"=",
"guild",
".",
"emojis",
".",
"find",
"(",
"'name'",
",",
"name",
")",
";",
"if",
"(",
"emoji",
"===",
"undefined",
"||",
"emoji",
"===",
"null",
")",
"return",
"name",
";",
"retu... | METHODS
Gets an emoji
@returns {string} emoji
@param {string} name Name of the emoji
@param {Guild} guild Guild for the emoji | [
"METHODS",
"Gets",
"an",
"emoji"
] | fdbc854fa2d64d0637e9d4797d916a7494d88f62 | https://github.com/TheDustyard/SimplerDiscord/blob/fdbc854fa2d64d0637e9d4797d916a7494d88f62/SimplerDiscord/index.js#L32-L37 | train | |
TheDustyard/SimplerDiscord | SimplerDiscord/index.js | function (name, guild) {
return guild.members.filter((item) => item.user.username.toLowerCase() === this.name.toLowerCase()).join();
} | javascript | function (name, guild) {
return guild.members.filter((item) => item.user.username.toLowerCase() === this.name.toLowerCase()).join();
} | [
"function",
"(",
"name",
",",
"guild",
")",
"{",
"return",
"guild",
".",
"members",
".",
"filter",
"(",
"(",
"item",
")",
"=>",
"item",
".",
"user",
".",
"username",
".",
"toLowerCase",
"(",
")",
"===",
"this",
".",
"name",
".",
"toLowerCase",
"(",
... | Gets a mention of a user
@returns {string} Mention
@param {string} name Name
@param {Guild} guild guild | [
"Gets",
"a",
"mention",
"of",
"a",
"user"
] | fdbc854fa2d64d0637e9d4797d916a7494d88f62 | https://github.com/TheDustyard/SimplerDiscord/blob/fdbc854fa2d64d0637e9d4797d916a7494d88f62/SimplerDiscord/index.js#L44-L46 | train | |
TheDustyard/SimplerDiscord | SimplerDiscord/index.js | function (name, guild) {
return guild.channels.filter((item) => item.type === "text").filter((item) => item.name === this.name).join();
} | javascript | function (name, guild) {
return guild.channels.filter((item) => item.type === "text").filter((item) => item.name === this.name).join();
} | [
"function",
"(",
"name",
",",
"guild",
")",
"{",
"return",
"guild",
".",
"channels",
".",
"filter",
"(",
"(",
"item",
")",
"=>",
"item",
".",
"type",
"===",
"\"text\"",
")",
".",
"filter",
"(",
"(",
"item",
")",
"=>",
"item",
".",
"name",
"===",
... | Gets a mention of a channel
@returns {string} Mention
@param {string} name Name
@param {Guild} guild Guild | [
"Gets",
"a",
"mention",
"of",
"a",
"channel"
] | fdbc854fa2d64d0637e9d4797d916a7494d88f62 | https://github.com/TheDustyard/SimplerDiscord/blob/fdbc854fa2d64d0637e9d4797d916a7494d88f62/SimplerDiscord/index.js#L53-L55 | train | |
redisjs/jsr-server | lib/command/database/zset/zrange.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var withscores;
if(args.length > 3) {
withscores = ('' + args[3]).toLowerCase();
if(withscores !== Constants.ZSET.WITHSCORES) {
throw CommandSyntax;
}
args[3] = withscores;
}
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var withscores;
if(args.length > 3) {
withscores = ('' + args[3]).toLowerCase();
if(withscores !== Constants.ZSET.WITHSCORES) {
throw CommandSyntax;
}
args[3] = withscores;
}
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"withscores",
";",
"if",
"(",
"args",
".",
"length",
">",
"3",
... | Validate the ZRANGE command. | [
"Validate",
"the",
"ZRANGE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/zset/zrange.js#L19-L29 | train |
mattaschmann/simple-menu | lib/simplemenu.js | _printItem | function _printItem (item) {
switch(item.type) {
case 'option':
console.log(item.index + ': ' + item.label);
break;
case 'break':
for (var breakString = ''; breakString.length < item.charCount;) {
breakString += item.character;
}
console.log(breakString);
break;
... | javascript | function _printItem (item) {
switch(item.type) {
case 'option':
console.log(item.index + ': ' + item.label);
break;
case 'break':
for (var breakString = ''; breakString.length < item.charCount;) {
breakString += item.character;
}
console.log(breakString);
break;
... | [
"function",
"_printItem",
"(",
"item",
")",
"{",
"switch",
"(",
"item",
".",
"type",
")",
"{",
"case",
"'option'",
":",
"console",
".",
"log",
"(",
"item",
".",
"index",
"+",
"': '",
"+",
"item",
".",
"label",
")",
";",
"break",
";",
"case",
"'brea... | Utility function to print out an item in the array.
@param {Object} item An item in the array. | [
"Utility",
"function",
"to",
"print",
"out",
"an",
"item",
"in",
"the",
"array",
"."
] | 8b93869fba5c2ffade6d33a97784201797a1e793 | https://github.com/mattaschmann/simple-menu/blob/8b93869fba5c2ffade6d33a97784201797a1e793/lib/simplemenu.js#L106-L125 | train |
inviqa/deck-task-registry | src/assets/buildImages.js | buildImages | function buildImages(conf, undertaker) {
const imageMinConfig = {
progressive: true,
svgoPlugins: [{
removeViewBox: false
}, {
cleanupIDs: true
}, {
cleanupAttrs: true
}]
};
const imageSrc = path.join(conf.themeConfig.root, conf.themeConfig.images.src,... | javascript | function buildImages(conf, undertaker) {
const imageMinConfig = {
progressive: true,
svgoPlugins: [{
removeViewBox: false
}, {
cleanupIDs: true
}, {
cleanupAttrs: true
}]
};
const imageSrc = path.join(conf.themeConfig.root, conf.themeConfig.images.src,... | [
"function",
"buildImages",
"(",
"conf",
",",
"undertaker",
")",
"{",
"const",
"imageMinConfig",
"=",
"{",
"progressive",
":",
"true",
",",
"svgoPlugins",
":",
"[",
"{",
"removeViewBox",
":",
"false",
"}",
",",
"{",
"cleanupIDs",
":",
"true",
"}",
",",
"{... | Build project images.
@param {ConfigParser} conf A configuration parser object.
@param {Undertaker} undertaker An Undertaker instance.
@returns {Stream} A stream of files. | [
"Build",
"project",
"images",
"."
] | 4c31787b978e9d99a47052e090d4589a50cd3015 | https://github.com/inviqa/deck-task-registry/blob/4c31787b978e9d99a47052e090d4589a50cd3015/src/assets/buildImages.js#L14-L34 | train |
gethuman/jyt | lib/jyt.runtime.js | render | function render(element, opts) {
opts = opts || {};
var prepend = opts.prepend;
var model = opts.model || {};
var indentLevel = opts.indentLevel || 0;
var isPretty = opts.isPretty;
var jtPrintIndent = isPretty ? '\t' : '';
var jtPrintNewline = isPretty ? '\n' : '';
var indent = '', i, l... | javascript | function render(element, opts) {
opts = opts || {};
var prepend = opts.prepend;
var model = opts.model || {};
var indentLevel = opts.indentLevel || 0;
var isPretty = opts.isPretty;
var jtPrintIndent = isPretty ? '\t' : '';
var jtPrintNewline = isPretty ? '\n' : '';
var indent = '', i, l... | [
"function",
"render",
"(",
"element",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"prepend",
"=",
"opts",
".",
"prepend",
";",
"var",
"model",
"=",
"opts",
".",
"model",
"||",
"{",
"}",
";",
"var",
"indentLevel",
"=",
... | Take a jyt element and render it to an HTML string
@param element
@param opts | [
"Take",
"a",
"jyt",
"element",
"and",
"render",
"it",
"to",
"an",
"HTML",
"string"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.runtime.js#L27-L123 | train |
gethuman/jyt | lib/jyt.runtime.js | addElemsToScope | function addElemsToScope(scope) {
var prop;
for (prop in elems) {
if (elems.hasOwnProperty(prop)) {
scope[prop] = elems[prop];
}
}
scope.elem = elem;
} | javascript | function addElemsToScope(scope) {
var prop;
for (prop in elems) {
if (elems.hasOwnProperty(prop)) {
scope[prop] = elems[prop];
}
}
scope.elem = elem;
} | [
"function",
"addElemsToScope",
"(",
"scope",
")",
"{",
"var",
"prop",
";",
"for",
"(",
"prop",
"in",
"elems",
")",
"{",
"if",
"(",
"elems",
".",
"hasOwnProperty",
"(",
"prop",
")",
")",
"{",
"scope",
"[",
"prop",
"]",
"=",
"elems",
"[",
"prop",
"]"... | Add all elements to the given scope
@param scope | [
"Add",
"all",
"elements",
"to",
"the",
"given",
"scope"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.runtime.js#L191-L199 | train |
gethuman/jyt | lib/jyt.runtime.js | registerComponents | function registerComponents(elemNames) {
if (!elemNames) { return; }
var elemNameDashCase, elemNameCamelCase;
for (var i = 0; i < elemNames.length; i++) {
elemNameDashCase = elemNames[i];
elemNameCamelCase = utils.dashToCamelCase(elemNameDashCase);
elems[elemNameCamelCase] = makeEle... | javascript | function registerComponents(elemNames) {
if (!elemNames) { return; }
var elemNameDashCase, elemNameCamelCase;
for (var i = 0; i < elemNames.length; i++) {
elemNameDashCase = elemNames[i];
elemNameCamelCase = utils.dashToCamelCase(elemNameDashCase);
elems[elemNameCamelCase] = makeEle... | [
"function",
"registerComponents",
"(",
"elemNames",
")",
"{",
"if",
"(",
"!",
"elemNames",
")",
"{",
"return",
";",
"}",
"var",
"elemNameDashCase",
",",
"elemNameCamelCase",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"elemNames",
".",
"length"... | Given an array of element names, register the custom
elements so that a user can make them accessible
@param elemNames | [
"Given",
"an",
"array",
"of",
"element",
"names",
"register",
"the",
"custom",
"elements",
"so",
"that",
"a",
"user",
"can",
"make",
"them",
"accessible"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.runtime.js#L218-L227 | train |
gethuman/jyt | lib/jyt.runtime.js | init | function init() {
var tagName;
for (var i = 0; i < allTags.length; i++) {
tagName = allTags[i];
elems[tagName] = makeElem(tagName);
}
} | javascript | function init() {
var tagName;
for (var i = 0; i < allTags.length; i++) {
tagName = allTags[i];
elems[tagName] = makeElem(tagName);
}
} | [
"function",
"init",
"(",
")",
"{",
"var",
"tagName",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"allTags",
".",
"length",
";",
"i",
"++",
")",
"{",
"tagName",
"=",
"allTags",
"[",
"i",
"]",
";",
"elems",
"[",
"tagName",
"]",
"=",
"... | Create functions for all standard HTML element | [
"Create",
"functions",
"for",
"all",
"standard",
"HTML",
"element"
] | 716be37e09217b4be917e179389f752212a428b3 | https://github.com/gethuman/jyt/blob/716be37e09217b4be917e179389f752212a428b3/lib/jyt.runtime.js#L232-L238 | train |
staticbuild/staticbuild | index.js | getBundleMinIf | function getBundleMinIf(bundle, build, min) {
// Disable minification?
if (bundle.noMin)
return false;
// Glob filter paths to exlude and include files for minification.
// Start by excluding absolute paths of pre-minified files.
var minGlobs = lodash.map(min, function minAbsPath(relPath) {
return bui... | javascript | function getBundleMinIf(bundle, build, min) {
// Disable minification?
if (bundle.noMin)
return false;
// Glob filter paths to exlude and include files for minification.
// Start by excluding absolute paths of pre-minified files.
var minGlobs = lodash.map(min, function minAbsPath(relPath) {
return bui... | [
"function",
"getBundleMinIf",
"(",
"bundle",
",",
"build",
",",
"min",
")",
"{",
"// Disable minification?",
"if",
"(",
"bundle",
".",
"noMin",
")",
"return",
"false",
";",
"// Glob filter paths to exlude and include files for minification.",
"// Start by excluding absolute... | Returns a minIf value for a new bundle-info object.
@param {string} - Array of pre-minified source paths.
@returns {boolean|string} - The minIf value. | [
"Returns",
"a",
"minIf",
"value",
"for",
"a",
"new",
"bundle",
"-",
"info",
"object",
"."
] | 73891a9a719de46ba07c26a10ce36c43da34ff0e | https://github.com/staticbuild/staticbuild/blob/73891a9a719de46ba07c26a10ce36c43da34ff0e/index.js#L1485-L1501 | train |
Nazariglez/perenquen | lib/pixi/src/core/sprites/Sprite.js | Sprite | function Sprite(texture)
{
Container.call(this);
/**
* The anchor sets the origin point of the texture.
* The default is 0,0 this means the texture's origin is the top left
* Setting the anchor to 0.5,0.5 means the texture's origin is centered
* Setting the anchor to 1,1 would mean the text... | javascript | function Sprite(texture)
{
Container.call(this);
/**
* The anchor sets the origin point of the texture.
* The default is 0,0 this means the texture's origin is the top left
* Setting the anchor to 0.5,0.5 means the texture's origin is centered
* Setting the anchor to 1,1 would mean the text... | [
"function",
"Sprite",
"(",
"texture",
")",
"{",
"Container",
".",
"call",
"(",
"this",
")",
";",
"/**\n * The anchor sets the origin point of the texture.\n * The default is 0,0 this means the texture's origin is the top left\n * Setting the anchor to 0.5,0.5 means the texture'... | The Sprite object is the base for all textured objects that are rendered to the screen
A sprite can be created directly from an image like this:
```js
var sprite = new PIXI.Sprite.fromImage('assets/image.png');
```
@class
@extends Container
@memberof PIXI
@param texture {Texture} The texture for this sprite | [
"The",
"Sprite",
"object",
"is",
"the",
"base",
"for",
"all",
"textured",
"objects",
"that",
"are",
"rendered",
"to",
"the",
"screen"
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/sprites/Sprite.js#L23-L94 | train |
bholloway/browserify-esprima-tools | index.js | processSync | function processSync(filename, content, updater, format) {
var text = String(content);
// parse code to AST using esprima
var ast = esprima.parse(text, {
loc : true,
comment: true,
source : filename
});
// sort nodes before changing the source-map
var sorted = orderNodes(ast);
// associa... | javascript | function processSync(filename, content, updater, format) {
var text = String(content);
// parse code to AST using esprima
var ast = esprima.parse(text, {
loc : true,
comment: true,
source : filename
});
// sort nodes before changing the source-map
var sorted = orderNodes(ast);
// associa... | [
"function",
"processSync",
"(",
"filename",
",",
"content",
",",
"updater",
",",
"format",
")",
"{",
"var",
"text",
"=",
"String",
"(",
"content",
")",
";",
"// parse code to AST using esprima",
"var",
"ast",
"=",
"esprima",
".",
"parse",
"(",
"text",
",",
... | Synchronously process the given content and apply the updater function on its AST then output with the given format.
@throws {Error} Esprima parse error or updater error
@param {string} filename The name of the file that contains the given content
@param {*} content The text content to parse
@param {function} updater A... | [
"Synchronously",
"process",
"the",
"given",
"content",
"and",
"apply",
"the",
"updater",
"function",
"on",
"its",
"AST",
"then",
"output",
"with",
"the",
"given",
"format",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L82-L127 | train |
bholloway/browserify-esprima-tools | index.js | depthFirst | function depthFirst(node, parent) {
var results = [];
if (node && (typeof node === 'object')) {
// valid node so push it to the list and set new parent
// don't overwrite parent if one was not given
if ('type' in node) {
if (parent !== undefined) {
node.parent = parent;
}
par... | javascript | function depthFirst(node, parent) {
var results = [];
if (node && (typeof node === 'object')) {
// valid node so push it to the list and set new parent
// don't overwrite parent if one was not given
if ('type' in node) {
if (parent !== undefined) {
node.parent = parent;
}
par... | [
"function",
"depthFirst",
"(",
"node",
",",
"parent",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"node",
"&&",
"(",
"typeof",
"node",
"===",
"'object'",
")",
")",
"{",
"// valid node so push it to the list and set new parent",
"// don't overwrit... | List the given node and all children, depth first.
@param {object} node An esprima node
@param {object|undefined} [parent] The parent of the given node, where known
@returns {Array} A list of nodes | [
"List",
"the",
"given",
"node",
"and",
"all",
"children",
"depth",
"first",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L149-L174 | train |
bholloway/browserify-esprima-tools | index.js | breadthFirst | function breadthFirst(node, parent) {
var results = [];
if (node && (typeof node === 'object')) {
// begin the queue with the given node
var queue = [{node:node, parent:parent}];
while (queue.length) {
// pull the next item from the front of the queue
var item = queue.shift();
node ... | javascript | function breadthFirst(node, parent) {
var results = [];
if (node && (typeof node === 'object')) {
// begin the queue with the given node
var queue = [{node:node, parent:parent}];
while (queue.length) {
// pull the next item from the front of the queue
var item = queue.shift();
node ... | [
"function",
"breadthFirst",
"(",
"node",
",",
"parent",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"node",
"&&",
"(",
"typeof",
"node",
"===",
"'object'",
")",
")",
"{",
"// begin the queue with the given node",
"var",
"queue",
"=",
"[",
... | List the given node and all children, breadth first.
@param {object} node An esprima node
@param {object|undefined} [parent] The parent of the given node, where known
@returns {Array} A list of nodes | [
"List",
"the",
"given",
"node",
"and",
"all",
"children",
"breadth",
"first",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L182-L220 | train |
bholloway/browserify-esprima-tools | index.js | nodeSplicer | function nodeSplicer(candidate, offset) {
offset = offset || 0;
return function setter(value) {
var found = findReferrer(candidate);
if (found) {
var key = found.key;
var obj = found.object;
var array = Array.isArray(obj) && obj;
if (!array) {
obj[key] = value;
}
... | javascript | function nodeSplicer(candidate, offset) {
offset = offset || 0;
return function setter(value) {
var found = findReferrer(candidate);
if (found) {
var key = found.key;
var obj = found.object;
var array = Array.isArray(obj) && obj;
if (!array) {
obj[key] = value;
}
... | [
"function",
"nodeSplicer",
"(",
"candidate",
",",
"offset",
")",
"{",
"offset",
"=",
"offset",
"||",
"0",
";",
"return",
"function",
"setter",
"(",
"value",
")",
"{",
"var",
"found",
"=",
"findReferrer",
"(",
"candidate",
")",
";",
"if",
"(",
"found",
... | Create a setter that will replace the given node or insert relative to it.
@param {object} candidate An esprima AST node to match
@param {number|function} [offset] 0 to replace, -1 to insert before node, +1 to insert after node
@returns {function|null} A setter that will replace the given node or do nothing if not vali... | [
"Create",
"a",
"setter",
"that",
"will",
"replace",
"the",
"given",
"node",
"or",
"insert",
"relative",
"to",
"it",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L228-L252 | train |
bholloway/browserify-esprima-tools | index.js | compareLocation | function compareLocation(nodeA, nodeB) {
var locA = nodeA && nodeA.loc;
var locB = nodeB && nodeB.loc;
if (!locA && !locB) {
return 0;
}
else if (Boolean(locA) !== Boolean(locB)) {
return locA ? +1 : locB ? -1 : 0;
}
else {
var result =
isOrdered(locB.end, locA.start) ? +1 : isOrdered(... | javascript | function compareLocation(nodeA, nodeB) {
var locA = nodeA && nodeA.loc;
var locB = nodeB && nodeB.loc;
if (!locA && !locB) {
return 0;
}
else if (Boolean(locA) !== Boolean(locB)) {
return locA ? +1 : locB ? -1 : 0;
}
else {
var result =
isOrdered(locB.end, locA.start) ? +1 : isOrdered(... | [
"function",
"compareLocation",
"(",
"nodeA",
",",
"nodeB",
")",
"{",
"var",
"locA",
"=",
"nodeA",
"&&",
"nodeA",
".",
"loc",
";",
"var",
"locB",
"=",
"nodeB",
"&&",
"nodeB",
".",
"loc",
";",
"if",
"(",
"!",
"locA",
"&&",
"!",
"locB",
")",
"{",
"r... | Compare function for nodes with location.
@param {object} nodeA First node
@param {object} nodeB Second node
@returns {number} -1 where a follows b, +1 where b follows a, 0 otherwise | [
"Compare",
"function",
"for",
"nodes",
"with",
"location",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L289-L306 | train |
bholloway/browserify-esprima-tools | index.js | isOrdered | function isOrdered(tupleA, tupleB) {
return (tupleA.line < tupleB.line) || ((tupleA.line === tupleB.line) && (tupleA.column < tupleB.column));
} | javascript | function isOrdered(tupleA, tupleB) {
return (tupleA.line < tupleB.line) || ((tupleA.line === tupleB.line) && (tupleA.column < tupleB.column));
} | [
"function",
"isOrdered",
"(",
"tupleA",
",",
"tupleB",
")",
"{",
"return",
"(",
"tupleA",
".",
"line",
"<",
"tupleB",
".",
"line",
")",
"||",
"(",
"(",
"tupleA",
".",
"line",
"===",
"tupleB",
".",
"line",
")",
"&&",
"(",
"tupleA",
".",
"column",
"<... | Check the order of the given location tuples.
@param {{line:number, column:number}} tupleA The first tuple
@param {{line:number, column:number}} tupleB The second tuple
@returns {boolean} True where tupleA precedes tupleB | [
"Check",
"the",
"order",
"of",
"the",
"given",
"location",
"tuples",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L314-L316 | train |
bholloway/browserify-esprima-tools | index.js | compareIndex | function compareIndex(nodeA, nodeB) {
var indexA = nodeA && nodeA.sortIndex;
var indexB = nodeB && nodeB.sortIndex;
if (!indexA && !indexB) {
return 0;
}
else if (Boolean(indexA) !== Boolean(indexB)) {
return indexA ? +1 : indexB ? -1 : 0;
}
else {
return indexA - indexB;
}
} | javascript | function compareIndex(nodeA, nodeB) {
var indexA = nodeA && nodeA.sortIndex;
var indexB = nodeB && nodeB.sortIndex;
if (!indexA && !indexB) {
return 0;
}
else if (Boolean(indexA) !== Boolean(indexB)) {
return indexA ? +1 : indexB ? -1 : 0;
}
else {
return indexA - indexB;
}
} | [
"function",
"compareIndex",
"(",
"nodeA",
",",
"nodeB",
")",
"{",
"var",
"indexA",
"=",
"nodeA",
"&&",
"nodeA",
".",
"sortIndex",
";",
"var",
"indexB",
"=",
"nodeB",
"&&",
"nodeB",
".",
"sortIndex",
";",
"if",
"(",
"!",
"indexA",
"&&",
"!",
"indexB",
... | Compare function for nodes with sort-index.
@param {object} nodeA First node
@param {object} nodeB Second node
@returns {number} -1 where a follows b, +1 where b follows a, 0 otherwise | [
"Compare",
"function",
"for",
"nodes",
"with",
"sort",
"-",
"index",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L324-L336 | train |
bholloway/browserify-esprima-tools | index.js | findReferrer | function findReferrer(candidate, container) {
var result;
if (candidate) {
// initially for the parent of the candidate node
container = container || candidate.parent;
// consider keys in the node until we have a result
var keys = getKeys(container);
for (var i = 0; !result && (i < keys.length... | javascript | function findReferrer(candidate, container) {
var result;
if (candidate) {
// initially for the parent of the candidate node
container = container || candidate.parent;
// consider keys in the node until we have a result
var keys = getKeys(container);
for (var i = 0; !result && (i < keys.length... | [
"function",
"findReferrer",
"(",
"candidate",
",",
"container",
")",
"{",
"var",
"result",
";",
"if",
"(",
"candidate",
")",
"{",
"// initially for the parent of the candidate node",
"container",
"=",
"container",
"||",
"candidate",
".",
"parent",
";",
"// consider ... | Find the object and field that refers to the given node.
@param {object} candidate An esprima AST node to match
@param {object} [container] Optional container to search within or the candidate parent where omitted
@returns {{object:object, key:*}} The object and its key where the candidate node is a value | [
"Find",
"the",
"object",
"and",
"field",
"that",
"refers",
"to",
"the",
"given",
"node",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L357-L388 | train |
bholloway/browserify-esprima-tools | index.js | getKeys | function getKeys(container) {
function arrayIndex(value, i) {
return i;
}
if (typeof container === 'object') {
return Array.isArray(container) ? container.map(arrayIndex) : Object.keys(container);
} else {
return [];
}
} | javascript | function getKeys(container) {
function arrayIndex(value, i) {
return i;
}
if (typeof container === 'object') {
return Array.isArray(container) ? container.map(arrayIndex) : Object.keys(container);
} else {
return [];
}
} | [
"function",
"getKeys",
"(",
"container",
")",
"{",
"function",
"arrayIndex",
"(",
"value",
",",
"i",
")",
"{",
"return",
"i",
";",
"}",
"if",
"(",
"typeof",
"container",
"===",
"'object'",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"container",
... | Get the keys of an object as strings or those of an array as integers.
@param {object|Array} container A hash or array
@returns {Array.<string|number>} The keys of the container | [
"Get",
"the",
"keys",
"of",
"an",
"object",
"as",
"strings",
"or",
"those",
"of",
"an",
"array",
"as",
"integers",
"."
] | a6f248ba3b486f6f7b1dbe27539dd139ede3df6a | https://github.com/bholloway/browserify-esprima-tools/blob/a6f248ba3b486f6f7b1dbe27539dd139ede3df6a/index.js#L395-L404 | train |
andrevinsky/redux-actions-sequences | src/index.js | tagResultFunction | function tagResultFunction(fn, tokenDescription, replacement) {
const description = tag(fn);
if (description) {
tokenDescription = description.replace(tokenDescription, replacement);
}
tag(fn, tokenDescription);
fn.toString = tokenToString;
return fn;
} | javascript | function tagResultFunction(fn, tokenDescription, replacement) {
const description = tag(fn);
if (description) {
tokenDescription = description.replace(tokenDescription, replacement);
}
tag(fn, tokenDescription);
fn.toString = tokenToString;
return fn;
} | [
"function",
"tagResultFunction",
"(",
"fn",
",",
"tokenDescription",
",",
"replacement",
")",
"{",
"const",
"description",
"=",
"tag",
"(",
"fn",
")",
";",
"if",
"(",
"description",
")",
"{",
"tokenDescription",
"=",
"description",
".",
"replace",
"(",
"toke... | Internal utility function that wraps result function
@param fn
@param tokenDescription
@param replacement
@returns {*} | [
"Internal",
"utility",
"function",
"that",
"wraps",
"result",
"function"
] | 1357fce58c674c106d4d850f3fa0bca9c2359c6b | https://github.com/andrevinsky/redux-actions-sequences/blob/1357fce58c674c106d4d850f3fa0bca9c2359c6b/src/index.js#L106-L116 | train |
inviqa/deck-task-registry | src/helpers/findRoot.js | findRoot | function findRoot() {
let rootPath;
try {
rootPath = glob.sync('../**/Drupal.php', {ignore: ['../vendor/**', '../node_modules/**']});
} catch (err) {
throw new Error('No Drupal root found.');
}
// If we found no results for Drupal.php..then bomb out.
if (rootPath.length === 0) {
throw new Err... | javascript | function findRoot() {
let rootPath;
try {
rootPath = glob.sync('../**/Drupal.php', {ignore: ['../vendor/**', '../node_modules/**']});
} catch (err) {
throw new Error('No Drupal root found.');
}
// If we found no results for Drupal.php..then bomb out.
if (rootPath.length === 0) {
throw new Err... | [
"function",
"findRoot",
"(",
")",
"{",
"let",
"rootPath",
";",
"try",
"{",
"rootPath",
"=",
"glob",
".",
"sync",
"(",
"'../**/Drupal.php'",
",",
"{",
"ignore",
":",
"[",
"'../vendor/**'",
",",
"'../node_modules/**'",
"]",
"}",
")",
";",
"}",
"catch",
"("... | Find the root of a Drupal project.
@throws {Error} Thrown if no Drupal root was found.
@returns {String} The root to the Drupal installation from tools root. | [
"Find",
"the",
"root",
"of",
"a",
"Drupal",
"project",
"."
] | 4c31787b978e9d99a47052e090d4589a50cd3015 | https://github.com/inviqa/deck-task-registry/blob/4c31787b978e9d99a47052e090d4589a50cd3015/src/helpers/findRoot.js#L13-L41 | train |
LeoYehTW/data-service | public/js/xeditable.js | function(name) {
var i;
if (this.$editables.length) {
//activate by name
if (angular.isString(name)) {
for(i=0; i<this.$editables.length; i++) {
if (this.$editables[i].name === name) {
this.$editables[i].activate();
return;
}
... | javascript | function(name) {
var i;
if (this.$editables.length) {
//activate by name
if (angular.isString(name)) {
for(i=0; i<this.$editables.length; i++) {
if (this.$editables[i].name === name) {
this.$editables[i].activate();
return;
}
... | [
"function",
"(",
"name",
")",
"{",
"var",
"i",
";",
"if",
"(",
"this",
".",
"$editables",
".",
"length",
")",
"{",
"//activate by name",
"if",
"(",
"angular",
".",
"isString",
"(",
"name",
")",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
... | Sets focus on form field specified by `name`.
@method $activate(name)
@param {string} name name of field
@memberOf editable-form | [
"Sets",
"focus",
"on",
"form",
"field",
"specified",
"by",
"name",
"."
] | b55871663c2aacf2e3bd61c397987fa5bbedbc8d | https://github.com/LeoYehTW/data-service/blob/b55871663c2aacf2e3bd61c397987fa5bbedbc8d/public/js/xeditable.js#L974-L998 | train | |
gethuman/pancakes-recipe | middleware/mw.auth.token.js | getUserForToken | function getUserForToken(decodedToken) {
var userId = decodedToken._id;
var authToken = decodedToken.authToken;
var cacheKey = userId + authToken;
var conditions = {
caller: userService.admin,
where: { _id: userId, authToken: authToken, status: 'created' },
... | javascript | function getUserForToken(decodedToken) {
var userId = decodedToken._id;
var authToken = decodedToken.authToken;
var cacheKey = userId + authToken;
var conditions = {
caller: userService.admin,
where: { _id: userId, authToken: authToken, status: 'created' },
... | [
"function",
"getUserForToken",
"(",
"decodedToken",
")",
"{",
"var",
"userId",
"=",
"decodedToken",
".",
"_id",
";",
"var",
"authToken",
"=",
"decodedToken",
".",
"authToken",
";",
"var",
"cacheKey",
"=",
"userId",
"+",
"authToken",
";",
"var",
"conditions",
... | Get a user for a particular token
@param decodedToken
@returns {*} | [
"Get",
"a",
"user",
"for",
"a",
"particular",
"token"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.token.js#L16-L46 | train |
gethuman/pancakes-recipe | middleware/mw.auth.token.js | validateToken | function validateToken(req, reply) {
var authorization = req.headers.authorization;
if (!authorization) {
return reply.continue();
}
// this is hack fix so that localStorage and cookies can either have Bearer or not
// if in local storate, it is serialized, so need t... | javascript | function validateToken(req, reply) {
var authorization = req.headers.authorization;
if (!authorization) {
return reply.continue();
}
// this is hack fix so that localStorage and cookies can either have Bearer or not
// if in local storate, it is serialized, so need t... | [
"function",
"validateToken",
"(",
"req",
",",
"reply",
")",
"{",
"var",
"authorization",
"=",
"req",
".",
"headers",
".",
"authorization",
";",
"if",
"(",
"!",
"authorization",
")",
"{",
"return",
"reply",
".",
"continue",
"(",
")",
";",
"}",
"// this is... | Attempt to find a user for a given token. There will be an error if the
Authorization header is invalid, but if it doesn't exist or the user
can't be found, no error because we let Fakeblock ACLs determine whether
transaction can be anonymous.
@param req
@param reply | [
"Attempt",
"to",
"find",
"a",
"user",
"for",
"a",
"given",
"token",
".",
"There",
"will",
"be",
"an",
"error",
"if",
"the",
"Authorization",
"header",
"is",
"invalid",
"but",
"if",
"it",
"doesn",
"t",
"exist",
"or",
"the",
"user",
"can",
"t",
"be",
"... | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.token.js#L57-L102 | train |
gethuman/pancakes-recipe | middleware/mw.auth.token.js | init | function init(ctx) {
var server = ctx.server;
if (!privateKey) {
throw new Error('Please set config.security.token.privateKey');
}
server.ext('onPreAuth', validateToken);
return new Q(ctx);
} | javascript | function init(ctx) {
var server = ctx.server;
if (!privateKey) {
throw new Error('Please set config.security.token.privateKey');
}
server.ext('onPreAuth', validateToken);
return new Q(ctx);
} | [
"function",
"init",
"(",
"ctx",
")",
"{",
"var",
"server",
"=",
"ctx",
".",
"server",
";",
"if",
"(",
"!",
"privateKey",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please set config.security.token.privateKey'",
")",
";",
"}",
"server",
".",
"ext",
"(",
"'... | Register the hapi auth strategy
@param ctx | [
"Register",
"the",
"hapi",
"auth",
"strategy"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/middleware/mw.auth.token.js#L109-L119 | train |
redisjs/jsr-server | lib/command/transaction/unwatch.js | execute | function execute(req, res) {
req.conn.unwatch(req.db);
res.send(null, Constants.OK);
} | javascript | function execute(req, res) {
req.conn.unwatch(req.db);
res.send(null, Constants.OK);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"req",
".",
"conn",
".",
"unwatch",
"(",
"req",
".",
"db",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the UNWATCH command. | [
"Respond",
"to",
"the",
"UNWATCH",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/transaction/unwatch.js#L19-L22 | train |
noderaider/redux-addons | lib/dispatcher.js | getLibStateAccessor | function getLibStateAccessor(libState) {
/** The current state name */
return { get actionName() {
return libState.actionName;
}
/** Is in idle state (no more states to progress to) */
, get isIdle() {
return libState.isIdle;
}
/** State can be pau... | javascript | function getLibStateAccessor(libState) {
/** The current state name */
return { get actionName() {
return libState.actionName;
}
/** Is in idle state (no more states to progress to) */
, get isIdle() {
return libState.isIdle;
}
/** State can be pau... | [
"function",
"getLibStateAccessor",
"(",
"libState",
")",
"{",
"/** The current state name */",
"return",
"{",
"get",
"actionName",
"(",
")",
"{",
"return",
"libState",
".",
"actionName",
";",
"}",
"/** Is in idle state (no more states to progress to) */",
",",
"get",
"i... | ABSTRACTS ACCESS TO STATE VIA GETTERS | [
"ABSTRACTS",
"ACCESS",
"TO",
"STATE",
"VIA",
"GETTERS"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/dispatcher.js#L118-L144 | train |
noderaider/redux-addons | lib/dispatcher.js | _shouldActivityUpdate | function _shouldActivityUpdate(_ref5) {
var type = _ref5.type;
var pageX = _ref5.pageX;
var pageY = _ref5.pageY;
if (type !== 'mousemove') return true;
var _stores$fast = stores.fast;
var lastActive = _stores$fast.lastActive;
var _stores$fast$lastEven = _stores$fast.lastEvent... | javascript | function _shouldActivityUpdate(_ref5) {
var type = _ref5.type;
var pageX = _ref5.pageX;
var pageY = _ref5.pageY;
if (type !== 'mousemove') return true;
var _stores$fast = stores.fast;
var lastActive = _stores$fast.lastActive;
var _stores$fast$lastEven = _stores$fast.lastEvent... | [
"function",
"_shouldActivityUpdate",
"(",
"_ref5",
")",
"{",
"var",
"type",
"=",
"_ref5",
".",
"type",
";",
"var",
"pageX",
"=",
"_ref5",
".",
"pageX",
";",
"var",
"pageY",
"=",
"_ref5",
".",
"pageY",
";",
"if",
"(",
"type",
"!==",
"'mousemove'",
")",
... | Detects whether the activity should trigger a redux update | [
"Detects",
"whether",
"the",
"activity",
"should",
"trigger",
"a",
"redux",
"update"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/dispatcher.js#L222-L243 | train |
noderaider/redux-addons | lib/dispatcher.js | onActivity | function onActivity(e) {
if (!_shouldActivityUpdate(e)) return;
if (_shouldRestart()) return dispatch(context.actions.start());
/** THIS WILL BE ROUTED TO FAST OR LOCAL STATE IF ENABLED */
setState(_constants.IDLEMONITOR_ACTIVITY, { lastActive: +new Date(), lastEvent: { x: e.pageX, y: e.pageY } ... | javascript | function onActivity(e) {
if (!_shouldActivityUpdate(e)) return;
if (_shouldRestart()) return dispatch(context.actions.start());
/** THIS WILL BE ROUTED TO FAST OR LOCAL STATE IF ENABLED */
setState(_constants.IDLEMONITOR_ACTIVITY, { lastActive: +new Date(), lastEvent: { x: e.pageX, y: e.pageY } ... | [
"function",
"onActivity",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"_shouldActivityUpdate",
"(",
"e",
")",
")",
"return",
";",
"if",
"(",
"_shouldRestart",
"(",
")",
")",
"return",
"dispatch",
"(",
"context",
".",
"actions",
".",
"start",
"(",
")",
")",
"... | One of the event listeners triggered an activity occurrence event. This gets spammed | [
"One",
"of",
"the",
"event",
"listeners",
"triggered",
"an",
"activity",
"occurrence",
"event",
".",
"This",
"gets",
"spammed"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/dispatcher.js#L250-L255 | train |
noderaider/redux-addons | lib/dispatcher.js | schedule | function schedule(actionName) {
timeout.clear();
var timeoutMS = timeout.timeoutMS(actionName);
log.debug({ actionName: actionName, timeoutMS: timeoutMS }, 'schedule');
var args = { actionName: actionName, isPaused: _isPauseTriggered(timeoutMS) };
if (timeoutMS > 0) return setTimeout(funct... | javascript | function schedule(actionName) {
timeout.clear();
var timeoutMS = timeout.timeoutMS(actionName);
log.debug({ actionName: actionName, timeoutMS: timeoutMS }, 'schedule');
var args = { actionName: actionName, isPaused: _isPauseTriggered(timeoutMS) };
if (timeoutMS > 0) return setTimeout(funct... | [
"function",
"schedule",
"(",
"actionName",
")",
"{",
"timeout",
".",
"clear",
"(",
")",
";",
"var",
"timeoutMS",
"=",
"timeout",
".",
"timeoutMS",
"(",
"actionName",
")",
";",
"log",
".",
"debug",
"(",
"{",
"actionName",
":",
"actionName",
",",
"timeoutM... | Responsible for clearing old timeout and scheduling new one or immediately executing, returns new timeoutID or undefined | [
"Responsible",
"for",
"clearing",
"old",
"timeout",
"and",
"scheduling",
"new",
"one",
"or",
"immediately",
"executing",
"returns",
"new",
"timeoutID",
"or",
"undefined"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/dispatcher.js#L298-L307 | train |
noderaider/redux-addons | lib/dispatcher.js | execute | function execute(_ref7) {
var actionName = _ref7.actionName;
var isPaused = _ref7.isPaused;
var nextActionName = getNextActionName(actionName);
var wasPaused = stores.redux.isPaused;
/** TODO: CHECK LOCAL STATE HERE AND IF ITS BEEN ACTIVE, POSTPONE THE ACTION ABOUT TO BE EXECUTED */
... | javascript | function execute(_ref7) {
var actionName = _ref7.actionName;
var isPaused = _ref7.isPaused;
var nextActionName = getNextActionName(actionName);
var wasPaused = stores.redux.isPaused;
/** TODO: CHECK LOCAL STATE HERE AND IF ITS BEEN ACTIVE, POSTPONE THE ACTION ABOUT TO BE EXECUTED */
... | [
"function",
"execute",
"(",
"_ref7",
")",
"{",
"var",
"actionName",
"=",
"_ref7",
".",
"actionName",
";",
"var",
"isPaused",
"=",
"_ref7",
".",
"isPaused",
";",
"var",
"nextActionName",
"=",
"getNextActionName",
"(",
"actionName",
")",
";",
"var",
"wasPaused... | Responsible for executing an action | [
"Responsible",
"for",
"executing",
"an",
"action"
] | 7b11262b5a89039e7d96e47b8391840e72510fe1 | https://github.com/noderaider/redux-addons/blob/7b11262b5a89039e7d96e47b8391840e72510fe1/lib/dispatcher.js#L310-L340 | train |
panjiesw/frest | internal/docs/themes/hugo-theme-learn/static/js/learn.js | function (e) {
var elem = e.target;
if (this.scrollIfAnchor(elem.getAttribute('href'), true)) {
e.preventDefault();
}
} | javascript | function (e) {
var elem = e.target;
if (this.scrollIfAnchor(elem.getAttribute('href'), true)) {
e.preventDefault();
}
} | [
"function",
"(",
"e",
")",
"{",
"var",
"elem",
"=",
"e",
".",
"target",
";",
"if",
"(",
"this",
".",
"scrollIfAnchor",
"(",
"elem",
".",
"getAttribute",
"(",
"'href'",
")",
",",
"true",
")",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"}... | If the click event's target was an anchor, fix the scroll position. | [
"If",
"the",
"click",
"event",
"s",
"target",
"was",
"an",
"anchor",
"fix",
"the",
"scroll",
"position",
"."
] | 975a16ae24bd214b608d0b0001d3d86e5cd65f9e | https://github.com/panjiesw/frest/blob/975a16ae24bd214b608d0b0001d3d86e5cd65f9e/internal/docs/themes/hugo-theme-learn/static/js/learn.js#L331-L337 | train | |
DIMLEO/dim | Session/Session.js | function(key, defaultValue){
var value = this.get(key, defaultValue);
if($ExpressSESSION.session.store[key]){
delete $ExpressSESSION.session.store[key];
}
return value;
} | javascript | function(key, defaultValue){
var value = this.get(key, defaultValue);
if($ExpressSESSION.session.store[key]){
delete $ExpressSESSION.session.store[key];
}
return value;
} | [
"function",
"(",
"key",
",",
"defaultValue",
")",
"{",
"var",
"value",
"=",
"this",
".",
"get",
"(",
"key",
",",
"defaultValue",
")",
";",
"if",
"(",
"$ExpressSESSION",
".",
"session",
".",
"store",
"[",
"key",
"]",
")",
"{",
"delete",
"$ExpressSESSION... | Retrieving An Item And Forgetting It | [
"Retrieving",
"An",
"Item",
"And",
"Forgetting",
"It"
] | 4e8066be4dfc6c6cf53698c302c1ad0cc082d5d3 | https://github.com/DIMLEO/dim/blob/4e8066be4dfc6c6cf53698c302c1ad0cc082d5d3/Session/Session.js#L44-L50 | train | |
phelpstream/svp | lib/functions/merge.js | merge | function merge(target) {
for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];
}
if (!sources.length) return target;
var source = sources.shift();
if ((0, _isObject2.default)(target) && (0, _isObject2.default)(so... | javascript | function merge(target) {
for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];
}
if (!sources.length) return target;
var source = sources.shift();
if ((0, _isObject2.default)(target) && (0, _isObject2.default)(so... | [
"function",
"merge",
"(",
"target",
")",
"{",
"for",
"(",
"var",
"_len",
"=",
"arguments",
".",
"length",
",",
"sources",
"=",
"Array",
"(",
"_len",
">",
"1",
"?",
"_len",
"-",
"1",
":",
"0",
")",
",",
"_key",
"=",
"1",
";",
"_key",
"<",
"_len"... | Recursively merge two objects.
@param target
@param ...sources | [
"Recursively",
"merge",
"two",
"objects",
"."
] | 2f99adb9c5d0709e567264bba896d6a59f6a0a59 | https://github.com/phelpstream/svp/blob/2f99adb9c5d0709e567264bba896d6a59f6a0a59/lib/functions/merge.js#L21-L41 | train |
chriskinsman/disque-eventemitter | index.js | readQueue | function readQueue() {
disq.getJob({queue: queueName, count: self.jobCount, withcounters: self.withCounters}, function(err, jobs) {
if(err) {
self.emit('error', err);
}
else {
jobs.forEach(function(job) {
pendingMessages++;
... | javascript | function readQueue() {
disq.getJob({queue: queueName, count: self.jobCount, withcounters: self.withCounters}, function(err, jobs) {
if(err) {
self.emit('error', err);
}
else {
jobs.forEach(function(job) {
pendingMessages++;
... | [
"function",
"readQueue",
"(",
")",
"{",
"disq",
".",
"getJob",
"(",
"{",
"queue",
":",
"queueName",
",",
"count",
":",
"self",
".",
"jobCount",
",",
"withcounters",
":",
"self",
".",
"withCounters",
"}",
",",
"function",
"(",
"err",
",",
"jobs",
")",
... | Main message processor | [
"Main",
"message",
"processor"
] | 0b7550def40f5e1e614de4b015c7fccc9bd6a497 | https://github.com/chriskinsman/disque-eventemitter/blob/0b7550def40f5e1e614de4b015c7fccc9bd6a497/index.js#L22-L47 | train |
implicit-invocation/world-walkable | index.js | dst | function dst(lat1, lon1, lat2, lon2) {
// generally used geo measurement function
var dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
var dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
var a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1 * Math.PI / 180) *
Math.cos(lat2 * Math.... | javascript | function dst(lat1, lon1, lat2, lon2) {
// generally used geo measurement function
var dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
var dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
var a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1 * Math.PI / 180) *
Math.cos(lat2 * Math.... | [
"function",
"dst",
"(",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
")",
"{",
"// generally used geo measurement function",
"var",
"dLat",
"=",
"lat2",
"*",
"Math",
".",
"PI",
"/",
"180",
"-",
"lat1",
"*",
"Math",
".",
"PI",
"/",
"180",
";",
"var",
... | Radius of earth in KM | [
"Radius",
"of",
"earth",
"in",
"KM"
] | fedeee4e03fe2e91d417621c325ad71400a1a258 | https://github.com/implicit-invocation/world-walkable/blob/fedeee4e03fe2e91d417621c325ad71400a1a258/index.js#L5-L18 | train |
gethuman/pancakes-angular | lib/middleware/jng.pages.js | renderLayout | function renderLayout(appName, layoutName, isAmp, dependencies) {
var layout = this.pancakes.cook('app/' + appName + '/layouts/' + layoutName + '.layout');
var layoutView = this.pancakes.cook(layout.view, { dependencies: dependencies });
return jangular.render(layoutView, dependencies.model, { strip: false,... | javascript | function renderLayout(appName, layoutName, isAmp, dependencies) {
var layout = this.pancakes.cook('app/' + appName + '/layouts/' + layoutName + '.layout');
var layoutView = this.pancakes.cook(layout.view, { dependencies: dependencies });
return jangular.render(layoutView, dependencies.model, { strip: false,... | [
"function",
"renderLayout",
"(",
"appName",
",",
"layoutName",
",",
"isAmp",
",",
"dependencies",
")",
"{",
"var",
"layout",
"=",
"this",
".",
"pancakes",
".",
"cook",
"(",
"'app/'",
"+",
"appName",
"+",
"'/layouts/'",
"+",
"layoutName",
"+",
"'.layout'",
... | Get a particular layout
@param appName
@param layoutName
@param isAmp
@param dependencies | [
"Get",
"a",
"particular",
"layout"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.pages.js#L18-L22 | train |
gethuman/pancakes-angular | lib/middleware/jng.directives.js | checkOnScopeChangeVals | function checkOnScopeChangeVals(partial, partialName) {
var remodelOnScopeChange = partial.remodelOnScopeChange || (partial.remodel && partial.remodel.onScopeChange);
var rerenderOnScopeChange = partial.rerenderOnScopeChange || (partial.rerender && partial.rerender.onScopeChange);
var scope = partial.scope ... | javascript | function checkOnScopeChangeVals(partial, partialName) {
var remodelOnScopeChange = partial.remodelOnScopeChange || (partial.remodel && partial.remodel.onScopeChange);
var rerenderOnScopeChange = partial.rerenderOnScopeChange || (partial.rerender && partial.rerender.onScopeChange);
var scope = partial.scope ... | [
"function",
"checkOnScopeChangeVals",
"(",
"partial",
",",
"partialName",
")",
"{",
"var",
"remodelOnScopeChange",
"=",
"partial",
".",
"remodelOnScopeChange",
"||",
"(",
"partial",
".",
"remodel",
"&&",
"partial",
".",
"remodel",
".",
"onScopeChange",
")",
";",
... | Make sure the remodelOnScopeChange and rerenderOnScopeChange values are
all from the isolated scope definition. In other words, are values that
come from the parent scope.
@param partial
@param partialName | [
"Make",
"sure",
"the",
"remodelOnScopeChange",
"and",
"rerenderOnScopeChange",
"values",
"are",
"all",
"from",
"the",
"isolated",
"scope",
"definition",
".",
"In",
"other",
"words",
"are",
"values",
"that",
"come",
"from",
"the",
"parent",
"scope",
"."
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L50-L70 | train |
gethuman/pancakes-angular | lib/middleware/jng.directives.js | getSubviews | function getSubviews(subviewFlapjacks) {
var renderedSubviews = {};
var jangularDeps = this.getJangularDeps();
var me = this;
_.each(subviewFlapjacks, function (subview, subviewName) {
renderedSubviews[subviewName] = me.pancakes.cook(subview, { dependencies: jangularDeps });
});
return... | javascript | function getSubviews(subviewFlapjacks) {
var renderedSubviews = {};
var jangularDeps = this.getJangularDeps();
var me = this;
_.each(subviewFlapjacks, function (subview, subviewName) {
renderedSubviews[subviewName] = me.pancakes.cook(subview, { dependencies: jangularDeps });
});
return... | [
"function",
"getSubviews",
"(",
"subviewFlapjacks",
")",
"{",
"var",
"renderedSubviews",
"=",
"{",
"}",
";",
"var",
"jangularDeps",
"=",
"this",
".",
"getJangularDeps",
"(",
")",
";",
"var",
"me",
"=",
"this",
";",
"_",
".",
"each",
"(",
"subviewFlapjacks"... | Get all subviews
@param subviewFlapjacks | [
"Get",
"all",
"subviews"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L162-L172 | train |
gethuman/pancakes-angular | lib/middleware/jng.directives.js | getPartialRenderFn | function getPartialRenderFn(partial, partialName) {
var jangularDeps = this.getJangularDeps();
var me = this;
return function renderPartial(model, elem, attrs) {
me.isolateScope(model, partial.scope, attrs);
// throw error if onScopeChange values not in the scope {} definition
me.c... | javascript | function getPartialRenderFn(partial, partialName) {
var jangularDeps = this.getJangularDeps();
var me = this;
return function renderPartial(model, elem, attrs) {
me.isolateScope(model, partial.scope, attrs);
// throw error if onScopeChange values not in the scope {} definition
me.c... | [
"function",
"getPartialRenderFn",
"(",
"partial",
",",
"partialName",
")",
"{",
"var",
"jangularDeps",
"=",
"this",
".",
"getJangularDeps",
"(",
")",
";",
"var",
"me",
"=",
"this",
";",
"return",
"function",
"renderPartial",
"(",
"model",
",",
"elem",
",",
... | Get a function to help render a partial
@param partial
@param partialName
@returns {Function} | [
"Get",
"a",
"function",
"to",
"help",
"render",
"a",
"partial"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/middleware/jng.directives.js#L180-L207 | 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.