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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
OpenSmartEnvironment/ose | lib/shard/index.js | init | function init() { // {{{2
/**
* Class constructor
*
* @method constructor
*/
O.inherited(this)();
this.setMaxListeners(Consts.coreListeners);
this.subjectState = this.SUBJECT_STATE.INIT;
this.homeTimeOffset = 0;
this.lastTid = 0; // {{{3
/**
* Autoincemental part of last transaction id created... | javascript | function init() { // {{{2
/**
* Class constructor
*
* @method constructor
*/
O.inherited(this)();
this.setMaxListeners(Consts.coreListeners);
this.subjectState = this.SUBJECT_STATE.INIT;
this.homeTimeOffset = 0;
this.lastTid = 0; // {{{3
/**
* Autoincemental part of last transaction id created... | [
"function",
"init",
"(",
")",
"{",
"// {{{2",
"/**\n * Class constructor\n *\n * @method constructor\n */",
"O",
".",
"inherited",
"(",
"this",
")",
"(",
")",
";",
"this",
".",
"setMaxListeners",
"(",
"Consts",
".",
"coreListeners",
")",
";",
"this",
".",
"subje... | master {{{2
Client socket linked to the master shard
@property master
@type Object
Public {{{1 | [
"master",
"{{{",
"2",
"Client",
"socket",
"linked",
"to",
"the",
"master",
"shard"
] | 2ab051d9db6e77341c40abb9cbdae6ce586917e0 | https://github.com/OpenSmartEnvironment/ose/blob/2ab051d9db6e77341c40abb9cbdae6ce586917e0/lib/shard/index.js#L94-L136 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | arrayIncludesWith | function arrayIncludesWith(array, value, comparator) {
var index = -1, length = array.length;
while (++index < length) {
if (comparator(value, array[index])) {
return true;
}
}
return false;
} | javascript | function arrayIncludesWith(array, value, comparator) {
var index = -1, length = array.length;
while (++index < length) {
if (comparator(value, array[index])) {
return true;
}
}
return false;
} | [
"function",
"arrayIncludesWith",
"(",
"array",
",",
"value",
",",
"comparator",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"array",
".",
"length",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"if",
"(",
"comparator",
"... | This function is like `arrayIncludes` except that it accepts a comparator.
@private
@param {Array} array The array to search.
@param {*} target The value to search for.
@param {Function} comparator The comparator invoked per element.
@returns {boolean} Returns `true` if `target` is found, else `false`. | [
"This",
"function",
"is",
"like",
"arrayIncludes",
"except",
"that",
"it",
"accepts",
"a",
"comparator",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L12059-L12067 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | arrayReduceRight | function arrayReduceRight(array, iteratee, accumulator, initAccum) {
var length = array.length;
if (initAccum && length) {
accumulator = array[--length];
}
while (length--) {
accumulator = iteratee(accumulator, array[length], length, array);
}
return accumulator;
... | javascript | function arrayReduceRight(array, iteratee, accumulator, initAccum) {
var length = array.length;
if (initAccum && length) {
accumulator = array[--length];
}
while (length--) {
accumulator = iteratee(accumulator, array[length], length, array);
}
return accumulator;
... | [
"function",
"arrayReduceRight",
"(",
"array",
",",
"iteratee",
",",
"accumulator",
",",
"initAccum",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
";",
"if",
"(",
"initAccum",
"&&",
"length",
")",
"{",
"accumulator",
"=",
"array",
"[",
"--",
"l... | A specialized version of `_.reduceRight` for arrays without support for
iteratee shorthands.
@private
@param {Array} array The array to iterate over.
@param {Function} iteratee The function invoked per iteration.
@param {*} [accumulator] The initial value.
@param {boolean} [initAccum] Specify using the last element of... | [
"A",
"specialized",
"version",
"of",
"_",
".",
"reduceRight",
"for",
"arrays",
"without",
"support",
"for",
"iteratee",
"shorthands",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L12131-L12140 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | baseExtremum | function baseExtremum(array, iteratee, comparator) {
var index = -1, length = array.length;
while (++index < length) {
var value = array[index], current = iteratee(value);
if (current != null && (computed === undefined ? current === current : comparator(current, computed))) {
var c... | javascript | function baseExtremum(array, iteratee, comparator) {
var index = -1, length = array.length;
while (++index < length) {
var value = array[index], current = iteratee(value);
if (current != null && (computed === undefined ? current === current : comparator(current, computed))) {
var c... | [
"function",
"baseExtremum",
"(",
"array",
",",
"iteratee",
",",
"comparator",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"array",
".",
"length",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"var",
"value",
"=",
"array"... | The base implementation of methods like `_.max` and `_.min` which accepts a
`comparator` to determine the extremum value.
@private
@param {Array} array The array to iterate over.
@param {Function} iteratee The iteratee invoked per iteration.
@param {Function} comparator The comparator used to compare values.
@returns ... | [
"The",
"base",
"implementation",
"of",
"methods",
"like",
"_",
".",
"max",
"and",
"_",
".",
"min",
"which",
"accepts",
"a",
"comparator",
"to",
"determine",
"the",
"extremum",
"value",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L12169-L12178 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | stringSize | function stringSize(string) {
if (!(string && reHasComplexSymbol.test(string))) {
return string.length;
}
var result = reComplexSymbol.lastIndex = 0;
while (reComplexSymbol.test(string)) {
result++;
}
return result;
} | javascript | function stringSize(string) {
if (!(string && reHasComplexSymbol.test(string))) {
return string.length;
}
var result = reComplexSymbol.lastIndex = 0;
while (reComplexSymbol.test(string)) {
result++;
}
return result;
} | [
"function",
"stringSize",
"(",
"string",
")",
"{",
"if",
"(",
"!",
"(",
"string",
"&&",
"reHasComplexSymbol",
".",
"test",
"(",
"string",
")",
")",
")",
"{",
"return",
"string",
".",
"length",
";",
"}",
"var",
"result",
"=",
"reComplexSymbol",
".",
"la... | Gets the number of symbols in `string`.
@private
@param {string} string The string to inspect.
@returns {number} Returns the string size. | [
"Gets",
"the",
"number",
"of",
"symbols",
"in",
"string",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L12640-L12649 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | cacheHas | function cacheHas(cache, value) {
var map = cache.__data__;
if (isKeyable(value)) {
var data = map.__data__, hash = typeof value == 'string' ? data.string : data.hash;
return hash[value] === HASH_UNDEFINED;
}
return map.has(value);
} | javascript | function cacheHas(cache, value) {
var map = cache.__data__;
if (isKeyable(value)) {
var data = map.__data__, hash = typeof value == 'string' ? data.string : data.hash;
return hash[value] === HASH_UNDEFINED;
}
return map.has(value);
} | [
"function",
"cacheHas",
"(",
"cache",
",",
"value",
")",
"{",
"var",
"map",
"=",
"cache",
".",
"__data__",
";",
"if",
"(",
"isKeyable",
"(",
"value",
")",
")",
"{",
"var",
"data",
"=",
"map",
".",
"__data__",
",",
"hash",
"=",
"typeof",
"value",
"=... | Checks if `value` is in `cache`.
@private
@param {Object} cache The set cache to search.
@param {*} value The value to search for.
@returns {number} Returns `true` if `value` is found, else `false`. | [
"Checks",
"if",
"value",
"is",
"in",
"cache",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L13177-L13184 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | baseHas | function baseHas(object, key) {
// Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
// that are composed entirely of index properties, return `false` for
// `hasOwnProperty` checks of them.
return hasOwnProperty.call(object, key) || typeof object == 'object' && key i... | javascript | function baseHas(object, key) {
// Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
// that are composed entirely of index properties, return `false` for
// `hasOwnProperty` checks of them.
return hasOwnProperty.call(object, key) || typeof object == 'object' && key i... | [
"function",
"baseHas",
"(",
"object",
",",
"key",
")",
"{",
"// Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,",
"// that are composed entirely of index properties, return `false` for",
"// `hasOwnProperty` checks of them.",
"return",
"hasOwnProperty",
".",
"call",... | The base implementation of `_.has` without support for deep paths.
@private
@param {Object} object The object to query.
@param {Array|string} key The key to check.
@returns {boolean} Returns `true` if `key` exists, else `false`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"has",
"without",
"support",
"for",
"deep",
"paths",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L13880-L13885 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | basePick | function basePick(object, props) {
object = Object(object);
return arrayReduce(props, function (result, key) {
if (key in object) {
result[key] = object[key];
}
return result;
}, {});
} | javascript | function basePick(object, props) {
object = Object(object);
return arrayReduce(props, function (result, key) {
if (key in object) {
result[key] = object[key];
}
return result;
}, {});
} | [
"function",
"basePick",
"(",
"object",
",",
"props",
")",
"{",
"object",
"=",
"Object",
"(",
"object",
")",
";",
"return",
"arrayReduce",
"(",
"props",
",",
"function",
"(",
"result",
",",
"key",
")",
"{",
"if",
"(",
"key",
"in",
"object",
")",
"{",
... | The base implementation of `_.pick` without support for individual
property names.
@private
@param {Object} object The source object.
@param {string[]} props The property names to pick.
@returns {Object} Returns the new object. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"pick",
"without",
"support",
"for",
"individual",
"property",
"names",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L14315-L14323 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | basePullAll | function basePullAll(array, values, iteratee, comparator) {
var indexOf = comparator ? baseIndexOfWith : baseIndexOf, index = -1, length = values.length, seen = array;
if (iteratee) {
seen = arrayMap(array, baseUnary(iteratee));
}
while (++index < length) {
var fromIn... | javascript | function basePullAll(array, values, iteratee, comparator) {
var indexOf = comparator ? baseIndexOfWith : baseIndexOf, index = -1, length = values.length, seen = array;
if (iteratee) {
seen = arrayMap(array, baseUnary(iteratee));
}
while (++index < length) {
var fromIn... | [
"function",
"basePullAll",
"(",
"array",
",",
"values",
",",
"iteratee",
",",
"comparator",
")",
"{",
"var",
"indexOf",
"=",
"comparator",
"?",
"baseIndexOfWith",
":",
"baseIndexOf",
",",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"values",
".",
"length",... | The base implementation of `_.pullAllBy` without support for iteratee
shorthands.
@private
@param {Array} array The array to modify.
@param {Array} values The values to remove.
@param {Function} [iteratee] The iteratee invoked per element.
@param {Function} [comparator] The comparator invoked per element.
@returns {Ar... | [
"The",
"base",
"implementation",
"of",
"_",
".",
"pullAllBy",
"without",
"support",
"for",
"iteratee",
"shorthands",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L14376-L14391 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | indexKeys | function indexKeys(object) {
var length = object ? object.length : undefined;
if (isLength(length) && (isArray(object) || isString(object) || isArguments(object))) {
return baseTimes(length, String);
}
return null;
} | javascript | function indexKeys(object) {
var length = object ? object.length : undefined;
if (isLength(length) && (isArray(object) || isString(object) || isArguments(object))) {
return baseTimes(length, String);
}
return null;
} | [
"function",
"indexKeys",
"(",
"object",
")",
"{",
"var",
"length",
"=",
"object",
"?",
"object",
".",
"length",
":",
"undefined",
";",
"if",
"(",
"isLength",
"(",
"length",
")",
"&&",
"(",
"isArray",
"(",
"object",
")",
"||",
"isString",
"(",
"object",... | Creates an array of index keys for `object` values of arrays,
`arguments` objects, and strings, otherwise `null` is returned.
@private
@param {Object} object The object to query.
@returns {Array|null} Returns index keys, else `null`. | [
"Creates",
"an",
"array",
"of",
"index",
"keys",
"for",
"object",
"values",
"of",
"arrays",
"arguments",
"objects",
"and",
"strings",
"otherwise",
"null",
"is",
"returned",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L15955-L15961 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | mergeDefaults | function mergeDefaults(objValue, srcValue, key, object, source, stack) {
if (isObject(objValue) && isObject(srcValue)) {
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue));
}
return objValue;
} | javascript | function mergeDefaults(objValue, srcValue, key, object, source, stack) {
if (isObject(objValue) && isObject(srcValue)) {
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue));
}
return objValue;
} | [
"function",
"mergeDefaults",
"(",
"objValue",
",",
"srcValue",
",",
"key",
",",
"object",
",",
"source",
",",
"stack",
")",
"{",
"if",
"(",
"isObject",
"(",
"objValue",
")",
"&&",
"isObject",
"(",
"srcValue",
")",
")",
"{",
"baseMerge",
"(",
"objValue",
... | Used by `_.defaultsDeep` to customize its `_.merge` use.
@private
@param {*} objValue The destination value.
@param {*} srcValue The source value.
@param {string} key The key of the property to merge.
@param {Object} object The parent object of `objValue`.
@param {Object} source The parent object of `srcValue`.
@param... | [
"Used",
"by",
"_",
".",
"defaultsDeep",
"to",
"customize",
"its",
"_",
".",
"merge",
"use",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L16118-L16123 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | sample | function sample(collection) {
var array = isArrayLike(collection) ? collection : values(collection), length = array.length;
return length > 0 ? array[baseRandom(0, length - 1)] : undefined;
} | javascript | function sample(collection) {
var array = isArrayLike(collection) ? collection : values(collection), length = array.length;
return length > 0 ? array[baseRandom(0, length - 1)] : undefined;
} | [
"function",
"sample",
"(",
"collection",
")",
"{",
"var",
"array",
"=",
"isArrayLike",
"(",
"collection",
")",
"?",
"collection",
":",
"values",
"(",
"collection",
")",
",",
"length",
"=",
"array",
".",
"length",
";",
"return",
"length",
">",
"0",
"?",
... | Gets a random element from `collection`.
@static
@memberOf _
@category Collection
@param {Array|Object} collection The collection to sample.
@returns {*} Returns the random element.
@example
_.sample([1, 2, 3, 4]);
// => 2 | [
"Gets",
"a",
"random",
"element",
"from",
"collection",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L18792-L18795 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | size | function size(collection) {
if (collection == null) {
return 0;
}
if (isArrayLike(collection)) {
var result = collection.length;
return result && isString(collection) ? stringSize(collection) : result;
}
return keys(collection).length;
} | javascript | function size(collection) {
if (collection == null) {
return 0;
}
if (isArrayLike(collection)) {
var result = collection.length;
return result && isString(collection) ? stringSize(collection) : result;
}
return keys(collection).length;
} | [
"function",
"size",
"(",
"collection",
")",
"{",
"if",
"(",
"collection",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"isArrayLike",
"(",
"collection",
")",
")",
"{",
"var",
"result",
"=",
"collection",
".",
"length",
";",
"return",
"... | Gets the size of `collection` by returning its length for array-like
values or the number of own enumerable properties for objects.
@static
@memberOf _
@category Collection
@param {Array|Object} collection The collection to inspect.
@returns {number} Returns the collection size.
@example
_.size([1, 2, 3]);
// => 3
_... | [
"Gets",
"the",
"size",
"of",
"collection",
"by",
"returning",
"its",
"length",
"for",
"array",
"-",
"like",
"values",
"or",
"the",
"number",
"of",
"own",
"enumerable",
"properties",
"for",
"objects",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L18862-L18871 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | isTypedArray | function isTypedArray(value) {
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
} | javascript | function isTypedArray(value) {
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
} | [
"function",
"isTypedArray",
"(",
"value",
")",
"{",
"return",
"isObjectLike",
"(",
"value",
")",
"&&",
"isLength",
"(",
"value",
".",
"length",
")",
"&&",
"!",
"!",
"typedArrayTags",
"[",
"objectToString",
".",
"call",
"(",
"value",
")",
"]",
";",
"}"
] | Checks if `value` is classified as a typed array.
@static
@memberOf _
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
@example
_.isTypedArray(new Uint8Array);
// => true
_.isTypedArray([]);
// => false | [
"Checks",
"if",
"value",
"is",
"classified",
"as",
"a",
"typed",
"array",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L20948-L20950 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | keys | function keys(object) {
var isProto = isPrototype(object);
if (!(isProto || isArrayLike(object))) {
return baseKeys(object);
}
var indexes = indexKeys(object), skipIndexes = !!indexes, result = indexes || [], length = result.length;
for (var key in object) {
i... | javascript | function keys(object) {
var isProto = isPrototype(object);
if (!(isProto || isArrayLike(object))) {
return baseKeys(object);
}
var indexes = indexKeys(object), skipIndexes = !!indexes, result = indexes || [], length = result.length;
for (var key in object) {
i... | [
"function",
"keys",
"(",
"object",
")",
"{",
"var",
"isProto",
"=",
"isPrototype",
"(",
"object",
")",
";",
"if",
"(",
"!",
"(",
"isProto",
"||",
"isArrayLike",
"(",
"object",
")",
")",
")",
"{",
"return",
"baseKeys",
"(",
"object",
")",
";",
"}",
... | Creates an array of the own enumerable property names of `object`.
**Note:** Non-object values are coerced to objects. See the
[ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
for more details.
@static
@memberOf _
@category Object
@param {Object} object The object to query.
@returns {Array} Retu... | [
"Creates",
"an",
"array",
"of",
"the",
"own",
"enumerable",
"property",
"names",
"of",
"object",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L21930-L21942 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | parseInt | function parseInt(string, radix, guard) {
// Chrome fails to trim leading <BOM> whitespace characters.
// See https://code.google.com/p/v8/issues/detail?id=3109 for more details.
if (guard || radix == null) {
radix = 0;
} else if (radix) {
radix = +radix;
}
... | javascript | function parseInt(string, radix, guard) {
// Chrome fails to trim leading <BOM> whitespace characters.
// See https://code.google.com/p/v8/issues/detail?id=3109 for more details.
if (guard || radix == null) {
radix = 0;
} else if (radix) {
radix = +radix;
}
... | [
"function",
"parseInt",
"(",
"string",
",",
"radix",
",",
"guard",
")",
"{",
"// Chrome fails to trim leading <BOM> whitespace characters.",
"// See https://code.google.com/p/v8/issues/detail?id=3109 for more details.",
"if",
"(",
"guard",
"||",
"radix",
"==",
"null",
")",
"{... | Converts `string` to an integer of the specified radix. If `radix` is
`undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal,
in which case a `radix` of `16` is used.
**Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#x15.1.2.2)
of `parseInt`.
@static
@memberOf _
... | [
"Converts",
"string",
"to",
"an",
"integer",
"of",
"the",
"specified",
"radix",
".",
"If",
"radix",
"is",
"undefined",
"or",
"0",
"a",
"radix",
"of",
"10",
"is",
"used",
"unless",
"value",
"is",
"a",
"hexadecimal",
"in",
"which",
"case",
"a",
"radix",
... | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L23004-L23014 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | words | function words(string, pattern, guard) {
string = toString(string);
pattern = guard ? undefined : pattern;
if (pattern === undefined) {
pattern = reHasComplexWord.test(string) ? reComplexWord : reBasicWord;
}
return string.match(pattern) || [];
} | javascript | function words(string, pattern, guard) {
string = toString(string);
pattern = guard ? undefined : pattern;
if (pattern === undefined) {
pattern = reHasComplexWord.test(string) ? reComplexWord : reBasicWord;
}
return string.match(pattern) || [];
} | [
"function",
"words",
"(",
"string",
",",
"pattern",
",",
"guard",
")",
"{",
"string",
"=",
"toString",
"(",
"string",
")",
";",
"pattern",
"=",
"guard",
"?",
"undefined",
":",
"pattern",
";",
"if",
"(",
"pattern",
"===",
"undefined",
")",
"{",
"pattern... | Splits `string` into an array of its words.
@static
@memberOf _
@category String
@param {string} [string=''] The string to inspect.
@param {RegExp|string} [pattern] The pattern to match words.
@param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
@returns {Array} Returns the words of `string`... | [
"Splits",
"string",
"into",
"an",
"array",
"of",
"its",
"words",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L23611-L23618 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | mixin | function mixin(object, source, options) {
var props = keys(source), methodNames = baseFunctions(source, props);
if (options == null && !(isObject(source) && (methodNames.length || !props.length))) {
options = source;
source = object;
object = this;
methodNames = b... | javascript | function mixin(object, source, options) {
var props = keys(source), methodNames = baseFunctions(source, props);
if (options == null && !(isObject(source) && (methodNames.length || !props.length))) {
options = source;
source = object;
object = this;
methodNames = b... | [
"function",
"mixin",
"(",
"object",
",",
"source",
",",
"options",
")",
"{",
"var",
"props",
"=",
"keys",
"(",
"source",
")",
",",
"methodNames",
"=",
"baseFunctions",
"(",
"source",
",",
"props",
")",
";",
"if",
"(",
"options",
"==",
"null",
"&&",
"... | Adds all own enumerable function properties of a source object to the
destination object. If `object` is a function then methods are added to
its prototype as well.
**Note:** Use `_.runInContext` to create a pristine `lodash` function to
avoid conflicts caused by modifying the original.
@static
@memberOf _
@category ... | [
"Adds",
"all",
"own",
"enumerable",
"function",
"properties",
"of",
"a",
"source",
"object",
"to",
"the",
"destination",
"object",
".",
"If",
"object",
"is",
"a",
"function",
"then",
"methods",
"are",
"added",
"to",
"its",
"prototype",
"as",
"well",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L24007-L24037 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | subtract | function subtract(minuend, subtrahend) {
var result;
if (minuend === undefined && subtrahend === undefined) {
return 0;
}
if (minuend !== undefined) {
result = minuend;
}
if (subtrahend !== undefined) {
result = result === undefined ? subtrah... | javascript | function subtract(minuend, subtrahend) {
var result;
if (minuend === undefined && subtrahend === undefined) {
return 0;
}
if (minuend !== undefined) {
result = minuend;
}
if (subtrahend !== undefined) {
result = result === undefined ? subtrah... | [
"function",
"subtract",
"(",
"minuend",
",",
"subtrahend",
")",
"{",
"var",
"result",
";",
"if",
"(",
"minuend",
"===",
"undefined",
"&&",
"subtrahend",
"===",
"undefined",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"minuend",
"!==",
"undefined",
")",... | Subtract two numbers.
@static
@memberOf _
@category Math
@param {number} minuend The first number in a subtraction.
@param {number} subtrahend The second number in a subtraction.
@returns {number} Returns the difference.
@example
_.subtract(6, 4);
// => 2 | [
"Subtract",
"two",
"numbers",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L24571-L24583 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | onWindowLoad | function onWindowLoad() {
self.isLoaded = true;
onPluginStart();
if (windowLoadListenderAttached) {
window.removeEventListener('load', onWindowLoad, false);
}
} | javascript | function onWindowLoad() {
self.isLoaded = true;
onPluginStart();
if (windowLoadListenderAttached) {
window.removeEventListener('load', onWindowLoad, false);
}
} | [
"function",
"onWindowLoad",
"(",
")",
"{",
"self",
".",
"isLoaded",
"=",
"true",
";",
"onPluginStart",
"(",
")",
";",
"if",
"(",
"windowLoadListenderAttached",
")",
"{",
"window",
".",
"removeEventListener",
"(",
"'load'",
",",
"onWindowLoad",
",",
"false",
... | Setup listeners to know when we're ready to go. | [
"Setup",
"listeners",
"to",
"know",
"when",
"we",
"re",
"ready",
"to",
"go",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L25415-L25423 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | isCordova | function isCordova() {
var isCordova = null;
var idxIsCordova = window.location.search.indexOf('isCordova=');
if (idxIsCordova >= 0) {
var isCordova = window.location.search.substring(idxIsCordova + 10);
if (isCordova.indexOf('&') >= 0) {
isCordova = isCordova.substring(0, i... | javascript | function isCordova() {
var isCordova = null;
var idxIsCordova = window.location.search.indexOf('isCordova=');
if (idxIsCordova >= 0) {
var isCordova = window.location.search.substring(idxIsCordova + 10);
if (isCordova.indexOf('&') >= 0) {
isCordova = isCordova.substring(0, i... | [
"function",
"isCordova",
"(",
")",
"{",
"var",
"isCordova",
"=",
"null",
";",
"var",
"idxIsCordova",
"=",
"window",
".",
"location",
".",
"search",
".",
"indexOf",
"(",
"'isCordova='",
")",
";",
"if",
"(",
"idxIsCordova",
">=",
"0",
")",
"{",
"var",
"i... | Get the isCordova boolean from the URL. | [
"Get",
"the",
"isCordova",
"boolean",
"from",
"the",
"URL",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L25573-L25584 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | createAccessors | function createAccessors(keys) {
var fname;
lodash.forEach(keys, function(key) {
key.replace(/[^\w\d-]/g, '');
// get<key>
fname = createFnName('get', key);
self[fname] = function() {
return getKey(ns + key);
};
// set<key>
fname = createF... | javascript | function createAccessors(keys) {
var fname;
lodash.forEach(keys, function(key) {
key.replace(/[^\w\d-]/g, '');
// get<key>
fname = createFnName('get', key);
self[fname] = function() {
return getKey(ns + key);
};
// set<key>
fname = createF... | [
"function",
"createAccessors",
"(",
"keys",
")",
"{",
"var",
"fname",
";",
"lodash",
".",
"forEach",
"(",
"keys",
",",
"function",
"(",
"key",
")",
"{",
"key",
".",
"replace",
"(",
"/",
"[^\\w\\d-]",
"/",
"g",
",",
"''",
")",
";",
"// get<key>",
"fna... | Private functions
Create accessor functions for each key. | [
"Private",
"functions",
"Create",
"accessor",
"functions",
"for",
"each",
"key",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L26987-L27012 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | timeout | function timeout(message) {
$log.warn('Plugin client request timeout: ' + serialize(message));
var promiseIndex = lodash.findIndex(promises, function(promise) {
return promise.id == message.header.id;
});
if (promiseIndex >= 0) {
var promise = lodash.pullAt(promises, promiseIndex);
... | javascript | function timeout(message) {
$log.warn('Plugin client request timeout: ' + serialize(message));
var promiseIndex = lodash.findIndex(promises, function(promise) {
return promise.id == message.header.id;
});
if (promiseIndex >= 0) {
var promise = lodash.pullAt(promises, promiseIndex);
... | [
"function",
"timeout",
"(",
"message",
")",
"{",
"$log",
".",
"warn",
"(",
"'Plugin client request timeout: '",
"+",
"serialize",
"(",
"message",
")",
")",
";",
"var",
"promiseIndex",
"=",
"lodash",
".",
"findIndex",
"(",
"promises",
",",
"function",
"(",
"p... | Timeout a message waiting for a response. Enables the client app to process a message delivery failure. | [
"Timeout",
"a",
"message",
"waiting",
"for",
"a",
"response",
".",
"Enables",
"the",
"client",
"app",
"to",
"process",
"a",
"message",
"delivery",
"failure",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L28037-L28058 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | transport | function transport(message) {
return {
header: message.header,
request: message.request,
response: message.response
}
} | javascript | function transport(message) {
return {
header: message.header,
request: message.request,
response: message.response
}
} | [
"function",
"transport",
"(",
"message",
")",
"{",
"return",
"{",
"header",
":",
"message",
".",
"header",
",",
"request",
":",
"message",
".",
"request",
",",
"response",
":",
"message",
".",
"response",
"}",
"}"
] | Only these properties of a message are sent and received. | [
"Only",
"these",
"properties",
"of",
"a",
"message",
"are",
"sent",
"and",
"received",
"."
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L28069-L28075 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | match | function match(mapEntry, request, route) {
var keys = [];
var m = pathToRegexpService.pathToRegexp(mapEntry.path, keys).exec(request.url);
if (!m) {
return false;
}
if (mapEntry.method != request.method) {
return false;
}
route.params = {};
route.path = m[0];
route.ha... | javascript | function match(mapEntry, request, route) {
var keys = [];
var m = pathToRegexpService.pathToRegexp(mapEntry.path, keys).exec(request.url);
if (!m) {
return false;
}
if (mapEntry.method != request.method) {
return false;
}
route.params = {};
route.path = m[0];
route.ha... | [
"function",
"match",
"(",
"mapEntry",
",",
"request",
",",
"route",
")",
"{",
"var",
"keys",
"=",
"[",
"]",
";",
"var",
"m",
"=",
"pathToRegexpService",
".",
"pathToRegexp",
"(",
"mapEntry",
".",
"path",
",",
"keys",
")",
".",
"exec",
"(",
"request",
... | Private static methods | [
"Private",
"static",
"methods"
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L28220-L28250 | train |
owstack/ows-wallet-plugin-client | release/ows-wallet-client.js | setConfig | function setConfig(configs) {
configProperties = platformConfigs;
provider.platform[platformName] = {};
addConfig(configProperties, configProperties.platform[platformName]);
createConfig(configProperties.platform[platformName], provider.platform[platformName], '');
} | javascript | function setConfig(configs) {
configProperties = platformConfigs;
provider.platform[platformName] = {};
addConfig(configProperties, configProperties.platform[platformName]);
createConfig(configProperties.platform[platformName], provider.platform[platformName], '');
} | [
"function",
"setConfig",
"(",
"configs",
")",
"{",
"configProperties",
"=",
"platformConfigs",
";",
"provider",
".",
"platform",
"[",
"platformName",
"]",
"=",
"{",
"}",
";",
"addConfig",
"(",
"configProperties",
",",
"configProperties",
".",
"platform",
"[",
... | Used to set configs | [
"Used",
"to",
"set",
"configs"
] | 431b510a0f10670a831e937a3f8a1f7e09dfca35 | https://github.com/owstack/ows-wallet-plugin-client/blob/431b510a0f10670a831e937a3f8a1f7e09dfca35/release/ows-wallet-client.js#L28644-L28651 | train |
tomasbasham/ember-cli-pubnub | index.js | function(app) {
this._super(app);
const vendorTree = this.treePaths.vendor;
// Import the PubNub package and shim.
app.import(`${vendorTree}/pubnub.js`);
app.import(`${vendorTree}/shims/pubnub.js`, {
exports: {
PubNub: ['default']
}
});
} | javascript | function(app) {
this._super(app);
const vendorTree = this.treePaths.vendor;
// Import the PubNub package and shim.
app.import(`${vendorTree}/pubnub.js`);
app.import(`${vendorTree}/shims/pubnub.js`, {
exports: {
PubNub: ['default']
}
});
} | [
"function",
"(",
"app",
")",
"{",
"this",
".",
"_super",
"(",
"app",
")",
";",
"const",
"vendorTree",
"=",
"this",
".",
"treePaths",
".",
"vendor",
";",
"// Import the PubNub package and shim.",
"app",
".",
"import",
"(",
"`",
"${",
"vendorTree",
"}",
"`",... | Add the PubNub JavaScript package
to the consuming application and
expose the vendor shim enabling it
to be imported as an es6 module.
@method included
@param {Object} app
An EmberApp instance. | [
"Add",
"the",
"PubNub",
"JavaScript",
"package",
"to",
"the",
"consuming",
"application",
"and",
"expose",
"the",
"vendor",
"shim",
"enabling",
"it",
"to",
"be",
"imported",
"as",
"an",
"es6",
"module",
"."
] | b758063df6989b0ce5ceee4f832ff4aeff08d036 | https://github.com/tomasbasham/ember-cli-pubnub/blob/b758063df6989b0ce5ceee4f832ff4aeff08d036/index.js#L21-L33 | train | |
tomasbasham/ember-cli-pubnub | index.js | function(vendorTree) {
const pubnubPath = path.dirname(require.resolve('pubnub/dist/web/pubnub.js'));
const pubnubTree = new Funnel(pubnubPath, {
src: 'pubnub.js',
dest: './',
annotation: 'Funnel (PubNub)'
});
return mergeTrees([vendorTree, pubnubTree]);
} | javascript | function(vendorTree) {
const pubnubPath = path.dirname(require.resolve('pubnub/dist/web/pubnub.js'));
const pubnubTree = new Funnel(pubnubPath, {
src: 'pubnub.js',
dest: './',
annotation: 'Funnel (PubNub)'
});
return mergeTrees([vendorTree, pubnubTree]);
} | [
"function",
"(",
"vendorTree",
")",
"{",
"const",
"pubnubPath",
"=",
"path",
".",
"dirname",
"(",
"require",
".",
"resolve",
"(",
"'pubnub/dist/web/pubnub.js'",
")",
")",
";",
"const",
"pubnubTree",
"=",
"new",
"Funnel",
"(",
"pubnubPath",
",",
"{",
"src",
... | Resolve the path to the PubNub web
bundle and transpose the files in
that path into the project's vendor
folder during build time.
@method treeForVendor
@params {Object} vendorTree
The broccoli tree representing vendor files. | [
"Resolve",
"the",
"path",
"to",
"the",
"PubNub",
"web",
"bundle",
"and",
"transpose",
"the",
"files",
"in",
"that",
"path",
"into",
"the",
"project",
"s",
"vendor",
"folder",
"during",
"build",
"time",
"."
] | b758063df6989b0ce5ceee4f832ff4aeff08d036 | https://github.com/tomasbasham/ember-cli-pubnub/blob/b758063df6989b0ce5ceee4f832ff4aeff08d036/index.js#L46-L55 | train | |
theboyWhoCriedWoolf/transition-manager | src/utils/default.js | defaultProps | function defaultProps( target, overwrite )
{
overwrite = overwrite || {};
for( var prop in overwrite ) {
if( target.hasOwnProperty(prop) && _isValid( overwrite[ prop ] ) ) {
target[ prop ] = overwrite[ prop ];
}
}
return target;
} | javascript | function defaultProps( target, overwrite )
{
overwrite = overwrite || {};
for( var prop in overwrite ) {
if( target.hasOwnProperty(prop) && _isValid( overwrite[ prop ] ) ) {
target[ prop ] = overwrite[ prop ];
}
}
return target;
} | [
"function",
"defaultProps",
"(",
"target",
",",
"overwrite",
")",
"{",
"overwrite",
"=",
"overwrite",
"||",
"{",
"}",
";",
"for",
"(",
"var",
"prop",
"in",
"overwrite",
")",
"{",
"if",
"(",
"target",
".",
"hasOwnProperty",
"(",
"prop",
")",
"&&",
"_isV... | replace target object properties with the overwrite
object properties if they have been set
@param {object} target - object to overwrite
@param {object} overwrite - object with new properies and values
@return {object} | [
"replace",
"target",
"object",
"properties",
"with",
"the",
"overwrite",
"object",
"properties",
"if",
"they",
"have",
"been",
"set"
] | a20fda0bb07c0098bf709ea03770b1ee2a855655 | https://github.com/theboyWhoCriedWoolf/transition-manager/blob/a20fda0bb07c0098bf709ea03770b1ee2a855655/src/utils/default.js#L11-L20 | train |
AlmogBaku/grunt-hook | tasks/hook.js | function(action, weight) {
if(weight===undefined) {
weight=0;
}
this.tasks.push({ name: action, weight: weight});
} | javascript | function(action, weight) {
if(weight===undefined) {
weight=0;
}
this.tasks.push({ name: action, weight: weight});
} | [
"function",
"(",
"action",
",",
"weight",
")",
"{",
"if",
"(",
"weight",
"===",
"undefined",
")",
"{",
"weight",
"=",
"0",
";",
"}",
"this",
".",
"tasks",
".",
"push",
"(",
"{",
"name",
":",
"action",
",",
"weight",
":",
"weight",
"}",
")",
";",
... | Push new task
@param action
@param weight | [
"Push",
"new",
"task"
] | dae10b5d12b49f2de94567545d40b6dea9830804 | https://github.com/AlmogBaku/grunt-hook/blob/dae10b5d12b49f2de94567545d40b6dea9830804/tasks/hook.js#L21-L26 | train | |
AlmogBaku/grunt-hook | tasks/hook.js | function () {
var tasks = this.tasks.sort(function(a,b) {
if (a.weight < b.weight) {
return -1;
} if (a.weight > b.weight) {
return 1;
}
return 0;
});
var queue = [];
for(var i=0;i<tasks.length; i+=1) {
queue.push(tasks[i].name);
... | javascript | function () {
var tasks = this.tasks.sort(function(a,b) {
if (a.weight < b.weight) {
return -1;
} if (a.weight > b.weight) {
return 1;
}
return 0;
});
var queue = [];
for(var i=0;i<tasks.length; i+=1) {
queue.push(tasks[i].name);
... | [
"function",
"(",
")",
"{",
"var",
"tasks",
"=",
"this",
".",
"tasks",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
".",
"weight",
"<",
"b",
".",
"weight",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"a"... | Get all tasks ordered by weight
@returns {Array} | [
"Get",
"all",
"tasks",
"ordered",
"by",
"weight"
] | dae10b5d12b49f2de94567545d40b6dea9830804 | https://github.com/AlmogBaku/grunt-hook/blob/dae10b5d12b49f2de94567545d40b6dea9830804/tasks/hook.js#L32-L47 | train | |
jokemmy/promisynch | src/index.js | throwWapper | function throwWapper( callback ) {
return function( resultSet ) {
callback(
resultSet.err || null,
resultSet.err ? null : resultSet.result,
...resultSet.argument
);
if ( resultSet.err ) {
throw resultSet.err;
}
return resultSet;
};
} | javascript | function throwWapper( callback ) {
return function( resultSet ) {
callback(
resultSet.err || null,
resultSet.err ? null : resultSet.result,
...resultSet.argument
);
if ( resultSet.err ) {
throw resultSet.err;
}
return resultSet;
};
} | [
"function",
"throwWapper",
"(",
"callback",
")",
"{",
"return",
"function",
"(",
"resultSet",
")",
"{",
"callback",
"(",
"resultSet",
".",
"err",
"||",
"null",
",",
"resultSet",
".",
"err",
"?",
"null",
":",
"resultSet",
".",
"result",
",",
"...",
"resul... | use in finally method, catch a error and throw this error or throw the last error | [
"use",
"in",
"finally",
"method",
"catch",
"a",
"error",
"and",
"throw",
"this",
"error",
"or",
"throw",
"the",
"last",
"error"
] | 80a239d169dfb5c74eea356da031c756d6237115 | https://github.com/jokemmy/promisynch/blob/80a239d169dfb5c74eea356da031c756d6237115/src/index.js#L72-L84 | train |
OpenSmartEnvironment/ose | lib/kind.js | init | function init(schema, name) { // {{{2
/**
* Kind constructor
*
* @param schema {Object|String} Schema containing the kind
* @param name {String} Unique kind name within the schema
*
* @method constructor
*/
this.name = name; // {{{3
/**
* Kind name unique within a schema
*
* @property name
* @... | javascript | function init(schema, name) { // {{{2
/**
* Kind constructor
*
* @param schema {Object|String} Schema containing the kind
* @param name {String} Unique kind name within the schema
*
* @method constructor
*/
this.name = name; // {{{3
/**
* Kind name unique within a schema
*
* @property name
* @... | [
"function",
"init",
"(",
"schema",
",",
"name",
")",
"{",
"// {{{2",
"/**\n * Kind constructor\n *\n * @param schema {Object|String} Schema containing the kind\n * @param name {String} Unique kind name within the schema\n *\n * @method constructor\n */",
"this",
".",
"name",
"=",
"name",... | `entry.dval` structure description
Contains an [ose/lib/field/object] instance
@property ddef
@type Object
Public {{{1 | [
"entry",
".",
"dval",
"structure",
"description"
] | 2ab051d9db6e77341c40abb9cbdae6ce586917e0 | https://github.com/OpenSmartEnvironment/ose/blob/2ab051d9db6e77341c40abb9cbdae6ce586917e0/lib/kind.js#L47-L92 | train |
DriveTimeInc/gangplank | lib/validator.js | isException | function isException(url, exceptions) {
if (exceptions && Array.isArray(exceptions)) {
for (let i = 0; i < exceptions.length; i++) {
if ((new RegExp(exceptions[i])).test(expressUtility.getBaseRoute(url))) {
// Found exception
return true;
}
}
}
return false;
} | javascript | function isException(url, exceptions) {
if (exceptions && Array.isArray(exceptions)) {
for (let i = 0; i < exceptions.length; i++) {
if ((new RegExp(exceptions[i])).test(expressUtility.getBaseRoute(url))) {
// Found exception
return true;
}
}
}
return false;
} | [
"function",
"isException",
"(",
"url",
",",
"exceptions",
")",
"{",
"if",
"(",
"exceptions",
"&&",
"Array",
".",
"isArray",
"(",
"exceptions",
")",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"exceptions",
".",
"length",
";",
"i",
"+... | Determines if the current route is an exception and thus will not be considered missing.
@param {string} url
@param {Array<string>} exceptions | [
"Determines",
"if",
"the",
"current",
"route",
"is",
"an",
"exception",
"and",
"thus",
"will",
"not",
"be",
"considered",
"missing",
"."
] | d7eed36d4ea9d18c537884548b59460ec8bd9b5e | https://github.com/DriveTimeInc/gangplank/blob/d7eed36d4ea9d18c537884548b59460ec8bd9b5e/lib/validator.js#L33-L43 | train |
DriveTimeInc/gangplank | lib/validator.js | preCast | function preCast(value, parameterDefinition) {
switch (parameterDefinition.type) {
case 'array': {
let values;
switch (parameterDefinition.collectionFormat) {
case 'ssv':
values = value.split(' ');
break;
case 'tsv':
values = value.split('\t');
break;
case 'pipes':
values ... | javascript | function preCast(value, parameterDefinition) {
switch (parameterDefinition.type) {
case 'array': {
let values;
switch (parameterDefinition.collectionFormat) {
case 'ssv':
values = value.split(' ');
break;
case 'tsv':
values = value.split('\t');
break;
case 'pipes':
values ... | [
"function",
"preCast",
"(",
"value",
",",
"parameterDefinition",
")",
"{",
"switch",
"(",
"parameterDefinition",
".",
"type",
")",
"{",
"case",
"'array'",
":",
"{",
"let",
"values",
";",
"switch",
"(",
"parameterDefinition",
".",
"collectionFormat",
")",
"{",
... | Casts raw values from the request before they are validated | [
"Casts",
"raw",
"values",
"from",
"the",
"request",
"before",
"they",
"are",
"validated"
] | d7eed36d4ea9d18c537884548b59460ec8bd9b5e | https://github.com/DriveTimeInc/gangplank/blob/d7eed36d4ea9d18c537884548b59460ec8bd9b5e/lib/validator.js#L120-L175 | train |
DriveTimeInc/gangplank | lib/validator.js | postCast | function postCast(value, parameterDefinition) {
const type = parameterDefinition.type;
const format = parameterDefinition.format;
if (type === 'string' && (format === 'date' || format === 'date-time')) {
return new Date(value);
} else {
return value;
}
} | javascript | function postCast(value, parameterDefinition) {
const type = parameterDefinition.type;
const format = parameterDefinition.format;
if (type === 'string' && (format === 'date' || format === 'date-time')) {
return new Date(value);
} else {
return value;
}
} | [
"function",
"postCast",
"(",
"value",
",",
"parameterDefinition",
")",
"{",
"const",
"type",
"=",
"parameterDefinition",
".",
"type",
";",
"const",
"format",
"=",
"parameterDefinition",
".",
"format",
";",
"if",
"(",
"type",
"===",
"'string'",
"&&",
"(",
"fo... | Casts values AFTER validated to support string formats | [
"Casts",
"values",
"AFTER",
"validated",
"to",
"support",
"string",
"formats"
] | d7eed36d4ea9d18c537884548b59460ec8bd9b5e | https://github.com/DriveTimeInc/gangplank/blob/d7eed36d4ea9d18c537884548b59460ec8bd9b5e/lib/validator.js#L178-L186 | train |
mikolalysenko/grid-mesh | grid.js | gridMesh | function gridMesh(nx, ny, origin, dx, dy) {
//Unpack default arguments
origin = origin || [0,0]
if(!dx || dx.length < origin.length) {
dx = dup(origin.length)
if(origin.length > 0) {
dx[0] = 1
}
}
if(!dy || dy.length < origin.length) {
dy = dup(origin.length)
if(origin.length > 1) {
... | javascript | function gridMesh(nx, ny, origin, dx, dy) {
//Unpack default arguments
origin = origin || [0,0]
if(!dx || dx.length < origin.length) {
dx = dup(origin.length)
if(origin.length > 0) {
dx[0] = 1
}
}
if(!dy || dy.length < origin.length) {
dy = dup(origin.length)
if(origin.length > 1) {
... | [
"function",
"gridMesh",
"(",
"nx",
",",
"ny",
",",
"origin",
",",
"dx",
",",
"dy",
")",
"{",
"//Unpack default arguments",
"origin",
"=",
"origin",
"||",
"[",
"0",
",",
"0",
"]",
"if",
"(",
"!",
"dx",
"||",
"dx",
".",
"length",
"<",
"origin",
".",
... | Creates a grid mesh | [
"Creates",
"a",
"grid",
"mesh"
] | 885fa9fd9ef08b6db6ac94c2bbc6ea967ed2e750 | https://github.com/mikolalysenko/grid-mesh/blob/885fa9fd9ef08b6db6ac94c2bbc6ea967ed2e750/grid.js#L8-L46 | train |
thorn0/tinymce.html | tinymce.html.js | buildEntitiesLookup | function buildEntitiesLookup(items, radix) {
var i, chr, entity, lookup = {};
if (items) {
items = items.split(',');
radix = radix || 10;
// Build entities lookup table
for (i = 0; i < items.length; i += 2) {
chr... | javascript | function buildEntitiesLookup(items, radix) {
var i, chr, entity, lookup = {};
if (items) {
items = items.split(',');
radix = radix || 10;
// Build entities lookup table
for (i = 0; i < items.length; i += 2) {
chr... | [
"function",
"buildEntitiesLookup",
"(",
"items",
",",
"radix",
")",
"{",
"var",
"i",
",",
"chr",
",",
"entity",
",",
"lookup",
"=",
"{",
"}",
";",
"if",
"(",
"items",
")",
"{",
"items",
"=",
"items",
".",
"split",
"(",
"','",
")",
";",
"radix",
"... | Build a two way lookup table for the entities | [
"Build",
"a",
"two",
"way",
"lookup",
"table",
"for",
"the",
"entities"
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L340-L357 | train |
thorn0/tinymce.html | tinymce.html.js | function(text, attr) {
return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function(chr) {
return baseEntities[chr] || chr;
});
} | javascript | function(text, attr) {
return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function(chr) {
return baseEntities[chr] || chr;
});
} | [
"function",
"(",
"text",
",",
"attr",
")",
"{",
"return",
"text",
".",
"replace",
"(",
"attr",
"?",
"attrsCharsRegExp",
":",
"textCharsRegExp",
",",
"function",
"(",
"chr",
")",
"{",
"return",
"baseEntities",
"[",
"chr",
"]",
"||",
"chr",
";",
"}",
")"... | Encodes the specified string using raw entities. This means only the required XML base entities will be encoded.
@method encodeRaw
@param {String} text Text to encode.
@param {Boolean} attr Optional flag to specify if the text is attribute contents.
@return {String} Entity encoded text. | [
"Encodes",
"the",
"specified",
"string",
"using",
"raw",
"entities",
".",
"This",
"means",
"only",
"the",
"required",
"XML",
"base",
"entities",
"will",
"be",
"encoded",
"."
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L369-L373 | train | |
thorn0/tinymce.html | tinymce.html.js | function(text, attr, entities) {
entities = entities || namedEntities;
return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function(chr) {
return baseEntities[chr] || entities[chr] || chr;
});
} | javascript | function(text, attr, entities) {
entities = entities || namedEntities;
return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function(chr) {
return baseEntities[chr] || entities[chr] || chr;
});
} | [
"function",
"(",
"text",
",",
"attr",
",",
"entities",
")",
"{",
"entities",
"=",
"entities",
"||",
"namedEntities",
";",
"return",
"text",
".",
"replace",
"(",
"attr",
"?",
"attrsCharsRegExp",
":",
"textCharsRegExp",
",",
"function",
"(",
"chr",
")",
"{",... | Encodes the specified string using named entities. The core entities will be encoded
as named ones but all non lower ascii characters will be encoded into named entities.
@method encodeNamed
@param {String} text Text to encode.
@param {Boolean} attr Optional flag to specify if the text is attribute contents.
@param {O... | [
"Encodes",
"the",
"specified",
"string",
"using",
"named",
"entities",
".",
"The",
"core",
"entities",
"will",
"be",
"encoded",
"as",
"named",
"ones",
"but",
"all",
"non",
"lower",
"ascii",
"characters",
"will",
"be",
"encoded",
"into",
"named",
"entities",
... | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L416-L421 | train | |
thorn0/tinymce.html | tinymce.html.js | addValidChildren | function addValidChildren(validChildren) {
var childRuleRegExp = /^([+\-]?)(\w+)\[([^\]]+)\]$/;
// Invalidate the schema cache if the schema is mutated
mapCache[settings.schema] = null;
validChildren && each(split(validChildren, ','), function(rule) {
... | javascript | function addValidChildren(validChildren) {
var childRuleRegExp = /^([+\-]?)(\w+)\[([^\]]+)\]$/;
// Invalidate the schema cache if the schema is mutated
mapCache[settings.schema] = null;
validChildren && each(split(validChildren, ','), function(rule) {
... | [
"function",
"addValidChildren",
"(",
"validChildren",
")",
"{",
"var",
"childRuleRegExp",
"=",
"/",
"^([+\\-]?)(\\w+)\\[([^\\]]+)\\]$",
"/",
";",
"// Invalidate the schema cache if the schema is mutated",
"mapCache",
"[",
"settings",
".",
"schema",
"]",
"=",
"null",
";",
... | Adds valid children to the schema object | [
"Adds",
"valid",
"children",
"to",
"the",
"schema",
"object"
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L1147-L1165 | train |
thorn0/tinymce.html | tinymce.html.js | function(node) {
var self = this;
node.parent && node.remove();
self.insert(node, self);
self.remove();
return self;
} | javascript | function(node) {
var self = this;
node.parent && node.remove();
self.insert(node, self);
self.remove();
return self;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"self",
"=",
"this",
";",
"node",
".",
"parent",
"&&",
"node",
".",
"remove",
"(",
")",
";",
"self",
".",
"insert",
"(",
"node",
",",
"self",
")",
";",
"self",
".",
"remove",
"(",
")",
";",
"return",
"s... | Replaces the current node with the specified one.
@example
someNode.replace(someNewNode);
@method replace
@param {tinymce.html.Node} node Node to replace the current node with.
@return {tinymce.html.Node} The old node that got replaced. | [
"Replaces",
"the",
"current",
"node",
"with",
"the",
"specified",
"one",
"."
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L1689-L1695 | train | |
thorn0/tinymce.html | tinymce.html.js | function() {
var i, l, selfAttrs, selfAttr, cloneAttrs, self = this,
clone = new Node(self.name, self.type);
// Clone element attributes
if (selfAttrs = self.attributes) {
cloneAttrs = [];
cloneAttrs.map = {};
... | javascript | function() {
var i, l, selfAttrs, selfAttr, cloneAttrs, self = this,
clone = new Node(self.name, self.type);
// Clone element attributes
if (selfAttrs = self.attributes) {
cloneAttrs = [];
cloneAttrs.map = {};
... | [
"function",
"(",
")",
"{",
"var",
"i",
",",
"l",
",",
"selfAttrs",
",",
"selfAttr",
",",
"cloneAttrs",
",",
"self",
"=",
"this",
",",
"clone",
"=",
"new",
"Node",
"(",
"self",
".",
"name",
",",
"self",
".",
"type",
")",
";",
"// Clone element attribu... | Does a shallow clones the node into a new node. It will also exclude id attributes since
there should only be one id per document.
@example
var clonedNode = node.clone();
@method clone
@return {tinymce.html.Node} New copy of the original node. | [
"Does",
"a",
"shallow",
"clones",
"the",
"node",
"into",
"a",
"new",
"node",
".",
"It",
"will",
"also",
"exclude",
"id",
"attributes",
"since",
"there",
"should",
"only",
"be",
"one",
"id",
"per",
"document",
"."
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L1765-L1788 | train | |
thorn0/tinymce.html | tinymce.html.js | function(wrapper) {
var self = this;
self.parent.insert(wrapper, self);
wrapper.append(self);
return self;
} | javascript | function(wrapper) {
var self = this;
self.parent.insert(wrapper, self);
wrapper.append(self);
return self;
} | [
"function",
"(",
"wrapper",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"parent",
".",
"insert",
"(",
"wrapper",
",",
"self",
")",
";",
"wrapper",
".",
"append",
"(",
"self",
")",
";",
"return",
"self",
";",
"}"
] | Wraps the node in in another node.
@example
node.wrap(wrapperNode);
@method wrap | [
"Wraps",
"the",
"node",
"in",
"in",
"another",
"node",
"."
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L1797-L1802 | train | |
thorn0/tinymce.html | tinymce.html.js | function() {
var node, next, self = this;
for (node = self.firstChild; node;) {
next = node.next;
self.insert(node, self, true);
node = next;
}
self.remove();
} | javascript | function() {
var node, next, self = this;
for (node = self.firstChild; node;) {
next = node.next;
self.insert(node, self, true);
node = next;
}
self.remove();
} | [
"function",
"(",
")",
"{",
"var",
"node",
",",
"next",
",",
"self",
"=",
"this",
";",
"for",
"(",
"node",
"=",
"self",
".",
"firstChild",
";",
"node",
";",
")",
"{",
"next",
"=",
"node",
".",
"next",
";",
"self",
".",
"insert",
"(",
"node",
","... | Unwraps the node in other words it removes the node but keeps the children.
@example
node.unwrap();
@method unwrap | [
"Unwraps",
"the",
"node",
"in",
"other",
"words",
"it",
"removes",
"the",
"node",
"but",
"keeps",
"the",
"children",
"."
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L1811-L1819 | train | |
thorn0/tinymce.html | tinymce.html.js | function(name) {
var node, self = this,
collection = [];
for (node = self.firstChild; node; node = walk(node, self)) {
node.name === name && collection.push(node);
}
return collection;
} | javascript | function(name) {
var node, self = this,
collection = [];
for (node = self.firstChild; node; node = walk(node, self)) {
node.name === name && collection.push(node);
}
return collection;
} | [
"function",
"(",
"name",
")",
"{",
"var",
"node",
",",
"self",
"=",
"this",
",",
"collection",
"=",
"[",
"]",
";",
"for",
"(",
"node",
"=",
"self",
".",
"firstChild",
";",
"node",
";",
"node",
"=",
"walk",
"(",
"node",
",",
"self",
")",
")",
"{... | Get all children by name.
@method getAll
@param {String} name Name of the child nodes to collect.
@return {Array} Array with child nodes matchin the specified name. | [
"Get",
"all",
"children",
"by",
"name",
"."
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L1912-L1919 | train | |
thorn0/tinymce.html | tinymce.html.js | function() {
var nodes, i, node, self = this;
// Remove all children
if (self.firstChild) {
nodes = [];
// Collect the children
for (node = self.firstChild; node; node = walk(node, self)) {
... | javascript | function() {
var nodes, i, node, self = this;
// Remove all children
if (self.firstChild) {
nodes = [];
// Collect the children
for (node = self.firstChild; node; node = walk(node, self)) {
... | [
"function",
"(",
")",
"{",
"var",
"nodes",
",",
"i",
",",
"node",
",",
"self",
"=",
"this",
";",
"// Remove all children",
"if",
"(",
"self",
".",
"firstChild",
")",
"{",
"nodes",
"=",
"[",
"]",
";",
"// Collect the children",
"for",
"(",
"node",
"=",
... | Removes all children of the current node.
@method empty
@return {tinymce.html.Node} The current node that got cleared. | [
"Removes",
"all",
"children",
"of",
"the",
"current",
"node",
"."
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L1926-L1944 | train | |
thorn0/tinymce.html | tinymce.html.js | compress2 | function compress2(target, a, b, c) {
if (!canCompress(a)) {
return;
}
if (!canCompress(b)) {
return;
}
if (!canCompress(c)) {
... | javascript | function compress2(target, a, b, c) {
if (!canCompress(a)) {
return;
}
if (!canCompress(b)) {
return;
}
if (!canCompress(c)) {
... | [
"function",
"compress2",
"(",
"target",
",",
"a",
",",
"b",
",",
"c",
")",
"{",
"if",
"(",
"!",
"canCompress",
"(",
"a",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"canCompress",
"(",
"b",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",... | Compresses multiple styles into one style. | [
"Compresses",
"multiple",
"styles",
"into",
"one",
"style",
"."
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L3150-L3165 | train |
thorn0/tinymce.html | tinymce.html.js | function(styles, elementName) {
var name, value, css = '';
function serializeStyles(name) {
var styleList, i, l, value;
styleList = validStyles[name];
if (styleList) {
for (i = 0,... | javascript | function(styles, elementName) {
var name, value, css = '';
function serializeStyles(name) {
var styleList, i, l, value;
styleList = validStyles[name];
if (styleList) {
for (i = 0,... | [
"function",
"(",
"styles",
",",
"elementName",
")",
"{",
"var",
"name",
",",
"value",
",",
"css",
"=",
"''",
";",
"function",
"serializeStyles",
"(",
"name",
")",
"{",
"var",
"styleList",
",",
"i",
",",
"l",
",",
"value",
";",
"styleList",
"=",
"vali... | Serializes the specified style object into a string.
@method serialize
@param {Object} styles Object to serialize as string for example: {border: '1px solid red'}
@param {String} elementName Optional element name, if specified only the styles that matches the schema will be serialized.
@return {String} String represen... | [
"Serializes",
"the",
"specified",
"style",
"object",
"into",
"a",
"string",
"."
] | 0bf3faa50368b68b5a4f5a436169295535778ead | https://github.com/thorn0/tinymce.html/blob/0bf3faa50368b68b5a4f5a436169295535778ead/tinymce.html.js#L3270-L3310 | train | |
socialally/air | lib/air/find.js | find | function find(selector) {
var arr = [], $ = this.air, slice = this.slice;
this.each(function(el) {
arr = arr.concat(slice.call($(selector, el).dom));
});
return $(arr);
} | javascript | function find(selector) {
var arr = [], $ = this.air, slice = this.slice;
this.each(function(el) {
arr = arr.concat(slice.call($(selector, el).dom));
});
return $(arr);
} | [
"function",
"find",
"(",
"selector",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
",",
"$",
"=",
"this",
".",
"air",
",",
"slice",
"=",
"this",
".",
"slice",
";",
"this",
".",
"each",
"(",
"function",
"(",
"el",
")",
"{",
"arr",
"=",
"arr",
".",
"c... | Get the descendants of each element in the current set
of matched elements, filtered by a selector. | [
"Get",
"the",
"descendants",
"of",
"each",
"element",
"in",
"the",
"current",
"set",
"of",
"matched",
"elements",
"filtered",
"by",
"a",
"selector",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/find.js#L5-L11 | train |
vid/SenseBase | util/importItemAnnotations.js | fv | function fv(vals, key) {
if (!vals) return;
vals.forEach(function(v) {
if (v.key === key && vals[key] !== 'Not available') {
return vals[key];
}
});
} | javascript | function fv(vals, key) {
if (!vals) return;
vals.forEach(function(v) {
if (v.key === key && vals[key] !== 'Not available') {
return vals[key];
}
});
} | [
"function",
"fv",
"(",
"vals",
",",
"key",
")",
"{",
"if",
"(",
"!",
"vals",
")",
"return",
";",
"vals",
".",
"forEach",
"(",
"function",
"(",
"v",
")",
"{",
"if",
"(",
"v",
".",
"key",
"===",
"key",
"&&",
"vals",
"[",
"key",
"]",
"!==",
"'No... | utility assigns field value | [
"utility",
"assigns",
"field",
"value"
] | d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/util/importItemAnnotations.js#L99-L106 | train |
theworkers/W.js | node/jade-middleware.js | hasMatchingJadeFileInPages | function hasMatchingJadeFileInPages(srcDir, url, pages, jadeOptions, callback) {
if (typeof pages[url] === 'undefined') {
// get the possible jade file path
var extension = path.extname(url);
var jadeFilePath;
var htmlFilePath;
if (extension === ".html" /* || extension === ".... | javascript | function hasMatchingJadeFileInPages(srcDir, url, pages, jadeOptions, callback) {
if (typeof pages[url] === 'undefined') {
// get the possible jade file path
var extension = path.extname(url);
var jadeFilePath;
var htmlFilePath;
if (extension === ".html" /* || extension === ".... | [
"function",
"hasMatchingJadeFileInPages",
"(",
"srcDir",
",",
"url",
",",
"pages",
",",
"jadeOptions",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"pages",
"[",
"url",
"]",
"===",
"'undefined'",
")",
"{",
"// get the possible jade file path",
"var",
"extensi... | creates a jade page if it doesn't exist in cache | [
"creates",
"a",
"jade",
"page",
"if",
"it",
"doesn",
"t",
"exist",
"in",
"cache"
] | 25a11baf8edb27c306f2baf6438bed2faf935bc6 | https://github.com/theworkers/W.js/blob/25a11baf8edb27c306f2baf6438bed2faf935bc6/node/jade-middleware.js#L56-L82 | train |
mattinsler/caboose | lib/view/helpers/view_helper.js | function( input, null_text ) {
if ( input == null || input === undefined ) return null_text || '';
if ( typeof input === 'object' && Object.prototype.toString.call(input) === '[object Date]' ) return input.toDateString();
if ( input.toString ) return input.toString().replace(/\n/g, '<br />').replace(/''/g, "'");
... | javascript | function( input, null_text ) {
if ( input == null || input === undefined ) return null_text || '';
if ( typeof input === 'object' && Object.prototype.toString.call(input) === '[object Date]' ) return input.toDateString();
if ( input.toString ) return input.toString().replace(/\n/g, '<br />').replace(/''/g, "'");
... | [
"function",
"(",
"input",
",",
"null_text",
")",
"{",
"if",
"(",
"input",
"==",
"null",
"||",
"input",
"===",
"undefined",
")",
"return",
"null_text",
"||",
"''",
";",
"if",
"(",
"typeof",
"input",
"===",
"'object'",
"&&",
"Object",
".",
"prototype",
"... | Converts response to text. | [
"Converts",
"response",
"to",
"text",
"."
] | b0e1d0d7962050a2f72e918197488011cfb8ba57 | https://github.com/mattinsler/caboose/blob/b0e1d0d7962050a2f72e918197488011cfb8ba57/lib/view/helpers/view_helper.js#L5-L10 | train | |
mattinsler/caboose | lib/view/helpers/view_helper.js | function( name, value, options, checked ) {
options = options || {};
if(checked) options.checked = "checked";
return this.input_field_tag(name, value, 'checkbox', options);
} | javascript | function( name, value, options, checked ) {
options = options || {};
if(checked) options.checked = "checked";
return this.input_field_tag(name, value, 'checkbox', options);
} | [
"function",
"(",
"name",
",",
"value",
",",
"options",
",",
"checked",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"checked",
")",
"options",
".",
"checked",
"=",
"\"checked\"",
";",
"return",
"this",
".",
"input_field_tag",
"(... | Creates a check box tag
@plugin view/helpers
@param {Object} name
@param {Object} value
@param {Object} options
@param {Object} checked | [
"Creates",
"a",
"check",
"box",
"tag"
] | b0e1d0d7962050a2f72e918197488011cfb8ba57 | https://github.com/mattinsler/caboose/blob/b0e1d0d7962050a2f72e918197488011cfb8ba57/lib/view/helpers/view_helper.js#L23-L27 | train | |
colleenjoyce/react-paginator | index.js | range | function range(start, stop) {
if (arguments.length <= 1) {
stop = start || 0;
start = 0;
}
var length = Math.max(stop - start, 0);
var idx = 0;
var arr = new Array(length);
while(idx < length) {
arr[idx++] = start;
start += 1;
}
return arr;
} | javascript | function range(start, stop) {
if (arguments.length <= 1) {
stop = start || 0;
start = 0;
}
var length = Math.max(stop - start, 0);
var idx = 0;
var arr = new Array(length);
while(idx < length) {
arr[idx++] = start;
start += 1;
}
return arr;
} | [
"function",
"range",
"(",
"start",
",",
"stop",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<=",
"1",
")",
"{",
"stop",
"=",
"start",
"||",
"0",
";",
"start",
"=",
"0",
";",
"}",
"var",
"length",
"=",
"Math",
".",
"max",
"(",
"stop",
"-",... | Slighlty modified from underscore source | [
"Slighlty",
"modified",
"from",
"underscore",
"source"
] | 13fe5de76a9b20e55d7e2e382e7744623a965e9f | https://github.com/colleenjoyce/react-paginator/blob/13fe5de76a9b20e55d7e2e382e7744623a965e9f/index.js#L7-L23 | train |
colleenjoyce/react-paginator | index.js | function(n) {
// n is out of range, don't do anything
if (n > this.props.numPages || n < 1) return;
if (this.props.onClick) this.props.onClick(n);
this.setState({ page: n });
} | javascript | function(n) {
// n is out of range, don't do anything
if (n > this.props.numPages || n < 1) return;
if (this.props.onClick) this.props.onClick(n);
this.setState({ page: n });
} | [
"function",
"(",
"n",
")",
"{",
"// n is out of range, don't do anything",
"if",
"(",
"n",
">",
"this",
".",
"props",
".",
"numPages",
"||",
"n",
"<",
"1",
")",
"return",
";",
"if",
"(",
"this",
".",
"props",
".",
"onClick",
")",
"this",
".",
"props",
... | Triggered by any button click within the paginator.
@param {number} n - Page number | [
"Triggered",
"by",
"any",
"button",
"click",
"within",
"the",
"paginator",
"."
] | 13fe5de76a9b20e55d7e2e382e7744623a965e9f | https://github.com/colleenjoyce/react-paginator/blob/13fe5de76a9b20e55d7e2e382e7744623a965e9f/index.js#L56-L61 | train | |
byteclubfr/npm-scripts-tree | index.js | archify | function archify (scripts, alpha) {
let names = Object.keys(scripts)
if (alpha) {
names = names.sort()
}
return {
label: `${names.length} scripts`,
nodes: names.map(n => scripts[n])
}
} | javascript | function archify (scripts, alpha) {
let names = Object.keys(scripts)
if (alpha) {
names = names.sort()
}
return {
label: `${names.length} scripts`,
nodes: names.map(n => scripts[n])
}
} | [
"function",
"archify",
"(",
"scripts",
",",
"alpha",
")",
"{",
"let",
"names",
"=",
"Object",
".",
"keys",
"(",
"scripts",
")",
"if",
"(",
"alpha",
")",
"{",
"names",
"=",
"names",
".",
"sort",
"(",
")",
"}",
"return",
"{",
"label",
":",
"`",
"${... | label and nodes | [
"label",
"and",
"nodes"
] | fee33c1a00b9aae01801afe5e6951af9a596670b | https://github.com/byteclubfr/npm-scripts-tree/blob/fee33c1a00b9aae01801afe5e6951af9a596670b/index.js#L53-L62 | train |
byteclubfr/npm-scripts-tree | index.js | isLifeCycleScript | function isLifeCycleScript (prefix, name, scripts) {
const re = new RegExp("^" + prefix)
const root = name.slice(prefix.length)
return Boolean(name.match(re) && (scripts[root] || BUILTINS.includes(root)))
} | javascript | function isLifeCycleScript (prefix, name, scripts) {
const re = new RegExp("^" + prefix)
const root = name.slice(prefix.length)
return Boolean(name.match(re) && (scripts[root] || BUILTINS.includes(root)))
} | [
"function",
"isLifeCycleScript",
"(",
"prefix",
",",
"name",
",",
"scripts",
")",
"{",
"const",
"re",
"=",
"new",
"RegExp",
"(",
"\"^\"",
"+",
"prefix",
")",
"const",
"root",
"=",
"name",
".",
"slice",
"(",
"prefix",
".",
"length",
")",
"return",
"Bool... | pre, post or builtins | [
"pre",
"post",
"or",
"builtins"
] | fee33c1a00b9aae01801afe5e6951af9a596670b | https://github.com/byteclubfr/npm-scripts-tree/blob/fee33c1a00b9aae01801afe5e6951af9a596670b/index.js#L77-L81 | train |
byteclubfr/npm-scripts-tree | index.js | getRunAllScripts | function getRunAllScripts (cmd) {
const re = RegExp("(?:npm-run-all" + RE_FLAGS + RE_NAMES + ")+", "gi")
const cmds = getMatches(re, cmd).map(m =>
// clean spaces
m.match.trim().split(" ").filter(x => x))
return unique(flatten(cmds))
} | javascript | function getRunAllScripts (cmd) {
const re = RegExp("(?:npm-run-all" + RE_FLAGS + RE_NAMES + ")+", "gi")
const cmds = getMatches(re, cmd).map(m =>
// clean spaces
m.match.trim().split(" ").filter(x => x))
return unique(flatten(cmds))
} | [
"function",
"getRunAllScripts",
"(",
"cmd",
")",
"{",
"const",
"re",
"=",
"RegExp",
"(",
"\"(?:npm-run-all\"",
"+",
"RE_FLAGS",
"+",
"RE_NAMES",
"+",
"\")+\"",
",",
"\"gi\"",
")",
"const",
"cmds",
"=",
"getMatches",
"(",
"re",
",",
"cmd",
")",
".",
"map"... | handled by npm-run-all module | [
"handled",
"by",
"npm",
"-",
"run",
"-",
"all",
"module"
] | fee33c1a00b9aae01801afe5e6951af9a596670b | https://github.com/byteclubfr/npm-scripts-tree/blob/fee33c1a00b9aae01801afe5e6951af9a596670b/index.js#L119-L126 | train |
KAIT-HEMS/node-picogw-plugin-admin | index.js | onProcCallGet | function onProcCallGet(method, path, args) {
// log('onProcCallGet('+JSON.stringify(arguments));
let pathSplit = path.split('/');
const serviceid = pathSplit.shift();
const propname = pathSplit.join('/');
const bInfo = (args.info === 'true');
if (serviceid == '') { // access 'admin/' => servic... | javascript | function onProcCallGet(method, path, args) {
// log('onProcCallGet('+JSON.stringify(arguments));
let pathSplit = path.split('/');
const serviceid = pathSplit.shift();
const propname = pathSplit.join('/');
const bInfo = (args.info === 'true');
if (serviceid == '') { // access 'admin/' => servic... | [
"function",
"onProcCallGet",
"(",
"method",
",",
"path",
",",
"args",
")",
"{",
"// log('onProcCallGet('+JSON.stringify(arguments));",
"let",
"pathSplit",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
";",
"const",
"serviceid",
"=",
"pathSplit",
".",
"shift",
"(",... | onCall handler of plugin for GET method
@param {string} method Caller method, accept GET only.
@param {string} path Plugin URL path
@param {object} args parameters of this call
@return {object} Returns a Promise object or object containing the result | [
"onCall",
"handler",
"of",
"plugin",
"for",
"GET",
"method"
] | 8c7ec31271b164eb90e12444388234a40cb470be | https://github.com/KAIT-HEMS/node-picogw-plugin-admin/blob/8c7ec31271b164eb90e12444388234a40cb470be/index.js#L121-L197 | train |
KAIT-HEMS/node-picogw-plugin-admin | index.js | listNetInterfaces | function listNetInterfaces() {
return new Promise((ac, rj) => {
exec('nmcli d', (err, stdout, stderr) => {
const lines = stdout.split('\n');
if (err || lines.length<2) {
rj({error: 'No network available.'});
return;
}
lines.shi... | javascript | function listNetInterfaces() {
return new Promise((ac, rj) => {
exec('nmcli d', (err, stdout, stderr) => {
const lines = stdout.split('\n');
if (err || lines.length<2) {
rj({error: 'No network available.'});
return;
}
lines.shi... | [
"function",
"listNetInterfaces",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"ac",
",",
"rj",
")",
"=>",
"{",
"exec",
"(",
"'nmcli d'",
",",
"(",
"err",
",",
"stdout",
",",
"stderr",
")",
"=>",
"{",
"const",
"lines",
"=",
"stdout",
".",
"s... | List Network Interfaces
@return {Promise} Return a list of network interfaces and whether you are using WiFi | [
"List",
"Network",
"Interfaces"
] | 8c7ec31271b164eb90e12444388234a40cb470be | https://github.com/KAIT-HEMS/node-picogw-plugin-admin/blob/8c7ec31271b164eb90e12444388234a40cb470be/index.js#L466-L489 | train |
KAIT-HEMS/node-picogw-plugin-admin | index.js | routeSet | async function routeSet(target, netInterface, rootPwd) {
const connName = await searchConnNameFromNetworkInterface(netInterface);
const prevRoutes = await searchPrevRoutes(target);
if (prevRoutes.length == 1) {
if (prevRoutes[0].connName === connName &&
prevRoutes[0].target === target &&... | javascript | async function routeSet(target, netInterface, rootPwd) {
const connName = await searchConnNameFromNetworkInterface(netInterface);
const prevRoutes = await searchPrevRoutes(target);
if (prevRoutes.length == 1) {
if (prevRoutes[0].connName === connName &&
prevRoutes[0].target === target &&... | [
"async",
"function",
"routeSet",
"(",
"target",
",",
"netInterface",
",",
"rootPwd",
")",
"{",
"const",
"connName",
"=",
"await",
"searchConnNameFromNetworkInterface",
"(",
"netInterface",
")",
";",
"const",
"prevRoutes",
"=",
"await",
"searchPrevRoutes",
"(",
"ta... | Set static route to ipv4 network
@param {string} target : the destination network or host. e.g. 224.0.23.0/32
@param {string} netInterface : network interface to set route
@param {string} rootPwd : root password for executing sudo
@return {Promise} Return last command output | [
"Set",
"static",
"route",
"to",
"ipv4",
"network"
] | 8c7ec31271b164eb90e12444388234a40cb470be | https://github.com/KAIT-HEMS/node-picogw-plugin-admin/blob/8c7ec31271b164eb90e12444388234a40cb470be/index.js#L527-L546 | train |
KAIT-HEMS/node-picogw-plugin-admin | index.js | routeDelete | async function routeDelete(target, rootPwd) {
const prevRoutes = await searchPrevRoutes(target);
if (prevRoutes.length == 0) {
return; // no need to do anything
}
const cmds = [];
for (const prevRoute of prevRoutes) {
cmds.push([
'nmcli', 'connection', 'modify', prevRoute... | javascript | async function routeDelete(target, rootPwd) {
const prevRoutes = await searchPrevRoutes(target);
if (prevRoutes.length == 0) {
return; // no need to do anything
}
const cmds = [];
for (const prevRoute of prevRoutes) {
cmds.push([
'nmcli', 'connection', 'modify', prevRoute... | [
"async",
"function",
"routeDelete",
"(",
"target",
",",
"rootPwd",
")",
"{",
"const",
"prevRoutes",
"=",
"await",
"searchPrevRoutes",
"(",
"target",
")",
";",
"if",
"(",
"prevRoutes",
".",
"length",
"==",
"0",
")",
"{",
"return",
";",
"// no need to do anyth... | Delete static route from ipv4 network
@param {string} target : the destination network or host. e.g. 224.0.23.0/32
@param {string} rootPwd : root password for executing sudo
@return {Promise} Return standard output of each command as an array | [
"Delete",
"static",
"route",
"from",
"ipv4",
"network"
] | 8c7ec31271b164eb90e12444388234a40cb470be | https://github.com/KAIT-HEMS/node-picogw-plugin-admin/blob/8c7ec31271b164eb90e12444388234a40cb470be/index.js#L555-L569 | train |
KAIT-HEMS/node-picogw-plugin-admin | index.js | listConnections | async function listConnections() {
const connList = await executeCommand(
['nmcli', '-f', 'NAME,DEVICE', '-t', 'connection', 'show']);
const ret = {};
connList.split('\n').map((l) => {
return l.split(/:/);
}).filter((ary) => {
return ary[0] && ary[1];
}).forEach((ary) => {
... | javascript | async function listConnections() {
const connList = await executeCommand(
['nmcli', '-f', 'NAME,DEVICE', '-t', 'connection', 'show']);
const ret = {};
connList.split('\n').map((l) => {
return l.split(/:/);
}).filter((ary) => {
return ary[0] && ary[1];
}).forEach((ary) => {
... | [
"async",
"function",
"listConnections",
"(",
")",
"{",
"const",
"connList",
"=",
"await",
"executeCommand",
"(",
"[",
"'nmcli'",
",",
"'-f'",
",",
"'NAME,DEVICE'",
",",
"'-t'",
",",
"'connection'",
",",
"'show'",
"]",
")",
";",
"const",
"ret",
"=",
"{",
... | List connection names with device name
@return {Array.<object>} Return list of connection name and device name | [
"List",
"connection",
"names",
"with",
"device",
"name"
] | 8c7ec31271b164eb90e12444388234a40cb470be | https://github.com/KAIT-HEMS/node-picogw-plugin-admin/blob/8c7ec31271b164eb90e12444388234a40cb470be/index.js#L576-L588 | train |
KAIT-HEMS/node-picogw-plugin-admin | index.js | searchPrevRoutes | async function searchPrevRoutes(target) {
const connNames = await listConnectionNames();
const ret = [];
for (const connName of connNames) {
const cmd = [
'nmcli', '-f', 'IP4.ROUTE', 'connection', 'show', connName,
];
const output = await executeCommand(cmd);
for ... | javascript | async function searchPrevRoutes(target) {
const connNames = await listConnectionNames();
const ret = [];
for (const connName of connNames) {
const cmd = [
'nmcli', '-f', 'IP4.ROUTE', 'connection', 'show', connName,
];
const output = await executeCommand(cmd);
for ... | [
"async",
"function",
"searchPrevRoutes",
"(",
"target",
")",
"{",
"const",
"connNames",
"=",
"await",
"listConnectionNames",
"(",
")",
";",
"const",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"const",
"connName",
"of",
"connNames",
")",
"{",
"const",
"cmd",
... | Search previous route from NetworkManager
@param {string} target : the destination network or host. e.g. 224.0.23.0/32
@return {Array.<object>} Return list of previous route setting | [
"Search",
"previous",
"route",
"from",
"NetworkManager"
] | 8c7ec31271b164eb90e12444388234a40cb470be | https://github.com/KAIT-HEMS/node-picogw-plugin-admin/blob/8c7ec31271b164eb90e12444388234a40cb470be/index.js#L603-L625 | train |
KAIT-HEMS/node-picogw-plugin-admin | index.js | searchConnNameFromIP | async function searchConnNameFromIP(ip) { // eslint-disable-line no-unused-vars
const connNames = await listConnectionNames();
const gipnum = ipv4.convToNum(ip);
for (const connName of connNames) {
const cmd = [
'nmcli', '-f', 'IP4.ADDRESS', 'connection', 'show', connName,
];
... | javascript | async function searchConnNameFromIP(ip) { // eslint-disable-line no-unused-vars
const connNames = await listConnectionNames();
const gipnum = ipv4.convToNum(ip);
for (const connName of connNames) {
const cmd = [
'nmcli', '-f', 'IP4.ADDRESS', 'connection', 'show', connName,
];
... | [
"async",
"function",
"searchConnNameFromIP",
"(",
"ip",
")",
"{",
"// eslint-disable-line no-unused-vars",
"const",
"connNames",
"=",
"await",
"listConnectionNames",
"(",
")",
";",
"const",
"gipnum",
"=",
"ipv4",
".",
"convToNum",
"(",
"ip",
")",
";",
"for",
"("... | Search the connection name of the same network from the ip address
@param {string} ip : ip address
@return {string} connection name for NetworkManager | [
"Search",
"the",
"connection",
"name",
"of",
"the",
"same",
"network",
"from",
"the",
"ip",
"address"
] | 8c7ec31271b164eb90e12444388234a40cb470be | https://github.com/KAIT-HEMS/node-picogw-plugin-admin/blob/8c7ec31271b164eb90e12444388234a40cb470be/index.js#L632-L653 | train |
KAIT-HEMS/node-picogw-plugin-admin | index.js | searchConnNameFromNetworkInterface | async function searchConnNameFromNetworkInterface(netInterface) { // eslint-disable-line no-unused-vars
const conns = await listConnections();
for (const [connName, nif] of Object.entries(conns)) {
if (nif === netInterface) {
return connName;
}
}
return null;
} | javascript | async function searchConnNameFromNetworkInterface(netInterface) { // eslint-disable-line no-unused-vars
const conns = await listConnections();
for (const [connName, nif] of Object.entries(conns)) {
if (nif === netInterface) {
return connName;
}
}
return null;
} | [
"async",
"function",
"searchConnNameFromNetworkInterface",
"(",
"netInterface",
")",
"{",
"// eslint-disable-line no-unused-vars",
"const",
"conns",
"=",
"await",
"listConnections",
"(",
")",
";",
"for",
"(",
"const",
"[",
"connName",
",",
"nif",
"]",
"of",
"Object"... | Search the connection name from the network interface
@param {string} netInterface : network interface
@return {string} connection name for NetworkManager | [
"Search",
"the",
"connection",
"name",
"from",
"the",
"network",
"interface"
] | 8c7ec31271b164eb90e12444388234a40cb470be | https://github.com/KAIT-HEMS/node-picogw-plugin-admin/blob/8c7ec31271b164eb90e12444388234a40cb470be/index.js#L660-L668 | train |
KAIT-HEMS/node-picogw-plugin-admin | index.js | executeCommand | function executeCommand(cmd, option) {
option = option || {};
return new Promise((ac, rj)=>{
let okMsg = '';
let erMsg='';
log('Exec:'+cmd.join(' '));
let child;
if (option.sudo) {
child = sudo(cmd, {password: option.password});
} else {
ch... | javascript | function executeCommand(cmd, option) {
option = option || {};
return new Promise((ac, rj)=>{
let okMsg = '';
let erMsg='';
log('Exec:'+cmd.join(' '));
let child;
if (option.sudo) {
child = sudo(cmd, {password: option.password});
} else {
ch... | [
"function",
"executeCommand",
"(",
"cmd",
",",
"option",
")",
"{",
"option",
"=",
"option",
"||",
"{",
"}",
";",
"return",
"new",
"Promise",
"(",
"(",
"ac",
",",
"rj",
")",
"=>",
"{",
"let",
"okMsg",
"=",
"''",
";",
"let",
"erMsg",
"=",
"''",
";"... | Execute command with sudo
@param {Array.<string>} cmd : Array of command
@param {object} [option] : option parameter
@return {Promise} Return stdout strings | [
"Execute",
"command",
"with",
"sudo"
] | 8c7ec31271b164eb90e12444388234a40cb470be | https://github.com/KAIT-HEMS/node-picogw-plugin-admin/blob/8c7ec31271b164eb90e12444388234a40cb470be/index.js#L676-L707 | train |
KAIT-HEMS/node-picogw-plugin-admin | index.js | executeCommands | async function executeCommands(commands, ignoreErrorFunc, option) {
const ret = [];
for (const cmd of commands) {
const r = await executeCommand(cmd, option).catch((e) => {
if (ignoreErrorFunc && ignoreErrorFunc(cmd)) {
// ignore error
return '';
}... | javascript | async function executeCommands(commands, ignoreErrorFunc, option) {
const ret = [];
for (const cmd of commands) {
const r = await executeCommand(cmd, option).catch((e) => {
if (ignoreErrorFunc && ignoreErrorFunc(cmd)) {
// ignore error
return '';
}... | [
"async",
"function",
"executeCommands",
"(",
"commands",
",",
"ignoreErrorFunc",
",",
"option",
")",
"{",
"const",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"const",
"cmd",
"of",
"commands",
")",
"{",
"const",
"r",
"=",
"await",
"executeCommand",
"(",
"cmd"... | Execute commands with sudo
@param {Array.<Array.<string>>} commands : Array of command list
@param {function} ignoreErrorFunc : Handler for determining whether to ignore when command fails
@param {object} [option] : option parameter
@return {Promise} Return standard output of each command as an array | [
"Execute",
"commands",
"with",
"sudo"
] | 8c7ec31271b164eb90e12444388234a40cb470be | https://github.com/KAIT-HEMS/node-picogw-plugin-admin/blob/8c7ec31271b164eb90e12444388234a40cb470be/index.js#L716-L729 | train |
DScheglov/merest | lib/controllers/search.js | search | function search(req, res, next) {
res.__apiMethod = 'search';
buildQuery.call(this, req).exec(function (err, obj) {
if (err) {
var isCastError =
(err.name === 'CastError') ||
(err.message && err.message[0] === '$') ||
(err.message === 'and needs an array')
;
... | javascript | function search(req, res, next) {
res.__apiMethod = 'search';
buildQuery.call(this, req).exec(function (err, obj) {
if (err) {
var isCastError =
(err.name === 'CastError') ||
(err.message && err.message[0] === '$') ||
(err.message === 'and needs an array')
;
... | [
"function",
"search",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"res",
".",
"__apiMethod",
"=",
"'search'",
";",
"buildQuery",
".",
"call",
"(",
"this",
",",
"req",
")",
".",
"exec",
"(",
"function",
"(",
"err",
",",
"obj",
")",
"{",
"if",
"... | search - Searches the objects in attached model collection
@param {express.Request} req the http(s) request
@param {express.Response} res the http(s) response
@param {Function} next the callback should be called if controller fails
@memberof ModelAPIRouter | [
"search",
"-",
"Searches",
"the",
"objects",
"in",
"attached",
"model",
"collection"
] | d39e7ef0d56236247773467e9bfe83cb128ebc01 | https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/controllers/search.js#L16-L36 | train |
jillix/flow-registry | lib/dev.js | installModule | function installModule (module, modulesDir, callback) {
let details = module.split('/');
let devModulePath = resolve(modulesDir, module);
fs.access(resolve(modulesDir, module), err => {
// skip next steps if module already exists
if (!err || err.code !== 'ENOENT') {
return cal... | javascript | function installModule (module, modulesDir, callback) {
let details = module.split('/');
let devModulePath = resolve(modulesDir, module);
fs.access(resolve(modulesDir, module), err => {
// skip next steps if module already exists
if (!err || err.code !== 'ENOENT') {
return cal... | [
"function",
"installModule",
"(",
"module",
",",
"modulesDir",
",",
"callback",
")",
"{",
"let",
"details",
"=",
"module",
".",
"split",
"(",
"'/'",
")",
";",
"let",
"devModulePath",
"=",
"resolve",
"(",
"modulesDir",
",",
"module",
")",
";",
"fs",
".",
... | this will clone and install all the required dependencies of a module | [
"this",
"will",
"clone",
"and",
"install",
"all",
"the",
"required",
"dependencies",
"of",
"a",
"module"
] | 4a2b8c462269098fe76551f5adf1acef5ceb1b1c | https://github.com/jillix/flow-registry/blob/4a2b8c462269098fe76551f5adf1acef5ceb1b1c/lib/dev.js#L76-L113 | train |
jillix/flow-registry | lib/dev.js | setupSymlinks | function setupSymlinks (module, modulesDir, callback) {
let details = module.split('/');
let modulePath = resolve(NODE_MODULES, details[1]);
let devModulePath = resolve(modulesDir, module);
rimraf(modulePath, err => {
if (err) {
return callback(err);
}
fs.symlink(... | javascript | function setupSymlinks (module, modulesDir, callback) {
let details = module.split('/');
let modulePath = resolve(NODE_MODULES, details[1]);
let devModulePath = resolve(modulesDir, module);
rimraf(modulePath, err => {
if (err) {
return callback(err);
}
fs.symlink(... | [
"function",
"setupSymlinks",
"(",
"module",
",",
"modulesDir",
",",
"callback",
")",
"{",
"let",
"details",
"=",
"module",
".",
"split",
"(",
"'/'",
")",
";",
"let",
"modulePath",
"=",
"resolve",
"(",
"NODE_MODULES",
",",
"details",
"[",
"1",
"]",
")",
... | this will remove the module from the registry and create all the required links | [
"this",
"will",
"remove",
"the",
"module",
"from",
"the",
"registry",
"and",
"create",
"all",
"the",
"required",
"links"
] | 4a2b8c462269098fe76551f5adf1acef5ceb1b1c | https://github.com/jillix/flow-registry/blob/4a2b8c462269098fe76551f5adf1acef5ceb1b1c/lib/dev.js#L116-L137 | train |
jillix/flow-registry | lib/dev.js | watchModule | function watchModule (module, modulesDir) {
const pathToModule = resolve(modulesDir, module);
const pathToHandlers = resolve(HANDLER_BASE, module);
modules[module] = {
handlers: []
};
fs.readdir(pathToHandlers, (err, files) => {
if (err) {
return console.log(new Error... | javascript | function watchModule (module, modulesDir) {
const pathToModule = resolve(modulesDir, module);
const pathToHandlers = resolve(HANDLER_BASE, module);
modules[module] = {
handlers: []
};
fs.readdir(pathToHandlers, (err, files) => {
if (err) {
return console.log(new Error... | [
"function",
"watchModule",
"(",
"module",
",",
"modulesDir",
")",
"{",
"const",
"pathToModule",
"=",
"resolve",
"(",
"modulesDir",
",",
"module",
")",
";",
"const",
"pathToHandlers",
"=",
"resolve",
"(",
"HANDLER_BASE",
",",
"module",
")",
";",
"modules",
"[... | this will watch for changes in a module or its handlers | [
"this",
"will",
"watch",
"for",
"changes",
"in",
"a",
"module",
"or",
"its",
"handlers"
] | 4a2b8c462269098fe76551f5adf1acef5ceb1b1c | https://github.com/jillix/flow-registry/blob/4a2b8c462269098fe76551f5adf1acef5ceb1b1c/lib/dev.js#L140-L179 | train |
jillix/flow-registry | lib/dev.js | bundleHandler | function bundleHandler (pathToHandlers, module, file) {
// only rebundle if js file changed
if (file.length < 3 || file.indexOf('bundle.') === 0 || file.substr(file.length - 3) !== '.js') {
return;
}
// only rebundle if handler was already bundled before
fs.access(pathToHandlers + '/bundle... | javascript | function bundleHandler (pathToHandlers, module, file) {
// only rebundle if js file changed
if (file.length < 3 || file.indexOf('bundle.') === 0 || file.substr(file.length - 3) !== '.js') {
return;
}
// only rebundle if handler was already bundled before
fs.access(pathToHandlers + '/bundle... | [
"function",
"bundleHandler",
"(",
"pathToHandlers",
",",
"module",
",",
"file",
")",
"{",
"// only rebundle if js file changed",
"if",
"(",
"file",
".",
"length",
"<",
"3",
"||",
"file",
".",
"indexOf",
"(",
"'bundle.'",
")",
"===",
"0",
"||",
"file",
".",
... | this will rebundle a handler | [
"this",
"will",
"rebundle",
"a",
"handler"
] | 4a2b8c462269098fe76551f5adf1acef5ceb1b1c | https://github.com/jillix/flow-registry/blob/4a2b8c462269098fe76551f5adf1acef5ceb1b1c/lib/dev.js#L182-L219 | train |
MikeShi42/rrequire | client/src/index.js | remoteRequest | function remoteRequest(moduleName, methodName, argsArr) {
// TODO: Handle moduleName properly
// TODO: Better ID generation
const id = Math.floor(Math.random() * 10000000);
const serializedRequest = serializer.request(id, methodName, argsArr);
return sendRequest(serializedRequest).then((res) => {
const r... | javascript | function remoteRequest(moduleName, methodName, argsArr) {
// TODO: Handle moduleName properly
// TODO: Better ID generation
const id = Math.floor(Math.random() * 10000000);
const serializedRequest = serializer.request(id, methodName, argsArr);
return sendRequest(serializedRequest).then((res) => {
const r... | [
"function",
"remoteRequest",
"(",
"moduleName",
",",
"methodName",
",",
"argsArr",
")",
"{",
"// TODO: Handle moduleName properly",
"// TODO: Better ID generation",
"const",
"id",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"10000000",
")... | Executes a RPC and returns a Promise resolving to the returned value or
rejecting on a client or remote exception.
@param {String} moduleName Full module path to resolve on remote
@param {String} methodName Method name to invoke on remote
@param {Array} argsArr Array of arguments to invoke the remote
method w... | [
"Executes",
"a",
"RPC",
"and",
"returns",
"a",
"Promise",
"resolving",
"to",
"the",
"returned",
"value",
"or",
"rejecting",
"on",
"a",
"client",
"or",
"remote",
"exception",
"."
] | a03ccf84ec0187497d2aa8bd564d5f612e3dc38c | https://github.com/MikeShi42/rrequire/blob/a03ccf84ec0187497d2aa8bd564d5f612e3dc38c/client/src/index.js#L39-L56 | train |
YazgelderRp/abp-electron-resources | Abp/Framework/scripts/libs/abp.jtable.js | function () {
var self = this;
base._create.apply(self, arguments);
if (self.options.actions.listAction) {
self._adaptListActionforAbp();
}
if (self.options.actions.createAction) {
self._adaptCreateActionforAbp();
... | javascript | function () {
var self = this;
base._create.apply(self, arguments);
if (self.options.actions.listAction) {
self._adaptListActionforAbp();
}
if (self.options.actions.createAction) {
self._adaptCreateActionforAbp();
... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"base",
".",
"_create",
".",
"apply",
"(",
"self",
",",
"arguments",
")",
";",
"if",
"(",
"self",
".",
"options",
".",
"actions",
".",
"listAction",
")",
"{",
"self",
".",
"_adaptListActionf... | Override _create function to change actions according to Abp system | [
"Override",
"_create",
"function",
"to",
"change",
"actions",
"according",
"to",
"Abp",
"system"
] | 0272277a83d71fe1c8821292dd44909d78bd54ec | https://github.com/YazgelderRp/abp-electron-resources/blob/0272277a83d71fe1c8821292dd44909d78bd54ec/Abp/Framework/scripts/libs/abp.jtable.js#L19-L38 | train | |
YazgelderRp/abp-electron-resources | Abp/Framework/scripts/libs/abp.jtable.js | function () {
var self = this;
var originalListAction = self.options.actions.listAction;
self.options.actions.listAction = function (postData, jtParams) {
return $.Deferred(function ($dfd) {
var input = $.extend({}, postData, {
... | javascript | function () {
var self = this;
var originalListAction = self.options.actions.listAction;
self.options.actions.listAction = function (postData, jtParams) {
return $.Deferred(function ($dfd) {
var input = $.extend({}, postData, {
... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"originalListAction",
"=",
"self",
".",
"options",
".",
"actions",
".",
"listAction",
";",
"self",
".",
"options",
".",
"actions",
".",
"listAction",
"=",
"function",
"(",
"postData",
","... | LIST ACTION ADAPTER | [
"LIST",
"ACTION",
"ADAPTER"
] | 0272277a83d71fe1c8821292dd44909d78bd54ec | https://github.com/YazgelderRp/abp-electron-resources/blob/0272277a83d71fe1c8821292dd44909d78bd54ec/Abp/Framework/scripts/libs/abp.jtable.js#L41-L67 | train | |
YazgelderRp/abp-electron-resources | Abp/Framework/scripts/libs/abp.jtable.js | function () {
var self = this;
var originalCreateAction = self.options.actions.createAction;
self.options.actions.createAction = function (postData) {
return $.Deferred(function ($dfd) {
var input = $.extend({}, postData);
ori... | javascript | function () {
var self = this;
var originalCreateAction = self.options.actions.createAction;
self.options.actions.createAction = function (postData) {
return $.Deferred(function ($dfd) {
var input = $.extend({}, postData);
ori... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"originalCreateAction",
"=",
"self",
".",
"options",
".",
"actions",
".",
"createAction",
";",
"self",
".",
"options",
".",
"actions",
".",
"createAction",
"=",
"function",
"(",
"postData",... | CREATE ACTION ADAPTER | [
"CREATE",
"ACTION",
"ADAPTER"
] | 0272277a83d71fe1c8821292dd44909d78bd54ec | https://github.com/YazgelderRp/abp-electron-resources/blob/0272277a83d71fe1c8821292dd44909d78bd54ec/Abp/Framework/scripts/libs/abp.jtable.js#L70-L91 | train | |
YazgelderRp/abp-electron-resources | Abp/Framework/scripts/libs/abp.jtable.js | function () {
var self = this;
var originalUpdateAction = self.options.actions.updateAction;
self.options.actions.updateAction = function (postData) {
return $.Deferred(function ($dfd) {
var input = $.extend({}, postData);
ori... | javascript | function () {
var self = this;
var originalUpdateAction = self.options.actions.updateAction;
self.options.actions.updateAction = function (postData) {
return $.Deferred(function ($dfd) {
var input = $.extend({}, postData);
ori... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"originalUpdateAction",
"=",
"self",
".",
"options",
".",
"actions",
".",
"updateAction",
";",
"self",
".",
"options",
".",
"actions",
".",
"updateAction",
"=",
"function",
"(",
"postData",... | UPDATE ACTION ADAPTER | [
"UPDATE",
"ACTION",
"ADAPTER"
] | 0272277a83d71fe1c8821292dd44909d78bd54ec | https://github.com/YazgelderRp/abp-electron-resources/blob/0272277a83d71fe1c8821292dd44909d78bd54ec/Abp/Framework/scripts/libs/abp.jtable.js#L94-L124 | train | |
YazgelderRp/abp-electron-resources | Abp/Framework/scripts/libs/abp.jtable.js | function () {
var self = this;
var originalDeleteAction = self.options.actions.deleteAction;
self.options.actions.deleteAction = function (postData) {
return $.Deferred(function ($dfd) {
var input = $.extend({}, postData);
ori... | javascript | function () {
var self = this;
var originalDeleteAction = self.options.actions.deleteAction;
self.options.actions.deleteAction = function (postData) {
return $.Deferred(function ($dfd) {
var input = $.extend({}, postData);
ori... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"originalDeleteAction",
"=",
"self",
".",
"options",
".",
"actions",
".",
"deleteAction",
";",
"self",
".",
"options",
".",
"actions",
".",
"deleteAction",
"=",
"function",
"(",
"postData",... | DELETE ACTION ADAPTER | [
"DELETE",
"ACTION",
"ADAPTER"
] | 0272277a83d71fe1c8821292dd44909d78bd54ec | https://github.com/YazgelderRp/abp-electron-resources/blob/0272277a83d71fe1c8821292dd44909d78bd54ec/Abp/Framework/scripts/libs/abp.jtable.js#L127-L147 | train | |
DScheglov/merest | lib/controllers/options.js | options | function options(req, res) {
res.__apiMethod = 'options';
res.status(200);
res.json(this.urls());
} | javascript | function options(req, res) {
res.__apiMethod = 'options';
res.status(200);
res.json(this.urls());
} | [
"function",
"options",
"(",
"req",
",",
"res",
")",
"{",
"res",
".",
"__apiMethod",
"=",
"'options'",
";",
"res",
".",
"status",
"(",
"200",
")",
";",
"res",
".",
"json",
"(",
"this",
".",
"urls",
"(",
")",
")",
";",
"}"
] | options - controller that returns urls
@param {express.Request} req the http(s) request
@param {express.Response} res the http(s) response
@param {Function} next the callback should be called if controller fails
@memberof ModelAPIRouter | [
"options",
"-",
"controller",
"that",
"returns",
"urls"
] | d39e7ef0d56236247773467e9bfe83cb128ebc01 | https://github.com/DScheglov/merest/blob/d39e7ef0d56236247773467e9bfe83cb128ebc01/lib/controllers/options.js#L12-L16 | train |
ForgeRock/node-openam-agent-cache-mongodb | lib/mongodb-cache.js | MongoCache | function MongoCache(options) {
options = options || {};
var url = options.url || 'http://localhost/openam-agent',
expireAfterSeconds = options.expireAfterSeconds || 60,
collectionName = options.collectionName || 'agentcache';
this.collection = mongodb.MongoClient.connectAsync(url).then(fun... | javascript | function MongoCache(options) {
options = options || {};
var url = options.url || 'http://localhost/openam-agent',
expireAfterSeconds = options.expireAfterSeconds || 60,
collectionName = options.collectionName || 'agentcache';
this.collection = mongodb.MongoClient.connectAsync(url).then(fun... | [
"function",
"MongoCache",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"url",
"=",
"options",
".",
"url",
"||",
"'http://localhost/openam-agent'",
",",
"expireAfterSeconds",
"=",
"options",
".",
"expireAfterSeconds",
"||",
"... | Cache implementation for MongoDB
@extends Cache
@param {object} [options] Options
@param {string} [options.url=http://localhost/openam-agent] MongoDB URL
@param {number} [options.expireAfterSeconds=60] Expiration time in seconds
@param {string} [options.collectionName=agentcache] MongoDB collection name
@example
var... | [
"Cache",
"implementation",
"for",
"MongoDB"
] | 07352fe7c846559b5362c403dc0b444159cae017 | https://github.com/ForgeRock/node-openam-agent-cache-mongodb/blob/07352fe7c846559b5362c403dc0b444159cae017/lib/mongodb-cache.js#L28-L41 | train |
socialally/air | lib/air/append.js | append | function append() {
var i, l = this.length, el, args = this.slice.call(arguments);
function it(node, index) {
// content elements to insert
el.each(function(ins) {
ins = (index < (l - 1)) ? ins.cloneNode(true) : ins;
node.appendChild(ins);
});
}
for(i = 0;i < args.length;i++) {
// wr... | javascript | function append() {
var i, l = this.length, el, args = this.slice.call(arguments);
function it(node, index) {
// content elements to insert
el.each(function(ins) {
ins = (index < (l - 1)) ? ins.cloneNode(true) : ins;
node.appendChild(ins);
});
}
for(i = 0;i < args.length;i++) {
// wr... | [
"function",
"append",
"(",
")",
"{",
"var",
"i",
",",
"l",
"=",
"this",
".",
"length",
",",
"el",
",",
"args",
"=",
"this",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"function",
"it",
"(",
"node",
",",
"index",
")",
"{",
"// content ... | Insert content, specified by the parameter, to the end of each
element in the set of matched elements. | [
"Insert",
"content",
"specified",
"by",
"the",
"parameter",
"to",
"the",
"end",
"of",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/append.js#L5-L21 | train |
haraldrudell/nodegod | lib/rotatedstream.js | rotate | function rotate(cb) {
var retryCount
var newName
if (self.writable && didWrite && !rotating) { // we wrote something to the log, and are not in process of rotating
rotating = true
retryCount = 0
newName = getRotatedName()
fs.stat(newName, doesNewNameExist) // see if the new filename already exist
}... | javascript | function rotate(cb) {
var retryCount
var newName
if (self.writable && didWrite && !rotating) { // we wrote something to the log, and are not in process of rotating
rotating = true
retryCount = 0
newName = getRotatedName()
fs.stat(newName, doesNewNameExist) // see if the new filename already exist
}... | [
"function",
"rotate",
"(",
"cb",
")",
"{",
"var",
"retryCount",
"var",
"newName",
"if",
"(",
"self",
".",
"writable",
"&&",
"didWrite",
"&&",
"!",
"rotating",
")",
"{",
"// we wrote something to the log, and are not in process of rotating",
"rotating",
"=",
"true",
... | rotate the log | [
"rotate",
"the",
"log"
] | 3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21 | https://github.com/haraldrudell/nodegod/blob/3be4fb280fb18e0ec0a1c1a8fea3254d92f00b21/lib/rotatedstream.js#L114-L174 | train |
onecommons/base | lib/dataForm.js | resolve | function resolve(obj, propstr, default_val){
// special case, no test and assignment needed for optional default_val; we don't mind if default_val is undefined!
// note: eval called on propstr!
var rv;
if(obj === undefined){
rv = default_val;
} else if(obj.hasOwnProperty... | javascript | function resolve(obj, propstr, default_val){
// special case, no test and assignment needed for optional default_val; we don't mind if default_val is undefined!
// note: eval called on propstr!
var rv;
if(obj === undefined){
rv = default_val;
} else if(obj.hasOwnProperty... | [
"function",
"resolve",
"(",
"obj",
",",
"propstr",
",",
"default_val",
")",
"{",
"// special case, no test and assignment needed for optional default_val; we don't mind if default_val is undefined!",
"// note: eval called on propstr!",
"var",
"rv",
";",
"if",
"(",
"obj",
"===",
... | return value of property in object. | [
"return",
"value",
"of",
"property",
"in",
"object",
"."
] | 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/lib/dataForm.js#L107-L128 | train |
charto/charto-loader | src/extra.js | loadMonaco | function loadMonaco(monaco) {
var deps = [
'vs/editor/editor.main.nls',
'vs/editor/editor.main'
];
charto.monaco = monaco;
// Monaco loader sets exports, then gets confused by them.
exports = void 0;
return(new Promise(function(resolve, reject) {
monaco.require(deps, resolve);
}));
} | javascript | function loadMonaco(monaco) {
var deps = [
'vs/editor/editor.main.nls',
'vs/editor/editor.main'
];
charto.monaco = monaco;
// Monaco loader sets exports, then gets confused by them.
exports = void 0;
return(new Promise(function(resolve, reject) {
monaco.require(deps, resolve);
}));
} | [
"function",
"loadMonaco",
"(",
"monaco",
")",
"{",
"var",
"deps",
"=",
"[",
"'vs/editor/editor.main.nls'",
",",
"'vs/editor/editor.main'",
"]",
";",
"charto",
".",
"monaco",
"=",
"monaco",
";",
"// Monaco loader sets exports, then gets confused by them.",
"exports",
"="... | Fetch main Monaco bundles. | [
"Fetch",
"main",
"Monaco",
"bundles",
"."
] | 640ebb383bbda2be388c7c04ba627cb7d4263a0b | https://github.com/charto/charto-loader/blob/640ebb383bbda2be388c7c04ba627cb7d4263a0b/src/extra.js#L61-L75 | train |
zxqfox/pym | lib/pym.js | updateCollected | function updateCollected(err, result) {
if (typeof result !== 'object') {
collection.err = collection.err || new Error('Invalid acrhitect plugin format');
return;
}
collection.err = collection.err || err;
if (!collection.loaded) {
... | javascript | function updateCollected(err, result) {
if (typeof result !== 'object') {
collection.err = collection.err || new Error('Invalid acrhitect plugin format');
return;
}
collection.err = collection.err || err;
if (!collection.loaded) {
... | [
"function",
"updateCollected",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"typeof",
"result",
"!==",
"'object'",
")",
"{",
"collection",
".",
"err",
"=",
"collection",
".",
"err",
"||",
"new",
"Error",
"(",
"'Invalid acrhitect plugin format'",
")",
";",... | update `collection` hash
@param {Error} err
@param {Object} result | [
"update",
"collection",
"hash"
] | 5a8f62d4b447e17565334baf43127c731fd53dc7 | https://github.com/zxqfox/pym/blob/5a8f62d4b447e17565334baf43127c731fd53dc7/lib/pym.js#L117-L140 | train |
zxqfox/pym | lib/pym.js | _resolvePackageSync | function _resolvePackageSync(base, relativePath) {
var packageJsonPath;
var packagePath;
// try to fetch node package
try {
packageJsonPath = _resolvePackagePathSync(base, PATH.join(relativePath, 'package.json'));
packagePath = dirname(packageJsonPath);
} catch (err) {
if (e... | javascript | function _resolvePackageSync(base, relativePath) {
var packageJsonPath;
var packagePath;
// try to fetch node package
try {
packageJsonPath = _resolvePackagePathSync(base, PATH.join(relativePath, 'package.json'));
packagePath = dirname(packageJsonPath);
} catch (err) {
if (e... | [
"function",
"_resolvePackageSync",
"(",
"base",
",",
"relativePath",
")",
"{",
"var",
"packageJsonPath",
";",
"var",
"packagePath",
";",
"// try to fetch node package",
"try",
"{",
"packageJsonPath",
"=",
"_resolvePackagePathSync",
"(",
"base",
",",
"PATH",
".",
"jo... | Loads a module, getting metadata from either it's package.json
or export object.
@private
@param {string} base
@param {string} relativePath
@returns {Object}
- {string[]} provides
- {string[]} consumes
- {string} packagePath
- {string} | [
"Loads",
"a",
"module",
"getting",
"metadata",
"from",
"either",
"it",
"s",
"package",
".",
"json",
"or",
"export",
"object",
"."
] | 5a8f62d4b447e17565334baf43127c731fd53dc7 | https://github.com/zxqfox/pym/blob/5a8f62d4b447e17565334baf43127c731fd53dc7/lib/pym.js#L191-L244 | train |
zxqfox/pym | lib/pym.js | _resolvePackagePathSync | function _resolvePackagePathSync(base, relativePath) {
var originalBase = base;
if (!(base in packagePathCache)) {
packagePathCache[base] = {};
}
var cache = packagePathCache[base];
if (relativePath in cache) {
return cache[relativePath];
}
var packagePath;
if (relative... | javascript | function _resolvePackagePathSync(base, relativePath) {
var originalBase = base;
if (!(base in packagePathCache)) {
packagePathCache[base] = {};
}
var cache = packagePathCache[base];
if (relativePath in cache) {
return cache[relativePath];
}
var packagePath;
if (relative... | [
"function",
"_resolvePackagePathSync",
"(",
"base",
",",
"relativePath",
")",
"{",
"var",
"originalBase",
"=",
"base",
";",
"if",
"(",
"!",
"(",
"base",
"in",
"packagePathCache",
")",
")",
"{",
"packagePathCache",
"[",
"base",
"]",
"=",
"{",
"}",
";",
"}... | Node style package resolving so that plugins' package.json can be found relative to the config file
It's not the full node require system algorithm, but it's the 99% case
This throws, make sure to wrap in try..catch
@private
@param {string} base - base path
@param {string} relativePath | [
"Node",
"style",
"package",
"resolving",
"so",
"that",
"plugins",
"package",
".",
"json",
"can",
"be",
"found",
"relative",
"to",
"the",
"config",
"file",
"It",
"s",
"not",
"the",
"full",
"node",
"require",
"system",
"algorithm",
"but",
"it",
"s",
"the",
... | 5a8f62d4b447e17565334baf43127c731fd53dc7 | https://github.com/zxqfox/pym/blob/5a8f62d4b447e17565334baf43127c731fd53dc7/lib/pym.js#L259-L298 | train |
whitelizard/extended-ds-client | src/index.js | _$updateRecord | function _$updateRecord(name, obj, mode = 'shallow', lockedKeys = [], protectedKeys = []) {
if (!Object.keys(updateModes).includes(mode)) throw new TypeError('Unsupported mode');
lockedKeys.push(this.datasetRecordIdKey);
if (mode === 'shallow') return this.record._$updateRecordShallowP(name, obj, lockedKeys);
i... | javascript | function _$updateRecord(name, obj, mode = 'shallow', lockedKeys = [], protectedKeys = []) {
if (!Object.keys(updateModes).includes(mode)) throw new TypeError('Unsupported mode');
lockedKeys.push(this.datasetRecordIdKey);
if (mode === 'shallow') return this.record._$updateRecordShallowP(name, obj, lockedKeys);
i... | [
"function",
"_$updateRecord",
"(",
"name",
",",
"obj",
",",
"mode",
"=",
"'shallow'",
",",
"lockedKeys",
"=",
"[",
"]",
",",
"protectedKeys",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"Object",
".",
"keys",
"(",
"updateModes",
")",
".",
"includes",
"(... | should never be called externally since it is undefined what happens if record does not exist | [
"should",
"never",
"be",
"called",
"externally",
"since",
"it",
"is",
"undefined",
"what",
"happens",
"if",
"record",
"does",
"not",
"exist"
] | b8a2a79c6c6e45c06bf19fed107d1a251716048c | https://github.com/whitelizard/extended-ds-client/blob/b8a2a79c6c6e45c06bf19fed107d1a251716048c/src/index.js#L227-L238 | train |
chapmanu/hb | lib/services/core/service.js | function(stream, post) {
this._credentials = [];
this._status = {};
this._modules = {
stream: stream || Stream,
post: post || Post
};
} | javascript | function(stream, post) {
this._credentials = [];
this._status = {};
this._modules = {
stream: stream || Stream,
post: post || Post
};
} | [
"function",
"(",
"stream",
",",
"post",
")",
"{",
"this",
".",
"_credentials",
"=",
"[",
"]",
";",
"this",
".",
"_status",
"=",
"{",
"}",
";",
"this",
".",
"_modules",
"=",
"{",
"stream",
":",
"stream",
"||",
"Stream",
",",
"post",
":",
"post",
"... | Service
Manages all interactions with a social media service API, including streams, tracking info, etc.
This is a parent class template, meant to be inherited.
@constructor | [
"Service",
"Manages",
"all",
"interactions",
"with",
"a",
"social",
"media",
"service",
"API",
"including",
"streams",
"tracking",
"info",
"etc",
".",
"This",
"is",
"a",
"parent",
"class",
"template",
"meant",
"to",
"be",
"inherited",
"."
] | 5edd8de89c7c5fdffc3df0c627513889220f7d51 | https://github.com/chapmanu/hb/blob/5edd8de89c7c5fdffc3df0c627513889220f7d51/lib/services/core/service.js#L16-L23 | train | |
prathamesh7pute/coral | lib/queryConfig.js | QueryConfig | function QueryConfig (req, res, config) {
var sort = req.query.sort
var order = req.query.order
var select = req.query.select
var skip = req.query.skip
var limit = req.query.limit
var page = req.query.page
var perPage = config.perPage || 10
var idAttribute = config.idParam ? req.params[config.idParam] :... | javascript | function QueryConfig (req, res, config) {
var sort = req.query.sort
var order = req.query.order
var select = req.query.select
var skip = req.query.skip
var limit = req.query.limit
var page = req.query.page
var perPage = config.perPage || 10
var idAttribute = config.idParam ? req.params[config.idParam] :... | [
"function",
"QueryConfig",
"(",
"req",
",",
"res",
",",
"config",
")",
"{",
"var",
"sort",
"=",
"req",
".",
"query",
".",
"sort",
"var",
"order",
"=",
"req",
".",
"query",
".",
"order",
"var",
"select",
"=",
"req",
".",
"query",
".",
"select",
"var... | returns the process object with the passed data for pagination and sorting | [
"returns",
"the",
"process",
"object",
"with",
"the",
"passed",
"data",
"for",
"pagination",
"and",
"sorting"
] | 9036255bb67df53a94df0d7d6998f67692cb8c73 | https://github.com/prathamesh7pute/coral/blob/9036255bb67df53a94df0d7d6998f67692cb8c73/lib/queryConfig.js#L48-L114 | train |
Krinkle/node-colorfactory | src/ColorFactory.js | function (color, angle) {
var hsl, color0, color2;
if (!angle) {
angle = 30;
}
hsl = ColorHelper.rgbToHSL(color);
hsl[0] = (hsl[0] + angle) % 360;
color0 = ColorHelper.hslToHexColor(hsl);
color0 = ColorHelper.darken(color0, 8);
color0 = ColorHelper.saturate(color0, -6);
hsl = ColorHelper.... | javascript | function (color, angle) {
var hsl, color0, color2;
if (!angle) {
angle = 30;
}
hsl = ColorHelper.rgbToHSL(color);
hsl[0] = (hsl[0] + angle) % 360;
color0 = ColorHelper.hslToHexColor(hsl);
color0 = ColorHelper.darken(color0, 8);
color0 = ColorHelper.saturate(color0, -6);
hsl = ColorHelper.... | [
"function",
"(",
"color",
",",
"angle",
")",
"{",
"var",
"hsl",
",",
"color0",
",",
"color2",
";",
"if",
"(",
"!",
"angle",
")",
"{",
"angle",
"=",
"30",
";",
"}",
"hsl",
"=",
"ColorHelper",
".",
"rgbToHSL",
"(",
"color",
")",
";",
"hsl",
"[",
... | Two adjacent colors on 12-part color wheel | [
"Two",
"adjacent",
"colors",
"on",
"12",
"-",
"part",
"color",
"wheel"
] | 4c9cec8f3f8e95a3fa402233ceef2dd9c2b040b0 | https://github.com/Krinkle/node-colorfactory/blob/4c9cec8f3f8e95a3fa402233ceef2dd9c2b040b0/src/ColorFactory.js#L29-L43 | train | |
Krinkle/node-colorfactory | src/ColorFactory.js | function (startColor, endColor, count) {
var lightness,
hsl = ColorHelper.rgbToHSL(startColor);
if (count === undefined) {
count = endColor;
lightness = hsl[2] - 20 * count;
if (lightness < 0) {
lightness = 100 - hsl[2];
}
endColor = ColorHelper.hslToHexColor([hsl[0], hsl[1], lightnes... | javascript | function (startColor, endColor, count) {
var lightness,
hsl = ColorHelper.rgbToHSL(startColor);
if (count === undefined) {
count = endColor;
lightness = hsl[2] - 20 * count;
if (lightness < 0) {
lightness = 100 - hsl[2];
}
endColor = ColorHelper.hslToHexColor([hsl[0], hsl[1], lightnes... | [
"function",
"(",
"startColor",
",",
"endColor",
",",
"count",
")",
"{",
"var",
"lightness",
",",
"hsl",
"=",
"ColorHelper",
".",
"rgbToHSL",
"(",
"startColor",
")",
";",
"if",
"(",
"count",
"===",
"undefined",
")",
"{",
"count",
"=",
"endColor",
";",
"... | Sequential schemes are suited to ordered data that progress from low to high.
Lightness steps dominate the look of these schemes, with light colors
for low data values to dark colors for high data values.
@param startColor
@param endColor (optional)
@param count | [
"Sequential",
"schemes",
"are",
"suited",
"to",
"ordered",
"data",
"that",
"progress",
"from",
"low",
"to",
"high",
".",
"Lightness",
"steps",
"dominate",
"the",
"look",
"of",
"these",
"schemes",
"with",
"light",
"colors",
"for",
"low",
"data",
"values",
"to... | 4c9cec8f3f8e95a3fa402233ceef2dd9c2b040b0 | https://github.com/Krinkle/node-colorfactory/blob/4c9cec8f3f8e95a3fa402233ceef2dd9c2b040b0/src/ColorFactory.js#L118-L131 | train | |
wunderbyte/grunt-spiritual-build | tasks/super.js | oncurlyclose | function oncurlyclose(state, curly, suber) {
curly.count--;
if (suber.protostring && curly.count === curly.protocount) {
suber.protostring = null;
}
} | javascript | function oncurlyclose(state, curly, suber) {
curly.count--;
if (suber.protostring && curly.count === curly.protocount) {
suber.protostring = null;
}
} | [
"function",
"oncurlyclose",
"(",
"state",
",",
"curly",
",",
"suber",
")",
"{",
"curly",
".",
"count",
"--",
";",
"if",
"(",
"suber",
".",
"protostring",
"&&",
"curly",
".",
"count",
"===",
"curly",
".",
"protocount",
")",
"{",
"suber",
".",
"protostri... | Curly brace ends.
@param {State} state
@param {Curly} curly
@param {Super} suber | [
"Curly",
"brace",
"ends",
"."
] | 6676b699904fe72f899fe7b88871de5ef23a23c3 | https://github.com/wunderbyte/grunt-spiritual-build/blob/6676b699904fe72f899fe7b88871de5ef23a23c3/tasks/super.js#L332-L337 | train |
elliottsj/memoize-id | src/index.js | get | function get(cache, keys) {
if (keys.length === 0) {
return cache.get(sentinel);
}
const [key, ...restKeys] = keys;
const nestedCache = cache.get(key);
if (!nestedCache) {
return undefined;
}
return get(nestedCache, restKeys);
} | javascript | function get(cache, keys) {
if (keys.length === 0) {
return cache.get(sentinel);
}
const [key, ...restKeys] = keys;
const nestedCache = cache.get(key);
if (!nestedCache) {
return undefined;
}
return get(nestedCache, restKeys);
} | [
"function",
"get",
"(",
"cache",
",",
"keys",
")",
"{",
"if",
"(",
"keys",
".",
"length",
"===",
"0",
")",
"{",
"return",
"cache",
".",
"get",
"(",
"sentinel",
")",
";",
"}",
"const",
"[",
"key",
",",
"...",
"restKeys",
"]",
"=",
"keys",
";",
"... | Get a value from the given cache Map, accessing an inner Map for each value in `keys`.
If a value does not exist, return undefined.
@param {Map} cache The base Map from which to get a value
@param {Array<Any>} keys An array of keys for which nested Maps will be accessed
@return {Any} The value itself | [
"Get",
"a",
"value",
"from",
"the",
"given",
"cache",
"Map",
"accessing",
"an",
"inner",
"Map",
"for",
"each",
"value",
"in",
"keys",
".",
"If",
"a",
"value",
"does",
"not",
"exist",
"return",
"undefined",
"."
] | 68b8771ada2b678509db31b403d406317003f7ea | https://github.com/elliottsj/memoize-id/blob/68b8771ada2b678509db31b403d406317003f7ea/src/index.js#L12-L22 | train |
hoist/hoist-js | src/hoist.js | DataManager | function DataManager(hoist, type, bucket) {
this.type = type;
this.hoist = hoist;
this.url = hoist._configs.data + "/" + type;
this.bucket = bucket;
} | javascript | function DataManager(hoist, type, bucket) {
this.type = type;
this.hoist = hoist;
this.url = hoist._configs.data + "/" + type;
this.bucket = bucket;
} | [
"function",
"DataManager",
"(",
"hoist",
",",
"type",
",",
"bucket",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"hoist",
"=",
"hoist",
";",
"this",
".",
"url",
"=",
"hoist",
".",
"_configs",
".",
"data",
"+",
"\"/\"",
"+",
"type"... | simple data manager | [
"simple",
"data",
"manager"
] | 999a2d3cde5e3e6cd70b4d8cf640c1623a002c2b | https://github.com/hoist/hoist-js/blob/999a2d3cde5e3e6cd70b4d8cf640c1623a002c2b/src/hoist.js#L170-L175 | train |
pkgcloud/pkgcloud-bootstrapper | lib/pkgcloud-bootstrapper.js | iterateKeys | function iterateKeys(keys) {
async.forEach(keys, readKey, function (err) {
return err ? callback(err) : callback(null, keyinfo);
});
} | javascript | function iterateKeys(keys) {
async.forEach(keys, readKey, function (err) {
return err ? callback(err) : callback(null, keyinfo);
});
} | [
"function",
"iterateKeys",
"(",
"keys",
")",
"{",
"async",
".",
"forEach",
"(",
"keys",
",",
"readKey",
",",
"function",
"(",
"err",
")",
"{",
"return",
"err",
"?",
"callback",
"(",
"err",
")",
":",
"callback",
"(",
"null",
",",
"keyinfo",
")",
";",
... | Helper function to iterate the array of keys | [
"Helper",
"function",
"to",
"iterate",
"the",
"array",
"of",
"keys"
] | 773d75b8ac3744408a9626c9c6161aafea0a33b4 | https://github.com/pkgcloud/pkgcloud-bootstrapper/blob/773d75b8ac3744408a9626c9c6161aafea0a33b4/lib/pkgcloud-bootstrapper.js#L94-L98 | train |
pkgcloud/pkgcloud-bootstrapper | lib/pkgcloud-bootstrapper.js | createDirs | function createDirs(next) {
if (!options.files || !options.files.length) {
return next();
}
self.ssh({
keys: options.keys,
server: options.server,
tunnel: options.tunnel,
remoteUser: options.remoteUser,
commands: ['mkdir -p ' + options.files.map(functio... | javascript | function createDirs(next) {
if (!options.files || !options.files.length) {
return next();
}
self.ssh({
keys: options.keys,
server: options.server,
tunnel: options.tunnel,
remoteUser: options.remoteUser,
commands: ['mkdir -p ' + options.files.map(functio... | [
"function",
"createDirs",
"(",
"next",
")",
"{",
"if",
"(",
"!",
"options",
".",
"files",
"||",
"!",
"options",
".",
"files",
".",
"length",
")",
"{",
"return",
"next",
"(",
")",
";",
"}",
"self",
".",
"ssh",
"(",
"{",
"keys",
":",
"options",
"."... | 1. Create any remote directories for files that will be uploaded. | [
"1",
".",
"Create",
"any",
"remote",
"directories",
"for",
"files",
"that",
"will",
"be",
"uploaded",
"."
] | 773d75b8ac3744408a9626c9c6161aafea0a33b4 | https://github.com/pkgcloud/pkgcloud-bootstrapper/blob/773d75b8ac3744408a9626c9c6161aafea0a33b4/lib/pkgcloud-bootstrapper.js#L271-L294 | train |
pkgcloud/pkgcloud-bootstrapper | lib/pkgcloud-bootstrapper.js | uploadFiles | function uploadFiles(next) {
return options.files && options.files.length
? async.forEachSeries(options.files, uploadFile, next)
: next();
} | javascript | function uploadFiles(next) {
return options.files && options.files.length
? async.forEachSeries(options.files, uploadFile, next)
: next();
} | [
"function",
"uploadFiles",
"(",
"next",
")",
"{",
"return",
"options",
".",
"files",
"&&",
"options",
".",
"files",
".",
"length",
"?",
"async",
".",
"forEachSeries",
"(",
"options",
".",
"files",
",",
"uploadFile",
",",
"next",
")",
":",
"next",
"(",
... | 2. Upload any required files. | [
"2",
".",
"Upload",
"any",
"required",
"files",
"."
] | 773d75b8ac3744408a9626c9c6161aafea0a33b4 | https://github.com/pkgcloud/pkgcloud-bootstrapper/blob/773d75b8ac3744408a9626c9c6161aafea0a33b4/lib/pkgcloud-bootstrapper.js#L297-L301 | 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.