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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
kogarashisan/LiquidLava | lib/packages/parsers.js | function(widget_config, raw_template) {
var storage_schema = this.getMergedStorageSchema(widget_config),
tags = Lava.parsers.Common.asBlockType(raw_template, 'tag'),
i = 0,
count = tags.length,
item_schema;
for (; i < count; i++) {
item_schema = storage_schema[tags[i].name];
if (Lava.schema.DEB... | javascript | function(widget_config, raw_template) {
var storage_schema = this.getMergedStorageSchema(widget_config),
tags = Lava.parsers.Common.asBlockType(raw_template, 'tag'),
i = 0,
count = tags.length,
item_schema;
for (; i < count; i++) {
item_schema = storage_schema[tags[i].name];
if (Lava.schema.DEB... | [
"function",
"(",
"widget_config",
",",
"raw_template",
")",
"{",
"var",
"storage_schema",
"=",
"this",
".",
"getMergedStorageSchema",
"(",
"widget_config",
")",
",",
"tags",
"=",
"Lava",
".",
"parsers",
".",
"Common",
".",
"asBlockType",
"(",
"raw_template",
"... | Parse raw tags as widget's storage
@param {_cWidget} widget_config
@param {_tRawTemplate} raw_template | [
"Parse",
"raw",
"tags",
"as",
"widget",
"s",
"storage"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L2293-L2309 | train | |
kogarashisan/LiquidLava | lib/packages/parsers.js | function(schema, raw_tag, exclude_name) {
var tags = Lava.parsers.Common.asBlockType(raw_tag.content, 'tag'),
i = 0,
count = tags.length,
result = {},
descriptor,
name;
for (; i < count; i++) {
descriptor = schema.properties[tags[i].name];
if (Lava.schema.DEBUG && !descriptor) Lava.t("Unknow... | javascript | function(schema, raw_tag, exclude_name) {
var tags = Lava.parsers.Common.asBlockType(raw_tag.content, 'tag'),
i = 0,
count = tags.length,
result = {},
descriptor,
name;
for (; i < count; i++) {
descriptor = schema.properties[tags[i].name];
if (Lava.schema.DEBUG && !descriptor) Lava.t("Unknow... | [
"function",
"(",
"schema",
",",
"raw_tag",
",",
"exclude_name",
")",
"{",
"var",
"tags",
"=",
"Lava",
".",
"parsers",
".",
"Common",
".",
"asBlockType",
"(",
"raw_tag",
".",
"content",
",",
"'tag'",
")",
",",
"i",
"=",
"0",
",",
"count",
"=",
"tags",... | Convert `raw_rag` into object with given `schema`
@param {_cStorageItemSchema} schema
@param {_cRawTag} raw_tag
@param {boolean} exclude_name
@returns {Object} | [
"Convert",
"raw_rag",
"into",
"object",
"with",
"given",
"schema"
] | fb8618821a51fad373106b5cc9247464b0a23cf6 | https://github.com/kogarashisan/LiquidLava/blob/fb8618821a51fad373106b5cc9247464b0a23cf6/lib/packages/parsers.js#L2387-L2417 | train | |
jonwoodring/octal-number-loader | index.js | function(s) {
var r = '';
for (var i = s.length - 1; i >= 0; i--) {
r += s[i];
}
return r;
} | javascript | function(s) {
var r = '';
for (var i = s.length - 1; i >= 0; i--) {
r += s[i];
}
return r;
} | [
"function",
"(",
"s",
")",
"{",
"var",
"r",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"s",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"r",
"+=",
"s",
"[",
"i",
"]",
";",
"}",
"return",
"r",
";",
"}"
] | javascript doesn't have negative lookbehind so we have to reverse the string | [
"javascript",
"doesn",
"t",
"have",
"negative",
"lookbehind",
"so",
"we",
"have",
"to",
"reverse",
"the",
"string"
] | 5b49b9ab8b116bbf9c1f0e36dd85c28ef8318c21 | https://github.com/jonwoodring/octal-number-loader/blob/5b49b9ab8b116bbf9c1f0e36dd85c28ef8318c21/index.js#L9-L15 | train | |
shama/grunt-required | tasks/required.js | npmInstall | function npmInstall(requires, done) {
var npmBin = path.join(path.dirname(process.argv[0]), 'npm');
if (process.platform === 'win32') { npmBin += '.cmd'; }
async.forEachSeries(requires, function(module, next) {
// skip existing modules
if (grunt.file.exists(path.join('./node_modules/' + module))... | javascript | function npmInstall(requires, done) {
var npmBin = path.join(path.dirname(process.argv[0]), 'npm');
if (process.platform === 'win32') { npmBin += '.cmd'; }
async.forEachSeries(requires, function(module, next) {
// skip existing modules
if (grunt.file.exists(path.join('./node_modules/' + module))... | [
"function",
"npmInstall",
"(",
"requires",
",",
"done",
")",
"{",
"var",
"npmBin",
"=",
"path",
".",
"join",
"(",
"path",
".",
"dirname",
"(",
"process",
".",
"argv",
"[",
"0",
"]",
")",
",",
"'npm'",
")",
";",
"if",
"(",
"process",
".",
"platform"... | use npm to install given modules | [
"use",
"npm",
"to",
"install",
"given",
"modules"
] | 367f1e7517592fedf1a0612f44e41c05437bfcbe | https://github.com/shama/grunt-required/blob/367f1e7517592fedf1a0612f44e41c05437bfcbe/tasks/required.js#L17-L36 | train |
bvalosek/sticky | util/camelize.js | camelize | function camelize()
{
return function(input, output)
{
var target = output || input;
var f = output ? remove : add;
for (var key in target) {
var value = target[key];
var key_ = f(key);
if (key_ === key) continue;
delete target[key];
target[key_] = value;
}
};
} | javascript | function camelize()
{
return function(input, output)
{
var target = output || input;
var f = output ? remove : add;
for (var key in target) {
var value = target[key];
var key_ = f(key);
if (key_ === key) continue;
delete target[key];
target[key_] = value;
}
};
} | [
"function",
"camelize",
"(",
")",
"{",
"return",
"function",
"(",
"input",
",",
"output",
")",
"{",
"var",
"target",
"=",
"output",
"||",
"input",
";",
"var",
"f",
"=",
"output",
"?",
"remove",
":",
"add",
";",
"for",
"(",
"var",
"key",
"in",
"targ... | A sticky transform that will change vars_like_this into varsLikeThis. | [
"A",
"sticky",
"transform",
"that",
"will",
"change",
"vars_like_this",
"into",
"varsLikeThis",
"."
] | 8cb5fdba05be161e5936f7208558bc4702aae59a | https://github.com/bvalosek/sticky/blob/8cb5fdba05be161e5936f7208558bc4702aae59a/util/camelize.js#L6-L22 | train |
timkuijsten/node-object-key-filter | index.js | filter | function filter(obj, keys, recurse) {
if (typeof obj !== 'object') { throw new TypeError('obj must be an object'); }
if (!Array.isArray(keys)) { throw new TypeError('keys must be an array'); }
if (recurse == null) {
recurse = false;
}
if (typeof recurse !== 'boolean') { throw new TypeError('recurse must ... | javascript | function filter(obj, keys, recurse) {
if (typeof obj !== 'object') { throw new TypeError('obj must be an object'); }
if (!Array.isArray(keys)) { throw new TypeError('keys must be an array'); }
if (recurse == null) {
recurse = false;
}
if (typeof recurse !== 'boolean') { throw new TypeError('recurse must ... | [
"function",
"filter",
"(",
"obj",
",",
"keys",
",",
"recurse",
")",
"{",
"if",
"(",
"typeof",
"obj",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'obj must be an object'",
")",
";",
"}",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
... | Filter certain keys from an object without side-effects, optionally recurse.
@param {Object|Array} obj object to filter keys from
@param {Array} keys array of key names to filter
@param {Boolean, default: false} recurse whether or not to recurse
@return {Object} object same as input but without the specified keys | [
"Filter",
"certain",
"keys",
"from",
"an",
"object",
"without",
"side",
"-",
"effects",
"optionally",
"recurse",
"."
] | 5452a6db0f85b55351742307cbce063654ebbb15 | https://github.com/timkuijsten/node-object-key-filter/blob/5452a6db0f85b55351742307cbce063654ebbb15/index.js#L27-L55 | train |
alexindigo/deeply | extra/arrays_append.js | arraysAppendAdapter | function arraysAppendAdapter(to, from, merge)
{
// transfer actual values
from.reduce(function(target, value)
{
target.push(merge(undefined, value));
return target;
}, to);
return to;
} | javascript | function arraysAppendAdapter(to, from, merge)
{
// transfer actual values
from.reduce(function(target, value)
{
target.push(merge(undefined, value));
return target;
}, to);
return to;
} | [
"function",
"arraysAppendAdapter",
"(",
"to",
",",
"from",
",",
"merge",
")",
"{",
"// transfer actual values",
"from",
".",
"reduce",
"(",
"function",
"(",
"target",
",",
"value",
")",
"{",
"target",
".",
"push",
"(",
"merge",
"(",
"undefined",
",",
"valu... | Adapter to merge arrays
by appending cloned elements
of the second array to the first
@param {array} to - target array to update
@param {array} from - array to clone
@param {function} merge - iterator to merge sub elements
@returns {array} - modified target object | [
"Adapter",
"to",
"merge",
"arrays",
"by",
"appending",
"cloned",
"elements",
"of",
"the",
"second",
"array",
"to",
"the",
"first"
] | d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1 | https://github.com/alexindigo/deeply/blob/d9f59eec37b75ce52038b3fcfb0fd86d4989c0c1/extra/arrays_append.js#L14-L25 | train |
SilentCicero/ethdeploy | src/lib/index.js | loadEnvironment | function loadEnvironment(environment, callback) {
const errorMsgBase = 'while transforming environment, ';
var transformedEnvironment = cloneDeep(environment); // eslint-disable-line
const query = new Eth(transformedEnvironment.provider);
query.net_version((versionError, result) => { // eslint-disable-line
... | javascript | function loadEnvironment(environment, callback) {
const errorMsgBase = 'while transforming environment, ';
var transformedEnvironment = cloneDeep(environment); // eslint-disable-line
const query = new Eth(transformedEnvironment.provider);
query.net_version((versionError, result) => { // eslint-disable-line
... | [
"function",
"loadEnvironment",
"(",
"environment",
",",
"callback",
")",
"{",
"const",
"errorMsgBase",
"=",
"'while transforming environment, '",
";",
"var",
"transformedEnvironment",
"=",
"cloneDeep",
"(",
"environment",
")",
";",
"// eslint-disable-line",
"const",
"qu... | Load the environment, get accounts, gas limits, balances etc.
@method loadEnvironment
@param {Object} environment the environment object specified in the config.js
@param {Function} callback the callback to return the environment
@callback {Object} output the transformed environment object | [
"Load",
"the",
"environment",
"get",
"accounts",
"gas",
"limits",
"balances",
"etc",
"."
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L40-L58 | train |
SilentCicero/ethdeploy | src/lib/index.js | transformContracts | function transformContracts(contracts, environmentName) {
const scopedContracts = Object.assign({}, cloneDeep(contracts[environmentName] || {}));
// add name property to all contracts for deployment identification
Object.keys(scopedContracts).forEach((contractName) => {
scopedContracts[contractName].name = c... | javascript | function transformContracts(contracts, environmentName) {
const scopedContracts = Object.assign({}, cloneDeep(contracts[environmentName] || {}));
// add name property to all contracts for deployment identification
Object.keys(scopedContracts).forEach((contractName) => {
scopedContracts[contractName].name = c... | [
"function",
"transformContracts",
"(",
"contracts",
",",
"environmentName",
")",
"{",
"const",
"scopedContracts",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"cloneDeep",
"(",
"contracts",
"[",
"environmentName",
"]",
"||",
"{",
"}",
")",
")",
";",
"... | Prepair the contracts for deployment, scope contracts array, add name
@method transformContracts
@param {Object} contracts the environment object specified in the config.js
@param {String} environmentName the callback to return the environment
@return {Object} output the scoped contracts object, ready for deployment m... | [
"Prepair",
"the",
"contracts",
"for",
"deployment",
"scope",
"contracts",
"array",
"add",
"name"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L68-L78 | train |
SilentCicero/ethdeploy | src/lib/index.js | configError | function configError(config) {
if (typeof config !== 'object') { return `the config method must return a config object, got type ${typeof config}`; }
if (typeof config.entry === 'undefined') { return `No defined entry! 'config.entry' must be defined, got type ${typeof config.entry}.`; }
if (typeof config.module !... | javascript | function configError(config) {
if (typeof config !== 'object') { return `the config method must return a config object, got type ${typeof config}`; }
if (typeof config.entry === 'undefined') { return `No defined entry! 'config.entry' must be defined, got type ${typeof config.entry}.`; }
if (typeof config.module !... | [
"function",
"configError",
"(",
"config",
")",
"{",
"if",
"(",
"typeof",
"config",
"!==",
"'object'",
")",
"{",
"return",
"`",
"${",
"typeof",
"config",
"}",
"`",
";",
"}",
"if",
"(",
"typeof",
"config",
".",
"entry",
"===",
"'undefined'",
")",
"{",
... | Validate the config, after the method has been called
@method configError
@param {Object} config the environment object specified in the config.js
@return {Object|Null} output the config error, if any | [
"Validate",
"the",
"config",
"after",
"the",
"method",
"has",
"been",
"called"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L87-L99 | train |
SilentCicero/ethdeploy | src/lib/index.js | requireLoader | function requireLoader(loaderConfig) {
const errMsgBase = `while requiring loader ${JSON.stringify(loaderConfig)} config,`;
if (typeof loaderConfig !== 'object') { throw error(`${errMsgBase}, config must be object, got ${typeof loaderConfig}`); }
if (typeof loaderConfig.loader !== 'string') { throw error(`${errMs... | javascript | function requireLoader(loaderConfig) {
const errMsgBase = `while requiring loader ${JSON.stringify(loaderConfig)} config,`;
if (typeof loaderConfig !== 'object') { throw error(`${errMsgBase}, config must be object, got ${typeof loaderConfig}`); }
if (typeof loaderConfig.loader !== 'string') { throw error(`${errMs... | [
"function",
"requireLoader",
"(",
"loaderConfig",
")",
"{",
"const",
"errMsgBase",
"=",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"loaderConfig",
")",
"}",
"`",
";",
"if",
"(",
"typeof",
"loaderConfig",
"!==",
"'object'",
")",
"{",
"throw",
"error",
"(",
... | Require the loader
@method requireLoader
@param {Object} loaderConfig the loader config
@return {Object} loader the required loader | [
"Require",
"the",
"loader"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L108-L114 | train |
SilentCicero/ethdeploy | src/lib/index.js | loadContracts | function loadContracts(loaders, base, sourceMap, environment, callback) { // eslint-disable-line
var outputContracts = cloneDeep(base); // eslint-disable-line
const errMsgBase = 'while processing entry data, ';
if (!Array.isArray(loaders)) { return callback(error(`${errMsgBase}loaders must be type Array, got ${ty... | javascript | function loadContracts(loaders, base, sourceMap, environment, callback) { // eslint-disable-line
var outputContracts = cloneDeep(base); // eslint-disable-line
const errMsgBase = 'while processing entry data, ';
if (!Array.isArray(loaders)) { return callback(error(`${errMsgBase}loaders must be type Array, got ${ty... | [
"function",
"loadContracts",
"(",
"loaders",
",",
"base",
",",
"sourceMap",
",",
"environment",
",",
"callback",
")",
"{",
"// eslint-disable-line",
"var",
"outputContracts",
"=",
"cloneDeep",
"(",
"base",
")",
";",
"// eslint-disable-line",
"const",
"errMsgBase",
... | Load contracts from the sourcemap, start from base
@method loadContracts
@param {Array} loaders the array of loaders
@param {Object} base the base contracts object from which to assign to
@param {Object} sourceMap the sourcemap from load time
@param {Object} environment the environments object
@param {Function} callba... | [
"Load",
"contracts",
"from",
"the",
"sourcemap",
"start",
"from",
"base"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L127-L156 | train |
SilentCicero/ethdeploy | src/lib/index.js | processOutput | function processOutput(plugins, outputObject, configObject, baseContracts, contracts, environment, callback) { // eslint-disable-line
// the final string to be outputed
let outputString = JSON.stringify(outputObject, null, 2); // eslint-disable-line
// the err msg base
const errMsgBase = 'while processing outp... | javascript | function processOutput(plugins, outputObject, configObject, baseContracts, contracts, environment, callback) { // eslint-disable-line
// the final string to be outputed
let outputString = JSON.stringify(outputObject, null, 2); // eslint-disable-line
// the err msg base
const errMsgBase = 'while processing outp... | [
"function",
"processOutput",
"(",
"plugins",
",",
"outputObject",
",",
"configObject",
",",
"baseContracts",
",",
"contracts",
",",
"environment",
",",
"callback",
")",
"{",
"// eslint-disable-line",
"// the final string to be outputed",
"let",
"outputString",
"=",
"JSO... | Process the final load output into string output for file creation.
@method processOutput
@param {Array} plugins the array of plugins, if any
@param {Object} outputObject the deplyed contracts
@param {Object} configObject the config js object
@param {Function} callback the method callback that returns the final string... | [
"Process",
"the",
"final",
"load",
"output",
"into",
"string",
"output",
"for",
"file",
"creation",
"."
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L168-L188 | train |
SilentCicero/ethdeploy | src/lib/index.js | contractIsDeployed | function contractIsDeployed(baseContract, stagedContract) {
// if bytecode and inputs match, then skip with instance
if (deepEqual(typeof baseContract.address, 'string')
&& deepEqual(baseContract.transactionObject, stagedContract.transactionObject)
&& deepEqual(`0x${stripHexPrefix(baseContract.bytecode)}`, ... | javascript | function contractIsDeployed(baseContract, stagedContract) {
// if bytecode and inputs match, then skip with instance
if (deepEqual(typeof baseContract.address, 'string')
&& deepEqual(baseContract.transactionObject, stagedContract.transactionObject)
&& deepEqual(`0x${stripHexPrefix(baseContract.bytecode)}`, ... | [
"function",
"contractIsDeployed",
"(",
"baseContract",
",",
"stagedContract",
")",
"{",
"// if bytecode and inputs match, then skip with instance",
"if",
"(",
"deepEqual",
"(",
"typeof",
"baseContract",
".",
"address",
",",
"'string'",
")",
"&&",
"deepEqual",
"(",
"base... | Determine if the contract has already been deployed.
@method contractIsDeployed
@param {Object} baseContract the base contracts on which to deploy new ones
@param {Object} stagedContract the transformed environment
@return {Boolean} isDeployed has the contract already been deployed | [
"Determine",
"if",
"the",
"contract",
"has",
"already",
"been",
"deployed",
"."
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L198-L208 | train |
SilentCicero/ethdeploy | src/lib/index.js | isTransactionObject | function isTransactionObject(value) {
if (typeof value !== 'object') { return false; }
const keys = Object.keys(value);
if (keys.length > 5) { return false; }
if (keys.length === 0) { return true; }
if (keys.length > 0 && isDefined(value.from) || isDefined(value.to) || isDefined(value.data) || isDefined(val... | javascript | function isTransactionObject(value) {
if (typeof value !== 'object') { return false; }
const keys = Object.keys(value);
if (keys.length > 5) { return false; }
if (keys.length === 0) { return true; }
if (keys.length > 0 && isDefined(value.from) || isDefined(value.to) || isDefined(value.data) || isDefined(val... | [
"function",
"isTransactionObject",
"(",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!==",
"'object'",
")",
"{",
"return",
"false",
";",
"}",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"value",
")",
";",
"if",
"(",
"keys",
".",
"length",
... | Is the value a transaction object.
@method isTransactionObject
@param {Optional} value the potential tx object
@return {Boolean} isTransactionObject is the object a tx object | [
"Is",
"the",
"value",
"a",
"transaction",
"object",
"."
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L221-L233 | train |
SilentCicero/ethdeploy | src/lib/index.js | buildDeployMethod | function buildDeployMethod(baseContracts, transformedEnvironment, report) {
return (...args) => {
let transactionObject = {};
const defaultTxObject = transformedEnvironment.defaultTxObject || {};
const contractData = args[0];
if (typeof contractData !== 'object') {
const noContractError = 'A c... | javascript | function buildDeployMethod(baseContracts, transformedEnvironment, report) {
return (...args) => {
let transactionObject = {};
const defaultTxObject = transformedEnvironment.defaultTxObject || {};
const contractData = args[0];
if (typeof contractData !== 'object') {
const noContractError = 'A c... | [
"function",
"buildDeployMethod",
"(",
"baseContracts",
",",
"transformedEnvironment",
",",
"report",
")",
"{",
"return",
"(",
"...",
"args",
")",
"=>",
"{",
"let",
"transactionObject",
"=",
"{",
"}",
";",
"const",
"defaultTxObject",
"=",
"transformedEnvironment",
... | Basic deployer, if not deployed, deploy, else, skip and return instance
@method buildDeployMethod
@param {Array} baseContracts the base contracts on which to compare to see if already deployed
@param {Object} transformedEnvironment the transformed environment
@param {Object} report the reporter method to report newly ... | [
"Basic",
"deployer",
"if",
"not",
"deployed",
"deploy",
"else",
"skip",
"and",
"return",
"instance"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L244-L323 | train |
SilentCicero/ethdeploy | src/lib/index.js | singleEntrySourceMap | function singleEntrySourceMap(entryItem, entryData, sourceMap, callback) { // eslint-disable-line
if (typeof entryItem !== 'string') { return callback(null, sourceMap); }
// get input sources for this entry
getInputSources(entryItem, (inputSourceError, inputSourceMap) => { // eslint-disable-line
if (inputSou... | javascript | function singleEntrySourceMap(entryItem, entryData, sourceMap, callback) { // eslint-disable-line
if (typeof entryItem !== 'string') { return callback(null, sourceMap); }
// get input sources for this entry
getInputSources(entryItem, (inputSourceError, inputSourceMap) => { // eslint-disable-line
if (inputSou... | [
"function",
"singleEntrySourceMap",
"(",
"entryItem",
",",
"entryData",
",",
"sourceMap",
",",
"callback",
")",
"{",
"// eslint-disable-line",
"if",
"(",
"typeof",
"entryItem",
"!==",
"'string'",
")",
"{",
"return",
"callback",
"(",
"null",
",",
"sourceMap",
")"... | Get source map for a single config object entry path.
@method singleEntrySourceMap
@param {String} entryItem the entry item string, generally a file or dir path
@param {Array} entryData the entry data
@param {Object} sourceMap the source map
@callback {Function} callback the callback | [
"Get",
"source",
"map",
"for",
"a",
"single",
"config",
"object",
"entry",
"path",
"."
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L334-L350 | train |
SilentCicero/ethdeploy | src/lib/index.js | entrySourceMap | function entrySourceMap(entry, callback) {
const entryData = typeof entry === 'string' ? [entry] : entry;
// get source map
singleEntrySourceMap(entryData[0], entryData, {}, callback);
} | javascript | function entrySourceMap(entry, callback) {
const entryData = typeof entry === 'string' ? [entry] : entry;
// get source map
singleEntrySourceMap(entryData[0], entryData, {}, callback);
} | [
"function",
"entrySourceMap",
"(",
"entry",
",",
"callback",
")",
"{",
"const",
"entryData",
"=",
"typeof",
"entry",
"===",
"'string'",
"?",
"[",
"entry",
"]",
":",
"entry",
";",
"// get source map",
"singleEntrySourceMap",
"(",
"entryData",
"[",
"0",
"]",
"... | Build complete file source map of all entry items from the config.entry.
@method entrySourceMap
@param {Array|String} entry the entry object
@param {Function} callback the callback that will return the source map
@callback {Object} sourceMap the source map object with all files/dirs in entry | [
"Build",
"complete",
"file",
"source",
"map",
"of",
"all",
"entry",
"items",
"from",
"the",
"config",
".",
"entry",
"."
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/lib/index.js#L360-L365 | train |
jsonmaur/node-crypto-extra | src/encryption.js | constantTimeCompare | function constantTimeCompare (val1, val2) {
let sentinel
if (val1.length !== val2.length) return false
for (let i = 0, len = val1.length; i < len; i++) {
sentinel |= val1.charCodeAt(i) ^ val2.charCodeAt(i)
}
return sentinel === 0
} | javascript | function constantTimeCompare (val1, val2) {
let sentinel
if (val1.length !== val2.length) return false
for (let i = 0, len = val1.length; i < len; i++) {
sentinel |= val1.charCodeAt(i) ^ val2.charCodeAt(i)
}
return sentinel === 0
} | [
"function",
"constantTimeCompare",
"(",
"val1",
",",
"val2",
")",
"{",
"let",
"sentinel",
"if",
"(",
"val1",
".",
"length",
"!==",
"val2",
".",
"length",
")",
"return",
"false",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"len",
"=",
"val1",
".",
"length"... | Ensures the encrypted payload has not been tampered with.
@param {string} val1 - Hash to compare
@param {string} val2 - Hash to compare to
@return {boolean} Whether it is valid | [
"Ensures",
"the",
"encrypted",
"payload",
"has",
"not",
"been",
"tampered",
"with",
"."
] | 43f73dd892e1ffcb38e0be4fe387a8da2695c986 | https://github.com/jsonmaur/node-crypto-extra/blob/43f73dd892e1ffcb38e0be4fe387a8da2695c986/src/encryption.js#L83-L93 | train |
mrzmmr/remark-extract-frontmatter | index.js | settings | function settings (options) {
var parsers
var throws
var name
if (options && typeof options === 'function') {
options = { yaml: options }
}
if (options && typeof options === 'object' && !Array.isArray(options)) {
throws = options.throws || false
name = options.name || null
delete options.t... | javascript | function settings (options) {
var parsers
var throws
var name
if (options && typeof options === 'function') {
options = { yaml: options }
}
if (options && typeof options === 'object' && !Array.isArray(options)) {
throws = options.throws || false
name = options.name || null
delete options.t... | [
"function",
"settings",
"(",
"options",
")",
"{",
"var",
"parsers",
"var",
"throws",
"var",
"name",
"if",
"(",
"options",
"&&",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"options",
"=",
"{",
"yaml",
":",
"options",
"}",
"}",
"if",
"(",
"optio... | Formats options passed. If options is a function then assume its a yaml
parser. Any keys other than the known options, `name`, `throws` are
assumed to be a parser type and put in `parsers`
options - Object of options, or a function to parse frontmatter
options.throws - Boolean whether to throw when there's an error or... | [
"Formats",
"options",
"passed",
".",
"If",
"options",
"is",
"a",
"function",
"then",
"assume",
"its",
"a",
"yaml",
"parser",
".",
"Any",
"keys",
"other",
"than",
"the",
"known",
"options",
"name",
"throws",
"are",
"assumed",
"to",
"be",
"a",
"parser",
"t... | be3dcba3b371940bacfba2fe1c8f0b47c3397262 | https://github.com/mrzmmr/remark-extract-frontmatter/blob/be3dcba3b371940bacfba2fe1c8f0b47c3397262/index.js#L156-L180 | train |
IonicaBizau/match.js | lib/index.js | Match | function Match(elm, options, data) {
this.ev = new EventEmitter();
this.data = options.data || data;
this.found = {};
this.timestamps = [];
this.flippedPairs = 0;
// [elm, elm]
this.active = [];
this.options = Ul.deepMerge(options, {
autoremove: true
, size: {
... | javascript | function Match(elm, options, data) {
this.ev = new EventEmitter();
this.data = options.data || data;
this.found = {};
this.timestamps = [];
this.flippedPairs = 0;
// [elm, elm]
this.active = [];
this.options = Ul.deepMerge(options, {
autoremove: true
, size: {
... | [
"function",
"Match",
"(",
"elm",
",",
"options",
",",
"data",
")",
"{",
"this",
".",
"ev",
"=",
"new",
"EventEmitter",
"(",
")",
";",
"this",
".",
"data",
"=",
"options",
".",
"data",
"||",
"data",
";",
"this",
".",
"found",
"=",
"{",
"}",
";",
... | Match
Creates a new `Match` instance.
Events you can listen to:
- `deactivate` (HTMLElement): Triggered when the block is deactivated.
- `activate` (HTMLElement): Triggered when the block is activated.
- `pair-flip` (HTMLElement, HTMLElement): After a pair flip.
- `success` (HTMLElement, HTMLElement): When a match is... | [
"Match",
"Creates",
"a",
"new",
"Match",
"instance",
"."
] | 0910530725dc7bc62fac55df6c371e75f9528112 | https://github.com/IonicaBizau/match.js/blob/0910530725dc7bc62fac55df6c371e75f9528112/lib/index.js#L47-L90 | train |
bevacqua/ponyedit | src/ponyedit.js | fix | function fix (html) {
if (self.options.htmlWrap === false) { return html; }
if (html.substr(0,5) !== '<div>') {
html = '<div>' + html + '</div>';
}
return html;
} | javascript | function fix (html) {
if (self.options.htmlWrap === false) { return html; }
if (html.substr(0,5) !== '<div>') {
html = '<div>' + html + '</div>';
}
return html;
} | [
"function",
"fix",
"(",
"html",
")",
"{",
"if",
"(",
"self",
".",
"options",
".",
"htmlWrap",
"===",
"false",
")",
"{",
"return",
"html",
";",
"}",
"if",
"(",
"html",
".",
"substr",
"(",
"0",
",",
"5",
")",
"!==",
"'<div>'",
")",
"{",
"html",
"... | wrap the HTML in a div. | [
"wrap",
"the",
"HTML",
"in",
"a",
"div",
"."
] | f142f70c6933686a088d2ed0e361182f56f77dbb | https://github.com/bevacqua/ponyedit/blob/f142f70c6933686a088d2ed0e361182f56f77dbb/src/ponyedit.js#L216-L223 | train |
bevacqua/ponyedit | src/ponyedit.js | report | function report (property, name, parse) {
var rquotes = /^['"]|['"]$/g;
var inspect = queries[property] || query;
return function () {
var self = this;
var value = inspect.call(self, property);
var ev = 'report.' + name;
if (parse === 'bool') {
... | javascript | function report (property, name, parse) {
var rquotes = /^['"]|['"]$/g;
var inspect = queries[property] || query;
return function () {
var self = this;
var value = inspect.call(self, property);
var ev = 'report.' + name;
if (parse === 'bool') {
... | [
"function",
"report",
"(",
"property",
",",
"name",
",",
"parse",
")",
"{",
"var",
"rquotes",
"=",
"/",
"^['\"]|['\"]$",
"/",
"g",
";",
"var",
"inspect",
"=",
"queries",
"[",
"property",
"]",
"||",
"query",
";",
"return",
"function",
"(",
")",
"{",
"... | property state emission | [
"property",
"state",
"emission"
] | f142f70c6933686a088d2ed0e361182f56f77dbb | https://github.com/bevacqua/ponyedit/blob/f142f70c6933686a088d2ed0e361182f56f77dbb/src/ponyedit.js#L526-L546 | train |
Saunalol/cssbeautify-cli | lib/cssbeautify-cli.js | isValid | function isValid(name, value) {
var tests = {
indent: function (value) {
return (/^(\s*|\d*)$/).test(value);
},
openbrace: function (value) {
return (['end-of-line', 'separate-line']).indexOf(value) !== -1;
},
autosemicolon: function (value) {
... | javascript | function isValid(name, value) {
var tests = {
indent: function (value) {
return (/^(\s*|\d*)$/).test(value);
},
openbrace: function (value) {
return (['end-of-line', 'separate-line']).indexOf(value) !== -1;
},
autosemicolon: function (value) {
... | [
"function",
"isValid",
"(",
"name",
",",
"value",
")",
"{",
"var",
"tests",
"=",
"{",
"indent",
":",
"function",
"(",
"value",
")",
"{",
"return",
"(",
"/",
"^(\\s*|\\d*)$",
"/",
")",
".",
"test",
"(",
"value",
")",
";",
"}",
",",
"openbrace",
":",... | Checks parameter validity
@param {string} name
@param {string} value
@return {Boolean} | [
"Checks",
"parameter",
"validity"
] | 6ecc56073659e82386ed855b02be9ceb2c44340e | https://github.com/Saunalol/cssbeautify-cli/blob/6ecc56073659e82386ed855b02be9ceb2c44340e/lib/cssbeautify-cli.js#L115-L129 | train |
SilentCicero/ethdeploy | src/plugins/index.js | JSONMinifier | function JSONMinifier() {
const self = this;
self.process = ({ output }) => JSON.stringify(JSON.parse(output));
} | javascript | function JSONMinifier() {
const self = this;
self.process = ({ output }) => JSON.stringify(JSON.parse(output));
} | [
"function",
"JSONMinifier",
"(",
")",
"{",
"const",
"self",
"=",
"this",
";",
"self",
".",
"process",
"=",
"(",
"{",
"output",
"}",
")",
"=>",
"JSON",
".",
"stringify",
"(",
"JSON",
".",
"parse",
"(",
"output",
")",
")",
";",
"}"
] | Minifies JSON output
@method JSONMinifier
@param {String} output the final build file produced by ethdeploy
@return {String} parsedOutput parsed output | [
"Minifies",
"JSON",
"output"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/plugins/index.js#L8-L11 | train |
SilentCicero/ethdeploy | src/plugins/index.js | JSONExpander | function JSONExpander() {
const self = this;
self.process = ({ output }) => JSON.stringify(JSON.parse(output), null, 2);
} | javascript | function JSONExpander() {
const self = this;
self.process = ({ output }) => JSON.stringify(JSON.parse(output), null, 2);
} | [
"function",
"JSONExpander",
"(",
")",
"{",
"const",
"self",
"=",
"this",
";",
"self",
".",
"process",
"=",
"(",
"{",
"output",
"}",
")",
"=>",
"JSON",
".",
"stringify",
"(",
"JSON",
".",
"parse",
"(",
"output",
")",
",",
"null",
",",
"2",
")",
";... | Expands JSON output
@method JSONMinifier
@param {String} output the final build file produced by ethdeploy with indents
@return {String} parsedOutput parsed output | [
"Expands",
"JSON",
"output"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/plugins/index.js#L20-L23 | train |
SilentCicero/ethdeploy | src/plugins/index.js | keyFilter | function keyFilter(obj, predicate) {
var result = {}, key; // eslint-disable-line
for (key in obj) { // eslint-disable-line
if (obj[key] && predicate(key)) {
result[key] = obj[key];
}
}
return result;
} | javascript | function keyFilter(obj, predicate) {
var result = {}, key; // eslint-disable-line
for (key in obj) { // eslint-disable-line
if (obj[key] && predicate(key)) {
result[key] = obj[key];
}
}
return result;
} | [
"function",
"keyFilter",
"(",
"obj",
",",
"predicate",
")",
"{",
"var",
"result",
"=",
"{",
"}",
",",
"key",
";",
"// eslint-disable-line",
"for",
"(",
"key",
"in",
"obj",
")",
"{",
"// eslint-disable-line",
"if",
"(",
"obj",
"[",
"key",
"]",
"&&",
"pr... | a basic util filter function | [
"a",
"basic",
"util",
"filter",
"function"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/plugins/index.js#L26-L36 | train |
SilentCicero/ethdeploy | src/plugins/index.js | IncludeContracts | function IncludeContracts(
contractsSelector,
propertyFilter = ['interface', 'bytecode'],
environmentName = 'contracts') {
const self = this;
self.process = ({ output, contracts }) => {
// parse output
const parsedOutput = JSON.parse(output);
// add contracts environment
parsedOutput[environm... | javascript | function IncludeContracts(
contractsSelector,
propertyFilter = ['interface', 'bytecode'],
environmentName = 'contracts') {
const self = this;
self.process = ({ output, contracts }) => {
// parse output
const parsedOutput = JSON.parse(output);
// add contracts environment
parsedOutput[environm... | [
"function",
"IncludeContracts",
"(",
"contractsSelector",
",",
"propertyFilter",
"=",
"[",
"'interface'",
",",
"'bytecode'",
"]",
",",
"environmentName",
"=",
"'contracts'",
")",
"{",
"const",
"self",
"=",
"this",
";",
"self",
".",
"process",
"=",
"(",
"{",
... | This wil include contracts data in the environments output
@method IncludeContracts
@param {Array} contractsSelector contracts to include in a contracts property
@param {Array} propertyFilter if fiter is not truthy, then ignore filtering
@param {String} environmentName environment name is usually contracts
@return {St... | [
"This",
"wil",
"include",
"contracts",
"data",
"in",
"the",
"environments",
"output"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/plugins/index.js#L47-L73 | train |
magne4000/node-libquassel | src/request.js | sync | function sync(className, functionName, ...datatypes) {
const qsync = qtypes.QInt.from(Types.SYNC);
const qclassName = qtypes.QByteArray.from(className);
const qfunctionName = qtypes.QByteArray.from(functionName);
return function(target, _key, descriptor) {
return {
enumerable: false,
configurabl... | javascript | function sync(className, functionName, ...datatypes) {
const qsync = qtypes.QInt.from(Types.SYNC);
const qclassName = qtypes.QByteArray.from(className);
const qfunctionName = qtypes.QByteArray.from(functionName);
return function(target, _key, descriptor) {
return {
enumerable: false,
configurabl... | [
"function",
"sync",
"(",
"className",
",",
"functionName",
",",
"...",
"datatypes",
")",
"{",
"const",
"qsync",
"=",
"qtypes",
".",
"QInt",
".",
"from",
"(",
"Types",
".",
"SYNC",
")",
";",
"const",
"qclassName",
"=",
"qtypes",
".",
"QByteArray",
".",
... | Decorator for SYNC methods
@protected | [
"Decorator",
"for",
"SYNC",
"methods"
] | 0cf97378ebe170b0abf4bdcc112933009a84156f | https://github.com/magne4000/node-libquassel/blob/0cf97378ebe170b0abf4bdcc112933009a84156f/src/request.js#L40-L61 | train |
magne4000/node-libquassel | src/request.js | rpc | function rpc(functionName, ...datatypes) {
const qrpc = qtypes.QInt.from(Types.RPCCALL);
const qfunctionName = qtypes.QByteArray.from(`2${functionName}`);
return function(target, _key, descriptor) {
return {
enumerable: false,
configurable: false,
writable: false,
value: function(...ar... | javascript | function rpc(functionName, ...datatypes) {
const qrpc = qtypes.QInt.from(Types.RPCCALL);
const qfunctionName = qtypes.QByteArray.from(`2${functionName}`);
return function(target, _key, descriptor) {
return {
enumerable: false,
configurable: false,
writable: false,
value: function(...ar... | [
"function",
"rpc",
"(",
"functionName",
",",
"...",
"datatypes",
")",
"{",
"const",
"qrpc",
"=",
"qtypes",
".",
"QInt",
".",
"from",
"(",
"Types",
".",
"RPCCALL",
")",
";",
"const",
"qfunctionName",
"=",
"qtypes",
".",
"QByteArray",
".",
"from",
"(",
"... | Decorator for RPC methods
@protected | [
"Decorator",
"for",
"RPC",
"methods"
] | 0cf97378ebe170b0abf4bdcc112933009a84156f | https://github.com/magne4000/node-libquassel/blob/0cf97378ebe170b0abf4bdcc112933009a84156f/src/request.js#L67-L85 | train |
dpjanes/iotdb-homestar | static/flat-ui/js/flat-ui.js | simulateMouseEvent | function simulateMouseEvent (event, simulatedType) {
// Ignore multi-touch events
if (event.originalEvent.touches.length > 1) {
return;
}
event.preventDefault();
var touch = event.originalEvent.changedTouches[0],
simulatedEvent = document.createEvent('MouseEvents');
... | javascript | function simulateMouseEvent (event, simulatedType) {
// Ignore multi-touch events
if (event.originalEvent.touches.length > 1) {
return;
}
event.preventDefault();
var touch = event.originalEvent.changedTouches[0],
simulatedEvent = document.createEvent('MouseEvents');
... | [
"function",
"simulateMouseEvent",
"(",
"event",
",",
"simulatedType",
")",
"{",
"// Ignore multi-touch events\r",
"if",
"(",
"event",
".",
"originalEvent",
".",
"touches",
".",
"length",
">",
"1",
")",
"{",
"return",
";",
"}",
"event",
".",
"preventDefault",
"... | Simulate a mouse event based on a corresponding touch event
@param {Object} event A touch event
@param {String} simulatedType The corresponding mouse event | [
"Simulate",
"a",
"mouse",
"event",
"based",
"on",
"a",
"corresponding",
"touch",
"event"
] | ed6535aa17c8b0538f43a876c9a6025e26a389e3 | https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/static/flat-ui/js/flat-ui.js#L3912-L3945 | train |
dpjanes/iotdb-homestar | static/flat-ui/js/flat-ui.js | evaluate | function evaluate(val, context) {
if ($.isFunction(val)) {
var args = Array.prototype.slice.call(arguments, 2);
return val.apply(context, args);
}
return val;
} | javascript | function evaluate(val, context) {
if ($.isFunction(val)) {
var args = Array.prototype.slice.call(arguments, 2);
return val.apply(context, args);
}
return val;
} | [
"function",
"evaluate",
"(",
"val",
",",
"context",
")",
"{",
"if",
"(",
"$",
".",
"isFunction",
"(",
"val",
")",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"2",
")",
";",
"return",
... | Returns a given value
If given a function, returns its output
@param val string|function
@param context value of "this" to be passed to function
@returns {*} | [
"Returns",
"a",
"given",
"value",
"If",
"given",
"a",
"function",
"returns",
"its",
"output"
] | ed6535aa17c8b0538f43a876c9a6025e26a389e3 | https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/static/flat-ui/js/flat-ui.js#L9680-L9686 | train |
dpjanes/iotdb-homestar | static/flat-ui/js/flat-ui.js | function (details) {
details = details || {};
details= $.extend({}, details, { type: "change", val: this.val() });
// prevents recursive triggering
this.opts.element.data("select2-change-triggered", true);
this.opts.element.trigger(details);
this.... | javascript | function (details) {
details = details || {};
details= $.extend({}, details, { type: "change", val: this.val() });
// prevents recursive triggering
this.opts.element.data("select2-change-triggered", true);
this.opts.element.trigger(details);
this.... | [
"function",
"(",
"details",
")",
"{",
"details",
"=",
"details",
"||",
"{",
"}",
";",
"details",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"details",
",",
"{",
"type",
":",
"\"change\"",
",",
"val",
":",
"this",
".",
"val",
"(",
")",
"}",
")... | Triggers the change event on the source element
abstract | [
"Triggers",
"the",
"change",
"event",
"on",
"the",
"source",
"element",
"abstract"
] | ed6535aa17c8b0538f43a876c9a6025e26a389e3 | https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/static/flat-ui/js/flat-ui.js#L10255-L10272 | train | |
dpjanes/iotdb-homestar | static/flat-ui/js/flat-ui.js | function () {
if (!this.shouldOpen()) return false;
this.opening();
// Only bind the document mousemove when the dropdown is visible
$document.on("mousemove.select2Event", function (e) {
lastMousePosition.x = e.pageX;
lastMousePosition.y... | javascript | function () {
if (!this.shouldOpen()) return false;
this.opening();
// Only bind the document mousemove when the dropdown is visible
$document.on("mousemove.select2Event", function (e) {
lastMousePosition.x = e.pageX;
lastMousePosition.y... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"shouldOpen",
"(",
")",
")",
"return",
"false",
";",
"this",
".",
"opening",
"(",
")",
";",
"// Only bind the document mousemove when the dropdown is visible",
"$document",
".",
"on",
"(",
"\"mousemove.sele... | Opens the dropdown
@return {Boolean} whether or not dropdown was opened. This method will return false if, for example,
the dropdown is already open, or if the 'open' event listener on the element called preventDefault().
abstract | [
"Opens",
"the",
"dropdown"
] | ed6535aa17c8b0538f43a876c9a6025e26a389e3 | https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/static/flat-ui/js/flat-ui.js#L10460-L10473 | train | |
dpjanes/iotdb-homestar | static/flat-ui/js/flat-ui.js | function () {
var selected;
if (this.isPlaceholderOptionSelected()) {
this.updateSelection(null);
this.close();
this.setPlaceholder();
} else {
var self = this;
this.opts.initSelection.call(null, this.opt... | javascript | function () {
var selected;
if (this.isPlaceholderOptionSelected()) {
this.updateSelection(null);
this.close();
this.setPlaceholder();
} else {
var self = this;
this.opts.initSelection.call(null, this.opt... | [
"function",
"(",
")",
"{",
"var",
"selected",
";",
"if",
"(",
"this",
".",
"isPlaceholderOptionSelected",
"(",
")",
")",
"{",
"this",
".",
"updateSelection",
"(",
"null",
")",
";",
"this",
".",
"close",
"(",
")",
";",
"this",
".",
"setPlaceholder",
"("... | Sets selection based on source element's value
single | [
"Sets",
"selection",
"based",
"on",
"source",
"element",
"s",
"value",
"single"
] | ed6535aa17c8b0538f43a876c9a6025e26a389e3 | https://github.com/dpjanes/iotdb-homestar/blob/ed6535aa17c8b0538f43a876c9a6025e26a389e3/static/flat-ui/js/flat-ui.js#L11389-L11406 | train | |
SilentCicero/ethdeploy | src/utils/index.js | bnToString | function bnToString(objInput, baseInput, hexPrefixed) {
var obj = objInput; // eslint-disable-line
const base = baseInput || 10;
// obj is an array
if (typeof obj === 'object' && obj !== null) {
if (Array.isArray(obj)) {
// convert items in array
obj = obj.map((item) => bnToString(item, base, h... | javascript | function bnToString(objInput, baseInput, hexPrefixed) {
var obj = objInput; // eslint-disable-line
const base = baseInput || 10;
// obj is an array
if (typeof obj === 'object' && obj !== null) {
if (Array.isArray(obj)) {
// convert items in array
obj = obj.map((item) => bnToString(item, base, h... | [
"function",
"bnToString",
"(",
"objInput",
",",
"baseInput",
",",
"hexPrefixed",
")",
"{",
"var",
"obj",
"=",
"objInput",
";",
"// eslint-disable-line",
"const",
"base",
"=",
"baseInput",
"||",
"10",
";",
"// obj is an array",
"if",
"(",
"typeof",
"obj",
"==="... | recursively converts all BN or BigNumber instances into string
Converts all BigNumber and BN instances to string, even nested deep in Arrays or Objects.
@method bnToString
@param {Optional} objInput optional input type, bypasses most
@param {Number} baseInput the base number (usually either 10 or 16).
@param {Boolean... | [
"recursively",
"converts",
"all",
"BN",
"or",
"BigNumber",
"instances",
"into",
"string",
"Converts",
"all",
"BigNumber",
"and",
"BN",
"instances",
"to",
"string",
"even",
"nested",
"deep",
"in",
"Arrays",
"or",
"Objects",
"."
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/utils/index.js#L49-L71 | train |
SilentCicero/ethdeploy | src/utils/index.js | filterSourceMap | function filterSourceMap(testRegex, includeRegex, sourceMap, excludeRegex) {
const outputData = Object.assign({});
const testTestRegex = testRegex || /./g;
const testIncludeRegex = includeRegex || null;
const testExcludeRegex = excludeRegex || null;
if (typeof testTestRegex !== 'object') { throw error(`while... | javascript | function filterSourceMap(testRegex, includeRegex, sourceMap, excludeRegex) {
const outputData = Object.assign({});
const testTestRegex = testRegex || /./g;
const testIncludeRegex = includeRegex || null;
const testExcludeRegex = excludeRegex || null;
if (typeof testTestRegex !== 'object') { throw error(`while... | [
"function",
"filterSourceMap",
"(",
"testRegex",
",",
"includeRegex",
",",
"sourceMap",
",",
"excludeRegex",
")",
"{",
"const",
"outputData",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
")",
";",
"const",
"testTestRegex",
"=",
"testRegex",
"||",
"/",
".",
... | Filters a given sourcemap by specific test regex's.
@method filterSourceMap
@param {Regex} testRegex the test regex (only include these files)
@param {Regex} includeRegex the include test regex (only include these files)
@param {Object} sourceMap the complete file sourcemap
@return {Object} filteredSourceMap the filte... | [
"Filters",
"a",
"given",
"sourcemap",
"by",
"specific",
"test",
"regex",
"s",
"."
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/utils/index.js#L103-L122 | train |
SilentCicero/ethdeploy | src/utils/index.js | getTransactionSuccess | function getTransactionSuccess(eth, txHash, timeout = 800000, callback) {
const cb = callback || function cb() {};
let count = 0;
return new Promise((resolve, reject) => {
const txInterval = setInterval(() => {
eth.getTransactionReceipt(txHash, (err, result) => {
if (err) {
clearInterv... | javascript | function getTransactionSuccess(eth, txHash, timeout = 800000, callback) {
const cb = callback || function cb() {};
let count = 0;
return new Promise((resolve, reject) => {
const txInterval = setInterval(() => {
eth.getTransactionReceipt(txHash, (err, result) => {
if (err) {
clearInterv... | [
"function",
"getTransactionSuccess",
"(",
"eth",
",",
"txHash",
",",
"timeout",
"=",
"800000",
",",
"callback",
")",
"{",
"const",
"cb",
"=",
"callback",
"||",
"function",
"cb",
"(",
")",
"{",
"}",
";",
"let",
"count",
"=",
"0",
";",
"return",
"new",
... | This will wait for a transaction to present a receipt
@method getTransactionSuccess
@param {Object} eth the eth query instance
@param {Object} txHash the transaction hash
@param {Object} timeout settings
@param {Function} callback the final callback
@callback {Object} contractInstance the deployed contract instance wi... | [
"This",
"will",
"wait",
"for",
"a",
"transaction",
"to",
"present",
"a",
"receipt"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/utils/index.js#L135-L163 | train |
SilentCicero/ethdeploy | src/utils/index.js | deployContract | function deployContract(eth, factory, args, callback) {
factory.new.apply(factory, args).then((txHash) => {
getTransactionSuccess(eth, txHash, 8000000, (receiptError, receipt) => {
if (receiptError) {
callback(receiptError, null);
}
if (receipt) {
const contractInstance = factor... | javascript | function deployContract(eth, factory, args, callback) {
factory.new.apply(factory, args).then((txHash) => {
getTransactionSuccess(eth, txHash, 8000000, (receiptError, receipt) => {
if (receiptError) {
callback(receiptError, null);
}
if (receipt) {
const contractInstance = factor... | [
"function",
"deployContract",
"(",
"eth",
",",
"factory",
",",
"args",
",",
"callback",
")",
"{",
"factory",
".",
"new",
".",
"apply",
"(",
"factory",
",",
"args",
")",
".",
"then",
"(",
"(",
"txHash",
")",
"=>",
"{",
"getTransactionSuccess",
"(",
"eth... | Deploy the contract with eth, factory, and args
@method deployContract
@param {Object} eth the eth query instance
@param {Object} factory the contract factory
@param {Array} args the contract constructor arguments
@param {Function} callback the final callback
@callback {Object} contractInstance the deployed contract i... | [
"Deploy",
"the",
"contract",
"with",
"eth",
"factory",
"and",
"args"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/utils/index.js#L175-L189 | train |
SilentCicero/ethdeploy | src/utils/index.js | getInputSources | function getInputSources(pathname, callback) {
let filesRead = 0;
let sources = {};
// test file is a file, the last section contains a extention period
if (String(pathname).split('/').pop().indexOf('.') !== -1) {
const searchPathname = pathname.substr(0, 2) === './' ? pathname.slice(2) : pathname;
fs... | javascript | function getInputSources(pathname, callback) {
let filesRead = 0;
let sources = {};
// test file is a file, the last section contains a extention period
if (String(pathname).split('/').pop().indexOf('.') !== -1) {
const searchPathname = pathname.substr(0, 2) === './' ? pathname.slice(2) : pathname;
fs... | [
"function",
"getInputSources",
"(",
"pathname",
",",
"callback",
")",
"{",
"let",
"filesRead",
"=",
"0",
";",
"let",
"sources",
"=",
"{",
"}",
";",
"// test file is a file, the last section contains a extention period",
"if",
"(",
"String",
"(",
"pathname",
")",
"... | Get all input source for a specific pathname, used for mapping config entry
@method getInputSources
@param {String} pathname a path string to a file or directory
@param {Function} callback the final callback that returns the sources
@callback {Object} sourceMap returns a source map for this pathname | [
"Get",
"all",
"input",
"source",
"for",
"a",
"specific",
"pathname",
"used",
"for",
"mapping",
"config",
"entry"
] | acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6 | https://github.com/SilentCicero/ethdeploy/blob/acb1212e1942ce604eb82e34ce2f8c9d6b20a0a6/src/utils/index.js#L199-L249 | train |
gwtw/js-binomial-heap | index.js | mergeHeaps | function mergeHeaps(a, b) {
if (typeof a.head === 'undefined') {
return b.head;
}
if (typeof b.head === 'undefined') {
return a.head;
}
var head;
var aNext = a.head;
var bNext = b.head;
if (a.head.degree <= b.head.degree) {
head = a.head;
aNext = aNext.sibling;
} else {
head = b.... | javascript | function mergeHeaps(a, b) {
if (typeof a.head === 'undefined') {
return b.head;
}
if (typeof b.head === 'undefined') {
return a.head;
}
var head;
var aNext = a.head;
var bNext = b.head;
if (a.head.degree <= b.head.degree) {
head = a.head;
aNext = aNext.sibling;
} else {
head = b.... | [
"function",
"mergeHeaps",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"typeof",
"a",
".",
"head",
"===",
"'undefined'",
")",
"{",
"return",
"b",
".",
"head",
";",
"}",
"if",
"(",
"typeof",
"b",
".",
"head",
"===",
"'undefined'",
")",
"{",
"return",
... | Merges two heaps together.
@private
@param {Node} a The head of the first heap to merge.
@param {Node} b The head of the second heap to merge.
@return {Node} The head of the merged heap. | [
"Merges",
"two",
"heaps",
"together",
"."
] | 75af9ee02d0089fdbaa54a2c5aa0bc6eb1d059b3 | https://github.com/gwtw/js-binomial-heap/blob/75af9ee02d0089fdbaa54a2c5aa0bc6eb1d059b3/index.js#L184-L221 | train |
gwtw/js-binomial-heap | index.js | Node | function Node(key, value) {
this.key = key;
this.value = value;
this.degree = 0;
this.parent = undefined;
this.child = undefined;
this.sibling = undefined;
} | javascript | function Node(key, value) {
this.key = key;
this.value = value;
this.degree = 0;
this.parent = undefined;
this.child = undefined;
this.sibling = undefined;
} | [
"function",
"Node",
"(",
"key",
",",
"value",
")",
"{",
"this",
".",
"key",
"=",
"key",
";",
"this",
".",
"value",
"=",
"value",
";",
"this",
".",
"degree",
"=",
"0",
";",
"this",
".",
"parent",
"=",
"undefined",
";",
"this",
".",
"child",
"=",
... | Creates a Binomial Heap node.
@constructor
@param {Object} key The key of the new node.
@param {Object} value The value of the new node. | [
"Creates",
"a",
"Binomial",
"Heap",
"node",
"."
] | 75af9ee02d0089fdbaa54a2c5aa0bc6eb1d059b3 | https://github.com/gwtw/js-binomial-heap/blob/75af9ee02d0089fdbaa54a2c5aa0bc6eb1d059b3/index.js#L275-L282 | train |
petarov/translitbg.js | src/translitbg.js | function() {
var result = new StringBuffer();
var array = this._input.split('');
// var prev = null;
for (var i = 0; i < array.length; i++) {
var cur = array[i];
var next = array[i + 1];
if (typeof next !== 'undefined') {
var curToken = cur + next;
... | javascript | function() {
var result = new StringBuffer();
var array = this._input.split('');
// var prev = null;
for (var i = 0; i < array.length; i++) {
var cur = array[i];
var next = array[i + 1];
if (typeof next !== 'undefined') {
var curToken = cur + next;
... | [
"function",
"(",
")",
"{",
"var",
"result",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"var",
"array",
"=",
"this",
".",
"_input",
".",
"split",
"(",
"''",
")",
";",
"// var prev = null;\r",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array",... | Transforms Cyrillic to Latin characters.
@return {string} Transliterated text | [
"Transforms",
"Cyrillic",
"to",
"Latin",
"characters",
"."
] | 003e81703efd098ae0ea4bb711d1e70c9aa989db | https://github.com/petarov/translitbg.js/blob/003e81703efd098ae0ea4bb711d1e70c9aa989db/src/translitbg.js#L153-L185 | train | |
toddself/jsondom | index.js | _regExpOrGTFO | function _regExpOrGTFO(expr){
var exp;
if(typeof expr === 'string'){
exp = new RegExp('^'+expr+'$');
} else if (expr instanceof RegExp){
exp = expr;
} else {
throw new Error('Needle must be either a string or a RegExp');
}
return exp;
} | javascript | function _regExpOrGTFO(expr){
var exp;
if(typeof expr === 'string'){
exp = new RegExp('^'+expr+'$');
} else if (expr instanceof RegExp){
exp = expr;
} else {
throw new Error('Needle must be either a string or a RegExp');
}
return exp;
} | [
"function",
"_regExpOrGTFO",
"(",
"expr",
")",
"{",
"var",
"exp",
";",
"if",
"(",
"typeof",
"expr",
"===",
"'string'",
")",
"{",
"exp",
"=",
"new",
"RegExp",
"(",
"'^'",
"+",
"expr",
"+",
"'$'",
")",
";",
"}",
"else",
"if",
"(",
"expr",
"instanceof... | Cohearses `expr` into a RegExp or throws an error if it can't
@private
@param {Mixed} expr RegExp or string.
@return {Object} Strict Regular Expression version of string | [
"Cohearses",
"expr",
"into",
"a",
"RegExp",
"or",
"throws",
"an",
"error",
"if",
"it",
"can",
"t"
] | d71d3ce355ab9a925bdf7a4754642e45c9678282 | https://github.com/toddself/jsondom/blob/d71d3ce355ab9a925bdf7a4754642e45c9678282/index.js#L33-L45 | train |
3rd-Eden/shrinkwrap | index.js | Shrinkwrap | function Shrinkwrap(options) {
this.fuse();
options = options || {};
options.registry = 'registry' in options
? options.registry
: 'http://registry.nodejitsu.com/';
options.production = 'production' in options
? options.production
: process.NODE_ENV === 'production';
options.optimize = 'op... | javascript | function Shrinkwrap(options) {
this.fuse();
options = options || {};
options.registry = 'registry' in options
? options.registry
: 'http://registry.nodejitsu.com/';
options.production = 'production' in options
? options.production
: process.NODE_ENV === 'production';
options.optimize = 'op... | [
"function",
"Shrinkwrap",
"(",
"options",
")",
"{",
"this",
".",
"fuse",
"(",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"registry",
"=",
"'registry'",
"in",
"options",
"?",
"options",
".",
"registry",
":",
"'http://registr... | Generate a new Shrinkwrap from a given package or module.
Options:
- registry: URL of the npm registry we should use to read package information.
- production: Should we only include production packages.
- limit: Amount of parallel processing tasks we could use to retrieve data.
- optimize: Should we attempt to optim... | [
"Generate",
"a",
"new",
"Shrinkwrap",
"from",
"a",
"given",
"package",
"or",
"module",
"."
] | 60e0004e4092896e9ba6bd0d83bdc22a973812da | https://github.com/3rd-Eden/shrinkwrap/blob/60e0004e4092896e9ba6bd0d83bdc22a973812da/index.js#L43-L79 | train |
3rd-Eden/shrinkwrap | index.js | queue | function queue(packages, ref, depth) {
packages = shrinkwrap.dedupe(packages);
Shrinkwrap.dependencies.forEach(function each(key) {
if (this.production && 'devDependencies' === key) return;
if ('object' !== this.type(packages[key])) return;
Object.keys(packages[key]).forEach(function each(na... | javascript | function queue(packages, ref, depth) {
packages = shrinkwrap.dedupe(packages);
Shrinkwrap.dependencies.forEach(function each(key) {
if (this.production && 'devDependencies' === key) return;
if ('object' !== this.type(packages[key])) return;
Object.keys(packages[key]).forEach(function each(na... | [
"function",
"queue",
"(",
"packages",
",",
"ref",
",",
"depth",
")",
"{",
"packages",
"=",
"shrinkwrap",
".",
"dedupe",
"(",
"packages",
")",
";",
"Shrinkwrap",
".",
"dependencies",
".",
"forEach",
"(",
"function",
"each",
"(",
"key",
")",
"{",
"if",
"... | Scan the given package.json like structure for possible dependency
locations which will be automatically queued for fetching and processing.
@param {Object} packages The packages.json body.
@param {Object} ref The location of the new packages in the tree.
@param {Number} depth How deep was this package nested
@api pri... | [
"Scan",
"the",
"given",
"package",
".",
"json",
"like",
"structure",
"for",
"possible",
"dependency",
"locations",
"which",
"will",
"be",
"automatically",
"queued",
"for",
"fetching",
"and",
"processing",
"."
] | 60e0004e4092896e9ba6bd0d83bdc22a973812da | https://github.com/3rd-Eden/shrinkwrap/blob/60e0004e4092896e9ba6bd0d83bdc22a973812da/index.js#L139-L162 | train |
3rd-Eden/shrinkwrap | index.js | parent | function parent(dependent) {
var node = dependent
, result = [];
while (node.parent) {
if (!available(node.parent)) break;
result.push(node.parent);
node = node.parent;
}
return result;
} | javascript | function parent(dependent) {
var node = dependent
, result = [];
while (node.parent) {
if (!available(node.parent)) break;
result.push(node.parent);
node = node.parent;
}
return result;
} | [
"function",
"parent",
"(",
"dependent",
")",
"{",
"var",
"node",
"=",
"dependent",
",",
"result",
"=",
"[",
"]",
";",
"while",
"(",
"node",
".",
"parent",
")",
"{",
"if",
"(",
"!",
"available",
"(",
"node",
".",
"parent",
")",
")",
"break",
";",
... | Find suitable parent nodes which can hold this module without creating
a possible conflict because there two different versions of the module in
the dependency tree.
@param {Object} dependent A dependent of a module.
@returns {Array} parents.
@api private | [
"Find",
"suitable",
"parent",
"nodes",
"which",
"can",
"hold",
"this",
"module",
"without",
"creating",
"a",
"possible",
"conflict",
"because",
"there",
"two",
"different",
"versions",
"of",
"the",
"module",
"in",
"the",
"dependency",
"tree",
"."
] | 60e0004e4092896e9ba6bd0d83bdc22a973812da | https://github.com/3rd-Eden/shrinkwrap/blob/60e0004e4092896e9ba6bd0d83bdc22a973812da/index.js#L384-L396 | train |
3rd-Eden/shrinkwrap | index.js | available | function available(dependencies) {
if (!dependencies) return false;
return Object.keys(dependencies).every(function every(key) {
var dependency = dependencies[key];
if (!dependency) return false;
if (dependency.name !== name) return true;
if (dependency.version === version) return tru... | javascript | function available(dependencies) {
if (!dependencies) return false;
return Object.keys(dependencies).every(function every(key) {
var dependency = dependencies[key];
if (!dependency) return false;
if (dependency.name !== name) return true;
if (dependency.version === version) return tru... | [
"function",
"available",
"(",
"dependencies",
")",
"{",
"if",
"(",
"!",
"dependencies",
")",
"return",
"false",
";",
"return",
"Object",
".",
"keys",
"(",
"dependencies",
")",
".",
"every",
"(",
"function",
"every",
"(",
"key",
")",
"{",
"var",
"dependen... | Checks if the dependency tree does not already contain a different version
of this module.
@param {Object} dependencies The dependencies of a module.
@returns {Boolean} Available as module location.
@api private | [
"Checks",
"if",
"the",
"dependency",
"tree",
"does",
"not",
"already",
"contain",
"a",
"different",
"version",
"of",
"this",
"module",
"."
] | 60e0004e4092896e9ba6bd0d83bdc22a973812da | https://github.com/3rd-Eden/shrinkwrap/blob/60e0004e4092896e9ba6bd0d83bdc22a973812da/index.js#L406-L419 | train |
oscmejia/libs | lib/libs/string.js | randomString | function randomString(_string_length, _mode) {
var string_length = _string_length;
if(string_length < 3)
string_length = 2;
var chars = chars_all;
if(_mode === 'lower_case') chars = chars_lower;
else if(_mode === 'upper_case') chars = chars_upper;
else if(_mode === 'nums_oly'... | javascript | function randomString(_string_length, _mode) {
var string_length = _string_length;
if(string_length < 3)
string_length = 2;
var chars = chars_all;
if(_mode === 'lower_case') chars = chars_lower;
else if(_mode === 'upper_case') chars = chars_upper;
else if(_mode === 'nums_oly'... | [
"function",
"randomString",
"(",
"_string_length",
",",
"_mode",
")",
"{",
"var",
"string_length",
"=",
"_string_length",
";",
"if",
"(",
"string_length",
"<",
"3",
")",
"string_length",
"=",
"2",
";",
"var",
"chars",
"=",
"chars_all",
";",
"if",
"(",
"_mo... | Generates a random string of the provided length, and including only
the required characters.
@param {int} _string_length
@param {String} _mode
@api public | [
"Generates",
"a",
"random",
"string",
"of",
"the",
"provided",
"length",
"and",
"including",
"only",
"the",
"required",
"characters",
"."
] | 81f8654af6ee922963e6cc3f6cda96ffa75142cf | https://github.com/oscmejia/libs/blob/81f8654af6ee922963e6cc3f6cda96ffa75142cf/lib/libs/string.js#L15-L35 | train |
oscmejia/libs | lib/libs/string.js | randomKey | function randomKey(_numOfBlocks, _blockLength, _mode, _timestamp) {
var numOfBlocks = _numOfBlocks;
var blockLength = _blockLength;
if(numOfBlocks === undefined || numOfBlocks < 3) numOfBlocks = 2;
if(blockLength === undefined || blockLength < 3) blockLength = 2;
var key = "";
for (var ... | javascript | function randomKey(_numOfBlocks, _blockLength, _mode, _timestamp) {
var numOfBlocks = _numOfBlocks;
var blockLength = _blockLength;
if(numOfBlocks === undefined || numOfBlocks < 3) numOfBlocks = 2;
if(blockLength === undefined || blockLength < 3) blockLength = 2;
var key = "";
for (var ... | [
"function",
"randomKey",
"(",
"_numOfBlocks",
",",
"_blockLength",
",",
"_mode",
",",
"_timestamp",
")",
"{",
"var",
"numOfBlocks",
"=",
"_numOfBlocks",
";",
"var",
"blockLength",
"=",
"_blockLength",
";",
"if",
"(",
"numOfBlocks",
"===",
"undefined",
"||",
"n... | Generates a random key of the provided length, and including only
the required characters.
A key is separated by `-`.
Also has the option to timestamp the resulting string at the begining.
@param {int} _numOfBlocks
@param {int} _blockLength
@param {String} _mode
@param {Boolean} _timestamp
@api public | [
"Generates",
"a",
"random",
"key",
"of",
"the",
"provided",
"length",
"and",
"including",
"only",
"the",
"required",
"characters",
".",
"A",
"key",
"is",
"separated",
"by",
"-",
".",
"Also",
"has",
"the",
"option",
"to",
"timestamp",
"the",
"resulting",
"s... | 81f8654af6ee922963e6cc3f6cda96ffa75142cf | https://github.com/oscmejia/libs/blob/81f8654af6ee922963e6cc3f6cda96ffa75142cf/lib/libs/string.js#L50-L70 | train |
jiridudekusy/uu5-to-markdown | src/converters/md2uu5/section.js | section | function section(state, startLine, endLine, silent) {
var ch,
level,
tmp,
pos = state.bMarks[startLine] + state.tShift[startLine],
max = state.eMarks[startLine];
if (pos >= max) {
return false;
}
ch = state.src.charCodeAt(pos);
if (ch !== 0x23 /* # */ || pos >= max) {
return false;
... | javascript | function section(state, startLine, endLine, silent) {
var ch,
level,
tmp,
pos = state.bMarks[startLine] + state.tShift[startLine],
max = state.eMarks[startLine];
if (pos >= max) {
return false;
}
ch = state.src.charCodeAt(pos);
if (ch !== 0x23 /* # */ || pos >= max) {
return false;
... | [
"function",
"section",
"(",
"state",
",",
"startLine",
",",
"endLine",
",",
"silent",
")",
"{",
"var",
"ch",
",",
"level",
",",
"tmp",
",",
"pos",
"=",
"state",
".",
"bMarks",
"[",
"startLine",
"]",
"+",
"state",
".",
"tShift",
"[",
"startLine",
"]",... | Block parser for UU5.Bricks.Section .
The section is defined similar to the header:
# {section} Section title
...section content...
{section}
@param state
@param startLine
@param endLine
@param silent
@returns {boolean} | [
"Block",
"parser",
"for",
"UU5",
".",
"Bricks",
".",
"Section",
"."
] | 559163aa8a4184e1a94888c4fc6d4302acbd857d | https://github.com/jiridudekusy/uu5-to-markdown/blob/559163aa8a4184e1a94888c4fc6d4302acbd857d/src/converters/md2uu5/section.js#L20-L121 | train |
Heymdall/cron-to-text | src/cron-to-text.js | numberToDateName | function numberToDateName(value, type) {
if (type == 'dow') {
return locale.DOW[value - 1];
} else if (type == 'mon') {
return locale.MONTH[value - 1];
}
} | javascript | function numberToDateName(value, type) {
if (type == 'dow') {
return locale.DOW[value - 1];
} else if (type == 'mon') {
return locale.MONTH[value - 1];
}
} | [
"function",
"numberToDateName",
"(",
"value",
",",
"type",
")",
"{",
"if",
"(",
"type",
"==",
"'dow'",
")",
"{",
"return",
"locale",
".",
"DOW",
"[",
"value",
"-",
"1",
"]",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"'mon'",
")",
"{",
"return",
... | Parse a number into day of week, or a month name;
used in dateList below.
@param {Number|String} value
@param {String} type
@returns {String} | [
"Parse",
"a",
"number",
"into",
"day",
"of",
"week",
"or",
"a",
"month",
"name",
";",
"used",
"in",
"dateList",
"below",
"."
] | a6a0ae74a4b98bb951a4ae0fa68778a3c7ab9978 | https://github.com/Heymdall/cron-to-text/blob/a6a0ae74a4b98bb951a4ae0fa68778a3c7ab9978/src/cron-to-text.js#L108-L114 | train |
VisionistInc/jibe | public/js/share-codemirror-json.js | applyToShareJS | function applyToShareJS(cm, change) {
// CodeMirror changes give a text replacement.
var startPos = 0; // Get character position from # of chars in each line.
var i = 0; // i goes through all lines.
while (i < change.from.line) {
startPos += cm.lineInfo(i).text.length + 1; ... | javascript | function applyToShareJS(cm, change) {
// CodeMirror changes give a text replacement.
var startPos = 0; // Get character position from # of chars in each line.
var i = 0; // i goes through all lines.
while (i < change.from.line) {
startPos += cm.lineInfo(i).text.length + 1; ... | [
"function",
"applyToShareJS",
"(",
"cm",
",",
"change",
")",
"{",
"// CodeMirror changes give a text replacement.",
"var",
"startPos",
"=",
"0",
";",
"// Get character position from # of chars in each line.",
"var",
"i",
"=",
"0",
";",
"// i goes through all lines.",
"while... | Convert a CodeMirror change into an op understood by share.js | [
"Convert",
"a",
"CodeMirror",
"change",
"into",
"an",
"op",
"understood",
"by",
"share",
".",
"js"
] | 3a154c0d86a3bcf8980c5104daec099ec738a4e0 | https://github.com/VisionistInc/jibe/blob/3a154c0d86a3bcf8980c5104daec099ec738a4e0/public/js/share-codemirror-json.js#L101-L236 | train |
quorrajs/Positron | lib/foundation/start.js | start | function start(CB, env) {
var app = this;
/*
|--------------------------------------------------------------------------
| Register The Environment Variables
|--------------------------------------------------------------------------
|
| Here we will register all of the ENV variables ... | javascript | function start(CB, env) {
var app = this;
/*
|--------------------------------------------------------------------------
| Register The Environment Variables
|--------------------------------------------------------------------------
|
| Here we will register all of the ENV variables ... | [
"function",
"start",
"(",
"CB",
",",
"env",
")",
"{",
"var",
"app",
"=",
"this",
";",
"/*\n |--------------------------------------------------------------------------\n | Register The Environment Variables\n |--------------------------------------------------------------------... | Application.prototype.start
@param CB
@param env | [
"Application",
".",
"prototype",
".",
"start"
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/foundation/start.js#L22-L152 | train |
edloidas/roll-parser | src/complex/parse.js | parse | function parse( roll ) {
const result = parseAny( roll );
const type = result ? result.type : '';
switch ( type ) {
case Type.simple:
return mapToRoll( result );
case Type.classic:
return mapToRoll( result );
case Type.wod:
return mapToWodRoll( result );
default:
return nu... | javascript | function parse( roll ) {
const result = parseAny( roll );
const type = result ? result.type : '';
switch ( type ) {
case Type.simple:
return mapToRoll( result );
case Type.classic:
return mapToRoll( result );
case Type.wod:
return mapToWodRoll( result );
default:
return nu... | [
"function",
"parse",
"(",
"roll",
")",
"{",
"const",
"result",
"=",
"parseAny",
"(",
"roll",
")",
";",
"const",
"type",
"=",
"result",
"?",
"result",
".",
"type",
":",
"''",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"Type",
".",
"simple",
":",
... | Parses simplified, classic or WoD roll notation.
@func
@since v2.0.0
@param {String} roll
@return {Roll|WodRoll|null}
@see parseSimpleRoll
@see parseClassicRoll
@see parseWodRoll
@example
parse('2 10 -1'); //=> { dice: 10, count: 2, modifier: -1 }
parse('2d10+1'); //=> { dice: 10, count: 2, modifier: 1 }
parse('4... | [
"Parses",
"simplified",
"classic",
"or",
"WoD",
"roll",
"notation",
"."
] | 38912b298edb0a4d67ba1c796d7ac159ebaf7901 | https://github.com/edloidas/roll-parser/blob/38912b298edb0a4d67ba1c796d7ac159ebaf7901/src/complex/parse.js#L21-L35 | train |
IonicaBizau/git-status | lib/index.js | gitStatus | function gitStatus (options, cb) {
if (typeof options === "function") {
cb = options;
options = {};
}
spawno("git", ["status", "--porcelain", "-z"], options, (err, stdout, stderr) => {
if (err || stderr) { return cb(err || stderr, stdout); }
cb(null, parse(stdout));
});
... | javascript | function gitStatus (options, cb) {
if (typeof options === "function") {
cb = options;
options = {};
}
spawno("git", ["status", "--porcelain", "-z"], options, (err, stdout, stderr) => {
if (err || stderr) { return cb(err || stderr, stdout); }
cb(null, parse(stdout));
});
... | [
"function",
"gitStatus",
"(",
"options",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"\"function\"",
")",
"{",
"cb",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"spawno",
"(",
"\"git\"",
",",
"[",
"\"status\"",
",",
"\"--... | gitStatus
A git-status wrapper.
[`parse-git-status`](https://github.com/jamestalmage/parse-git-status) is used to parse the output.
@name gitStatus
@function
@param {Object} options The `spawno` options.
@param {Function} cb The callback function. | [
"gitStatus",
"A",
"git",
"-",
"status",
"wrapper",
"."
] | b0298a14cbac920952e6a137177aa3a701d94441 | https://github.com/IonicaBizau/git-status/blob/b0298a14cbac920952e6a137177aa3a701d94441/lib/index.js#L19-L29 | train |
Heymdall/cron-to-text | src/parseCron.js | getValue | function getValue(value, offset = 0, max = 9999) {
return isNaN(value) ? NAMES[value] || null : Math.min(+value + (offset), max);
} | javascript | function getValue(value, offset = 0, max = 9999) {
return isNaN(value) ? NAMES[value] || null : Math.min(+value + (offset), max);
} | [
"function",
"getValue",
"(",
"value",
",",
"offset",
"=",
"0",
",",
"max",
"=",
"9999",
")",
"{",
"return",
"isNaN",
"(",
"value",
")",
"?",
"NAMES",
"[",
"value",
"]",
"||",
"null",
":",
"Math",
".",
"min",
"(",
"+",
"value",
"+",
"(",
"offset",... | Returns the value + offset if value is a number, otherwise it
attempts to look up the value in the NAMES table and returns
that result instead.
@param {Number,String} value: The value that should be parsed
@param {Number=} offset: Any offset that must be added to the value
@param {Number=} max
@returns {Number|null} | [
"Returns",
"the",
"value",
"+",
"offset",
"if",
"value",
"is",
"a",
"number",
"otherwise",
"it",
"attempts",
"to",
"look",
"up",
"the",
"value",
"in",
"the",
"NAMES",
"table",
"and",
"returns",
"that",
"result",
"instead",
"."
] | a6a0ae74a4b98bb951a4ae0fa68778a3c7ab9978 | https://github.com/Heymdall/cron-to-text/blob/a6a0ae74a4b98bb951a4ae0fa68778a3c7ab9978/src/parseCron.js#L40-L42 | train |
diosney/json2pot | index.js | setDefaultOptions | function setDefaultOptions(options) {
const defaultOptions = {
src : [
'**/*.i18n.json',
'**/i18n/*.json',
'!node_modules'
],
destFile : 'translations.pot',
headers : {
'X-Poedit-Basepath' : '..',
'X-Poedit-SourceCharset': 'UTF-8',
'X-Poedit... | javascript | function setDefaultOptions(options) {
const defaultOptions = {
src : [
'**/*.i18n.json',
'**/i18n/*.json',
'!node_modules'
],
destFile : 'translations.pot',
headers : {
'X-Poedit-Basepath' : '..',
'X-Poedit-SourceCharset': 'UTF-8',
'X-Poedit... | [
"function",
"setDefaultOptions",
"(",
"options",
")",
"{",
"const",
"defaultOptions",
"=",
"{",
"src",
":",
"[",
"'**/*.i18n.json'",
",",
"'**/i18n/*.json'",
",",
"'!node_modules'",
"]",
",",
"destFile",
":",
"'translations.pot'",
",",
"headers",
":",
"{",
"'X-P... | Set default options.
@param {Object} options
@return {Object} | [
"Set",
"default",
"options",
"."
] | a46c8dc0f479141824d05330d7b31cf72a5e8aa1 | https://github.com/diosney/json2pot/blob/a46c8dc0f479141824d05330d7b31cf72a5e8aa1/index.js#L17-L45 | train |
marksmccann/boost-js | src/boost.js | function( str ) {
return str
// Replaces any - or _ characters with a space
.replace( /[-_]+/g, ' ')
// Removes any non alphanumeric characters
.replace( /[^\w\s]/g, '')
// Uppercases the first character in each group
// immediately followi... | javascript | function( str ) {
return str
// Replaces any - or _ characters with a space
.replace( /[-_]+/g, ' ')
// Removes any non alphanumeric characters
.replace( /[^\w\s]/g, '')
// Uppercases the first character in each group
// immediately followi... | [
"function",
"(",
"str",
")",
"{",
"return",
"str",
"// Replaces any - or _ characters with a space",
".",
"replace",
"(",
"/",
"[-_]+",
"/",
"g",
",",
"' '",
")",
"// Removes any non alphanumeric characters",
".",
"replace",
"(",
"/",
"[^\\w\\s]",
"/",
"g",
",",
... | Converts any string into a "javascript-friendly" version.
@param {string} str
@return {string} camelized | [
"Converts",
"any",
"string",
"into",
"a",
"javascript",
"-",
"friendly",
"version",
"."
] | 0ed0972c4f1ca07f45d5a74f70378007c1e625cd | https://github.com/marksmccann/boost-js/blob/0ed0972c4f1ca07f45d5a74f70378007c1e625cd/src/boost.js#L17-L28 | train | |
marksmccann/boost-js | src/boost.js | function( str ) {
// if whole numbers, convert to integer
if( /^\d+$/.test(str) ) return parseInt( str );
// if decimal, convert to float
if( /^\d*\.\d+$/.test(str) ) return parseFloat( str );
// if "true" or "false", return boolean
if( /^true$/.test(str) ) return true;
... | javascript | function( str ) {
// if whole numbers, convert to integer
if( /^\d+$/.test(str) ) return parseInt( str );
// if decimal, convert to float
if( /^\d*\.\d+$/.test(str) ) return parseFloat( str );
// if "true" or "false", return boolean
if( /^true$/.test(str) ) return true;
... | [
"function",
"(",
"str",
")",
"{",
"// if whole numbers, convert to integer",
"if",
"(",
"/",
"^\\d+$",
"/",
".",
"test",
"(",
"str",
")",
")",
"return",
"parseInt",
"(",
"str",
")",
";",
"// if decimal, convert to float",
"if",
"(",
"/",
"^\\d*\\.\\d+$",
"/",
... | Intelligently converts a string to integer or boolean.
@param {string} str
@return {multi} str string|integer|boolean | [
"Intelligently",
"converts",
"a",
"string",
"to",
"integer",
"or",
"boolean",
"."
] | 0ed0972c4f1ca07f45d5a74f70378007c1e625cd | https://github.com/marksmccann/boost-js/blob/0ed0972c4f1ca07f45d5a74f70378007c1e625cd/src/boost.js#L36-L46 | train | |
marksmccann/boost-js | src/boost.js | function( MyPlugin, defaults ) {
// make sure a function has been passed in to
// create a plugin from.
if (typeof MyPlugin === 'function') {
/**
* the plugin object, inherits all attributes and methods
* from the base plugin and the user's plugin
... | javascript | function( MyPlugin, defaults ) {
// make sure a function has been passed in to
// create a plugin from.
if (typeof MyPlugin === 'function') {
/**
* the plugin object, inherits all attributes and methods
* from the base plugin and the user's plugin
... | [
"function",
"(",
"MyPlugin",
",",
"defaults",
")",
"{",
"// make sure a function has been passed in to",
"// create a plugin from.",
"if",
"(",
"typeof",
"MyPlugin",
"===",
"'function'",
")",
"{",
"/**\n * the plugin object, inherits all attributes and methods\n ... | Creates a new plugin
@param {object} MyPlugin Class from which plugin will be created
@param {object} defaults Default settings for this plugin
@return {object} instance | [
"Creates",
"a",
"new",
"plugin"
] | 0ed0972c4f1ca07f45d5a74f70378007c1e625cd | https://github.com/marksmccann/boost-js/blob/0ed0972c4f1ca07f45d5a74f70378007c1e625cd/src/boost.js#L140-L194 | train | |
marksmccann/boost-js | src/boost.js | function( element, options ) {
Boilerplate.call( this, element, options || {}, defaults || {} );
MyPlugin.call( this, element, options );
return this;
} | javascript | function( element, options ) {
Boilerplate.call( this, element, options || {}, defaults || {} );
MyPlugin.call( this, element, options );
return this;
} | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"Boilerplate",
".",
"call",
"(",
"this",
",",
"element",
",",
"options",
"||",
"{",
"}",
",",
"defaults",
"||",
"{",
"}",
")",
";",
"MyPlugin",
".",
"call",
"(",
"this",
",",
"element",
",",
"op... | the plugin object, inherits all attributes and methods
from the base plugin and the user's plugin
@param {object} element
@param {object} options
@return {object} instance | [
"the",
"plugin",
"object",
"inherits",
"all",
"attributes",
"and",
"methods",
"from",
"the",
"base",
"plugin",
"and",
"the",
"user",
"s",
"plugin"
] | 0ed0972c4f1ca07f45d5a74f70378007c1e625cd | https://github.com/marksmccann/boost-js/blob/0ed0972c4f1ca07f45d5a74f70378007c1e625cd/src/boost.js#L154-L158 | train | |
kengz/poly-socketio | src/start-io.js | ioServer | function ioServer(port = 6466, clientCount = 1, timeoutMs = 100000) {
if (global.io) {
// if already started
return Promise.resolve()
}
log.info(`Starting poly-socketio server on port: ${port}, expecting ${clientCount} IO clients`)
global.io = socketIO(server)
var count = clientCount
global.ioPromi... | javascript | function ioServer(port = 6466, clientCount = 1, timeoutMs = 100000) {
if (global.io) {
// if already started
return Promise.resolve()
}
log.info(`Starting poly-socketio server on port: ${port}, expecting ${clientCount} IO clients`)
global.io = socketIO(server)
var count = clientCount
global.ioPromi... | [
"function",
"ioServer",
"(",
"port",
"=",
"6466",
",",
"clientCount",
"=",
"1",
",",
"timeoutMs",
"=",
"100000",
")",
"{",
"if",
"(",
"global",
".",
"io",
")",
"{",
"// if already started",
"return",
"Promise",
".",
"resolve",
"(",
")",
"}",
"log",
"."... | Start a Socket IO server connecting to a brand new Express server for use in dev. Sets global.io too.
Has a failsafe for not starting multiple times even when called repeatedly by accident in the same thread.
@param {*} robot The hubot object
@return {server} server
/* istanbul ignore next | [
"Start",
"a",
"Socket",
"IO",
"server",
"connecting",
"to",
"a",
"brand",
"new",
"Express",
"server",
"for",
"use",
"in",
"dev",
".",
"Sets",
"global",
".",
"io",
"too",
".",
"Has",
"a",
"failsafe",
"for",
"not",
"starting",
"multiple",
"times",
"even",
... | 261f84d3b4267a6d1a36eadd6526ddb45369973e | https://github.com/kengz/poly-socketio/blob/261f84d3b4267a6d1a36eadd6526ddb45369973e/src/start-io.js#L21-L74 | train |
YR/clock | src/index.js | run | function run() {
const current = now();
const queue = timeoutQueue.slice();
let interval = INTERVAL_MAX;
timeoutQueue.length = 0;
// Reset
if (runRafId > 0 || runTimeoutId > 0) {
stop();
}
for (let i = queue.length - 1; i >= 0; i--) {
const item = queue[i];
if (!item.cancelled) {
c... | javascript | function run() {
const current = now();
const queue = timeoutQueue.slice();
let interval = INTERVAL_MAX;
timeoutQueue.length = 0;
// Reset
if (runRafId > 0 || runTimeoutId > 0) {
stop();
}
for (let i = queue.length - 1; i >= 0; i--) {
const item = queue[i];
if (!item.cancelled) {
c... | [
"function",
"run",
"(",
")",
"{",
"const",
"current",
"=",
"now",
"(",
")",
";",
"const",
"queue",
"=",
"timeoutQueue",
".",
"slice",
"(",
")",
";",
"let",
"interval",
"=",
"INTERVAL_MAX",
";",
"timeoutQueue",
".",
"length",
"=",
"0",
";",
"// Reset",
... | Process outstanding queue items | [
"Process",
"outstanding",
"queue",
"items"
] | 015badf5fdaef050b708b3a01e7f000afd76ab40 | https://github.com/YR/clock/blob/015badf5fdaef050b708b3a01e7f000afd76ab40/src/index.js#L141-L183 | train |
YR/clock | src/index.js | onVisibilityChangeFactory | function onVisibilityChangeFactory(hidden) {
return function onVisibilityChange(evt) {
if (document[hidden]) {
debug('disable while hidden');
stop();
} else {
debug('enable while visible');
if (process.env.NODE_ENV === 'development') {
const current = now();
for (let i... | javascript | function onVisibilityChangeFactory(hidden) {
return function onVisibilityChange(evt) {
if (document[hidden]) {
debug('disable while hidden');
stop();
} else {
debug('enable while visible');
if (process.env.NODE_ENV === 'development') {
const current = now();
for (let i... | [
"function",
"onVisibilityChangeFactory",
"(",
"hidden",
")",
"{",
"return",
"function",
"onVisibilityChange",
"(",
"evt",
")",
"{",
"if",
"(",
"document",
"[",
"hidden",
"]",
")",
"{",
"debug",
"(",
"'disable while hidden'",
")",
";",
"stop",
"(",
")",
";",
... | Generate visibilityChange handler
@param {String} hidden
@returns {Function} | [
"Generate",
"visibilityChange",
"handler"
] | 015badf5fdaef050b708b3a01e7f000afd76ab40 | https://github.com/YR/clock/blob/015badf5fdaef050b708b3a01e7f000afd76ab40/src/index.js#L203-L229 | train |
justinhelmer/npm-publish-release | index.js | publishToNpm | function publishToNpm() {
return new Promise(function(resolve, reject) {
_spork('npm', ['publish'], done, _.partial(reject, new Error('failed to publish to npm')));
function done() {
if (!options.quiet) {
gutil.log('Published to \'' + chalk.cyan('npm') + '\'');
... | javascript | function publishToNpm() {
return new Promise(function(resolve, reject) {
_spork('npm', ['publish'], done, _.partial(reject, new Error('failed to publish to npm')));
function done() {
if (!options.quiet) {
gutil.log('Published to \'' + chalk.cyan('npm') + '\'');
... | [
"function",
"publishToNpm",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"_spork",
"(",
"'npm'",
",",
"[",
"'publish'",
"]",
",",
"done",
",",
"_",
".",
"partial",
"(",
"reject",
",",
"new",
"Er... | Publish the current codebase to npm.
@return {Bluebird promise} - Resolves or rejects (with nothing) based on the status of the `git` commands. | [
"Publish",
"the",
"current",
"codebase",
"to",
"npm",
"."
] | 9536354c2012097c77ca63f3ef6e0f394d3784e4 | https://github.com/justinhelmer/npm-publish-release/blob/9536354c2012097c77ca63f3ef6e0f394d3784e4/index.js#L168-L180 | train |
justinhelmer/npm-publish-release | index.js | _spork | function _spork(command, args, resolve, reject) {
spork(command, args, {exit: false, quiet: true})
.on('exit:code', function(code) {
if (code === 0) {
resolve();
} else {
reject();
}
});
} | javascript | function _spork(command, args, resolve, reject) {
spork(command, args, {exit: false, quiet: true})
.on('exit:code', function(code) {
if (code === 0) {
resolve();
} else {
reject();
}
});
} | [
"function",
"_spork",
"(",
"command",
",",
"args",
",",
"resolve",
",",
"reject",
")",
"{",
"spork",
"(",
"command",
",",
"args",
",",
"{",
"exit",
":",
"false",
",",
"quiet",
":",
"true",
"}",
")",
".",
"on",
"(",
"'exit:code'",
",",
"function",
"... | Wrapper around spork to shorthand common behavior | [
"Wrapper",
"around",
"spork",
"to",
"shorthand",
"common",
"behavior"
] | 9536354c2012097c77ca63f3ef6e0f394d3784e4 | https://github.com/justinhelmer/npm-publish-release/blob/9536354c2012097c77ca63f3ef6e0f394d3784e4/index.js#L204-L213 | train |
edus44/express-deliver | lib/loader/main.js | wrapMethod | function wrapMethod(app,fn){
//Override original express method
return function(){
let args = Array.prototype.slice.call(arguments)
//Check if any middleware argument is a generator function
for( let i=0; i<args.length; i++ ){
//Wrap this if necessary
args[i] = co... | javascript | function wrapMethod(app,fn){
//Override original express method
return function(){
let args = Array.prototype.slice.call(arguments)
//Check if any middleware argument is a generator function
for( let i=0; i<args.length; i++ ){
//Wrap this if necessary
args[i] = co... | [
"function",
"wrapMethod",
"(",
"app",
",",
"fn",
")",
"{",
"//Override original express method",
"return",
"function",
"(",
")",
"{",
"let",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
"//Check if any middleware argu... | Wrap an express method handler
@param {ExpressApp} app
@param {Function} fn
@returns {Function} | [
"Wrap",
"an",
"express",
"method",
"handler"
] | 895abfaf2e5e48a00b4fef943dccaffcbf244780 | https://github.com/edus44/express-deliver/blob/895abfaf2e5e48a00b4fef943dccaffcbf244780/lib/loader/main.js#L69-L82 | train |
chjj/rondo | lib/dom.js | function(el, deep) {
var sub = document.createElement(el.nodeName)
, attr = el.attributes
, i = attr.length;
while (i--) {
if (attr[i].nodeValue) {
sub.setAttribute(attr[i].name, attr[i].value);
}
}
if (el.namespaceURI) {
sub.namespaceURI = el.namespaceURI;
}
... | javascript | function(el, deep) {
var sub = document.createElement(el.nodeName)
, attr = el.attributes
, i = attr.length;
while (i--) {
if (attr[i].nodeValue) {
sub.setAttribute(attr[i].name, attr[i].value);
}
}
if (el.namespaceURI) {
sub.namespaceURI = el.namespaceURI;
}
... | [
"function",
"(",
"el",
",",
"deep",
")",
"{",
"var",
"sub",
"=",
"document",
".",
"createElement",
"(",
"el",
".",
"nodeName",
")",
",",
"attr",
"=",
"el",
".",
"attributes",
",",
"i",
"=",
"attr",
".",
"length",
";",
"while",
"(",
"i",
"--",
")"... | this gives a clean "userspace" clone with no events or data. .cloneNode is so damn buggy i dont even want to touch it. | [
"this",
"gives",
"a",
"clean",
"userspace",
"clone",
"with",
"no",
"events",
"or",
"data",
".",
".",
"cloneNode",
"is",
"so",
"damn",
"buggy",
"i",
"dont",
"even",
"want",
"to",
"touch",
"it",
"."
] | 5a0643a2e4ce74e25240517e1cf423df5a188008 | https://github.com/chjj/rondo/blob/5a0643a2e4ce74e25240517e1cf423df5a188008/lib/dom.js#L380-L404 | train | |
chjj/rondo | lib/dom.js | function(el, sub) {
sub = normalize(sub);
DOM.removeAllListeners(el);
DOM.clearData(el);
DOM.clean(el);
//el.parentNode.replaceChild(sub, el);
el.parentNode.insertBefore(sub, el);
el.parentNode.removeChild(el);
return sub;
} | javascript | function(el, sub) {
sub = normalize(sub);
DOM.removeAllListeners(el);
DOM.clearData(el);
DOM.clean(el);
//el.parentNode.replaceChild(sub, el);
el.parentNode.insertBefore(sub, el);
el.parentNode.removeChild(el);
return sub;
} | [
"function",
"(",
"el",
",",
"sub",
")",
"{",
"sub",
"=",
"normalize",
"(",
"sub",
")",
";",
"DOM",
".",
"removeAllListeners",
"(",
"el",
")",
";",
"DOM",
".",
"clearData",
"(",
"el",
")",
";",
"DOM",
".",
"clean",
"(",
"el",
")",
";",
"//el.paren... | "replace this with that" | [
"replace",
"this",
"with",
"that"
] | 5a0643a2e4ce74e25240517e1cf423df5a188008 | https://github.com/chjj/rondo/blob/5a0643a2e4ce74e25240517e1cf423df5a188008/lib/dom.js#L559-L571 | train | |
chjj/rondo | lib/dom.js | function(el, sub) {
sub = normalize(sub);
el.parentNode.insertBefore(sub, el);
return sub;
} | javascript | function(el, sub) {
sub = normalize(sub);
el.parentNode.insertBefore(sub, el);
return sub;
} | [
"function",
"(",
"el",
",",
"sub",
")",
"{",
"sub",
"=",
"normalize",
"(",
"sub",
")",
";",
"el",
".",
"parentNode",
".",
"insertBefore",
"(",
"sub",
",",
"el",
")",
";",
"return",
"sub",
";",
"}"
] | "insert that before this" | [
"insert",
"that",
"before",
"this"
] | 5a0643a2e4ce74e25240517e1cf423df5a188008 | https://github.com/chjj/rondo/blob/5a0643a2e4ce74e25240517e1cf423df5a188008/lib/dom.js#L576-L581 | train | |
quorrajs/Positron | lib/config/Repository.js | Repository | function Repository(loader, environment) {
/**
* The loader implementation.
*
* @var {FileLoader}
* @protected
*/
this.__loader = loader;
/**
* The current environment.
*
* @var {string}
* @protected
*/
this.__environment = environment;
/**
*... | javascript | function Repository(loader, environment) {
/**
* The loader implementation.
*
* @var {FileLoader}
* @protected
*/
this.__loader = loader;
/**
* The current environment.
*
* @var {string}
* @protected
*/
this.__environment = environment;
/**
*... | [
"function",
"Repository",
"(",
"loader",
",",
"environment",
")",
"{",
"/**\n * The loader implementation.\n *\n * @var {FileLoader}\n * @protected\n */",
"this",
".",
"__loader",
"=",
"loader",
";",
"/**\n * The current environment.\n *\n * @var {string... | Create a new configuration repository.
@param {FileLoader} loader
@param {string} environment
@inherits NamespacedItemResolver
@return void | [
"Create",
"a",
"new",
"configuration",
"repository",
"."
] | a4bad5a5f581743d1885405c11ae26600fb957af | https://github.com/quorrajs/Positron/blob/a4bad5a5f581743d1885405c11ae26600fb957af/lib/config/Repository.js#L20-L57 | train |
SamyPesse/parse-changelog | index.js | function() {
if (!version) return;
if (note) version.notes.push(note);
version.rawNote = normText(
_.chain(version.notes)
.map(function(note) {
return '* '+note.trim();
})
.value()
.join('\n')
);
version... | javascript | function() {
if (!version) return;
if (note) version.notes.push(note);
version.rawNote = normText(
_.chain(version.notes)
.map(function(note) {
return '* '+note.trim();
})
.value()
.join('\n')
);
version... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"version",
")",
"return",
";",
"if",
"(",
"note",
")",
"version",
".",
"notes",
".",
"push",
"(",
"note",
")",
";",
"version",
".",
"rawNote",
"=",
"normText",
"(",
"_",
".",
"chain",
"(",
"version",
"."... | Push a new version and normalize notes | [
"Push",
"a",
"new",
"version",
"and",
"normalize",
"notes"
] | 2c4f5fb0c9d265aa6e39bed60c7d01d867cf07db | https://github.com/SamyPesse/parse-changelog/blob/2c4f5fb0c9d265aa6e39bed60c7d01d867cf07db/index.js#L32-L49 | train | |
sdgluck/sw-register | index.js | register | function register (options, __mockSelf) {
var _self = __mockSelf || self
var navigator = _self.navigator
if (!('serviceWorker' in navigator)) {
return Promise.reject(new Error('Service Workers unsupported'))
}
var serviceWorker = navigator.serviceWorker.controller
return Promise.resolve()
.then(f... | javascript | function register (options, __mockSelf) {
var _self = __mockSelf || self
var navigator = _self.navigator
if (!('serviceWorker' in navigator)) {
return Promise.reject(new Error('Service Workers unsupported'))
}
var serviceWorker = navigator.serviceWorker.controller
return Promise.resolve()
.then(f... | [
"function",
"register",
"(",
"options",
",",
"__mockSelf",
")",
"{",
"var",
"_self",
"=",
"__mockSelf",
"||",
"self",
"var",
"navigator",
"=",
"_self",
".",
"navigator",
"if",
"(",
"!",
"(",
"'serviceWorker'",
"in",
"navigator",
")",
")",
"{",
"return",
... | Register or retrieve a Service Worker that controls the page.
@param {Object} options
@returns {Promise} | [
"Register",
"or",
"retrieve",
"a",
"Service",
"Worker",
"that",
"controls",
"the",
"page",
"."
] | 294873c5d3c0a7df143401e5f14de51e2771704d | https://github.com/sdgluck/sw-register/blob/294873c5d3c0a7df143401e5f14de51e2771704d/index.js#L18-L55 | train |
agneta/platform | pages/scripts/helpers/debug.js | inspectObject | function inspectObject(object, options) {
var result = util.inspect(object, options);
console.log(result);
return result;
} | javascript | function inspectObject(object, options) {
var result = util.inspect(object, options);
console.log(result);
return result;
} | [
"function",
"inspectObject",
"(",
"object",
",",
"options",
")",
"{",
"var",
"result",
"=",
"util",
".",
"inspect",
"(",
"object",
",",
"options",
")",
";",
"console",
".",
"log",
"(",
"result",
")",
";",
"return",
"result",
";",
"}"
] | this solves circular reference in object | [
"this",
"solves",
"circular",
"reference",
"in",
"object"
] | 9364b03b06b91b64f786d0439a32b08bb018606f | https://github.com/agneta/platform/blob/9364b03b06b91b64f786d0439a32b08bb018606f/pages/scripts/helpers/debug.js#L24-L28 | train |
arboleya/ways | lib/ways.js | Ways | function Ways(pattern, runner, destroyer, dependency){
if(flow && arguments.length < 3)
throw new Error('In `flow` mode you must to pass at least 3 args.');
var route = new Way(pattern, runner, destroyer, dependency);
routes.push(route);
return route;
} | javascript | function Ways(pattern, runner, destroyer, dependency){
if(flow && arguments.length < 3)
throw new Error('In `flow` mode you must to pass at least 3 args.');
var route = new Way(pattern, runner, destroyer, dependency);
routes.push(route);
return route;
} | [
"function",
"Ways",
"(",
"pattern",
",",
"runner",
",",
"destroyer",
",",
"dependency",
")",
"{",
"if",
"(",
"flow",
"&&",
"arguments",
".",
"length",
"<",
"3",
")",
"throw",
"new",
"Error",
"(",
"'In `flow` mode you must to pass at least 3 args.'",
")",
";",
... | Sets up a new route
@param {String} pattern Pattern string
@param {Function} runner Route's action runner
@param {Function} destroyer Optional, Route's action destroyer (flow mode)
@param {String} dependency Optional, specifies a dependency by pattern | [
"Sets",
"up",
"a",
"new",
"route"
] | 01a91066de320aa045a5301b2a905ba5f8f141f4 | https://github.com/arboleya/ways/blob/01a91066de320aa045a5301b2a905ba5f8f141f4/lib/ways.js#L38-L47 | train |
feedhenry-raincatcher/raincatcher-angularjs | packages/angularjs-workorder/lib/workorder-detail/workorder-detail-controller.js | WorkorderDetailController | function WorkorderDetailController($state, WORKORDER_CONFIG, workorderStatusService) {
var self = this;
self.adminMode = WORKORDER_CONFIG.adminMode;
self.getColorIcon = function(status) {
return workorderStatusService.getStatusIconColor(status).statusColor;
};
} | javascript | function WorkorderDetailController($state, WORKORDER_CONFIG, workorderStatusService) {
var self = this;
self.adminMode = WORKORDER_CONFIG.adminMode;
self.getColorIcon = function(status) {
return workorderStatusService.getStatusIconColor(status).statusColor;
};
} | [
"function",
"WorkorderDetailController",
"(",
"$state",
",",
"WORKORDER_CONFIG",
",",
"workorderStatusService",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"adminMode",
"=",
"WORKORDER_CONFIG",
".",
"adminMode",
";",
"self",
".",
"getColorIcon",
"=",
... | Controller for displaying workorder details to the user.
@param WORKORDER_CONFIG
@constructor | [
"Controller",
"for",
"displaying",
"workorder",
"details",
"to",
"the",
"user",
"."
] | b394689227901e18871ad9edd0ec226c5e6839e1 | https://github.com/feedhenry-raincatcher/raincatcher-angularjs/blob/b394689227901e18871ad9edd0ec226c5e6839e1/packages/angularjs-workorder/lib/workorder-detail/workorder-detail-controller.js#L9-L17 | train |
jiridudekusy/uu5-to-markdown | src/converters/md2uu5/richText/richText.js | richtext | function richtext(state, startLine, endLine, silent, opts) {
let pos = state.bMarks[startLine] + state.tShift[startLine],
max = state.eMarks[startLine],
contentEndLine;
if (pos >= max) {
return false;
}
let line = state.getLines(startLine, startLine + 1, 0, false);
if (!line.startsWith(RICHTEXT... | javascript | function richtext(state, startLine, endLine, silent, opts) {
let pos = state.bMarks[startLine] + state.tShift[startLine],
max = state.eMarks[startLine],
contentEndLine;
if (pos >= max) {
return false;
}
let line = state.getLines(startLine, startLine + 1, 0, false);
if (!line.startsWith(RICHTEXT... | [
"function",
"richtext",
"(",
"state",
",",
"startLine",
",",
"endLine",
",",
"silent",
",",
"opts",
")",
"{",
"let",
"pos",
"=",
"state",
".",
"bMarks",
"[",
"startLine",
"]",
"+",
"state",
".",
"tShift",
"[",
"startLine",
"]",
",",
"max",
"=",
"stat... | Block parser for UU5.RichText.Block .
The rich text block is using following signature:
{richtext}
...richtext content...
{/richtext}
@param state
@param startLine
@param endLine
@param silent
@returns {boolean} | [
"Block",
"parser",
"for",
"UU5",
".",
"RichText",
".",
"Block",
"."
] | 559163aa8a4184e1a94888c4fc6d4302acbd857d | https://github.com/jiridudekusy/uu5-to-markdown/blob/559163aa8a4184e1a94888c4fc6d4302acbd857d/src/converters/md2uu5/richText/richText.js#L20-L62 | train |
fti-technology/node-skytap | lib/rest.js | apiRequest | function apiRequest(args, next) {
var deferred = Q.defer()
, opts;
opts = {
json: true,
headers: headers,
};
if(args.version === 'v2') {
opts.headers.Accept = 'application/vnd.skytap.api.v2+json';
}
opts = arghelper.combine(opts, args);
opts = arghelper.convertAu... | javascript | function apiRequest(args, next) {
var deferred = Q.defer()
, opts;
opts = {
json: true,
headers: headers,
};
if(args.version === 'v2') {
opts.headers.Accept = 'application/vnd.skytap.api.v2+json';
}
opts = arghelper.combine(opts, args);
opts = arghelper.convertAu... | [
"function",
"apiRequest",
"(",
"args",
",",
"next",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
",",
"opts",
";",
"opts",
"=",
"{",
"json",
":",
"true",
",",
"headers",
":",
"headers",
",",
"}",
";",
"if",
"(",
"args",
".",
"... | Performs the api request based on the supplied arguments
@param {Object} args
@config {String} url - required
@config {String} method - required
@config {Object} auth - required
@config {String} auth.user - required
@config {String} auth.pass - required
@config {Object} body
@callback next
@return {Promise}
@api priv... | [
"Performs",
"the",
"api",
"request",
"based",
"on",
"the",
"supplied",
"arguments"
] | 1d5af43ee26aabfebe52627ea09f291c99923a49 | https://github.com/fti-technology/node-skytap/blob/1d5af43ee26aabfebe52627ea09f291c99923a49/lib/rest.js#L47-L100 | train |
alexyoung/pop | lib/helpers.js | function(template, options) {
options = options || {};
options.pretty = true;
var fn = jade.compile(template, options);
return fn(options.locals);
} | javascript | function(template, options) {
options = options || {};
options.pretty = true;
var fn = jade.compile(template, options);
return fn(options.locals);
} | [
"function",
"(",
"template",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"pretty",
"=",
"true",
";",
"var",
"fn",
"=",
"jade",
".",
"compile",
"(",
"template",
",",
"options",
")",
";",
"return",
"fn",
... | Renders a Jade template
@param {String} A Jade template
@param {Object} Options passed to Jade
@return {String} | [
"Renders",
"a",
"Jade",
"template"
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/helpers.js#L25-L30 | train | |
alexyoung/pop | lib/helpers.js | function(paginator) {
var template = '';
template += '.pages\n';
template += ' - if (paginator.previousPage)\n';
template += ' span.prev_next\n';
template += ' - if (paginator.previousPage === 1)\n';
template += ' span ←\n';
template += ' a.previous(href="/") Prev... | javascript | function(paginator) {
var template = '';
template += '.pages\n';
template += ' - if (paginator.previousPage)\n';
template += ' span.prev_next\n';
template += ' - if (paginator.previousPage === 1)\n';
template += ' span ←\n';
template += ' a.previous(href="/") Prev... | [
"function",
"(",
"paginator",
")",
"{",
"var",
"template",
"=",
"''",
";",
"template",
"+=",
"'.pages\\n'",
";",
"template",
"+=",
"' - if (paginator.previousPage)\\n'",
";",
"template",
"+=",
"' span.prev_next\\n'",
";",
"template",
"+=",
"' - if (paginator.... | Pagination links.
@param {Object} Paginator object
@return {String} | [
"Pagination",
"links",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/helpers.js#L38-L62 | train | |
alexyoung/pop | lib/helpers.js | function() {
var template
, site = this;
template = ''
+ '- for (var i = 0; i < paginator.items.length; i++)\n'
+ ' !{hNews(paginator.items[i], true)}\n';
return helpers.render(template, { locals: site.applyHelpers({ paginator: site.paginator }) });
} | javascript | function() {
var template
, site = this;
template = ''
+ '- for (var i = 0; i < paginator.items.length; i++)\n'
+ ' !{hNews(paginator.items[i], true)}\n';
return helpers.render(template, { locals: site.applyHelpers({ paginator: site.paginator }) });
} | [
"function",
"(",
")",
"{",
"var",
"template",
",",
"site",
"=",
"this",
";",
"template",
"=",
"''",
"+",
"'- for (var i = 0; i < paginator.items.length; i++)\\n'",
"+",
"' !{hNews(paginator.items[i], true)}\\n'",
";",
"return",
"helpers",
".",
"render",
"(",
"templat... | Generates paginated blog posts, suitable for use on an index page.
@return {String} | [
"Generates",
"paginated",
"blog",
"posts",
"suitable",
"for",
"use",
"on",
"an",
"index",
"page",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/helpers.js#L69-L77 | train | |
alexyoung/pop | lib/helpers.js | function(feed, summarise) {
var template = ''
, url = this.config.url
, title = this.config.title
, perPage = this.config.perPage
, posts = this.posts.slice(0, perPage)
, site = this;
summarise = typeof summarise === 'boolean' && summarise ? 3 : summarise;
perPage = site.posts... | javascript | function(feed, summarise) {
var template = ''
, url = this.config.url
, title = this.config.title
, perPage = this.config.perPage
, posts = this.posts.slice(0, perPage)
, site = this;
summarise = typeof summarise === 'boolean' && summarise ? 3 : summarise;
perPage = site.posts... | [
"function",
"(",
"feed",
",",
"summarise",
")",
"{",
"var",
"template",
"=",
"''",
",",
"url",
"=",
"this",
".",
"config",
".",
"url",
",",
"title",
"=",
"this",
".",
"config",
".",
"title",
",",
"perPage",
"=",
"this",
".",
"config",
".",
"perPage... | Atom Jade template.
@param {String} Feed URL
@param {Integer} Number of paragraphs to summarise
@return {String} | [
"Atom",
"Jade",
"template",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/helpers.js#L87-L130 | train | |
alexyoung/pop | lib/helpers.js | function() {
var allTags = [];
for (var key in this.posts) {
if (this.posts[key].tags) {
for (var i = 0; i < this.posts[key].tags.length; i++) {
var tag = this.posts[key].tags[i];
if (allTags.indexOf(tag) === -1) allTags.push(tag);
}
}
}
allTags.sort... | javascript | function() {
var allTags = [];
for (var key in this.posts) {
if (this.posts[key].tags) {
for (var i = 0; i < this.posts[key].tags.length; i++) {
var tag = this.posts[key].tags[i];
if (allTags.indexOf(tag) === -1) allTags.push(tag);
}
}
}
allTags.sort... | [
"function",
"(",
")",
"{",
"var",
"allTags",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"this",
".",
"posts",
")",
"{",
"if",
"(",
"this",
".",
"posts",
"[",
"key",
"]",
".",
"tags",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",... | Returns unique sorted tags for every post.
@return {Array} | [
"Returns",
"unique",
"sorted",
"tags",
"for",
"every",
"post",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/helpers.js#L196-L217 | train | |
alexyoung/pop | lib/helpers.js | function(tag) {
var posts = [];
for (var key in this.posts) {
if (this.posts[key].tags && this.posts[key].tags.indexOf(tag) !== -1) {
posts.push(this.posts[key]);
}
}
return posts;
} | javascript | function(tag) {
var posts = [];
for (var key in this.posts) {
if (this.posts[key].tags && this.posts[key].tags.indexOf(tag) !== -1) {
posts.push(this.posts[key]);
}
}
return posts;
} | [
"function",
"(",
"tag",
")",
"{",
"var",
"posts",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"this",
".",
"posts",
")",
"{",
"if",
"(",
"this",
".",
"posts",
"[",
"key",
"]",
".",
"tags",
"&&",
"this",
".",
"posts",
"[",
"key",
"]",
... | Get a set of posts for a tag.
@param {String} Tag name
@return {Array} | [
"Get",
"a",
"set",
"of",
"posts",
"for",
"a",
"tag",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/helpers.js#L225-L233 | train | |
alexyoung/pop | lib/helpers.js | function(text, length, moreText) {
var t = text.split('</p>');
return t.length < length ? text : t.slice(0, length).join('</p>') + '</p>' + moreText;
} | javascript | function(text, length, moreText) {
var t = text.split('</p>');
return t.length < length ? text : t.slice(0, length).join('</p>') + '</p>' + moreText;
} | [
"function",
"(",
"text",
",",
"length",
",",
"moreText",
")",
"{",
"var",
"t",
"=",
"text",
".",
"split",
"(",
"'</p>'",
")",
";",
"return",
"t",
".",
"length",
"<",
"length",
"?",
"text",
":",
"t",
".",
"slice",
"(",
"0",
",",
"length",
")",
"... | Truncates HTML based on paragraph counts.
@param {String} Text to truncate
@param {Integer} Number of paragraphs
@param {String} Text to append when truncated
@return {String} | [
"Truncates",
"HTML",
"based",
"on",
"paragraph",
"counts",
"."
] | 8a0b3f2605cb58e8ae6b34f1373dde00610e9858 | https://github.com/alexyoung/pop/blob/8a0b3f2605cb58e8ae6b34f1373dde00610e9858/lib/helpers.js#L341-L344 | train | |
parsnick/laravel-elixir-bowerbundle | index.js | function(paths) {
return (
gulp
.src(paths.src.path)
.pipe(rework(
reworkUrl(function (url) {
return isRelative(url) ? path.basename(url) : url;
})
))
.pipe($.if(config.sourcemaps, $.sourcemaps.init({ loadMaps: true })))
.pipe($... | javascript | function(paths) {
return (
gulp
.src(paths.src.path)
.pipe(rework(
reworkUrl(function (url) {
return isRelative(url) ? path.basename(url) : url;
})
))
.pipe($.if(config.sourcemaps, $.sourcemaps.init({ loadMaps: true })))
.pipe($... | [
"function",
"(",
"paths",
")",
"{",
"return",
"(",
"gulp",
".",
"src",
"(",
"paths",
".",
"src",
".",
"path",
")",
".",
"pipe",
"(",
"rework",
"(",
"reworkUrl",
"(",
"function",
"(",
"url",
")",
"{",
"return",
"isRelative",
"(",
"url",
")",
"?",
... | Combine stylesheets.
@param {GulpPaths} paths
@return {stream} | [
"Combine",
"stylesheets",
"."
] | f6e7df503b4abec1c721a8b56b508162f714dd71 | https://github.com/parsnick/laravel-elixir-bowerbundle/blob/f6e7df503b4abec1c721a8b56b508162f714dd71/index.js#L107-L122 | train | |
parsnick/laravel-elixir-bowerbundle | index.js | logMissingPackages | function logMissingPackages(bundle)
{
var missing = _(bundle.packages).reject('installed')
.map('name').uniq().value();
if ( ! missing.length) return;
console.log('')
console.log(
colors.black.bgRed('!!! ' + bundle.name + ' is missing ' + colors.bold(missing.length) + ' package(s)')
... | javascript | function logMissingPackages(bundle)
{
var missing = _(bundle.packages).reject('installed')
.map('name').uniq().value();
if ( ! missing.length) return;
console.log('')
console.log(
colors.black.bgRed('!!! ' + bundle.name + ' is missing ' + colors.bold(missing.length) + ' package(s)')
... | [
"function",
"logMissingPackages",
"(",
"bundle",
")",
"{",
"var",
"missing",
"=",
"_",
"(",
"bundle",
".",
"packages",
")",
".",
"reject",
"(",
"'installed'",
")",
".",
"map",
"(",
"'name'",
")",
".",
"uniq",
"(",
")",
".",
"value",
"(",
")",
";",
... | Log to console any packages that were requested but not installed.
@param {Bundle} bundle | [
"Log",
"to",
"console",
"any",
"packages",
"that",
"were",
"requested",
"but",
"not",
"installed",
"."
] | f6e7df503b4abec1c721a8b56b508162f714dd71 | https://github.com/parsnick/laravel-elixir-bowerbundle/blob/f6e7df503b4abec1c721a8b56b508162f714dd71/index.js#L193-L209 | train |
goliney/coderoom | lib/coderoom.js | buildRooms | function buildRooms(baseRoom, dir, depth, attachments) {
depth++;
// group attachments
attachments = _.chain(attachments)
.clone()
.concat(baseRoom.getMedia(false).map(file => path.join('media', path.relative(commonFolder, file))))
.uniq()
.value(... | javascript | function buildRooms(baseRoom, dir, depth, attachments) {
depth++;
// group attachments
attachments = _.chain(attachments)
.clone()
.concat(baseRoom.getMedia(false).map(file => path.join('media', path.relative(commonFolder, file))))
.uniq()
.value(... | [
"function",
"buildRooms",
"(",
"baseRoom",
",",
"dir",
",",
"depth",
",",
"attachments",
")",
"{",
"depth",
"++",
";",
"// group attachments",
"attachments",
"=",
"_",
".",
"chain",
"(",
"attachments",
")",
".",
"clone",
"(",
")",
".",
"concat",
"(",
"ba... | depth=2, fixes path to targetDir | [
"depth",
"=",
"2",
"fixes",
"path",
"to",
"targetDir"
] | a8c30d45ae724dfc87348ffba5474cf62c10911c | https://github.com/goliney/coderoom/blob/a8c30d45ae724dfc87348ffba5474cf62c10911c/lib/coderoom.js#L103-L175 | train |
theThings/jailed-node | sandbox/sandbox.js | function(url) {
var done = _onImportScript(url)
loadScript(
url,
function runScript(err, code) {
if (err) return done(err)
executeNormal(code, url, done)
}
)
} | javascript | function(url) {
var done = _onImportScript(url)
loadScript(
url,
function runScript(err, code) {
if (err) return done(err)
executeNormal(code, url, done)
}
)
} | [
"function",
"(",
"url",
")",
"{",
"var",
"done",
"=",
"_onImportScript",
"(",
"url",
")",
"loadScript",
"(",
"url",
",",
"function",
"runScript",
"(",
"err",
",",
"code",
")",
"{",
"if",
"(",
"err",
")",
"return",
"done",
"(",
"err",
")",
"executeNor... | Loads and executes the JavaScript file with the given url
@param {String} url of the script to load | [
"Loads",
"and",
"executes",
"the",
"JavaScript",
"file",
"with",
"the",
"given",
"url"
] | 6e453d97e74fbd1c0b27b982084f6fd7c1aa0173 | https://github.com/theThings/jailed-node/blob/6e453d97e74fbd1c0b27b982084f6fd7c1aa0173/sandbox/sandbox.js#L72-L81 | train | |
theThings/jailed-node | sandbox/sandbox.js | function(url) {
var done = _onImportScript(url)
loadScript(
url,
function runScript(err, code) {
if (err) return done(err)
executeJailed(code, url, done)
}
)
} | javascript | function(url) {
var done = _onImportScript(url)
loadScript(
url,
function runScript(err, code) {
if (err) return done(err)
executeJailed(code, url, done)
}
)
} | [
"function",
"(",
"url",
")",
"{",
"var",
"done",
"=",
"_onImportScript",
"(",
"url",
")",
"loadScript",
"(",
"url",
",",
"function",
"runScript",
"(",
"err",
",",
"code",
")",
"{",
"if",
"(",
"err",
")",
"return",
"done",
"(",
"err",
")",
"executeJai... | Loads and executes the JavaScript file with the given url in a
jailed environment
@param {String} url of the script to load | [
"Loads",
"and",
"executes",
"the",
"JavaScript",
"file",
"with",
"the",
"given",
"url",
"in",
"a",
"jailed",
"environment"
] | 6e453d97e74fbd1c0b27b982084f6fd7c1aa0173 | https://github.com/theThings/jailed-node/blob/6e453d97e74fbd1c0b27b982084f6fd7c1aa0173/sandbox/sandbox.js#L89-L98 | train | |
theThings/jailed-node | sandbox/sandbox.js | function(code, url, done) {
var vm = require('vm')
var sandbox = {}
var expose = [
'application',
'setTimeout',
'setInterval',
'clearTimeout',
'clearInterval'
]
for (var i = 0; i < expose.length; i++) {
sandbox[expose[i]] = global[expose[i]]
}
code = '"use strict";\n' + code
tr... | javascript | function(code, url, done) {
var vm = require('vm')
var sandbox = {}
var expose = [
'application',
'setTimeout',
'setInterval',
'clearTimeout',
'clearInterval'
]
for (var i = 0; i < expose.length; i++) {
sandbox[expose[i]] = global[expose[i]]
}
code = '"use strict";\n' + code
tr... | [
"function",
"(",
"code",
",",
"url",
",",
"done",
")",
"{",
"var",
"vm",
"=",
"require",
"(",
"'vm'",
")",
"var",
"sandbox",
"=",
"{",
"}",
"var",
"expose",
"=",
"[",
"'application'",
",",
"'setTimeout'",
",",
"'setInterval'",
",",
"'clearTimeout'",
",... | Executes the given code in a jailed environment, runs the
corresponding callback when done
@param {String} code to execute
@param {String} url of the script (for displaying the stack) | [
"Executes",
"the",
"given",
"code",
"in",
"a",
"jailed",
"environment",
"runs",
"the",
"corresponding",
"callback",
"when",
"done"
] | 6e453d97e74fbd1c0b27b982084f6fd7c1aa0173 | https://github.com/theThings/jailed-node/blob/6e453d97e74fbd1c0b27b982084f6fd7c1aa0173/sandbox/sandbox.js#L134-L156 | train | |
theThings/jailed-node | sandbox/sandbox.js | function(url, done) {
var receive = function(res) {
if (res.statusCode != 200) {
var msg = 'Failed to load ' + url + '\n' +
'HTTP responce status code: ' + res.statusCode
printError(msg)
done(new Error(msg))
} else {
var content = ''
res
.on('end', function() {
... | javascript | function(url, done) {
var receive = function(res) {
if (res.statusCode != 200) {
var msg = 'Failed to load ' + url + '\n' +
'HTTP responce status code: ' + res.statusCode
printError(msg)
done(new Error(msg))
} else {
var content = ''
res
.on('end', function() {
... | [
"function",
"(",
"url",
",",
"done",
")",
"{",
"var",
"receive",
"=",
"function",
"(",
"res",
")",
"{",
"if",
"(",
"res",
".",
"statusCode",
"!=",
"200",
")",
"{",
"var",
"msg",
"=",
"'Failed to load '",
"+",
"url",
"+",
"'\\n'",
"+",
"'HTTP responce... | Downloads the script by remote url and provides its content as a
string to the callback
@param {String} url of the remote module to load
@param {Function} sCb success callback
@param {Function} fCb failure callback | [
"Downloads",
"the",
"script",
"by",
"remote",
"url",
"and",
"provides",
"its",
"content",
"as",
"a",
"string",
"to",
"the",
"callback"
] | 6e453d97e74fbd1c0b27b982084f6fd7c1aa0173 | https://github.com/theThings/jailed-node/blob/6e453d97e74fbd1c0b27b982084f6fd7c1aa0173/sandbox/sandbox.js#L220-L245 | train | |
theThings/jailed-node | sandbox/sandbox.js | printError | function printError() {
var _log = [new Date().toGMTString().concat(' jailed:sandbox')].concat([].slice.call(arguments))
console.error.apply(null, _log)
} | javascript | function printError() {
var _log = [new Date().toGMTString().concat(' jailed:sandbox')].concat([].slice.call(arguments))
console.error.apply(null, _log)
} | [
"function",
"printError",
"(",
")",
"{",
"var",
"_log",
"=",
"[",
"new",
"Date",
"(",
")",
".",
"toGMTString",
"(",
")",
".",
"concat",
"(",
"' jailed:sandbox'",
")",
"]",
".",
"concat",
"(",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
"... | Prints error message and its stack
@param {Object} msg stack provided by error.stack or a message | [
"Prints",
"error",
"message",
"and",
"its",
"stack"
] | 6e453d97e74fbd1c0b27b982084f6fd7c1aa0173 | https://github.com/theThings/jailed-node/blob/6e453d97e74fbd1c0b27b982084f6fd7c1aa0173/sandbox/sandbox.js#L267-L270 | train |
oscmejia/libs | lib/libs/number.js | random | function random(_length) {
var string_length = _length;
if(string_length < 0)
string_length = 1;
var chars = "0123456789";
var num = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
num += chars.substring(rnum,rnum+1)... | javascript | function random(_length) {
var string_length = _length;
if(string_length < 0)
string_length = 1;
var chars = "0123456789";
var num = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
num += chars.substring(rnum,rnum+1)... | [
"function",
"random",
"(",
"_length",
")",
"{",
"var",
"string_length",
"=",
"_length",
";",
"if",
"(",
"string_length",
"<",
"0",
")",
"string_length",
"=",
"1",
";",
"var",
"chars",
"=",
"\"0123456789\"",
";",
"var",
"num",
"=",
"''",
";",
"for",
"("... | Generates a random number of the provided length
@param {int} _length
@api public | [
"Generates",
"a",
"random",
"number",
"of",
"the",
"provided",
"length"
] | 81f8654af6ee922963e6cc3f6cda96ffa75142cf | https://github.com/oscmejia/libs/blob/81f8654af6ee922963e6cc3f6cda96ffa75142cf/lib/libs/number.js#L7-L21 | train |
oscmejia/libs | lib/libs/number.js | randomBetween | function randomBetween(_min, _max) {
var max, min;
if(_min > _max){
min = _max;
max = _min;
}
else if(_min === _max){
return _min;
}
else{
max = _max;
min = _min;
}
var r = Math.floor(Math.random() * max) + min;
if(r > max)
return max;
if(r < min)
return min;
else... | javascript | function randomBetween(_min, _max) {
var max, min;
if(_min > _max){
min = _max;
max = _min;
}
else if(_min === _max){
return _min;
}
else{
max = _max;
min = _min;
}
var r = Math.floor(Math.random() * max) + min;
if(r > max)
return max;
if(r < min)
return min;
else... | [
"function",
"randomBetween",
"(",
"_min",
",",
"_max",
")",
"{",
"var",
"max",
",",
"min",
";",
"if",
"(",
"_min",
">",
"_max",
")",
"{",
"min",
"=",
"_max",
";",
"max",
"=",
"_min",
";",
"}",
"else",
"if",
"(",
"_min",
"===",
"_max",
")",
"{",... | Generates a random number between two numbers
@param {int} _min
@param {int} _max
@api public | [
"Generates",
"a",
"random",
"number",
"between",
"two",
"numbers"
] | 81f8654af6ee922963e6cc3f6cda96ffa75142cf | https://github.com/oscmejia/libs/blob/81f8654af6ee922963e6cc3f6cda96ffa75142cf/lib/libs/number.js#L30-L53 | train |
brewster/imagine | lib/imagine/statsd.js | function (data) {
if (this.silent) {
return;
}
data = this.prefix ? this.prefix + '.' + data : data;
var buffer = new Buffer(data);
this.client.send(buffer, 0, buffer.length, this.port, this.host);
} | javascript | function (data) {
if (this.silent) {
return;
}
data = this.prefix ? this.prefix + '.' + data : data;
var buffer = new Buffer(data);
this.client.send(buffer, 0, buffer.length, this.port, this.host);
} | [
"function",
"(",
"data",
")",
"{",
"if",
"(",
"this",
".",
"silent",
")",
"{",
"return",
";",
"}",
"data",
"=",
"this",
".",
"prefix",
"?",
"this",
".",
"prefix",
"+",
"'.'",
"+",
"data",
":",
"data",
";",
"var",
"buffer",
"=",
"new",
"Buffer",
... | Send a request Do nothing if we've been silenced | [
"Send",
"a",
"request",
"Do",
"nothing",
"if",
"we",
"ve",
"been",
"silenced"
] | 42782ff6365f225f1fb9d90d3a654791286ef023 | https://github.com/brewster/imagine/blob/42782ff6365f225f1fb9d90d3a654791286ef023/lib/imagine/statsd.js#L44-L51 | train | |
bjnortier/lathe | lib/bsp.js | function(obj) {
if (obj instanceof Cell) {
return {
inside: obj.inside
};
} else {
return {
back : serialize(obj.back),
front : serialize(obj.front),
plane: obj.plane,
shp: obj.shp,
complemented: obj.complemented,
};
}
} | javascript | function(obj) {
if (obj instanceof Cell) {
return {
inside: obj.inside
};
} else {
return {
back : serialize(obj.back),
front : serialize(obj.front),
plane: obj.plane,
shp: obj.shp,
complemented: obj.complemented,
};
}
} | [
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"Cell",
")",
"{",
"return",
"{",
"inside",
":",
"obj",
".",
"inside",
"}",
";",
"}",
"else",
"{",
"return",
"{",
"back",
":",
"serialize",
"(",
"obj",
".",
"back",
")",
",",
"front... | Serialize to a non-circular Javascript object | [
"Serialize",
"to",
"a",
"non",
"-",
"circular",
"Javascript",
"object"
] | dca3ff6662fed9160f7b0ac82adad1af254b1147 | https://github.com/bjnortier/lathe/blob/dca3ff6662fed9160f7b0ac82adad1af254b1147/lib/bsp.js#L372-L386 | train | |
zlash/kwyjibo | js/controller.js | Middleware | function Middleware(...middleware) {
return (ctr) => {
if (middleware != undefined) {
let c = exports.globalKCState.getOrInsertController(ctr);
c.middleware = middleware.concat(c.middleware);
}
};
} | javascript | function Middleware(...middleware) {
return (ctr) => {
if (middleware != undefined) {
let c = exports.globalKCState.getOrInsertController(ctr);
c.middleware = middleware.concat(c.middleware);
}
};
} | [
"function",
"Middleware",
"(",
"...",
"middleware",
")",
"{",
"return",
"(",
"ctr",
")",
"=>",
"{",
"if",
"(",
"middleware",
"!=",
"undefined",
")",
"{",
"let",
"c",
"=",
"exports",
".",
"globalKCState",
".",
"getOrInsertController",
"(",
"ctr",
")",
";"... | Adds express middleware to run before mounting the controller
@param { Express.RequestHandler[] } middleware - Array of middleware to add. | [
"Adds",
"express",
"middleware",
"to",
"run",
"before",
"mounting",
"the",
"controller"
] | 466da0e0445f04b48e0e0ff83ecaaa0554114c64 | https://github.com/zlash/kwyjibo/blob/466da0e0445f04b48e0e0ff83ecaaa0554114c64/js/controller.js#L157-L164 | train |
zlash/kwyjibo | js/controller.js | ActionMiddleware | function ActionMiddleware(...middleware) {
return function (target, propertyKey, descriptor) {
if (middleware != undefined) {
let m = exports.globalKCState.getOrInsertController(target.constructor).getOrInsertMethod(propertyKey);
m.middleware = middleware.concat(m.middleware);
... | javascript | function ActionMiddleware(...middleware) {
return function (target, propertyKey, descriptor) {
if (middleware != undefined) {
let m = exports.globalKCState.getOrInsertController(target.constructor).getOrInsertMethod(propertyKey);
m.middleware = middleware.concat(m.middleware);
... | [
"function",
"ActionMiddleware",
"(",
"...",
"middleware",
")",
"{",
"return",
"function",
"(",
"target",
",",
"propertyKey",
",",
"descriptor",
")",
"{",
"if",
"(",
"middleware",
"!=",
"undefined",
")",
"{",
"let",
"m",
"=",
"exports",
".",
"globalKCState",
... | Adds express middleware to run before the method
@param { Express.RequestHandler[] } middleware - Array of middleware to add. | [
"Adds",
"express",
"middleware",
"to",
"run",
"before",
"the",
"method"
] | 466da0e0445f04b48e0e0ff83ecaaa0554114c64 | https://github.com/zlash/kwyjibo/blob/466da0e0445f04b48e0e0ff83ecaaa0554114c64/js/controller.js#L239-L246 | 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.