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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
RackHD/on-tasks | spec/lib/task-data/schemas/schema-ut-helper.js | loadSchemas | function loadSchemas(ajv) {
var metaSchema = helper.require('/lib/task-data/schemas/rackhd-task-schema.json');
ajv.addMetaSchema(metaSchema, 'rackhd-task-schema.json');
var fileNames = glob.sync(helper.relativeToRoot('/lib/task-data/schemas/*.json'));
_(fileNames).filter(function (filename) {
re... | javascript | function loadSchemas(ajv) {
var metaSchema = helper.require('/lib/task-data/schemas/rackhd-task-schema.json');
ajv.addMetaSchema(metaSchema, 'rackhd-task-schema.json');
var fileNames = glob.sync(helper.relativeToRoot('/lib/task-data/schemas/*.json'));
_(fileNames).filter(function (filename) {
re... | [
"function",
"loadSchemas",
"(",
"ajv",
")",
"{",
"var",
"metaSchema",
"=",
"helper",
".",
"require",
"(",
"'/lib/task-data/schemas/rackhd-task-schema.json'",
")",
";",
"ajv",
".",
"addMetaSchema",
"(",
"metaSchema",
",",
"'rackhd-task-schema.json'",
")",
";",
"var",... | load all schemas into the validator to resolve all schema references
@param {Object} ajv - The Ajv instance
@return {Object} the input Ajv instance | [
"load",
"all",
"schemas",
"into",
"the",
"validator",
"to",
"resolve",
"all",
"schema",
"references"
] | 18ca8021a18e51cb8fc01ef3c08c9e48d34f73ea | https://github.com/RackHD/on-tasks/blob/18ca8021a18e51cb8fc01ef3c08c9e48d34f73ea/spec/lib/task-data/schemas/schema-ut-helper.js#L18-L38 | train |
RackHD/on-tasks | spec/lib/task-data/schemas/schema-ut-helper.js | getSchema | function getSchema(ajv, name) {
var result = ajv.getSchema(name);
if (!result || !result.schema) {
throw new Error('cannot find the schema with name "' + name + '".');
}
return result.schema;
} | javascript | function getSchema(ajv, name) {
var result = ajv.getSchema(name);
if (!result || !result.schema) {
throw new Error('cannot find the schema with name "' + name + '".');
}
return result.schema;
} | [
"function",
"getSchema",
"(",
"ajv",
",",
"name",
")",
"{",
"var",
"result",
"=",
"ajv",
".",
"getSchema",
"(",
"name",
")",
";",
"if",
"(",
"!",
"result",
"||",
"!",
"result",
".",
"schema",
")",
"{",
"throw",
"new",
"Error",
"(",
"'cannot find the ... | Get the schema definition via name
@param {Object} ajv - The Ajv instance
@param {String} name - The schema name or id
@return {Object} The schema definition. | [
"Get",
"the",
"schema",
"definition",
"via",
"name"
] | 18ca8021a18e51cb8fc01ef3c08c9e48d34f73ea | https://github.com/RackHD/on-tasks/blob/18ca8021a18e51cb8fc01ef3c08c9e48d34f73ea/spec/lib/task-data/schemas/schema-ut-helper.js#L46-L52 | train |
RackHD/on-tasks | spec/lib/task-data/schemas/schema-ut-helper.js | validateData | function validateData(validator, schemaId, data, expected) {
var result = validator.validate(schemaId, data);
if (!result && expected || result && !expected) {
if (!result) {
return new Error(validator.errorsText());
}
else {
return new Error('expected schema viol... | javascript | function validateData(validator, schemaId, data, expected) {
var result = validator.validate(schemaId, data);
if (!result && expected || result && !expected) {
if (!result) {
return new Error(validator.errorsText());
}
else {
return new Error('expected schema viol... | [
"function",
"validateData",
"(",
"validator",
",",
"schemaId",
",",
"data",
",",
"expected",
")",
"{",
"var",
"result",
"=",
"validator",
".",
"validate",
"(",
"schemaId",
",",
"data",
")",
";",
"if",
"(",
"!",
"result",
"&&",
"expected",
"||",
"result",... | validate the data against a schema
@param {Object} validator - The JSON-Schema validator instance
@param {String} schemaId - The schema id
@param {Object} data - The data that to be validated
@param {Boolean} expected - true if expect data conforms to schema, otherwise expect violation.
@return {undefined | Error} - re... | [
"validate",
"the",
"data",
"against",
"a",
"schema"
] | 18ca8021a18e51cb8fc01ef3c08c9e48d34f73ea | https://github.com/RackHD/on-tasks/blob/18ca8021a18e51cb8fc01ef3c08c9e48d34f73ea/spec/lib/task-data/schemas/schema-ut-helper.js#L74-L84 | train |
stadt-bielefeld/wms-downloader | src/helper/getNumberOfTiles.js | getNumberOfTiles | function getNumberOfTiles(options) {
// Determine ground resolution if scale is only set
determineGroundResolution(options.tiles.resolutions);
// Counter of all tiles
let countOfAllTiles = 0;
// Calculate parameters of bbox
let widthM = options.task.area.bbox.xmax - options.task.area.bbox.xmin;
let hei... | javascript | function getNumberOfTiles(options) {
// Determine ground resolution if scale is only set
determineGroundResolution(options.tiles.resolutions);
// Counter of all tiles
let countOfAllTiles = 0;
// Calculate parameters of bbox
let widthM = options.task.area.bbox.xmax - options.task.area.bbox.xmin;
let hei... | [
"function",
"getNumberOfTiles",
"(",
"options",
")",
"{",
"// Determine ground resolution if scale is only set",
"determineGroundResolution",
"(",
"options",
".",
"tiles",
".",
"resolutions",
")",
";",
"// Counter of all tiles",
"let",
"countOfAllTiles",
"=",
"0",
";",
"/... | Calculates the number of tiles of a task.
@param {Object} options Task options (see example)
@returns {Number} Number of all tiles of this task
@example
// task options
const task = {
'task': {
'area': {
'bbox': {
'xmin': 455000,
'ymin': 5750000,
'xmax': 479000,
'ymax': 5774000
}
}
},
'tiles': {
'maxSizePx': 2500,
'gu... | [
"Calculates",
"the",
"number",
"of",
"tiles",
"of",
"a",
"task",
"."
] | 8e20d7d5547ed43d24d81b8fe3a2c6b4ced83f5d | https://github.com/stadt-bielefeld/wms-downloader/blob/8e20d7d5547ed43d24d81b8fe3a2c6b4ced83f5d/src/helper/getNumberOfTiles.js#L49-L82 | train |
stadt-bielefeld/wms-downloader | src/helper/handleTask.js | handleTask | function handleTask(options, config, progress, callback) {
fs.ensureDir(options.task.workspace, (err) => {
if (err) {
// Call callback function with error.
callback(err);
} else {
// Workspace of this task
let ws = options.task.workspace + '/' + options.task.id;
// Create direc... | javascript | function handleTask(options, config, progress, callback) {
fs.ensureDir(options.task.workspace, (err) => {
if (err) {
// Call callback function with error.
callback(err);
} else {
// Workspace of this task
let ws = options.task.workspace + '/' + options.task.id;
// Create direc... | [
"function",
"handleTask",
"(",
"options",
",",
"config",
",",
"progress",
",",
"callback",
")",
"{",
"fs",
".",
"ensureDir",
"(",
"options",
".",
"task",
".",
"workspace",
",",
"(",
"err",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"// Call callback f... | It handles a download task of Web Map Services.
@param {Object} options
@param {Object} config See options of the {@link WMSDownloader|WMSDownloader constructor}
@param {Array} progress Array of the progress of all WMSDownloader tasks.
@param {Function} callback function(err){} | [
"It",
"handles",
"a",
"download",
"task",
"of",
"Web",
"Map",
"Services",
"."
] | 8e20d7d5547ed43d24d81b8fe3a2c6b4ced83f5d | https://github.com/stadt-bielefeld/wms-downloader/blob/8e20d7d5547ed43d24d81b8fe3a2c6b4ced83f5d/src/helper/handleTask.js#L14-L59 | train |
iatsiuk/vuegister | src/vuegister.js | load | function load(buf, file, cfg) {
if (typeof buf !== 'string') {
throw new TypeError('First argument must be a string.');
}
cfg = Object.assign({
maps: false,
lang: {script: 'js', template: 'html'},
plugins: {},
}, cfg);
let vue = {};
for (let section of extract(buf, ['script', 'template'])... | javascript | function load(buf, file, cfg) {
if (typeof buf !== 'string') {
throw new TypeError('First argument must be a string.');
}
cfg = Object.assign({
maps: false,
lang: {script: 'js', template: 'html'},
plugins: {},
}, cfg);
let vue = {};
for (let section of extract(buf, ['script', 'template'])... | [
"function",
"load",
"(",
"buf",
",",
"file",
",",
"cfg",
")",
"{",
"if",
"(",
"typeof",
"buf",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'First argument must be a string.'",
")",
";",
"}",
"cfg",
"=",
"Object",
".",
"assign",
"(",
... | Parses SFC, high level API.
@alias module:vuegister
@param {string} buf - Content of the SFC file.
@param {string} [file] - Full path to the SFC.
@param {object} [cfg] - Options, an object of the following format:
```js
{
maps: boolean, // false, provide source map
lang: object, // {}, default language for tag wi... | [
"Parses",
"SFC",
"high",
"level",
"API",
"."
] | 38b30127df9f66a3d250229abcf2442c766c3b15 | https://github.com/iatsiuk/vuegister/blob/38b30127df9f66a3d250229abcf2442c766c3b15/src/vuegister.js#L124-L165 | train |
iatsiuk/vuegister | src/vuegister.js | unregister | function unregister() {
let list = [];
// removes module and all its children from the node's require cache
let unload = (id) => {
let module = require.cache[id];
if (!module) return;
module.children.forEach((child) => unload(child.id));
delete require.cache[id];
list.push(id);
};
let ... | javascript | function unregister() {
let list = [];
// removes module and all its children from the node's require cache
let unload = (id) => {
let module = require.cache[id];
if (!module) return;
module.children.forEach((child) => unload(child.id));
delete require.cache[id];
list.push(id);
};
let ... | [
"function",
"unregister",
"(",
")",
"{",
"let",
"list",
"=",
"[",
"]",
";",
"// removes module and all its children from the node's require cache",
"let",
"unload",
"=",
"(",
"id",
")",
"=>",
"{",
"let",
"module",
"=",
"require",
".",
"cache",
"[",
"id",
"]",
... | Removes requre hook.
@alias module:vuegister
@return {array} Returns list of unloaded modules. | [
"Removes",
"requre",
"hook",
"."
] | 38b30127df9f66a3d250229abcf2442c766c3b15 | https://github.com/iatsiuk/vuegister/blob/38b30127df9f66a3d250229abcf2442c766c3b15/src/vuegister.js#L219-L252 | train |
iatsiuk/vuegister | src/vuegister.js | transpile | function transpile(lang, text, options) {
let plugin = `vuegister-plugin-${lang}`;
let langs = {
js() {
let map = (options.maps && options.offset > 0) ?
generateMap(text, options.file, options.offset) : null;
return {data: text, map};
},
html() {
return {data: text, ... | javascript | function transpile(lang, text, options) {
let plugin = `vuegister-plugin-${lang}`;
let langs = {
js() {
let map = (options.maps && options.offset > 0) ?
generateMap(text, options.file, options.offset) : null;
return {data: text, map};
},
html() {
return {data: text, ... | [
"function",
"transpile",
"(",
"lang",
",",
"text",
",",
"options",
")",
"{",
"let",
"plugin",
"=",
"`",
"${",
"lang",
"}",
"`",
";",
"let",
"langs",
"=",
"{",
"js",
"(",
")",
"{",
"let",
"map",
"=",
"(",
"options",
".",
"maps",
"&&",
"options",
... | Passes given code to the external plugin.
@param {string} lang - Lang attribute from the tag.
@param {string} text - Code for the transpiler.
@param {object} options - Options, an object of the following format:
```js
{
file: string, // 'unknown', file name
maps: boolean, // false, provide source map
mapOffse... | [
"Passes",
"given",
"code",
"to",
"the",
"external",
"plugin",
"."
] | 38b30127df9f66a3d250229abcf2442c766c3b15 | https://github.com/iatsiuk/vuegister/blob/38b30127df9f66a3d250229abcf2442c766c3b15/src/vuegister.js#L276-L304 | train |
iatsiuk/vuegister | src/vuegister.js | generateMap | function generateMap(content, file, offset) {
if (offset <= 0) {
throw new RangeError('Offset parameter should be greater than zero.');
}
let generator = new sourceMap.SourceMapGenerator();
let options = {
locations: true,
sourceType: 'module',
};
for (let token of tokenizer(content, options))... | javascript | function generateMap(content, file, offset) {
if (offset <= 0) {
throw new RangeError('Offset parameter should be greater than zero.');
}
let generator = new sourceMap.SourceMapGenerator();
let options = {
locations: true,
sourceType: 'module',
};
for (let token of tokenizer(content, options))... | [
"function",
"generateMap",
"(",
"content",
",",
"file",
",",
"offset",
")",
"{",
"if",
"(",
"offset",
"<=",
"0",
")",
"{",
"throw",
"new",
"RangeError",
"(",
"'Offset parameter should be greater than zero.'",
")",
";",
"}",
"let",
"generator",
"=",
"new",
"s... | Generates source map for JavaScript.
@param {string} content - Content of the script tag.
@param {string} file - File name of the generated source.
@param {number} offset - Offset for script tag
@return {object} Returns the source map. | [
"Generates",
"source",
"map",
"for",
"JavaScript",
"."
] | 38b30127df9f66a3d250229abcf2442c766c3b15 | https://github.com/iatsiuk/vuegister/blob/38b30127df9f66a3d250229abcf2442c766c3b15/src/vuegister.js#L314-L337 | train |
iatsiuk/vuegister | src/vuegister.js | installMapsSupport | function installMapsSupport() {
require('source-map-support').install({
environment: 'node',
handleUncaughtExceptions: false,
retrieveSourceMap: (source) => {
return sourceMapsCache.has(source) ?
{map: sourceMapsCache.get(source), url: source} :
null;
},
});
} | javascript | function installMapsSupport() {
require('source-map-support').install({
environment: 'node',
handleUncaughtExceptions: false,
retrieveSourceMap: (source) => {
return sourceMapsCache.has(source) ?
{map: sourceMapsCache.get(source), url: source} :
null;
},
});
} | [
"function",
"installMapsSupport",
"(",
")",
"{",
"require",
"(",
"'source-map-support'",
")",
".",
"install",
"(",
"{",
"environment",
":",
"'node'",
",",
"handleUncaughtExceptions",
":",
"false",
",",
"retrieveSourceMap",
":",
"(",
"source",
")",
"=>",
"{",
"... | Installs handler on prepareStackTrace | [
"Installs",
"handler",
"on",
"prepareStackTrace"
] | 38b30127df9f66a3d250229abcf2442c766c3b15 | https://github.com/iatsiuk/vuegister/blob/38b30127df9f66a3d250229abcf2442c766c3b15/src/vuegister.js#L342-L352 | train |
anticoders/gagarin | lib/meteor/meteorProcess.js | kill | function kill (cb) {
if (!meteor) {
return cb();
}
meteor.once('exit', function (code) {
if (!code || code === 0 || code === 130) {
cb();
} else {
cb(new Error('exited with code ' + code));
}
});
meteor.kill('SIGINT');
meteor = null;
//----------------... | javascript | function kill (cb) {
if (!meteor) {
return cb();
}
meteor.once('exit', function (code) {
if (!code || code === 0 || code === 130) {
cb();
} else {
cb(new Error('exited with code ' + code));
}
});
meteor.kill('SIGINT');
meteor = null;
//----------------... | [
"function",
"kill",
"(",
"cb",
")",
"{",
"if",
"(",
"!",
"meteor",
")",
"{",
"return",
"cb",
"(",
")",
";",
"}",
"meteor",
".",
"once",
"(",
"'exit'",
",",
"function",
"(",
"code",
")",
"{",
"if",
"(",
"!",
"code",
"||",
"code",
"===",
"0",
"... | Kill the meteor process and cleanup.
@param {Function} cb | [
"Kill",
"the",
"meteor",
"process",
"and",
"cleanup",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/lib/meteor/meteorProcess.js#L141-L156 | train |
ciena-blueplanet/ember-test-utils | cli/lint-markdown.js | getIgnoredFiles | function getIgnoredFiles () {
const filePath = path.join(process.cwd(), '.remarkignore')
const ignoredFilesSource = fs.existsSync(filePath) ? fs.readFileSync(filePath, {encoding: 'utf8'}) : ''
var ignoredFiles = ignoredFilesSource.split('\n')
ignoredFiles = ignoredFiles.filter(function (item) {
return item... | javascript | function getIgnoredFiles () {
const filePath = path.join(process.cwd(), '.remarkignore')
const ignoredFilesSource = fs.existsSync(filePath) ? fs.readFileSync(filePath, {encoding: 'utf8'}) : ''
var ignoredFiles = ignoredFilesSource.split('\n')
ignoredFiles = ignoredFiles.filter(function (item) {
return item... | [
"function",
"getIgnoredFiles",
"(",
")",
"{",
"const",
"filePath",
"=",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"'.remarkignore'",
")",
"const",
"ignoredFilesSource",
"=",
"fs",
".",
"existsSync",
"(",
"filePath",
")",
"?",
"fs",
... | The entries in the consumer's `.remarkignore` file
@returns {Array} entries | [
"The",
"entries",
"in",
"the",
"consumer",
"s",
".",
"remarkignore",
"file"
] | 7e40f35d53c488b5f12968212110bb5a5ec138ea | https://github.com/ciena-blueplanet/ember-test-utils/blob/7e40f35d53c488b5f12968212110bb5a5ec138ea/cli/lint-markdown.js#L79-L89 | train |
anticoders/gagarin | lib/tools/index.js | function (err) {
"use strict";
var message = '';
if (typeof err === 'string') {
return new Error(err);
} else if (typeof err === 'object') {
if (err.cause) {
// probably a webdriver error
try {
message = JSON.parse(err.cause.value.message).errorMessage;
... | javascript | function (err) {
"use strict";
var message = '';
if (typeof err === 'string') {
return new Error(err);
} else if (typeof err === 'object') {
if (err.cause) {
// probably a webdriver error
try {
message = JSON.parse(err.cause.value.message).errorMessage;
... | [
"function",
"(",
"err",
")",
"{",
"\"use strict\"",
";",
"var",
"message",
"=",
"''",
";",
"if",
"(",
"typeof",
"err",
"===",
"'string'",
")",
"{",
"return",
"new",
"Error",
"(",
"err",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"err",
"===",
"'ob... | Make an error comming from webdriver a little more readable. | [
"Make",
"an",
"error",
"comming",
"from",
"webdriver",
"a",
"little",
"more",
"readable",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/lib/tools/index.js#L231-L254 | train | |
anticoders/gagarin | lib/tools/index.js | function () {
"use strict";
return new Promise(function (resolve, reject) {
var numberOfRetries = 5;
(function retry () {
var port = 4000 + Math.floor(Math.random() * 1000);
portscanner.checkPortStatus(port, 'localhost', function (err, status) {
if (err || status !== 'clo... | javascript | function () {
"use strict";
return new Promise(function (resolve, reject) {
var numberOfRetries = 5;
(function retry () {
var port = 4000 + Math.floor(Math.random() * 1000);
portscanner.checkPortStatus(port, 'localhost', function (err, status) {
if (err || status !== 'clo... | [
"function",
"(",
")",
"{",
"\"use strict\"",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"numberOfRetries",
"=",
"5",
";",
"(",
"function",
"retry",
"(",
")",
"{",
"var",
"port",
"=",
"4000",
"+",
... | Find a port, nobody is listening on. | [
"Find",
"a",
"port",
"nobody",
"is",
"listening",
"on",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/lib/tools/index.js#L328-L349 | train | |
anticoders/gagarin | lib/tools/index.js | function (text, options) {
"use strict";
var marginX = options.marginX !== undefined ? options.marginX : 2;
var marginY = options.marginY !== undefined ? options.marginY : 1;
var margin = new Array(marginX+1).join(" ");
var indent = options.indent !== undefined ? options.indent : ... | javascript | function (text, options) {
"use strict";
var marginX = options.marginX !== undefined ? options.marginX : 2;
var marginY = options.marginY !== undefined ? options.marginY : 1;
var margin = new Array(marginX+1).join(" ");
var indent = options.indent !== undefined ? options.indent : ... | [
"function",
"(",
"text",
",",
"options",
")",
"{",
"\"use strict\"",
";",
"var",
"marginX",
"=",
"options",
".",
"marginX",
"!==",
"undefined",
"?",
"options",
".",
"marginX",
":",
"2",
";",
"var",
"marginY",
"=",
"options",
".",
"marginY",
"!==",
"undef... | Creates a nice banner containing the given text.
@param {object} options | [
"Creates",
"a",
"nice",
"banner",
"containing",
"the",
"given",
"text",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/lib/tools/index.js#L356-L398 | train | |
css-modules/postcss-modules-resolve-imports | src/resolveDeps.js | resolveDeps | function resolveDeps(ast, result) {
const {
from: selfPath,
graph,
resolve,
rootPath,
rootTree,
} = result.opts;
const cwd = dirname(selfPath);
const rootDir = dirname(rootPath);
const processor = result.processor;
const self = graph[selfPath] = graph[selfPath] || {};
self.mark = TEM... | javascript | function resolveDeps(ast, result) {
const {
from: selfPath,
graph,
resolve,
rootPath,
rootTree,
} = result.opts;
const cwd = dirname(selfPath);
const rootDir = dirname(rootPath);
const processor = result.processor;
const self = graph[selfPath] = graph[selfPath] || {};
self.mark = TEM... | [
"function",
"resolveDeps",
"(",
"ast",
",",
"result",
")",
"{",
"const",
"{",
"from",
":",
"selfPath",
",",
"graph",
",",
"resolve",
",",
"rootPath",
",",
"rootTree",
",",
"}",
"=",
"result",
".",
"opts",
";",
"const",
"cwd",
"=",
"dirname",
"(",
"se... | Topological sorting is used to resolve the deps order,
actually depth-first search algorithm.
@see https://en.wikipedia.org/wiki/Topological_sorting | [
"Topological",
"sorting",
"is",
"used",
"to",
"resolve",
"the",
"deps",
"order",
"actually",
"depth",
"-",
"first",
"search",
"algorithm",
"."
] | 31ba1f0ab6b727cf7c5630f56256f1f8dd34d67f | https://github.com/css-modules/postcss-modules-resolve-imports/blob/31ba1f0ab6b727cf7c5630f56256f1f8dd34d67f/src/resolveDeps.js#L25-L115 | train |
anticoders/gagarin | lib/tools/closure.js | Closure | function Closure (parent, listOfKeys, accessor) {
"use strict";
var closure = {};
listOfKeys = listOfKeys || [];
accessor = accessor || function () {};
parent && parent.__mixin__ && parent.__mixin__(closure);
listOfKeys.forEach(function (key) {
closure[key] = accessor.bind(null, key);
});
t... | javascript | function Closure (parent, listOfKeys, accessor) {
"use strict";
var closure = {};
listOfKeys = listOfKeys || [];
accessor = accessor || function () {};
parent && parent.__mixin__ && parent.__mixin__(closure);
listOfKeys.forEach(function (key) {
closure[key] = accessor.bind(null, key);
});
t... | [
"function",
"Closure",
"(",
"parent",
",",
"listOfKeys",
",",
"accessor",
")",
"{",
"\"use strict\"",
";",
"var",
"closure",
"=",
"{",
"}",
";",
"listOfKeys",
"=",
"listOfKeys",
"||",
"[",
"]",
";",
"accessor",
"=",
"accessor",
"||",
"function",
"(",
")"... | Creates a new closure manager.
@param {Object} parent
@param {Array} listOfKeys (names)
@param {Function} accessor | [
"Creates",
"a",
"new",
"closure",
"manager",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/lib/tools/closure.js#L11-L51 | train |
ionic-team/ionic-service-core | ionic-core.js | function(key, object) {
// Convert object to JSON and store in localStorage
var json = JSON.stringify(object);
persistenceStrategy.set(key, json);
// Then store it in the object cache
objectCache[key] = object;
} | javascript | function(key, object) {
// Convert object to JSON and store in localStorage
var json = JSON.stringify(object);
persistenceStrategy.set(key, json);
// Then store it in the object cache
objectCache[key] = object;
} | [
"function",
"(",
"key",
",",
"object",
")",
"{",
"// Convert object to JSON and store in localStorage",
"var",
"json",
"=",
"JSON",
".",
"stringify",
"(",
"object",
")",
";",
"persistenceStrategy",
".",
"set",
"(",
"key",
",",
"json",
")",
";",
"// Then store it... | Stores an object in local storage under the given key | [
"Stores",
"an",
"object",
"in",
"local",
"storage",
"under",
"the",
"given",
"key"
] | 8997fb52e8b8bc4545ba54a9a31d7e6f36b4a744 | https://github.com/ionic-team/ionic-service-core/blob/8997fb52e8b8bc4545ba54a9a31d7e6f36b4a744/ionic-core.js#L28-L36 | train | |
ionic-team/ionic-service-core | ionic-core.js | function(key) {
// First check to see if it's the object cache
var cached = objectCache[key];
if (cached) {
return cached;
}
// Deserialize the object from JSON
var json = persistenceStrategy.get(key);
// null or undefined --> return n... | javascript | function(key) {
// First check to see if it's the object cache
var cached = objectCache[key];
if (cached) {
return cached;
}
// Deserialize the object from JSON
var json = persistenceStrategy.get(key);
// null or undefined --> return n... | [
"function",
"(",
"key",
")",
"{",
"// First check to see if it's the object cache",
"var",
"cached",
"=",
"objectCache",
"[",
"key",
"]",
";",
"if",
"(",
"cached",
")",
"{",
"return",
"cached",
";",
"}",
"// Deserialize the object from JSON",
"var",
"json",
"=",
... | Either retrieves the cached copy of an object,
or the object itself from localStorage.
Returns null if the object couldn't be found. | [
"Either",
"retrieves",
"the",
"cached",
"copy",
"of",
"an",
"object",
"or",
"the",
"object",
"itself",
"from",
"localStorage",
".",
"Returns",
"null",
"if",
"the",
"object",
"couldn",
"t",
"be",
"found",
"."
] | 8997fb52e8b8bc4545ba54a9a31d7e6f36b4a744 | https://github.com/ionic-team/ionic-service-core/blob/8997fb52e8b8bc4545ba54a9a31d7e6f36b4a744/ionic-core.js#L43-L64 | train | |
ionic-team/ionic-service-core | ionic-core.js | function(lockKey, asyncFunction) {
var deferred = $q.defer();
// If the memory lock is set, error out.
if (memoryLocks[lockKey]) {
deferred.reject('in_progress');
return deferred.promise;
}
// If there is a stored lock but no memory lock, flag... | javascript | function(lockKey, asyncFunction) {
var deferred = $q.defer();
// If the memory lock is set, error out.
if (memoryLocks[lockKey]) {
deferred.reject('in_progress');
return deferred.promise;
}
// If there is a stored lock but no memory lock, flag... | [
"function",
"(",
"lockKey",
",",
"asyncFunction",
")",
"{",
"var",
"deferred",
"=",
"$q",
".",
"defer",
"(",
")",
";",
"// If the memory lock is set, error out.",
"if",
"(",
"memoryLocks",
"[",
"lockKey",
"]",
")",
"{",
"deferred",
".",
"reject",
"(",
"'in_p... | Locks the async call represented by the given promise and lock key.
Only one asyncFunction given by the lockKey can be running at any time.
@param lockKey should be a string representing the name of this async call.
This is required for persistence.
@param asyncFunction Returns a promise of the async call.
@returns A ... | [
"Locks",
"the",
"async",
"call",
"represented",
"by",
"the",
"given",
"promise",
"and",
"lock",
"key",
".",
"Only",
"one",
"asyncFunction",
"given",
"by",
"the",
"lockKey",
"can",
"be",
"running",
"at",
"any",
"time",
"."
] | 8997fb52e8b8bc4545ba54a9a31d7e6f36b4a744 | https://github.com/ionic-team/ionic-service-core/blob/8997fb52e8b8bc4545ba54a9a31d7e6f36b4a744/ionic-core.js#L76-L117 | train | |
ionic-team/ionic-service-core | ionic-core.js | function(key, value, isUnique) {
if(isUnique) {
return this._op(key, value, 'pushUnique');
} else {
return this._op(key, value, 'push');
}
} | javascript | function(key, value, isUnique) {
if(isUnique) {
return this._op(key, value, 'pushUnique');
} else {
return this._op(key, value, 'push');
}
} | [
"function",
"(",
"key",
",",
"value",
",",
"isUnique",
")",
"{",
"if",
"(",
"isUnique",
")",
"{",
"return",
"this",
".",
"_op",
"(",
"key",
",",
"value",
",",
"'pushUnique'",
")",
";",
"}",
"else",
"{",
"return",
"this",
".",
"_op",
"(",
"key",
"... | Push the given value into the array field identified by the key.
Pass true to isUnique to only push the value if the value does not
already exist in the array. | [
"Push",
"the",
"given",
"value",
"into",
"the",
"array",
"field",
"identified",
"by",
"the",
"key",
".",
"Pass",
"true",
"to",
"isUnique",
"to",
"only",
"push",
"the",
"value",
"if",
"the",
"value",
"does",
"not",
"already",
"exist",
"in",
"the",
"array"... | 8997fb52e8b8bc4545ba54a9a31d7e6f36b4a744 | https://github.com/ionic-team/ionic-service-core/blob/8997fb52e8b8bc4545ba54a9a31d7e6f36b4a744/ionic-core.js#L377-L383 | train | |
anticoders/gagarin | lib/meteor/build.js | BuildPromise | function BuildPromise(options) {
"use strict";
options = options || {};
var pathToApp = options.pathToApp || path.resolve('.');
var mongoUrl = options.mongoUrl || "http://localhost:27017";
var timeout = options.timeout || 120000;
var verbose = options.verbose !== undefined ? !!options.verbose : fa... | javascript | function BuildPromise(options) {
"use strict";
options = options || {};
var pathToApp = options.pathToApp || path.resolve('.');
var mongoUrl = options.mongoUrl || "http://localhost:27017";
var timeout = options.timeout || 120000;
var verbose = options.verbose !== undefined ? !!options.verbose : fa... | [
"function",
"BuildPromise",
"(",
"options",
")",
"{",
"\"use strict\"",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"pathToApp",
"=",
"options",
".",
"pathToApp",
"||",
"path",
".",
"resolve",
"(",
"'.'",
")",
";",
"var",
"mongoUrl",
"=",... | PRIVATE BUILD PROMISE IMPLEMENTATION | [
"PRIVATE",
"BUILD",
"PROMISE",
"IMPLEMENTATION"
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/lib/meteor/build.js#L103-L224 | train |
anticoders/gagarin | lib/meteor/build.js | ensureGagarinVersionsMatch | function ensureGagarinVersionsMatch(pathToApp, verbose) {
var pathToMeteorPackages = path.join(pathToApp, '.meteor', 'packages');
var nodeModuleVersion = require('../../package.json').version;
return new Promise(function (resolve, reject) {
utils.getGagarinPackageVersion(pathToApp).then(function (packag... | javascript | function ensureGagarinVersionsMatch(pathToApp, verbose) {
var pathToMeteorPackages = path.join(pathToApp, '.meteor', 'packages');
var nodeModuleVersion = require('../../package.json').version;
return new Promise(function (resolve, reject) {
utils.getGagarinPackageVersion(pathToApp).then(function (packag... | [
"function",
"ensureGagarinVersionsMatch",
"(",
"pathToApp",
",",
"verbose",
")",
"{",
"var",
"pathToMeteorPackages",
"=",
"path",
".",
"join",
"(",
"pathToApp",
",",
"'.meteor'",
",",
"'packages'",
")",
";",
"var",
"nodeModuleVersion",
"=",
"require",
"(",
"'../... | Build
Check smart package version and if it's wrong, install the right one.
@param {string} pathToApp | [
"Build",
"Check",
"smart",
"package",
"version",
"and",
"if",
"it",
"s",
"wrong",
"install",
"the",
"right",
"one",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/lib/meteor/build.js#L232-L286 | train |
anticoders/gagarin | lib/meteor/build.js | checkIfMeteorIsRunning | function checkIfMeteorIsRunning(pathToApp) {
var pathToMongoLock = path.join(pathToApp, '.meteor', 'local', 'db', 'mongod.lock');
return new Promise(function (resolve, reject) {
fs.readFile(pathToMongoLock, { encoding: 'utf8' }, function (err, data) {
if (err) {
// if the file does not exist, then... | javascript | function checkIfMeteorIsRunning(pathToApp) {
var pathToMongoLock = path.join(pathToApp, '.meteor', 'local', 'db', 'mongod.lock');
return new Promise(function (resolve, reject) {
fs.readFile(pathToMongoLock, { encoding: 'utf8' }, function (err, data) {
if (err) {
// if the file does not exist, then... | [
"function",
"checkIfMeteorIsRunning",
"(",
"pathToApp",
")",
"{",
"var",
"pathToMongoLock",
"=",
"path",
".",
"join",
"(",
"pathToApp",
",",
"'.meteor'",
",",
"'local'",
",",
"'db'",
",",
"'mongod.lock'",
")",
";",
"return",
"new",
"Promise",
"(",
"function",
... | Guess if "develop" meteor is currently running.
@param {string} pathToApp | [
"Guess",
"if",
"develop",
"meteor",
"is",
"currently",
"running",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/lib/meteor/build.js#L294-L307 | train |
anticoders/gagarin | lib/meteor/build.js | smartJsonWarning | function smartJsonWarning(pathToApp) {
var pathToSmartJSON = path.join(pathToApp, 'smart.json');
return new Promise(function (resolve, reject) {
fs.readFile(pathToSmartJSON, { endcoding: 'urf8' }, function (err, data) {
if (err) {
// if the file does not exist, then we are ok anyway
return... | javascript | function smartJsonWarning(pathToApp) {
var pathToSmartJSON = path.join(pathToApp, 'smart.json');
return new Promise(function (resolve, reject) {
fs.readFile(pathToSmartJSON, { endcoding: 'urf8' }, function (err, data) {
if (err) {
// if the file does not exist, then we are ok anyway
return... | [
"function",
"smartJsonWarning",
"(",
"pathToApp",
")",
"{",
"var",
"pathToSmartJSON",
"=",
"path",
".",
"join",
"(",
"pathToApp",
",",
"'smart.json'",
")",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"fs",
"."... | Look for "smart.json" file. If there's one, print warning
before resolving.
@param {string} pathToApp | [
"Look",
"for",
"smart",
".",
"json",
"file",
".",
"If",
"there",
"s",
"one",
"print",
"warning",
"before",
"resolving",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/lib/meteor/build.js#L315-L335 | train |
velop-io/server | examples/4-react-app/server.js | start | async function start() {
const mainRoute = server.addReactRoute(
"",
path.resolve(process.cwd(), "app/Routes.js")
);
await server.start(); //start server
console.log("started");
} | javascript | async function start() {
const mainRoute = server.addReactRoute(
"",
path.resolve(process.cwd(), "app/Routes.js")
);
await server.start(); //start server
console.log("started");
} | [
"async",
"function",
"start",
"(",
")",
"{",
"const",
"mainRoute",
"=",
"server",
".",
"addReactRoute",
"(",
"\"\"",
",",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"\"app/Routes.js\"",
")",
")",
";",
"await",
"server",
".",
"st... | create a new instance | [
"create",
"a",
"new",
"instance"
] | 0d9521f2c6bacff0ab6b717432ab1cb87ccbc9bc | https://github.com/velop-io/server/blob/0d9521f2c6bacff0ab6b717432ab1cb87ccbc9bc/examples/4-react-app/server.js#L7-L15 | train |
anticoders/gagarin | meteor/backdoor.js | providePlugins | function providePlugins(code) {
var chunks = [];
if (typeof code === 'string') {
code = code.split('\n');
}
chunks.push("function (" + Object.keys(plugins).join(', ') + ") {");
chunks.push(" return " + code[0]);
code.forEach(function (line, index) {
if (index === 0) return; // omit the first line
... | javascript | function providePlugins(code) {
var chunks = [];
if (typeof code === 'string') {
code = code.split('\n');
}
chunks.push("function (" + Object.keys(plugins).join(', ') + ") {");
chunks.push(" return " + code[0]);
code.forEach(function (line, index) {
if (index === 0) return; // omit the first line
... | [
"function",
"providePlugins",
"(",
"code",
")",
"{",
"var",
"chunks",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"code",
"===",
"'string'",
")",
"{",
"code",
"=",
"code",
".",
"split",
"(",
"'\\n'",
")",
";",
"}",
"chunks",
".",
"push",
"(",
"\"funct... | Provide plugins the the local context.
@param {(string|string[])} code
@returns {string[]} | [
"Provide",
"plugins",
"the",
"the",
"local",
"context",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/meteor/backdoor.js#L159-L173 | train |
anticoders/gagarin | meteor/backdoor.js | isolateScope | function isolateScope(code, closure) {
if (typeof code === 'string') {
code = code.split('\n');
}
var keys = Object.keys(closure).map(function (key) {
return stringify(key) + ": " + key;
});
var chunks = [];
chunks.push(
"function (" + Object.keys(closure).join(', ') + ") {",
" 'use strict... | javascript | function isolateScope(code, closure) {
if (typeof code === 'string') {
code = code.split('\n');
}
var keys = Object.keys(closure).map(function (key) {
return stringify(key) + ": " + key;
});
var chunks = [];
chunks.push(
"function (" + Object.keys(closure).join(', ') + ") {",
" 'use strict... | [
"function",
"isolateScope",
"(",
"code",
",",
"closure",
")",
"{",
"if",
"(",
"typeof",
"code",
"===",
"'string'",
")",
"{",
"code",
"=",
"code",
".",
"split",
"(",
"'\\n'",
")",
";",
"}",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"closure",
... | Make sure that the only local variables visible inside the code,
are those from the closure object.
@param {(string|string[])} code
@param {Object} closure
@returns {string[]} | [
"Make",
"sure",
"that",
"the",
"only",
"local",
"variables",
"visible",
"inside",
"the",
"code",
"are",
"those",
"from",
"the",
"closure",
"object",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/meteor/backdoor.js#L183-L224 | train |
anticoders/gagarin | meteor/backdoor.js | align | function align(code) {
if (typeof code === 'string') {
code = code.split('\n');
}
var match = code[code.length-1].match(/^(\s+)\}/);
var regex = null;
if (match && code[0].match(/^function/)) {
regex = new RegExp("^" + match[1]);
return code.map(function (line) {
return line.replace(regex, "... | javascript | function align(code) {
if (typeof code === 'string') {
code = code.split('\n');
}
var match = code[code.length-1].match(/^(\s+)\}/);
var regex = null;
if (match && code[0].match(/^function/)) {
regex = new RegExp("^" + match[1]);
return code.map(function (line) {
return line.replace(regex, "... | [
"function",
"align",
"(",
"code",
")",
"{",
"if",
"(",
"typeof",
"code",
"===",
"'string'",
")",
"{",
"code",
"=",
"code",
".",
"split",
"(",
"'\\n'",
")",
";",
"}",
"var",
"match",
"=",
"code",
"[",
"code",
".",
"length",
"-",
"1",
"]",
".",
"... | Fixes the source code indentation.
@param {(string|string[])} code
@returns {string[]} | [
"Fixes",
"the",
"source",
"code",
"indentation",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/meteor/backdoor.js#L232-L245 | train |
anticoders/gagarin | meteor/backdoor.js | compile | function compile(code, closure) {
code = providePlugins(isolateScope(code, closure)).join('\n');
try {
return vm.runInThisContext('(' + code + ')').apply({}, values(plugins));
} catch (err) {
throw new Meteor.Error(400, err);
}
} | javascript | function compile(code, closure) {
code = providePlugins(isolateScope(code, closure)).join('\n');
try {
return vm.runInThisContext('(' + code + ')').apply({}, values(plugins));
} catch (err) {
throw new Meteor.Error(400, err);
}
} | [
"function",
"compile",
"(",
"code",
",",
"closure",
")",
"{",
"code",
"=",
"providePlugins",
"(",
"isolateScope",
"(",
"code",
",",
"closure",
")",
")",
".",
"join",
"(",
"'\\n'",
")",
";",
"try",
"{",
"return",
"vm",
".",
"runInThisContext",
"(",
"'('... | Creates a function from the provided source code and closure object.
@param {(string|string[])} code
@param {Object} closure
@returns {string[]} | [
"Creates",
"a",
"function",
"from",
"the",
"provided",
"source",
"code",
"and",
"closure",
"object",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/meteor/backdoor.js#L254-L261 | train |
anticoders/gagarin | lib/mocha/gagarin.js | Gagarin | function Gagarin (options) {
"use strict";
var write = process.stdout.write.bind(process.stdout);
var listOfFrameworks = [];
var numberOfLinesPrinted = 0;
// XXX gagarin user interface is defined here
require('./interface');
options.settings = tools.getSettings(options.settings);
options.ui = '... | javascript | function Gagarin (options) {
"use strict";
var write = process.stdout.write.bind(process.stdout);
var listOfFrameworks = [];
var numberOfLinesPrinted = 0;
// XXX gagarin user interface is defined here
require('./interface');
options.settings = tools.getSettings(options.settings);
options.ui = '... | [
"function",
"Gagarin",
"(",
"options",
")",
"{",
"\"use strict\"",
";",
"var",
"write",
"=",
"process",
".",
"stdout",
".",
"write",
".",
"bind",
"(",
"process",
".",
"stdout",
")",
";",
"var",
"listOfFrameworks",
"=",
"[",
"]",
";",
"var",
"numberOfLine... | Creates Gagarin with `options`.
It inherits everything from Mocha except that the ui
is always set to "gagarin".
@param {Object} options | [
"Creates",
"Gagarin",
"with",
"options",
"."
] | 4f06bbff4221d8e75b73026b638b003f11821fa5 | https://github.com/anticoders/gagarin/blob/4f06bbff4221d8e75b73026b638b003f11821fa5/lib/mocha/gagarin.js#L33-L151 | train |
ciena-blueplanet/ember-test-utils | cli/lint-docker.js | getConfigFilePath | function getConfigFilePath () {
// Look for configuration file in current working directory
const files = fs.readdirSync(process.cwd())
const configFile = files.find((filePath) => {
return CONFIG_FILE_NAMES.find((configFileName) => filePath.indexOf(configFileName) !== -1)
})
// If no configuration file w... | javascript | function getConfigFilePath () {
// Look for configuration file in current working directory
const files = fs.readdirSync(process.cwd())
const configFile = files.find((filePath) => {
return CONFIG_FILE_NAMES.find((configFileName) => filePath.indexOf(configFileName) !== -1)
})
// If no configuration file w... | [
"function",
"getConfigFilePath",
"(",
")",
"{",
"// Look for configuration file in current working directory",
"const",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"process",
".",
"cwd",
"(",
")",
")",
"const",
"configFile",
"=",
"files",
".",
"find",
"(",
"(",
... | Get configuration options for dockerfile_lint
@returns {DockerfileLintConfig} dockerfile lint configuration options | [
"Get",
"configuration",
"options",
"for",
"dockerfile_lint"
] | 7e40f35d53c488b5f12968212110bb5a5ec138ea | https://github.com/ciena-blueplanet/ember-test-utils/blob/7e40f35d53c488b5f12968212110bb5a5ec138ea/cli/lint-docker.js#L32-L46 | train |
ciena-blueplanet/ember-test-utils | cli/lint-docker.js | lintFile | function lintFile (linter, fileName) {
const fileContents = fs.readFileSync(fileName, {encoding: 'utf8'}).toString()
const report = linter.validate(fileContents)
const errors = report.error.count
const warnings = report.warn.count
if (errors || warnings) {
this.printFilePath(fileName)
report.error.d... | javascript | function lintFile (linter, fileName) {
const fileContents = fs.readFileSync(fileName, {encoding: 'utf8'}).toString()
const report = linter.validate(fileContents)
const errors = report.error.count
const warnings = report.warn.count
if (errors || warnings) {
this.printFilePath(fileName)
report.error.d... | [
"function",
"lintFile",
"(",
"linter",
",",
"fileName",
")",
"{",
"const",
"fileContents",
"=",
"fs",
".",
"readFileSync",
"(",
"fileName",
",",
"{",
"encoding",
":",
"'utf8'",
"}",
")",
".",
"toString",
"(",
")",
"const",
"report",
"=",
"linter",
".",
... | Lint a single Dockerfile
@param {Object} linter - linter
@param {String} fileName - name of file to lint
@returns {Object} lint result | [
"Lint",
"a",
"single",
"Dockerfile"
] | 7e40f35d53c488b5f12968212110bb5a5ec138ea | https://github.com/ciena-blueplanet/ember-test-utils/blob/7e40f35d53c488b5f12968212110bb5a5ec138ea/cli/lint-docker.js#L71-L87 | train |
Testlio/lambda-tools | lib/helpers/newlines.js | processByte | function processByte (stream, b) {
assert.equal(typeof b, 'number');
if (b === NEWLINE) {
stream.emit('newline');
}
} | javascript | function processByte (stream, b) {
assert.equal(typeof b, 'number');
if (b === NEWLINE) {
stream.emit('newline');
}
} | [
"function",
"processByte",
"(",
"stream",
",",
"b",
")",
"{",
"assert",
".",
"equal",
"(",
"typeof",
"b",
",",
"'number'",
")",
";",
"if",
"(",
"b",
"===",
"NEWLINE",
")",
"{",
"stream",
".",
"emit",
"(",
"'newline'",
")",
";",
"}",
"}"
] | Processes an individual byte being written to a stream | [
"Processes",
"an",
"individual",
"byte",
"being",
"written",
"to",
"a",
"stream"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/helpers/newlines.js#L34-L39 | train |
Testlio/lambda-tools | lib/helpers/logger.js | log | function log(fn, args, indent) {
if (args.length === 0) {
return;
}
// Assumes args are something you would pass into console.log
// Applies appropriate nesting
const indentation = _.repeat('\t', indent);
// Prepend tabs to first arg (if string)
if (_.isString(args[0])) {
a... | javascript | function log(fn, args, indent) {
if (args.length === 0) {
return;
}
// Assumes args are something you would pass into console.log
// Applies appropriate nesting
const indentation = _.repeat('\t', indent);
// Prepend tabs to first arg (if string)
if (_.isString(args[0])) {
a... | [
"function",
"log",
"(",
"fn",
",",
"args",
",",
"indent",
")",
"{",
"if",
"(",
"args",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"// Assumes args are something you would pass into console.log",
"// Applies appropriate nesting",
"const",
"indentation",... | Internal helper for logging stuff out | [
"Internal",
"helper",
"for",
"logging",
"stuff",
"out"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/helpers/logger.js#L15-L32 | train |
Testlio/lambda-tools | lib/cf-resources/lambda-version-resource/index.js | getFunction | function getFunction(name) {
return new Promise((resolve, reject) => {
lambda.getFunctionConfiguration({
FunctionName: name
}, function(err, data) {
if (err) return reject(err);
resolve(data);
});
});
} | javascript | function getFunction(name) {
return new Promise((resolve, reject) => {
lambda.getFunctionConfiguration({
FunctionName: name
}, function(err, data) {
if (err) return reject(err);
resolve(data);
});
});
} | [
"function",
"getFunction",
"(",
"name",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"lambda",
".",
"getFunctionConfiguration",
"(",
"{",
"FunctionName",
":",
"name",
"}",
",",
"function",
"(",
"err",
",",
"da... | Get function configuration by its name
@return {Promise} which resolves into the function configuration | [
"Get",
"function",
"configuration",
"by",
"its",
"name"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/lambda-version-resource/index.js#L21-L30 | train |
Testlio/lambda-tools | lib/cf-resources/lambda-version-resource/index.js | getFunctionVersions | function getFunctionVersions(name, marker) {
// Grab functions
return new Promise((resolve, reject) => {
lambda.listVersionsByFunction({
FunctionName: name,
Marker: marker
}, function(err, data) {
if (err) return reject(err);
// Check if we can gr... | javascript | function getFunctionVersions(name, marker) {
// Grab functions
return new Promise((resolve, reject) => {
lambda.listVersionsByFunction({
FunctionName: name,
Marker: marker
}, function(err, data) {
if (err) return reject(err);
// Check if we can gr... | [
"function",
"getFunctionVersions",
"(",
"name",
",",
"marker",
")",
"{",
"// Grab functions",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"lambda",
".",
"listVersionsByFunction",
"(",
"{",
"FunctionName",
":",
"name",
",",
... | Get all function versions
@return {Promise} which resolves into an array of version configurations | [
"Get",
"all",
"function",
"versions"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/lambda-version-resource/index.js#L37-L56 | train |
Testlio/lambda-tools | lib/cf-resources/lambda-version-resource/index.js | functionPublishVersion | function functionPublishVersion(name, description, hash) {
return new Promise((resolve, reject) => {
lambda.publishVersion({
FunctionName: name,
Description: description,
CodeSha256: hash
}, function(err, data) {
if (err) return reject(err);
... | javascript | function functionPublishVersion(name, description, hash) {
return new Promise((resolve, reject) => {
lambda.publishVersion({
FunctionName: name,
Description: description,
CodeSha256: hash
}, function(err, data) {
if (err) return reject(err);
... | [
"function",
"functionPublishVersion",
"(",
"name",
",",
"description",
",",
"hash",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"lambda",
".",
"publishVersion",
"(",
"{",
"FunctionName",
":",
"name",
",",
"Desc... | Publish a new Lambda function version
@return {Promise} which resolves into the newly published version | [
"Publish",
"a",
"new",
"Lambda",
"function",
"version"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/lambda-version-resource/index.js#L63-L74 | train |
Testlio/lambda-tools | lib/run/execution.js | getDirectoryTree | function getDirectoryTree(dir) {
const items = [];
return new Promise(function(resolve) {
fs.walk(dir)
.on('data', function (item) {
items.push(item.path);
})
.on('end', function () {
resolve(items);
});
});
} | javascript | function getDirectoryTree(dir) {
const items = [];
return new Promise(function(resolve) {
fs.walk(dir)
.on('data', function (item) {
items.push(item.path);
})
.on('end', function () {
resolve(items);
});
});
} | [
"function",
"getDirectoryTree",
"(",
"dir",
")",
"{",
"const",
"items",
"=",
"[",
"]",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"fs",
".",
"walk",
"(",
"dir",
")",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"... | Helper function for capturing the state of a directory | [
"Helper",
"function",
"for",
"capturing",
"the",
"state",
"of",
"a",
"directory"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/run/execution.js#L14-L25 | train |
Testlio/lambda-tools | lib/cf-resources/api-gateway-resource/index.js | replaceVariables | function replaceVariables(localPath, variables) {
return new Promise(function(resolve, reject) {
// Read the file
let body = fs.readFileSync(localPath, 'utf8');
// Do the replacement for all of the variables
const keys = Object.keys(variables);
keys.forEach(function(key) {
... | javascript | function replaceVariables(localPath, variables) {
return new Promise(function(resolve, reject) {
// Read the file
let body = fs.readFileSync(localPath, 'utf8');
// Do the replacement for all of the variables
const keys = Object.keys(variables);
keys.forEach(function(key) {
... | [
"function",
"replaceVariables",
"(",
"localPath",
",",
"variables",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// Read the file",
"let",
"body",
"=",
"fs",
".",
"readFileSync",
"(",
"localPath",
",",
"'ut... | Helper function for replacing variables in the API definition
@returns {Promise} which resolves into the same localPath the file was
written back to | [
"Helper",
"function",
"for",
"replacing",
"variables",
"in",
"the",
"API",
"definition"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/api-gateway-resource/index.js#L22-L49 | train |
Testlio/lambda-tools | lib/cf-resources/api-gateway-resource/apig-utility.js | function(apiId) {
return APIG.getStages({
restApiId: apiId
}).promise().then(function(data) {
return data.item;
});
} | javascript | function(apiId) {
return APIG.getStages({
restApiId: apiId
}).promise().then(function(data) {
return data.item;
});
} | [
"function",
"(",
"apiId",
")",
"{",
"return",
"APIG",
".",
"getStages",
"(",
"{",
"restApiId",
":",
"apiId",
"}",
")",
".",
"promise",
"(",
")",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"return",
"data",
".",
"item",
";",
"}",
")",
";... | Fetch existing stages for a specific API
@return {Promise} which resolves to all stages for the specific API | [
"Fetch",
"existing",
"stages",
"for",
"a",
"specific",
"API"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/api-gateway-resource/apig-utility.js#L51-L57 | train | |
Testlio/lambda-tools | lib/cf-resources/api-gateway-resource/apig-utility.js | function(apiId, stageName) {
return new Promise(function(resolve, reject) {
APIG.deleteStage({
restApiId: apiId,
stageName: stageName
}, function(err) {
if (err) {
// If no such stage, then success
if... | javascript | function(apiId, stageName) {
return new Promise(function(resolve, reject) {
APIG.deleteStage({
restApiId: apiId,
stageName: stageName
}, function(err) {
if (err) {
// If no such stage, then success
if... | [
"function",
"(",
"apiId",
",",
"stageName",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"APIG",
".",
"deleteStage",
"(",
"{",
"restApiId",
":",
"apiId",
",",
"stageName",
":",
"stageName",
"}",
",",
"... | Delete a specific stage on a specific API
@return {Promise} which resolves to the API ID that the stage was deleted on | [
"Delete",
"a",
"specific",
"stage",
"on",
"a",
"specific",
"API"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/api-gateway-resource/apig-utility.js#L71-L89 | train | |
Testlio/lambda-tools | lib/cf-resources/api-gateway-resource/apig-utility.js | function(apiId) {
return new Promise(function(resolve, reject) {
APIG.deleteRestApi({
restApiId: apiId
}, function(err) {
if (err) {
if (err.code === 404 || err.code === 'NotFoundException') {
// API didn't exist... | javascript | function(apiId) {
return new Promise(function(resolve, reject) {
APIG.deleteRestApi({
restApiId: apiId
}, function(err) {
if (err) {
if (err.code === 404 || err.code === 'NotFoundException') {
// API didn't exist... | [
"function",
"(",
"apiId",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"APIG",
".",
"deleteRestApi",
"(",
"{",
"restApiId",
":",
"apiId",
"}",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",... | Delete the entire API ID
@return {Promise} which resolves to the ID of the API that was deleted | [
"Delete",
"the",
"entire",
"API",
"ID"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/api-gateway-resource/apig-utility.js#L96-L113 | train | |
Testlio/lambda-tools | lib/cf-resources/api-gateway-resource/apig-utility.js | function(apiId) {
return module.exports.fetchExistingStages(apiId).then(function(stages) {
// If there are no stages, then delete the API
if (!stages || stages.length === 0) {
return module.exports.deleteAPI(apiId);
}
return apiId;
});
... | javascript | function(apiId) {
return module.exports.fetchExistingStages(apiId).then(function(stages) {
// If there are no stages, then delete the API
if (!stages || stages.length === 0) {
return module.exports.deleteAPI(apiId);
}
return apiId;
});
... | [
"function",
"(",
"apiId",
")",
"{",
"return",
"module",
".",
"exports",
".",
"fetchExistingStages",
"(",
"apiId",
")",
".",
"then",
"(",
"function",
"(",
"stages",
")",
"{",
"// If there are no stages, then delete the API",
"if",
"(",
"!",
"stages",
"||",
"sta... | Delete the API if and only if there are no more stages deployed on it
@return {Promise} which resolves to the ID of the API that was deleted | [
"Delete",
"the",
"API",
"if",
"and",
"only",
"if",
"there",
"are",
"no",
"more",
"stages",
"deployed",
"on",
"it"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/api-gateway-resource/apig-utility.js#L120-L129 | train | |
Testlio/lambda-tools | lib/cf-resources/api-gateway-resource/apig-utility.js | function(apiName, swaggerPath) {
return new Promise(function(resolve, reject) {
fs.readFile(swaggerPath, function(err, data) {
if (err) return reject(err);
resolve(APIG.importRestApi({
body: data,
failOnWarnings... | javascript | function(apiName, swaggerPath) {
return new Promise(function(resolve, reject) {
fs.readFile(swaggerPath, function(err, data) {
if (err) return reject(err);
resolve(APIG.importRestApi({
body: data,
failOnWarnings... | [
"function",
"(",
"apiName",
",",
"swaggerPath",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"fs",
".",
"readFile",
"(",
"swaggerPath",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
... | Create a new API instance from a Swagger file
@return {Promise} which resolves to the newly created API instance | [
"Create",
"a",
"new",
"API",
"instance",
"from",
"a",
"Swagger",
"file"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/api-gateway-resource/apig-utility.js#L161-L172 | train | |
Testlio/lambda-tools | lib/cf-resources/api-gateway-resource/apig-utility.js | function(apiId, swaggerPath) {
return new Promise(function(resolve, reject) {
fs.readFile(swaggerPath, function(err, data) {
if (err) return reject(err);
resolve(APIG.putRestApi({
restApiId: apiId,
body: data,
... | javascript | function(apiId, swaggerPath) {
return new Promise(function(resolve, reject) {
fs.readFile(swaggerPath, function(err, data) {
if (err) return reject(err);
resolve(APIG.putRestApi({
restApiId: apiId,
body: data,
... | [
"function",
"(",
"apiId",
",",
"swaggerPath",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"fs",
".",
"readFile",
"(",
"swaggerPath",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"e... | Update an API with a specification from a Swagger file
The update is done in the "overwrite" mode of API Gateway
@return {Promise} which resolves to the updated API | [
"Update",
"an",
"API",
"with",
"a",
"specification",
"from",
"a",
"Swagger",
"file",
"The",
"update",
"is",
"done",
"in",
"the",
"overwrite",
"mode",
"of",
"API",
"Gateway"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/api-gateway-resource/apig-utility.js#L180-L192 | train | |
Testlio/lambda-tools | lib/deploy/bundle-lambdas-step.js | archiveDependencies | function archiveDependencies(cwd, pkg) {
let result = [];
if (pkg.path) {
result.push({
data: pkg.path,
type: 'directory',
name: path.relative(cwd, pkg.path)
});
}
pkg.dependencies.forEach(function(dep) {
if (dep.path) {
result.pu... | javascript | function archiveDependencies(cwd, pkg) {
let result = [];
if (pkg.path) {
result.push({
data: pkg.path,
type: 'directory',
name: path.relative(cwd, pkg.path)
});
}
pkg.dependencies.forEach(function(dep) {
if (dep.path) {
result.pu... | [
"function",
"archiveDependencies",
"(",
"cwd",
",",
"pkg",
")",
"{",
"let",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"pkg",
".",
"path",
")",
"{",
"result",
".",
"push",
"(",
"{",
"data",
":",
"pkg",
".",
"path",
",",
"type",
":",
"'directory'",
... | Helper for recursively adding all dependencies to an archive | [
"Helper",
"for",
"recursively",
"adding",
"all",
"dependencies",
"to",
"an",
"archive"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/deploy/bundle-lambdas-step.js#L26-L52 | train |
Testlio/lambda-tools | lib/deploy/bundle-lambdas-step.js | bundleLambda | function bundleLambda(lambda, exclude, environment, bundlePath, sourceMapPath) {
environment = environment || {};
exclude = exclude || [];
return new Promise(function(resolve, reject) {
const bundler = new Browserify(lambda.path, {
basedir: path.dirname(lambda.path),
standal... | javascript | function bundleLambda(lambda, exclude, environment, bundlePath, sourceMapPath) {
environment = environment || {};
exclude = exclude || [];
return new Promise(function(resolve, reject) {
const bundler = new Browserify(lambda.path, {
basedir: path.dirname(lambda.path),
standal... | [
"function",
"bundleLambda",
"(",
"lambda",
",",
"exclude",
",",
"environment",
",",
"bundlePath",
",",
"sourceMapPath",
")",
"{",
"environment",
"=",
"environment",
"||",
"{",
"}",
";",
"exclude",
"=",
"exclude",
"||",
"[",
"]",
";",
"return",
"new",
"Prom... | Processing pipeline, all functions should return a promise
Bundles the lambda code, returning the bundled code
@param lambda Lambda function to bundle, should at minimum have a path property
with the entry point
@param exclude Array of packages to exclude from the bundle, defaults to aws-sdk
@param environment Env v... | [
"Processing",
"pipeline",
"all",
"functions",
"should",
"return",
"a",
"promise",
"Bundles",
"the",
"lambda",
"code",
"returning",
"the",
"bundled",
"code"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/deploy/bundle-lambdas-step.js#L70-L118 | train |
Testlio/lambda-tools | lib/cf-resources/api-gateway-resource/s3-utility.js | function(bucket, key, version, localPath) {
return S3.getObject({
Bucket: bucket,
Key: key,
VersionId: version
}).promise().then(function(data) {
return new Promise(function(resolve, reject) {
fs.writeFile(localPath, data.Body, function(err... | javascript | function(bucket, key, version, localPath) {
return S3.getObject({
Bucket: bucket,
Key: key,
VersionId: version
}).promise().then(function(data) {
return new Promise(function(resolve, reject) {
fs.writeFile(localPath, data.Body, function(err... | [
"function",
"(",
"bucket",
",",
"key",
",",
"version",
",",
"localPath",
")",
"{",
"return",
"S3",
".",
"getObject",
"(",
"{",
"Bucket",
":",
"bucket",
",",
"Key",
":",
"key",
",",
"VersionId",
":",
"version",
"}",
")",
".",
"promise",
"(",
")",
".... | Download a file from remote bucket to a local path
@return {Promise} which resolves to the local path the file was saved to | [
"Download",
"a",
"file",
"from",
"remote",
"bucket",
"to",
"a",
"local",
"path"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/api-gateway-resource/s3-utility.js#L16-L29 | train | |
Testlio/lambda-tools | lib/cf-resources/api-gateway-resource/s3-utility.js | function(bucket, key, version) {
return S3.headObject({
Bucket: bucket,
Key: key,
VersionId: version
}).promise();
} | javascript | function(bucket, key, version) {
return S3.headObject({
Bucket: bucket,
Key: key,
VersionId: version
}).promise();
} | [
"function",
"(",
"bucket",
",",
"key",
",",
"version",
")",
"{",
"return",
"S3",
".",
"headObject",
"(",
"{",
"Bucket",
":",
"bucket",
",",
"Key",
":",
"key",
",",
"VersionId",
":",
"version",
"}",
")",
".",
"promise",
"(",
")",
";",
"}"
] | Execute a HEAD operation on a specific key in a bucket. The request
can also contain an optional version for the file
@returns {Promise} which resolves to the response data for the request | [
"Execute",
"a",
"HEAD",
"operation",
"on",
"a",
"specific",
"key",
"in",
"a",
"bucket",
".",
"The",
"request",
"can",
"also",
"contain",
"an",
"optional",
"version",
"for",
"the",
"file"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/cf-resources/api-gateway-resource/s3-utility.js#L37-L43 | train | |
Testlio/lambda-tools | lib/helpers/cf-template-functions.js | cloudFormationDependencies | function cloudFormationDependencies(value) {
if (_.isString(value)) {
return [value];
}
if (!_.isObject(value)) {
return [];
}
const keys = _.keys(value);
if (keys.length !== 1) {
// CF functions always have a single key
return [];
}
const key = keys[0]... | javascript | function cloudFormationDependencies(value) {
if (_.isString(value)) {
return [value];
}
if (!_.isObject(value)) {
return [];
}
const keys = _.keys(value);
if (keys.length !== 1) {
// CF functions always have a single key
return [];
}
const key = keys[0]... | [
"function",
"cloudFormationDependencies",
"(",
"value",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"value",
")",
")",
"{",
"return",
"[",
"value",
"]",
";",
"}",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"value",
")",
")",
"{",
"return",
"[",... | Helper function for deriving the list of resources that are referenced
by a CF function
@param value, CF value, may be a string, or an object
@returns {array} array of strings, containing all resource names that are used
by the value (that the value depends on) | [
"Helper",
"function",
"for",
"deriving",
"the",
"list",
"of",
"resources",
"that",
"are",
"referenced",
"by",
"a",
"CF",
"function"
] | b9ae92917cfea511da5528c738985777ed87c1d3 | https://github.com/Testlio/lambda-tools/blob/b9ae92917cfea511da5528c738985777ed87c1d3/lib/helpers/cf-template-functions.js#L13-L55 | train |
dashersw/erste | src/lib/base/eventemitter3.js | EE | function EE(fn, context, once) {
this.fn = fn;
this.context = context;
this.once = once || false;
} | javascript | function EE(fn, context, once) {
this.fn = fn;
this.context = context;
this.once = once || false;
} | [
"function",
"EE",
"(",
"fn",
",",
"context",
",",
"once",
")",
"{",
"this",
".",
"fn",
"=",
"fn",
";",
"this",
".",
"context",
"=",
"context",
";",
"this",
".",
"once",
"=",
"once",
"||",
"false",
";",
"}"
] | Representation of a single event listener.
@param {Function} fn The listener function.
@param {*} context The context to invoke the listener with.
@param {boolean} [once=false] Specify if the listener is a one-time listener.
@constructor
@private | [
"Representation",
"of",
"a",
"single",
"event",
"listener",
"."
] | f916bfdf87bdf6f939184d205c049bbd54a6574f | https://github.com/dashersw/erste/blob/f916bfdf87bdf6f939184d205c049bbd54a6574f/src/lib/base/eventemitter3.js#L76-L80 | train |
dashersw/erste | src/lib/base/eventemitter3.js | addListener | function addListener(emitter, event, fn, context, once) {
if (typeof fn !== 'function') {
throw new TypeError('The listener must be a function');
}
var listener = new EE(fn, context || emitter, once)
, evt = prefix ? prefix + event : event;
if (!emitter._events[evt]) emitter._events[evt] = listener, e... | javascript | function addListener(emitter, event, fn, context, once) {
if (typeof fn !== 'function') {
throw new TypeError('The listener must be a function');
}
var listener = new EE(fn, context || emitter, once)
, evt = prefix ? prefix + event : event;
if (!emitter._events[evt]) emitter._events[evt] = listener, e... | [
"function",
"addListener",
"(",
"emitter",
",",
"event",
",",
"fn",
",",
"context",
",",
"once",
")",
"{",
"if",
"(",
"typeof",
"fn",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'The listener must be a function'",
")",
";",
"}",
"var"... | Add a listener for a given event.
@param {EventEmitter} emitter Reference to the `EventEmitter` instance.
@param {(string|Symbol)} event The event name.
@param {Function} fn The listener function.
@param {*} context The context to invoke the listener with.
@param {boolean} once Specify if the listener is a one-time li... | [
"Add",
"a",
"listener",
"for",
"a",
"given",
"event",
"."
] | f916bfdf87bdf6f939184d205c049bbd54a6574f | https://github.com/dashersw/erste/blob/f916bfdf87bdf6f939184d205c049bbd54a6574f/src/lib/base/eventemitter3.js#L93-L106 | train |
dashersw/erste | src/lib/base/eventemitter3.js | clearEvent | function clearEvent(emitter, evt) {
if (--emitter._eventsCount === 0) emitter._events = new Events();
else delete emitter._events[evt];
} | javascript | function clearEvent(emitter, evt) {
if (--emitter._eventsCount === 0) emitter._events = new Events();
else delete emitter._events[evt];
} | [
"function",
"clearEvent",
"(",
"emitter",
",",
"evt",
")",
"{",
"if",
"(",
"--",
"emitter",
".",
"_eventsCount",
"===",
"0",
")",
"emitter",
".",
"_events",
"=",
"new",
"Events",
"(",
")",
";",
"else",
"delete",
"emitter",
".",
"_events",
"[",
"evt",
... | Clear event by name.
@param {EventEmitter} emitter Reference to the `EventEmitter` instance.
@param {(string|Symbol|number)} evt The Event name.
@private | [
"Clear",
"event",
"by",
"name",
"."
] | f916bfdf87bdf6f939184d205c049bbd54a6574f | https://github.com/dashersw/erste/blob/f916bfdf87bdf6f939184d205c049bbd54a6574f/src/lib/base/eventemitter3.js#L115-L118 | train |
meeroslav/gulp-inject-partials | src/index.js | handleStream | function handleStream(target, encoding, cb) {
if (target.isNull()) {
return cb(null, target);
}
if (target.isStream()) {
return cb(error(target.path + ': Streams not supported for target templates!'));
}
try {
const tagsRegExp = getRegExpTags(opt, null);
target.contents = processContent(target, ... | javascript | function handleStream(target, encoding, cb) {
if (target.isNull()) {
return cb(null, target);
}
if (target.isStream()) {
return cb(error(target.path + ': Streams not supported for target templates!'));
}
try {
const tagsRegExp = getRegExpTags(opt, null);
target.contents = processContent(target, ... | [
"function",
"handleStream",
"(",
"target",
",",
"encoding",
",",
"cb",
")",
"{",
"if",
"(",
"target",
".",
"isNull",
"(",
")",
")",
"{",
"return",
"cb",
"(",
"null",
",",
"target",
")",
";",
"}",
"if",
"(",
"target",
".",
"isStream",
"(",
")",
")... | Handle injection of files
@param target
@param encoding
@param cb
@returns {*} | [
"Handle",
"injection",
"of",
"files"
] | 6a7fee734decb03f2537ee54897162da7bc0a634 | https://github.com/meeroslav/gulp-inject-partials/blob/6a7fee734decb03f2537ee54897162da7bc0a634/src/index.js#L40-L58 | train |
meeroslav/gulp-inject-partials | src/index.js | processContent | function processContent(target, opt, tagsRegExp, listOfFiles) {
let targetContent = String(target.contents);
const targetPath = target.path;
const files = extractFilePaths(targetContent, targetPath, opt, tagsRegExp);
// recursively process files
files.forEach(function (fileData) {
if (listOfFiles.indexOf(fileDa... | javascript | function processContent(target, opt, tagsRegExp, listOfFiles) {
let targetContent = String(target.contents);
const targetPath = target.path;
const files = extractFilePaths(targetContent, targetPath, opt, tagsRegExp);
// recursively process files
files.forEach(function (fileData) {
if (listOfFiles.indexOf(fileDa... | [
"function",
"processContent",
"(",
"target",
",",
"opt",
",",
"tagsRegExp",
",",
"listOfFiles",
")",
"{",
"let",
"targetContent",
"=",
"String",
"(",
"target",
".",
"contents",
")",
";",
"const",
"targetPath",
"=",
"target",
".",
"path",
";",
"const",
"fil... | Parse content and create new template
with all injections made
@param {Object} target
@param {Object} opt
@param {Object} tagsRegExp
@param {Array} listOfFiles
@returns {Buffer} | [
"Parse",
"content",
"and",
"create",
"new",
"template",
"with",
"all",
"injections",
"made"
] | 6a7fee734decb03f2537ee54897162da7bc0a634 | https://github.com/meeroslav/gulp-inject-partials/blob/6a7fee734decb03f2537ee54897162da7bc0a634/src/index.js#L73-L97 | train |
meeroslav/gulp-inject-partials | src/index.js | inject | function inject(targetContent, sourceContent, opt, tagsRegExp) {
const startTag = tagsRegExp.start;
const endTag = tagsRegExp.end;
let startMatch;
let endMatch;
while ((startMatch = startTag.exec(targetContent)) !== null) {
// Take care of content length change
endTag.lastIndex = startTag.lastIndex;
endMatc... | javascript | function inject(targetContent, sourceContent, opt, tagsRegExp) {
const startTag = tagsRegExp.start;
const endTag = tagsRegExp.end;
let startMatch;
let endMatch;
while ((startMatch = startTag.exec(targetContent)) !== null) {
// Take care of content length change
endTag.lastIndex = startTag.lastIndex;
endMatc... | [
"function",
"inject",
"(",
"targetContent",
",",
"sourceContent",
",",
"opt",
",",
"tagsRegExp",
")",
"{",
"const",
"startTag",
"=",
"tagsRegExp",
".",
"start",
";",
"const",
"endTag",
"=",
"tagsRegExp",
".",
"end",
";",
"let",
"startMatch",
";",
"let",
"e... | Inject tags into target content between given
start and end tags
@param {String} targetContent
@param {String} sourceContent
@param {Object} opt
@param {Object} tagsRegExp
@returns {String} | [
"Inject",
"tags",
"into",
"target",
"content",
"between",
"given",
"start",
"and",
"end",
"tags"
] | 6a7fee734decb03f2537ee54897162da7bc0a634 | https://github.com/meeroslav/gulp-inject-partials/blob/6a7fee734decb03f2537ee54897162da7bc0a634/src/index.js#L109-L146 | train |
meeroslav/gulp-inject-partials | src/index.js | extractFilePaths | function extractFilePaths(content, targetPath, opt, tagsRegExp) {
const files = [];
const tagMatches = content.match(tagsRegExp.start);
if (tagMatches) {
tagMatches.forEach(function (tagMatch) {
const fileUrl = tagsRegExp.startex.exec(tagMatch)[1];
const filePath = setFullPath(targetPath, opt.prefix + fileU... | javascript | function extractFilePaths(content, targetPath, opt, tagsRegExp) {
const files = [];
const tagMatches = content.match(tagsRegExp.start);
if (tagMatches) {
tagMatches.forEach(function (tagMatch) {
const fileUrl = tagsRegExp.startex.exec(tagMatch)[1];
const filePath = setFullPath(targetPath, opt.prefix + fileU... | [
"function",
"extractFilePaths",
"(",
"content",
",",
"targetPath",
",",
"opt",
",",
"tagsRegExp",
")",
"{",
"const",
"files",
"=",
"[",
"]",
";",
"const",
"tagMatches",
"=",
"content",
".",
"match",
"(",
"tagsRegExp",
".",
"start",
")",
";",
"if",
"(",
... | Parse content and get all partials to be injected
@param {String} content
@param {String} targetPath
@param {Object} opt
@param {Object} tagsRegExp
@returns {Array} | [
"Parse",
"content",
"and",
"get",
"all",
"partials",
"to",
"be",
"injected"
] | 6a7fee734decb03f2537ee54897162da7bc0a634 | https://github.com/meeroslav/gulp-inject-partials/blob/6a7fee734decb03f2537ee54897162da7bc0a634/src/index.js#L183-L214 | train |
weepy/kaffeine | lib/token.js | function(child, parent) {
var ctor = function(){ };
ctor.prototype = parent.prototype;
child.__super__ = parent.prototype;
child.prototype = new ctor();
child.prototype.constructor = child;
child.fn = child.prototype
} | javascript | function(child, parent) {
var ctor = function(){ };
ctor.prototype = parent.prototype;
child.__super__ = parent.prototype;
child.prototype = new ctor();
child.prototype.constructor = child;
child.fn = child.prototype
} | [
"function",
"(",
"child",
",",
"parent",
")",
"{",
"var",
"ctor",
"=",
"function",
"(",
")",
"{",
"}",
";",
"ctor",
".",
"prototype",
"=",
"parent",
".",
"prototype",
";",
"child",
".",
"__super__",
"=",
"parent",
".",
"prototype",
";",
"child",
".",... | var log = console.log | [
"var",
"log",
"=",
"console",
".",
"log"
] | 231333e6563501235bc10b24e7efcafd2e2d9b91 | https://github.com/weepy/kaffeine/blob/231333e6563501235bc10b24e7efcafd2e2d9b91/lib/token.js#L3-L10 | train | |
sparkartgroup/gulp-markdown-to-json | lib/plugin.js | consolidateFiles | function consolidateFiles (files, config) {
return Promise.resolve(files)
.then(files => {
var data = {};
files.forEach(file => {
var path = file.relative.split('.').shift().split(Path.sep);
if (path.length >= 2 && config.flattenIndex) {
var relPath = path.splice(-2, 2);
... | javascript | function consolidateFiles (files, config) {
return Promise.resolve(files)
.then(files => {
var data = {};
files.forEach(file => {
var path = file.relative.split('.').shift().split(Path.sep);
if (path.length >= 2 && config.flattenIndex) {
var relPath = path.splice(-2, 2);
... | [
"function",
"consolidateFiles",
"(",
"files",
",",
"config",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"files",
")",
".",
"then",
"(",
"files",
"=>",
"{",
"var",
"data",
"=",
"{",
"}",
";",
"files",
".",
"forEach",
"(",
"file",
"=>",
"{",
... | Consolidates JSON output into a nested and sorted object whose hierarchy matches the input directory structure
@param {Array} files - JSON output as Vinyl file objects
@returns {Promise.<Vinyl>} | [
"Consolidates",
"JSON",
"output",
"into",
"a",
"nested",
"and",
"sorted",
"object",
"whose",
"hierarchy",
"matches",
"the",
"input",
"directory",
"structure"
] | ef32234bec31171bb11f16a38d985d88f78640bc | https://github.com/sparkartgroup/gulp-markdown-to-json/blob/ef32234bec31171bb11f16a38d985d88f78640bc/lib/plugin.js#L85-L115 | train |
sparkartgroup/gulp-markdown-to-json | lib/plugin.js | isBinary | function isBinary (file) {
return new Promise((resolve, reject) => {
isTextOrBinary.isText(Path.basename(file.path), file.contents, (err, isText) => {
if (err) return reject(err);
if (isText) file.isText = true;
resolve(file);
});
});
} | javascript | function isBinary (file) {
return new Promise((resolve, reject) => {
isTextOrBinary.isText(Path.basename(file.path), file.contents, (err, isText) => {
if (err) return reject(err);
if (isText) file.isText = true;
resolve(file);
});
});
} | [
"function",
"isBinary",
"(",
"file",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"isTextOrBinary",
".",
"isText",
"(",
"Path",
".",
"basename",
"(",
"file",
".",
"path",
")",
",",
"file",
".",
"contents",
... | Tests if file content is ASCII
@param {Vinyl} file - Vinyl file object
@returns {Promise.<boolean>}
@private | [
"Tests",
"if",
"file",
"content",
"is",
"ASCII"
] | ef32234bec31171bb11f16a38d985d88f78640bc | https://github.com/sparkartgroup/gulp-markdown-to-json/blob/ef32234bec31171bb11f16a38d985d88f78640bc/lib/plugin.js#L146-L154 | train |
sparkartgroup/gulp-markdown-to-json | lib/plugin.js | isJSON | function isJSON (file) {
try {
JSON.parse(file.contents.toString());
return true;
} catch (err) {
return false;
}
} | javascript | function isJSON (file) {
try {
JSON.parse(file.contents.toString());
return true;
} catch (err) {
return false;
}
} | [
"function",
"isJSON",
"(",
"file",
")",
"{",
"try",
"{",
"JSON",
".",
"parse",
"(",
"file",
".",
"contents",
".",
"toString",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Tests if file content is valid JSON
@param {object} Vinyl file
@returns {boolean}
@private | [
"Tests",
"if",
"file",
"content",
"is",
"valid",
"JSON"
] | ef32234bec31171bb11f16a38d985d88f78640bc | https://github.com/sparkartgroup/gulp-markdown-to-json/blob/ef32234bec31171bb11f16a38d985d88f78640bc/lib/plugin.js#L163-L170 | train |
sparkartgroup/gulp-markdown-to-json | lib/plugin.js | toJSON | function toJSON (file, config) {
if (Path.extname(file.path) === '.json') {
if (!isJSON(file)) file.isInvalid = true;
return Promise.resolve(file);
}
let jsonFile = file.clone();
return Promise.resolve(file)
// parse YAML
.then(file => {
try {
let parsed = frontmatter(file.conten... | javascript | function toJSON (file, config) {
if (Path.extname(file.path) === '.json') {
if (!isJSON(file)) file.isInvalid = true;
return Promise.resolve(file);
}
let jsonFile = file.clone();
return Promise.resolve(file)
// parse YAML
.then(file => {
try {
let parsed = frontmatter(file.conten... | [
"function",
"toJSON",
"(",
"file",
",",
"config",
")",
"{",
"if",
"(",
"Path",
".",
"extname",
"(",
"file",
".",
"path",
")",
"===",
"'.json'",
")",
"{",
"if",
"(",
"!",
"isJSON",
"(",
"file",
")",
")",
"file",
".",
"isInvalid",
"=",
"true",
";",... | Parse text files for YAML and Markdown, render to HTML and wrap in JSON
@param {Vinyl} file - Vinyl file object
@returns {Promise.<Vinyl>}
@private | [
"Parse",
"text",
"files",
"for",
"YAML",
"and",
"Markdown",
"render",
"to",
"HTML",
"and",
"wrap",
"in",
"JSON"
] | ef32234bec31171bb11f16a38d985d88f78640bc | https://github.com/sparkartgroup/gulp-markdown-to-json/blob/ef32234bec31171bb11f16a38d985d88f78640bc/lib/plugin.js#L179-L221 | train |
dashersw/erste | src/lib/base/component-manager.js | decorateEvents | function decorateEvents(comp) {
const prototype = /** @type {!Function} */(comp.constructor).prototype;
if (prototype.__events) return;
let events = {};
if (prototype.events) {
events = prototype.events;
}
Object.getOwnPropertyNames(prototype)
.map(propertyName => handlerMeth... | javascript | function decorateEvents(comp) {
const prototype = /** @type {!Function} */(comp.constructor).prototype;
if (prototype.__events) return;
let events = {};
if (prototype.events) {
events = prototype.events;
}
Object.getOwnPropertyNames(prototype)
.map(propertyName => handlerMeth... | [
"function",
"decorateEvents",
"(",
"comp",
")",
"{",
"const",
"prototype",
"=",
"/** @type {!Function} */",
"(",
"comp",
".",
"constructor",
")",
".",
"prototype",
";",
"if",
"(",
"prototype",
".",
"__events",
")",
"return",
";",
"let",
"events",
"=",
"{",
... | Fills events object of given component class from method names that match event handler pattern.
@param {!Component} comp Component instance to decorate events for. | [
"Fills",
"events",
"object",
"of",
"given",
"component",
"class",
"from",
"method",
"names",
"that",
"match",
"event",
"handler",
"pattern",
"."
] | f916bfdf87bdf6f939184d205c049bbd54a6574f | https://github.com/dashersw/erste/blob/f916bfdf87bdf6f939184d205c049bbd54a6574f/src/lib/base/component-manager.js#L191-L213 | train |
meeroslav/gulp-inject-partials | src/index.spec.js | expectedFile | function expectedFile(file) {
const filePath = path.resolve(__dirname, 'expected', file);
return new File({
path: filePath,
cwd: __dirname,
base: path.resolve(__dirname, 'expected', path.dirname(file)),
contents: fs.readFileSync(filePath)
});
} | javascript | function expectedFile(file) {
const filePath = path.resolve(__dirname, 'expected', file);
return new File({
path: filePath,
cwd: __dirname,
base: path.resolve(__dirname, 'expected', path.dirname(file)),
contents: fs.readFileSync(filePath)
});
} | [
"function",
"expectedFile",
"(",
"file",
")",
"{",
"const",
"filePath",
"=",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"'expected'",
",",
"file",
")",
";",
"return",
"new",
"File",
"(",
"{",
"path",
":",
"filePath",
",",
"cwd",
":",
"__dirname",
"... | get expected file | [
"get",
"expected",
"file"
] | 6a7fee734decb03f2537ee54897162da7bc0a634 | https://github.com/meeroslav/gulp-inject-partials/blob/6a7fee734decb03f2537ee54897162da7bc0a634/src/index.spec.js#L131-L139 | train |
131/xterm2 | lib/terminal.js | encode | function encode(data, ch) {
if (!self.utfMouse) {
if (ch === 255) return data.push(0);
if (ch > 127) ch = 127;
data.push(ch);
} else {
if (ch === 2047) return data.push(0);
if (ch < 127) {
data.push(ch);
} else {
if (ch ... | javascript | function encode(data, ch) {
if (!self.utfMouse) {
if (ch === 255) return data.push(0);
if (ch > 127) ch = 127;
data.push(ch);
} else {
if (ch === 2047) return data.push(0);
if (ch < 127) {
data.push(ch);
} else {
if (ch ... | [
"function",
"encode",
"(",
"data",
",",
"ch",
")",
"{",
"if",
"(",
"!",
"self",
".",
"utfMouse",
")",
"{",
"if",
"(",
"ch",
"===",
"255",
")",
"return",
"data",
".",
"push",
"(",
"0",
")",
";",
"if",
"(",
"ch",
">",
"127",
")",
"ch",
"=",
"... | encode button and position to characters | [
"encode",
"button",
"and",
"position",
"to",
"characters"
] | d0724ac1e637241b37e7bdb6dc3ef64c22976343 | https://github.com/131/xterm2/blob/d0724ac1e637241b37e7bdb6dc3ef64c22976343/lib/terminal.js#L643-L658 | train |
dhershman1/kyanite | src/_internals/_curry2.js | _curry2 | function _curry2 (fn) {
return function f2 (a, b) {
if (!arguments.length) {
return f2
}
if (arguments.length === 1) {
return function (_b) {
return fn(a, _b)
}
}
return fn(a, b)
}
} | javascript | function _curry2 (fn) {
return function f2 (a, b) {
if (!arguments.length) {
return f2
}
if (arguments.length === 1) {
return function (_b) {
return fn(a, _b)
}
}
return fn(a, b)
}
} | [
"function",
"_curry2",
"(",
"fn",
")",
"{",
"return",
"function",
"f2",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"!",
"arguments",
".",
"length",
")",
"{",
"return",
"f2",
"}",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"return"... | This is an optimized internal curry function for 2 param functions
@private
@category Function
@param {Function} fn The function to curry
@return {Function} The curried function | [
"This",
"is",
"an",
"optimized",
"internal",
"curry",
"function",
"for",
"2",
"param",
"functions"
] | 92524aaea522c3094ea339603125b149272926da | https://github.com/dhershman1/kyanite/blob/92524aaea522c3094ea339603125b149272926da/src/_internals/_curry2.js#L8-L22 | train |
dignifiedquire/pull-length-prefixed | src/decode.js | next | function next () {
let doNext = true
let decoded = false
const decodeCb = (err, msg) => {
decoded = true
if (err) {
p.end(err)
doNext = false
} else {
p.push(msg)
if (!doNext) {
next()
}
}
}
whi... | javascript | function next () {
let doNext = true
let decoded = false
const decodeCb = (err, msg) => {
decoded = true
if (err) {
p.end(err)
doNext = false
} else {
p.push(msg)
if (!doNext) {
next()
}
}
}
whi... | [
"function",
"next",
"(",
")",
"{",
"let",
"doNext",
"=",
"true",
"let",
"decoded",
"=",
"false",
"const",
"decodeCb",
"=",
"(",
"err",
",",
"msg",
")",
"=>",
"{",
"decoded",
"=",
"true",
"if",
"(",
"err",
")",
"{",
"p",
".",
"end",
"(",
"err",
... | this function has to be written without recursion or it blows the stack in case of sync stream | [
"this",
"function",
"has",
"to",
"be",
"written",
"without",
"recursion",
"or",
"it",
"blows",
"the",
"stack",
"in",
"case",
"of",
"sync",
"stream"
] | b22fbe1408447a0efbd6aff8d9bd4c42c9ea0366 | https://github.com/dignifiedquire/pull-length-prefixed/blob/b22fbe1408447a0efbd6aff8d9bd4c42c9ea0366/src/decode.js#L26-L50 | train |
dignifiedquire/pull-length-prefixed | src/decode.js | decodeFromReader | function decodeFromReader (reader, opts, cb) {
if (typeof opts === 'function') {
cb = opts
opts = {}
}
_decodeFromReader(reader, opts, function onComplete (err, msg) {
if (err) {
if (err === true) return cb(new Error('Unexpected end of input from reader.'))
return cb(err)
}
cb(nul... | javascript | function decodeFromReader (reader, opts, cb) {
if (typeof opts === 'function') {
cb = opts
opts = {}
}
_decodeFromReader(reader, opts, function onComplete (err, msg) {
if (err) {
if (err === true) return cb(new Error('Unexpected end of input from reader.'))
return cb(err)
}
cb(nul... | [
"function",
"decodeFromReader",
"(",
"reader",
",",
"opts",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"opts",
"===",
"'function'",
")",
"{",
"cb",
"=",
"opts",
"opts",
"=",
"{",
"}",
"}",
"_decodeFromReader",
"(",
"reader",
",",
"opts",
",",
"function"... | wrapper to detect sudden pull-stream disconnects | [
"wrapper",
"to",
"detect",
"sudden",
"pull",
"-",
"stream",
"disconnects"
] | b22fbe1408447a0efbd6aff8d9bd4c42c9ea0366 | https://github.com/dignifiedquire/pull-length-prefixed/blob/b22fbe1408447a0efbd6aff8d9bd4c42c9ea0366/src/decode.js#L59-L72 | train |
131/xterm2 | demo/main.js | function(str){
var ret = new Array(str.length), len = str.length;
while(len--) ret[len] = str.charCodeAt(len);
return Uint8Array.from(ret);
} | javascript | function(str){
var ret = new Array(str.length), len = str.length;
while(len--) ret[len] = str.charCodeAt(len);
return Uint8Array.from(ret);
} | [
"function",
"(",
"str",
")",
"{",
"var",
"ret",
"=",
"new",
"Array",
"(",
"str",
".",
"length",
")",
",",
"len",
"=",
"str",
".",
"length",
";",
"while",
"(",
"len",
"--",
")",
"ret",
"[",
"len",
"]",
"=",
"str",
".",
"charCodeAt",
"(",
"len",
... | we do not need Buffer pollyfill for now | [
"we",
"do",
"not",
"need",
"Buffer",
"pollyfill",
"for",
"now"
] | d0724ac1e637241b37e7bdb6dc3ef64c22976343 | https://github.com/131/xterm2/blob/d0724ac1e637241b37e7bdb6dc3ef64c22976343/demo/main.js#L85-L89 | train | |
gl-vis/gl-axes3d | axes.js | parseOption | function parseOption(nest, cons, name) {
if(name in options) {
var opt = options[name]
var prev = this[name]
var next
if(nest ? (Array.isArray(opt) && Array.isArray(opt[0])) :
Array.isArray(opt) ) {
this[name] = next = [ cons(opt[0]), cons(opt[1]), cons(opt[2]) ]
... | javascript | function parseOption(nest, cons, name) {
if(name in options) {
var opt = options[name]
var prev = this[name]
var next
if(nest ? (Array.isArray(opt) && Array.isArray(opt[0])) :
Array.isArray(opt) ) {
this[name] = next = [ cons(opt[0]), cons(opt[1]), cons(opt[2]) ]
... | [
"function",
"parseOption",
"(",
"nest",
",",
"cons",
",",
"name",
")",
"{",
"if",
"(",
"name",
"in",
"options",
")",
"{",
"var",
"opt",
"=",
"options",
"[",
"name",
"]",
"var",
"prev",
"=",
"this",
"[",
"name",
"]",
"var",
"next",
"if",
"(",
"nes... | Option parsing helper functions | [
"Option",
"parsing",
"helper",
"functions"
] | a7a99d8047183657a4a288dc1c9e7341103b81d9 | https://github.com/gl-vis/gl-axes3d/blob/a7a99d8047183657a4a288dc1c9e7341103b81d9/axes.js#L93-L111 | train |
Pier1/rocketbelt | templates/js/site.js | launchPlayground | function launchPlayground(){
$('.playground-item').playground();
// Eyedropper Helper Functions
$('.cp_eyedropper').on('click', function() {
if ($(this).next('.cp_grid').hasClass('visuallyhidden')) {
$(".cp_grid").addClass('visuallyhidden');
$(this).next(".cp_grid").removeClass('visua... | javascript | function launchPlayground(){
$('.playground-item').playground();
// Eyedropper Helper Functions
$('.cp_eyedropper').on('click', function() {
if ($(this).next('.cp_grid').hasClass('visuallyhidden')) {
$(".cp_grid").addClass('visuallyhidden');
$(this).next(".cp_grid").removeClass('visua... | [
"function",
"launchPlayground",
"(",
")",
"{",
"$",
"(",
"'.playground-item'",
")",
".",
"playground",
"(",
")",
";",
"// Eyedropper Helper Functions",
"$",
"(",
"'.cp_eyedropper'",
")",
".",
"on",
"(",
"'click'",
",",
"function",
"(",
")",
"{",
"if",
"(",
... | Sets up all playground elements and makes the code copy function for dynamic elements | [
"Sets",
"up",
"all",
"playground",
"elements",
"and",
"makes",
"the",
"code",
"copy",
"function",
"for",
"dynamic",
"elements"
] | 73e1243e7fcedb731591dbafcc8ecf480ec4700f | https://github.com/Pier1/rocketbelt/blob/73e1243e7fcedb731591dbafcc8ecf480ec4700f/templates/js/site.js#L86-L129 | train |
gl-vis/gl-axes3d | example/example.js | f | function f(x,y,z) {
return x*x + y*y + z*z - 2.0
} | javascript | function f(x,y,z) {
return x*x + y*y + z*z - 2.0
} | [
"function",
"f",
"(",
"x",
",",
"y",
",",
"z",
")",
"{",
"return",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
"+",
"z",
"*",
"z",
"-",
"2.0",
"}"
] | Plot level set of f = 0 | [
"Plot",
"level",
"set",
"of",
"f",
"=",
"0"
] | a7a99d8047183657a4a288dc1c9e7341103b81d9 | https://github.com/gl-vis/gl-axes3d/blob/a7a99d8047183657a4a288dc1c9e7341103b81d9/example/example.js#L17-L19 | train |
Pier1/rocketbelt | rocketbelt/base/animation/rocketbelt.animate.js | animate | function animate(animationName, configOrCallback) {
return this.each(function eachAnimate() {
return window.rb.animate.animate(this, animationName, configOrCallback);
});
} | javascript | function animate(animationName, configOrCallback) {
return this.each(function eachAnimate() {
return window.rb.animate.animate(this, animationName, configOrCallback);
});
} | [
"function",
"animate",
"(",
"animationName",
",",
"configOrCallback",
")",
"{",
"return",
"this",
".",
"each",
"(",
"function",
"eachAnimate",
"(",
")",
"{",
"return",
"window",
".",
"rb",
".",
"animate",
".",
"animate",
"(",
"this",
",",
"animationName",
... | Add a Rocketbelt animation to a jQuery object.
@param {string} animationName The Rocketbelt animation name.
@param {(object|function)} configOrCallback A configuration object or a callback to run after the animation finishes.
@returns {object} A chainable jQuery object. | [
"Add",
"a",
"Rocketbelt",
"animation",
"to",
"a",
"jQuery",
"object",
"."
] | 73e1243e7fcedb731591dbafcc8ecf480ec4700f | https://github.com/Pier1/rocketbelt/blob/73e1243e7fcedb731591dbafcc8ecf480ec4700f/rocketbelt/base/animation/rocketbelt.animate.js#L145-L149 | train |
saneef/qgen | dist/lib/file-helpers.js | isFileOrDir | function isFileOrDir(filePath) {
let fsStat;
try {
fsStat = fs.statSync(filePath);
} catch (error) {
return error;
}
let r = 'file';
if (fsStat.isDirectory()) {
r = 'directory';
}
return r;
} | javascript | function isFileOrDir(filePath) {
let fsStat;
try {
fsStat = fs.statSync(filePath);
} catch (error) {
return error;
}
let r = 'file';
if (fsStat.isDirectory()) {
r = 'directory';
}
return r;
} | [
"function",
"isFileOrDir",
"(",
"filePath",
")",
"{",
"let",
"fsStat",
";",
"try",
"{",
"fsStat",
"=",
"fs",
".",
"statSync",
"(",
"filePath",
")",
";",
"}",
"catch",
"(",
"error",
")",
"{",
"return",
"error",
";",
"}",
"let",
"r",
"=",
"'file'",
"... | Check if a path points to a file or a directory
@param {String} filePath - Path to a file or directory
@return {String} 'directory' if paths points a directory, 'file' if path points to a file | [
"Check",
"if",
"a",
"path",
"points",
"to",
"a",
"file",
"or",
"a",
"directory"
] | c413d902f4ea79b628b0006fa08e9ae727738831 | https://github.com/saneef/qgen/blob/c413d902f4ea79b628b0006fa08e9ae727738831/dist/lib/file-helpers.js#L12-L26 | train |
dhershman1/kyanite | src/_internals/_curry3.js | _curry3 | function _curry3 (fn) {
return function f3 (a, b, c) {
switch (arguments.length) {
case 0:
return f3
case 1:
return _curry2(function (_b, _c) {
return fn(a, _b, _c)
})
case 2:
return function (_c) {
return fn(a, b, _c)
}
default:
... | javascript | function _curry3 (fn) {
return function f3 (a, b, c) {
switch (arguments.length) {
case 0:
return f3
case 1:
return _curry2(function (_b, _c) {
return fn(a, _b, _c)
})
case 2:
return function (_c) {
return fn(a, b, _c)
}
default:
... | [
"function",
"_curry3",
"(",
"fn",
")",
"{",
"return",
"function",
"f3",
"(",
"a",
",",
"b",
",",
"c",
")",
"{",
"switch",
"(",
"arguments",
".",
"length",
")",
"{",
"case",
"0",
":",
"return",
"f3",
"case",
"1",
":",
"return",
"_curry2",
"(",
"fu... | This is an optimized internal curry function for 3 param functions
@private
@category Function
@param {Function} fn The function to curry
@return {Function} The curried function | [
"This",
"is",
"an",
"optimized",
"internal",
"curry",
"function",
"for",
"3",
"param",
"functions"
] | 92524aaea522c3094ea339603125b149272926da | https://github.com/dhershman1/kyanite/blob/92524aaea522c3094ea339603125b149272926da/src/_internals/_curry3.js#L10-L27 | train |
saneef/qgen | src/qgen.js | qgen | function qgen(options) {
const defaultOptions = {
dest: DEFAULT_DESTINATION,
cwd: process.cwd(),
directory: 'qgen-templates',
config: './qgen.json',
helpers: undefined,
force: false,
preview: false
};
const configfilePath = createConfigFilePath(defaultOptions, options);
const configfileOptions = load... | javascript | function qgen(options) {
const defaultOptions = {
dest: DEFAULT_DESTINATION,
cwd: process.cwd(),
directory: 'qgen-templates',
config: './qgen.json',
helpers: undefined,
force: false,
preview: false
};
const configfilePath = createConfigFilePath(defaultOptions, options);
const configfileOptions = load... | [
"function",
"qgen",
"(",
"options",
")",
"{",
"const",
"defaultOptions",
"=",
"{",
"dest",
":",
"DEFAULT_DESTINATION",
",",
"cwd",
":",
"process",
".",
"cwd",
"(",
")",
",",
"directory",
":",
"'qgen-templates'",
",",
"config",
":",
"'./qgen.json'",
",",
"h... | Creates new qgen object
@param {Object} options - Options such as dest, config file path etc.
@returns {qgen} qgen object | [
"Creates",
"new",
"qgen",
"object"
] | c413d902f4ea79b628b0006fa08e9ae727738831 | https://github.com/saneef/qgen/blob/c413d902f4ea79b628b0006fa08e9ae727738831/src/qgen.js#L71-L157 | train |
Pier1/rocketbelt | rocketbelt/components/dialogs/rocketbelt.dialogs.js | trapTabKey | function trapTabKey(node, event) {
var focusableChildren = getFocusableChildren(node);
var focusedItemIndex = focusableChildren.index($(document.activeElement));
if (event.shiftKey && focusedItemIndex === 0) {
focusableChildren[focusableChildren.length - 1].focus();
event.preventDefault();
... | javascript | function trapTabKey(node, event) {
var focusableChildren = getFocusableChildren(node);
var focusedItemIndex = focusableChildren.index($(document.activeElement));
if (event.shiftKey && focusedItemIndex === 0) {
focusableChildren[focusableChildren.length - 1].focus();
event.preventDefault();
... | [
"function",
"trapTabKey",
"(",
"node",
",",
"event",
")",
"{",
"var",
"focusableChildren",
"=",
"getFocusableChildren",
"(",
"node",
")",
";",
"var",
"focusedItemIndex",
"=",
"focusableChildren",
".",
"index",
"(",
"$",
"(",
"document",
".",
"activeElement",
"... | Helper function trapping the tab key inside a node | [
"Helper",
"function",
"trapping",
"the",
"tab",
"key",
"inside",
"a",
"node"
] | 73e1243e7fcedb731591dbafcc8ecf480ec4700f | https://github.com/Pier1/rocketbelt/blob/73e1243e7fcedb731591dbafcc8ecf480ec4700f/rocketbelt/components/dialogs/rocketbelt.dialogs.js#L149-L160 | train |
jonschlinkert/regex-cache | index.js | regexCache | function regexCache(fn, str, opts) {
var key = '_default_', regex, cached;
if (!str && !opts) {
if (typeof fn !== 'function') {
return fn;
}
return basic[key] || (basic[key] = fn(str));
}
var isString = typeof str === 'string';
if (isString) {
if (!opts) {
return basic[str] || (b... | javascript | function regexCache(fn, str, opts) {
var key = '_default_', regex, cached;
if (!str && !opts) {
if (typeof fn !== 'function') {
return fn;
}
return basic[key] || (basic[key] = fn(str));
}
var isString = typeof str === 'string';
if (isString) {
if (!opts) {
return basic[str] || (b... | [
"function",
"regexCache",
"(",
"fn",
",",
"str",
",",
"opts",
")",
"{",
"var",
"key",
"=",
"'_default_'",
",",
"regex",
",",
"cached",
";",
"if",
"(",
"!",
"str",
"&&",
"!",
"opts",
")",
"{",
"if",
"(",
"typeof",
"fn",
"!==",
"'function'",
")",
"... | Memoize the results of a call to the new RegExp constructor.
@param {Function} fn [description]
@param {String} str [description]
@param {Options} options [description]
@param {Boolean} nocompare [description]
@return {RegExp} | [
"Memoize",
"the",
"results",
"of",
"a",
"call",
"to",
"the",
"new",
"RegExp",
"constructor",
"."
] | 1c001df1e266328fa9e34906660c79169ab9fa4f | https://github.com/jonschlinkert/regex-cache/blob/1c001df1e266328fa9e34906660c79169ab9fa4f/index.js#L30-L57 | train |
y-js/y-webrtc | src/WebRTC.js | function () {
// check if the clients still exists
var peer = self.swr.webrtc.getPeers(uid)[0]
var success
if (peer) {
// success is true, if the message is successfully sent
success = peer.sendDirectly('simplewebrtc', 'yjs', message)
}
if (!success) {... | javascript | function () {
// check if the clients still exists
var peer = self.swr.webrtc.getPeers(uid)[0]
var success
if (peer) {
// success is true, if the message is successfully sent
success = peer.sendDirectly('simplewebrtc', 'yjs', message)
}
if (!success) {... | [
"function",
"(",
")",
"{",
"// check if the clients still exists",
"var",
"peer",
"=",
"self",
".",
"swr",
".",
"webrtc",
".",
"getPeers",
"(",
"uid",
")",
"[",
"0",
"]",
"var",
"success",
"if",
"(",
"peer",
")",
"{",
"// success is true, if the message is suc... | we have to make sure that the message is sent under all circumstances | [
"we",
"have",
"to",
"make",
"sure",
"that",
"the",
"message",
"is",
"sent",
"under",
"all",
"circumstances"
] | 1c6559b57dae9f9e5da18b6755afd92577fda878 | https://github.com/y-js/y-webrtc/blob/1c6559b57dae9f9e5da18b6755afd92577fda878/src/WebRTC.js#L73-L85 | train | |
libp2p/js-libp2p-ping | src/handler.js | next | function next () {
shake.read(PING_LENGTH, (err, buf) => {
if (err === true) {
// stream closed
return
}
if (err) {
return log.error(err)
}
shake.write(buf)
return next()
})
} | javascript | function next () {
shake.read(PING_LENGTH, (err, buf) => {
if (err === true) {
// stream closed
return
}
if (err) {
return log.error(err)
}
shake.write(buf)
return next()
})
} | [
"function",
"next",
"(",
")",
"{",
"shake",
".",
"read",
"(",
"PING_LENGTH",
",",
"(",
"err",
",",
"buf",
")",
"=>",
"{",
"if",
"(",
"err",
"===",
"true",
")",
"{",
"// stream closed",
"return",
"}",
"if",
"(",
"err",
")",
"{",
"return",
"log",
"... | receive and echo back | [
"receive",
"and",
"echo",
"back"
] | 349eecf68ae5f5fb7c35333cdb42c138bbf5c766 | https://github.com/libp2p/js-libp2p-ping/blob/349eecf68ae5f5fb7c35333cdb42c138bbf5c766/src/handler.js#L19-L32 | train |
jeffijoe/yenv | lib/applyEnv.js | raw | function raw(obj) {
const result = {}
for (const key in obj) {
const value = obj[key]
if (value !== null && value !== undefined) {
result[key] = value.toString()
}
}
return result
} | javascript | function raw(obj) {
const result = {}
for (const key in obj) {
const value = obj[key]
if (value !== null && value !== undefined) {
result[key] = value.toString()
}
}
return result
} | [
"function",
"raw",
"(",
"obj",
")",
"{",
"const",
"result",
"=",
"{",
"}",
"for",
"(",
"const",
"key",
"in",
"obj",
")",
"{",
"const",
"value",
"=",
"obj",
"[",
"key",
"]",
"if",
"(",
"value",
"!==",
"null",
"&&",
"value",
"!==",
"undefined",
")"... | Serializes env values as strings. | [
"Serializes",
"env",
"values",
"as",
"strings",
"."
] | fb3eaca3550718c89853fa891ecef837eecc2992 | https://github.com/jeffijoe/yenv/blob/fb3eaca3550718c89853fa891ecef837eecc2992/lib/applyEnv.js#L38-L47 | train |
jeffijoe/yenv | lib/composeSections.js | circularSectionsError | function circularSectionsError(sectionName, path) {
const joinedPath = path.join(' -> ')
const message = `Circular sections! Path: ${joinedPath} -> [${sectionName}]`
return new Error(message)
} | javascript | function circularSectionsError(sectionName, path) {
const joinedPath = path.join(' -> ')
const message = `Circular sections! Path: ${joinedPath} -> [${sectionName}]`
return new Error(message)
} | [
"function",
"circularSectionsError",
"(",
"sectionName",
",",
"path",
")",
"{",
"const",
"joinedPath",
"=",
"path",
".",
"join",
"(",
"' -> '",
")",
"const",
"message",
"=",
"`",
"${",
"joinedPath",
"}",
"${",
"sectionName",
"}",
"`",
"return",
"new",
"Err... | Returns a new error indicating circular sections.
@param {String} sectionName
The section at which the circularity was determined.
@param {String[]} path
The circular sections path.
@return {Error} Our beautiful error. | [
"Returns",
"a",
"new",
"error",
"indicating",
"circular",
"sections",
"."
] | fb3eaca3550718c89853fa891ecef837eecc2992 | https://github.com/jeffijoe/yenv/blob/fb3eaca3550718c89853fa891ecef837eecc2992/lib/composeSections.js#L17-L21 | train |
jeffijoe/yenv | lib/processImports.js | circularImportsError | function circularImportsError(fileBeingImported, importTrail) {
const message =
`Circular import of "${fileBeingImported}".\r\n` +
'Import trace:\r\n' +
importTrail.map(f => ` -> ${f}`).join('\r\n')
return new Error(message)
} | javascript | function circularImportsError(fileBeingImported, importTrail) {
const message =
`Circular import of "${fileBeingImported}".\r\n` +
'Import trace:\r\n' +
importTrail.map(f => ` -> ${f}`).join('\r\n')
return new Error(message)
} | [
"function",
"circularImportsError",
"(",
"fileBeingImported",
",",
"importTrail",
")",
"{",
"const",
"message",
"=",
"`",
"${",
"fileBeingImported",
"}",
"\\r",
"\\n",
"`",
"+",
"'Import trace:\\r\\n'",
"+",
"importTrail",
".",
"map",
"(",
"f",
"=>",
"`",
"${"... | Constructs a circular imports error.
@param {string} fileBeingImported
The file being imported.
@param {string} importingFile
The file that imported.
@return {Error}
An error. | [
"Constructs",
"a",
"circular",
"imports",
"error",
"."
] | fb3eaca3550718c89853fa891ecef837eecc2992 | https://github.com/jeffijoe/yenv/blob/fb3eaca3550718c89853fa891ecef837eecc2992/lib/processImports.js#L25-L31 | train |
jeffijoe/yenv | lib/processImports.js | mapFiles | function mapFiles(files, relative, required) {
if (!files) {
return []
}
if (Array.isArray(files) === false) {
files = [files]
}
return files.map(f => ({
file: resolvePath(relative, f),
required: required
}))
} | javascript | function mapFiles(files, relative, required) {
if (!files) {
return []
}
if (Array.isArray(files) === false) {
files = [files]
}
return files.map(f => ({
file: resolvePath(relative, f),
required: required
}))
} | [
"function",
"mapFiles",
"(",
"files",
",",
"relative",
",",
"required",
")",
"{",
"if",
"(",
"!",
"files",
")",
"{",
"return",
"[",
"]",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"files",
")",
"===",
"false",
")",
"{",
"files",
"=",
"[",
"fil... | Maps file paths as well as whether not they are required to descriptors. | [
"Maps",
"file",
"paths",
"as",
"well",
"as",
"whether",
"not",
"they",
"are",
"required",
"to",
"descriptors",
"."
] | fb3eaca3550718c89853fa891ecef837eecc2992 | https://github.com/jeffijoe/yenv/blob/fb3eaca3550718c89853fa891ecef837eecc2992/lib/processImports.js#L98-L111 | train |
KleeGroup/focus-core | src/definition/validator/validate.js | validate | function validate(property, validators) {
//console.log("validate", property, validators);
let errors = [], res, validator;
if (validators) {
for (let i = 0, _len = validators.length; i < _len; i++) {
validator = validators[i];
res = validateProperty(property, validator);
... | javascript | function validate(property, validators) {
//console.log("validate", property, validators);
let errors = [], res, validator;
if (validators) {
for (let i = 0, _len = validators.length; i < _len; i++) {
validator = validators[i];
res = validateProperty(property, validator);
... | [
"function",
"validate",
"(",
"property",
",",
"validators",
")",
"{",
"//console.log(\"validate\", property, validators);",
"let",
"errors",
"=",
"[",
"]",
",",
"res",
",",
"validator",
";",
"if",
"(",
"validators",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0"... | Validae a property given validators.
@param {object} property - Property to validate which should be as follows: `{name: "field_name",value: "field_value", validators: [{...}] }`.
@param {array} validators - The validators to apply on the property.
@return {object} - The validation status. | [
"Validae",
"a",
"property",
"given",
"validators",
"."
] | 6ce70638e0c5acdd25830a14ce3b154f84a17405 | https://github.com/KleeGroup/focus-core/blob/6ce70638e0c5acdd25830a14ce3b154f84a17405/src/definition/validator/validate.js#L19-L38 | train |
KleeGroup/focus-core | src/definition/validator/validate.js | getErrorLabel | function getErrorLabel(type, fieldName, options = {}) {
options = options || {};
const translationKey = options.translationKey ? options.translationKey : `domain.validation.${type}`;
const opts = { fieldName: translate(fieldName), ...options };
return translate(translationKey, opts);
} | javascript | function getErrorLabel(type, fieldName, options = {}) {
options = options || {};
const translationKey = options.translationKey ? options.translationKey : `domain.validation.${type}`;
const opts = { fieldName: translate(fieldName), ...options };
return translate(translationKey, opts);
} | [
"function",
"getErrorLabel",
"(",
"type",
",",
"fieldName",
",",
"options",
"=",
"{",
"}",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"const",
"translationKey",
"=",
"options",
".",
"translationKey",
"?",
"options",
".",
"translationKey",
":... | Get the error label from a type and a field name.
@param {string} type - The type name.
@param {string} fieldName - The field name.
@param {object} options - The options to put such as the translationKey which could be defined in the domain.
@return {string} The formatted error. | [
"Get",
"the",
"error",
"label",
"from",
"a",
"type",
"and",
"a",
"field",
"name",
"."
] | 6ce70638e0c5acdd25830a14ce3b154f84a17405 | https://github.com/KleeGroup/focus-core/blob/6ce70638e0c5acdd25830a14ce3b154f84a17405/src/definition/validator/validate.js#L100-L105 | train |
KleeGroup/focus-core | src/list/load-action/builder.js | orderAndSort | function orderAndSort(sortConf) {
return {
sortFieldName: sortConf.sortBy,
sortDesc: sortConf.sortAsc === undefined ? false : !sortConf.sortAsc
};
} | javascript | function orderAndSort(sortConf) {
return {
sortFieldName: sortConf.sortBy,
sortDesc: sortConf.sortAsc === undefined ? false : !sortConf.sortAsc
};
} | [
"function",
"orderAndSort",
"(",
"sortConf",
")",
"{",
"return",
"{",
"sortFieldName",
":",
"sortConf",
".",
"sortBy",
",",
"sortDesc",
":",
"sortConf",
".",
"sortAsc",
"===",
"undefined",
"?",
"false",
":",
"!",
"sortConf",
".",
"sortAsc",
"}",
";",
"}"
] | Build sort infotmation.
@param {object} sortConf - The sort configuration.
@return {object} - The builded sort configuration. | [
"Build",
"sort",
"infotmation",
"."
] | 6ce70638e0c5acdd25830a14ce3b154f84a17405 | https://github.com/KleeGroup/focus-core/blob/6ce70638e0c5acdd25830a14ce3b154f84a17405/src/list/load-action/builder.js#L7-L12 | train |
KleeGroup/focus-core | src/list/load-action/builder.js | pagination | function pagination(opts) {
let { isScroll, dataList, totalCount, nbElement } = opts;
if (isScroll) {
if (!isArray(dataList)) {
throw new Error('The data list options sould exist and be an array')
}
if (dataList.length < totalCount) {
return { top: nbElement, skip... | javascript | function pagination(opts) {
let { isScroll, dataList, totalCount, nbElement } = opts;
if (isScroll) {
if (!isArray(dataList)) {
throw new Error('The data list options sould exist and be an array')
}
if (dataList.length < totalCount) {
return { top: nbElement, skip... | [
"function",
"pagination",
"(",
"opts",
")",
"{",
"let",
"{",
"isScroll",
",",
"dataList",
",",
"totalCount",
",",
"nbElement",
"}",
"=",
"opts",
";",
"if",
"(",
"isScroll",
")",
"{",
"if",
"(",
"!",
"isArray",
"(",
"dataList",
")",
")",
"{",
"throw",... | Build the pagination configuration given the options.
@param {object} opts - The pagination options should be :
isScroll (:bool) - Are we in a scroll context.
totalCount (:number) - The total number of element. (intresting only in the scroll case)
nbSearchElement (:number) - The number of elements you want to get back... | [
"Build",
"the",
"pagination",
"configuration",
"given",
"the",
"options",
"."
] | 6ce70638e0c5acdd25830a14ce3b154f84a17405 | https://github.com/KleeGroup/focus-core/blob/6ce70638e0c5acdd25830a14ce3b154f84a17405/src/list/load-action/builder.js#L22-L36 | train |
reflux/reflux-promise | src/index.js | triggerPromise | function triggerPromise() {
var me = this;
var args = arguments;
var canHandlePromise =
this.children.indexOf("completed") >= 0 &&
this.children.indexOf("failed") >= 0;
var createdPromise = new PromiseFactory(function(resolve, reject) {
// If `listen... | javascript | function triggerPromise() {
var me = this;
var args = arguments;
var canHandlePromise =
this.children.indexOf("completed") >= 0 &&
this.children.indexOf("failed") >= 0;
var createdPromise = new PromiseFactory(function(resolve, reject) {
// If `listen... | [
"function",
"triggerPromise",
"(",
")",
"{",
"var",
"me",
"=",
"this",
";",
"var",
"args",
"=",
"arguments",
";",
"var",
"canHandlePromise",
"=",
"this",
".",
"children",
".",
"indexOf",
"(",
"\"completed\"",
")",
">=",
"0",
"&&",
"this",
".",
"children"... | Returns a Promise for the triggered action
@return {Promise}
Resolved by completed child action.
Rejected by failed child action.
If listenAndPromise'd, then promise associated to this trigger.
Otherwise, the promise is for next child action completion. | [
"Returns",
"a",
"Promise",
"for",
"the",
"triggered",
"action"
] | fa0633ee09f776f7b6d6d4d8fa2e9d3a3ef81cd6 | https://github.com/reflux/reflux-promise/blob/fa0633ee09f776f7b6d6d4d8fa2e9d3a3ef81cd6/src/index.js#L14-L69 | train |
reflux/reflux-promise | src/index.js | promise | function promise(p) {
var me = this;
var canHandlePromise =
this.children.indexOf("completed") >= 0 &&
this.children.indexOf("failed") >= 0;
if (!canHandlePromise){
throw new Error("Publisher must have \"completed\" and \"failed\" child publishers");
... | javascript | function promise(p) {
var me = this;
var canHandlePromise =
this.children.indexOf("completed") >= 0 &&
this.children.indexOf("failed") >= 0;
if (!canHandlePromise){
throw new Error("Publisher must have \"completed\" and \"failed\" child publishers");
... | [
"function",
"promise",
"(",
"p",
")",
"{",
"var",
"me",
"=",
"this",
";",
"var",
"canHandlePromise",
"=",
"this",
".",
"children",
".",
"indexOf",
"(",
"\"completed\"",
")",
">=",
"0",
"&&",
"this",
".",
"children",
".",
"indexOf",
"(",
"\"failed\"",
"... | Attach handlers to promise that trigger the completed and failed
child publishers, if available.
@param {Object} p The promise to attach to | [
"Attach",
"handlers",
"to",
"promise",
"that",
"trigger",
"the",
"completed",
"and",
"failed",
"child",
"publishers",
"if",
"available",
"."
] | fa0633ee09f776f7b6d6d4d8fa2e9d3a3ef81cd6 | https://github.com/reflux/reflux-promise/blob/fa0633ee09f776f7b6d6d4d8fa2e9d3a3ef81cd6/src/index.js#L77-L93 | train |
reflux/reflux-promise | src/index.js | listenAndPromise | function listenAndPromise(callback, bindContext) {
var me = this;
bindContext = bindContext || this;
this.willCallPromise = (this.willCallPromise || 0) + 1;
var removeListen = this.listen(function() {
if (!callback) {
throw new Error("Expected a function ret... | javascript | function listenAndPromise(callback, bindContext) {
var me = this;
bindContext = bindContext || this;
this.willCallPromise = (this.willCallPromise || 0) + 1;
var removeListen = this.listen(function() {
if (!callback) {
throw new Error("Expected a function ret... | [
"function",
"listenAndPromise",
"(",
"callback",
",",
"bindContext",
")",
"{",
"var",
"me",
"=",
"this",
";",
"bindContext",
"=",
"bindContext",
"||",
"this",
";",
"this",
".",
"willCallPromise",
"=",
"(",
"this",
".",
"willCallPromise",
"||",
"0",
")",
"+... | Subscribes the given callback for action triggered, which should
return a promise that in turn is passed to `this.promise`
@param {Function} callback The callback to register as event handler | [
"Subscribes",
"the",
"given",
"callback",
"for",
"action",
"triggered",
"which",
"should",
"return",
"a",
"promise",
"that",
"in",
"turn",
"is",
"passed",
"to",
"this",
".",
"promise"
] | fa0633ee09f776f7b6d6d4d8fa2e9d3a3ef81cd6 | https://github.com/reflux/reflux-promise/blob/fa0633ee09f776f7b6d6d4d8fa2e9d3a3ef81cd6/src/index.js#L101-L122 | train |
KleeGroup/focus-core | src/user/index.js | hasRole | function hasRole(role) {
role = isArray(role) ? role : [role];
return 0 < intersection(role, userBuiltInStore.getRoles()).length;
} | javascript | function hasRole(role) {
role = isArray(role) ? role : [role];
return 0 < intersection(role, userBuiltInStore.getRoles()).length;
} | [
"function",
"hasRole",
"(",
"role",
")",
"{",
"role",
"=",
"isArray",
"(",
"role",
")",
"?",
"role",
":",
"[",
"role",
"]",
";",
"return",
"0",
"<",
"intersection",
"(",
"role",
",",
"userBuiltInStore",
".",
"getRoles",
"(",
")",
")",
".",
"length",
... | Check if a user has the givent role or roles.
@param {string | array} role - Check if the user has one or many roles.
@return {Boolean} - True if the user has at least on of the givent roles. | [
"Check",
"if",
"a",
"user",
"has",
"the",
"givent",
"role",
"or",
"roles",
"."
] | 6ce70638e0c5acdd25830a14ce3b154f84a17405 | https://github.com/KleeGroup/focus-core/blob/6ce70638e0c5acdd25830a14ce3b154f84a17405/src/user/index.js#L19-L22 | train |
ExtraHop/metalsmith-sitemap | lib/index.js | check | function check(file, frontmatter) {
// Only process files that match the pattern
if (!match(file, pattern)[0]) {
return false;
}
// Don't process private files
if (get(frontmatter, privateProperty)) {
return false;
}
return true;
} | javascript | function check(file, frontmatter) {
// Only process files that match the pattern
if (!match(file, pattern)[0]) {
return false;
}
// Don't process private files
if (get(frontmatter, privateProperty)) {
return false;
}
return true;
} | [
"function",
"check",
"(",
"file",
",",
"frontmatter",
")",
"{",
"// Only process files that match the pattern",
"if",
"(",
"!",
"match",
"(",
"file",
",",
"pattern",
")",
"[",
"0",
"]",
")",
"{",
"return",
"false",
";",
"}",
"// Don't process private files",
"... | Checks whether files should be processed | [
"Checks",
"whether",
"files",
"should",
"be",
"processed"
] | 6b69101e96c1d3c6e7fedac74fbd45a867615944 | https://github.com/ExtraHop/metalsmith-sitemap/blob/6b69101e96c1d3c6e7fedac74fbd45a867615944/lib/index.js#L77-L89 | train |
ExtraHop/metalsmith-sitemap | lib/index.js | buildUrl | function buildUrl(file, frontmatter) {
// Frontmatter settings take precedence
var canonicalUrl = get(frontmatter, urlProperty);
if (is.string(canonicalUrl)) {
return canonicalUrl;
}
// Remove index.html if necessary
var indexFile = 'index.html';
if (omitIndex && path.... | javascript | function buildUrl(file, frontmatter) {
// Frontmatter settings take precedence
var canonicalUrl = get(frontmatter, urlProperty);
if (is.string(canonicalUrl)) {
return canonicalUrl;
}
// Remove index.html if necessary
var indexFile = 'index.html';
if (omitIndex && path.... | [
"function",
"buildUrl",
"(",
"file",
",",
"frontmatter",
")",
"{",
"// Frontmatter settings take precedence",
"var",
"canonicalUrl",
"=",
"get",
"(",
"frontmatter",
",",
"urlProperty",
")",
";",
"if",
"(",
"is",
".",
"string",
"(",
"canonicalUrl",
")",
")",
"{... | Builds a url | [
"Builds",
"a",
"url"
] | 6b69101e96c1d3c6e7fedac74fbd45a867615944 | https://github.com/ExtraHop/metalsmith-sitemap/blob/6b69101e96c1d3c6e7fedac74fbd45a867615944/lib/index.js#L92-L112 | train |
KleeGroup/focus-core | src/definition/formatter/number.js | init | function init(format = DEFAULT_FORMAT, locale = 'fr') {
numeral.locale(locale);
numeral.defaultFormat(format);
} | javascript | function init(format = DEFAULT_FORMAT, locale = 'fr') {
numeral.locale(locale);
numeral.defaultFormat(format);
} | [
"function",
"init",
"(",
"format",
"=",
"DEFAULT_FORMAT",
",",
"locale",
"=",
"'fr'",
")",
"{",
"numeral",
".",
"locale",
"(",
"locale",
")",
";",
"numeral",
".",
"defaultFormat",
"(",
"format",
")",
";",
"}"
] | Initialize numeral locale and default format.
@param {string} [format='0,0'] format to use
@param {string} [locale='fr'] locale to use | [
"Initialize",
"numeral",
"locale",
"and",
"default",
"format",
"."
] | 6ce70638e0c5acdd25830a14ce3b154f84a17405 | https://github.com/KleeGroup/focus-core/blob/6ce70638e0c5acdd25830a14ce3b154f84a17405/src/definition/formatter/number.js#L21-L24 | train |
KleeGroup/focus-core | src/network/fetch.js | updateRequestStatus | function updateRequestStatus(request) {
if (!request || !request.id || !request.status) { return; }
dispatcher.handleViewAction({
data: { request: request },
type: 'update'
});
return request;
} | javascript | function updateRequestStatus(request) {
if (!request || !request.id || !request.status) { return; }
dispatcher.handleViewAction({
data: { request: request },
type: 'update'
});
return request;
} | [
"function",
"updateRequestStatus",
"(",
"request",
")",
"{",
"if",
"(",
"!",
"request",
"||",
"!",
"request",
".",
"id",
"||",
"!",
"request",
".",
"status",
")",
"{",
"return",
";",
"}",
"dispatcher",
".",
"handleViewAction",
"(",
"{",
"data",
":",
"{... | Update the request status.
@param {object} request - The request to treat.
@return {object} - The request to dispatch. | [
"Update",
"the",
"request",
"status",
"."
] | 6ce70638e0c5acdd25830a14ce3b154f84a17405 | https://github.com/KleeGroup/focus-core/blob/6ce70638e0c5acdd25830a14ce3b154f84a17405/src/network/fetch.js#L22-L29 | train |
KleeGroup/focus-core | src/network/fetch.js | getResponseContent | function getResponseContent(response, dataType) {
const { type, status, ok } = response;
// Handling errors
if (type === 'opaque') {
console.error('You tried to make a Cross Domain Request with no-cors options');
return Promise.reject({ status: status, globalErrors: ['error.noCorsOptsOnCors... | javascript | function getResponseContent(response, dataType) {
const { type, status, ok } = response;
// Handling errors
if (type === 'opaque') {
console.error('You tried to make a Cross Domain Request with no-cors options');
return Promise.reject({ status: status, globalErrors: ['error.noCorsOptsOnCors... | [
"function",
"getResponseContent",
"(",
"response",
",",
"dataType",
")",
"{",
"const",
"{",
"type",
",",
"status",
",",
"ok",
"}",
"=",
"response",
";",
"// Handling errors",
"if",
"(",
"type",
"===",
"'opaque'",
")",
"{",
"console",
".",
"error",
"(",
"... | Extract the data from the response, and handle network or server errors or wrong data format.
@param {Response} response the response to extract from
@param {string} dataType the datatype (can be 'arrayBuffer', 'blob', 'formData', 'json' or 'text')
@returns {Promise} a Promise containing response data, or error data | [
"Extract",
"the",
"data",
"from",
"the",
"response",
"and",
"handle",
"network",
"or",
"server",
"errors",
"or",
"wrong",
"data",
"format",
"."
] | 6ce70638e0c5acdd25830a14ce3b154f84a17405 | https://github.com/KleeGroup/focus-core/blob/6ce70638e0c5acdd25830a14ce3b154f84a17405/src/network/fetch.js#L38-L65 | train |
KleeGroup/focus-core | src/network/fetch.js | checkErrors | function checkErrors(response, xhrErrors) {
let { status, ok } = response;
if (!ok) {
if (xhrErrors[status]) {
xhrErrors[status](response);
}
}
} | javascript | function checkErrors(response, xhrErrors) {
let { status, ok } = response;
if (!ok) {
if (xhrErrors[status]) {
xhrErrors[status](response);
}
}
} | [
"function",
"checkErrors",
"(",
"response",
",",
"xhrErrors",
")",
"{",
"let",
"{",
"status",
",",
"ok",
"}",
"=",
"response",
";",
"if",
"(",
"!",
"ok",
")",
"{",
"if",
"(",
"xhrErrors",
"[",
"status",
"]",
")",
"{",
"xhrErrors",
"[",
"status",
"]... | Check if a special treatment is specify for a specific error code
@param {Object} response The fetch response
@param {Object} xhrErrors The specific treatment | [
"Check",
"if",
"a",
"special",
"treatment",
"is",
"specify",
"for",
"a",
"specific",
"error",
"code"
] | 6ce70638e0c5acdd25830a14ce3b154f84a17405 | https://github.com/KleeGroup/focus-core/blob/6ce70638e0c5acdd25830a14ce3b154f84a17405/src/network/fetch.js#L73-L80 | train |
KleeGroup/focus-core | src/network/fetch.js | wrappingFetch | function wrappingFetch({ url, method, data }, optionsArg) {
let requestStatus = createRequestStatus();
// Here we are using destruct to filter properties we do not want to give to fetch.
// CORS and isCORS are useless legacy code, xhrErrors is used only in error parsing
// eslint-disable-next-line no-un... | javascript | function wrappingFetch({ url, method, data }, optionsArg) {
let requestStatus = createRequestStatus();
// Here we are using destruct to filter properties we do not want to give to fetch.
// CORS and isCORS are useless legacy code, xhrErrors is used only in error parsing
// eslint-disable-next-line no-un... | [
"function",
"wrappingFetch",
"(",
"{",
"url",
",",
"method",
",",
"data",
"}",
",",
"optionsArg",
")",
"{",
"let",
"requestStatus",
"=",
"createRequestStatus",
"(",
")",
";",
"// Here we are using destruct to filter properties we do not want to give to fetch.",
"// CORS a... | Fetch function to ease http request.
@param {object} obj - method: http verb, url: http url, data:The json to save.
@param {object} options - The options object.
@return {CancellablePromise} The promise of the execution of the HTTP request. | [
"Fetch",
"function",
"to",
"ease",
"http",
"request",
"."
] | 6ce70638e0c5acdd25830a14ce3b154f84a17405 | https://github.com/KleeGroup/focus-core/blob/6ce70638e0c5acdd25830a14ce3b154f84a17405/src/network/fetch.js#L88-L116 | 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.