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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
IndigoUnited/js-dejavu | dist/amd/strict/Interface.js | checkClass | function checkClass(target) {
/*jshint validthis:true*/
var key,
value;
// Check normal functions
for (key in this[$interface].methods) {
value = this[$interface].methods[key];
if (!target[$class].methods[key]) {
throw new Error('Clas... | javascript | function checkClass(target) {
/*jshint validthis:true*/
var key,
value;
// Check normal functions
for (key in this[$interface].methods) {
value = this[$interface].methods[key];
if (!target[$class].methods[key]) {
throw new Error('Clas... | [
"function",
"checkClass",
"(",
"target",
")",
"{",
"/*jshint validthis:true*/",
"var",
"key",
",",
"value",
";",
"// Check normal functions",
"for",
"(",
"key",
"in",
"this",
"[",
"$interface",
"]",
".",
"methods",
")",
"{",
"value",
"=",
"this",
"[",
"$inte... | Checks if an interface is well implemented in a class.
In order to this function to work, it must be bound to an interface definition.
@param {Function} target The class to be checked | [
"Checks",
"if",
"an",
"interface",
"is",
"well",
"implemented",
"in",
"a",
"class",
".",
"In",
"order",
"to",
"this",
"function",
"to",
"work",
"it",
"must",
"be",
"bound",
"to",
"an",
"interface",
"definition",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/amd/strict/Interface.js#L64-L93 | train |
IndigoUnited/js-dejavu | dist/amd/strict/Interface.js | assignConstant | function assignConstant(name, value, interf) {
if (hasDefineProperty) {
Object.defineProperty(interf, name, {
get: function () {
return value;
},
set: function () {
throw new Error('Cannot change value of constan... | javascript | function assignConstant(name, value, interf) {
if (hasDefineProperty) {
Object.defineProperty(interf, name, {
get: function () {
return value;
},
set: function () {
throw new Error('Cannot change value of constan... | [
"function",
"assignConstant",
"(",
"name",
",",
"value",
",",
"interf",
")",
"{",
"if",
"(",
"hasDefineProperty",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"interf",
",",
"name",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"return",
"value",
... | Assigns a constant to the interface.
This method will protect the constant from being changed.
@param {String} name The constant name
@param {Function} value The constant value
@param {Function} interf The interface in which the constant will be saved | [
"Assigns",
"a",
"constant",
"to",
"the",
"interface",
".",
"This",
"method",
"will",
"protect",
"the",
"constant",
"from",
"being",
"changed",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/amd/strict/Interface.js#L149-L164 | train |
IndigoUnited/js-dejavu | dist/amd/strict/Interface.js | addConstant | function addConstant(name, value, interf) {
var target;
// Check if it is public
if (name.charAt(0) === '_') {
throw new Error('Interface "' + interf.prototype.$name + '" contains an unallowed non public method: "' + name + '".');
}
// Check if it is a primitive valu... | javascript | function addConstant(name, value, interf) {
var target;
// Check if it is public
if (name.charAt(0) === '_') {
throw new Error('Interface "' + interf.prototype.$name + '" contains an unallowed non public method: "' + name + '".');
}
// Check if it is a primitive valu... | [
"function",
"addConstant",
"(",
"name",
",",
"value",
",",
"interf",
")",
"{",
"var",
"target",
";",
"// Check if it is public",
"if",
"(",
"name",
".",
"charAt",
"(",
"0",
")",
"===",
"'_'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Interface \"'",
"+",... | Adds a constant to an interface.
This method will throw an error if something is not right.
@param {String} name The constant name
@param {Function} value The constant value
@param {Function} interf The interface in which the constant will be saved | [
"Adds",
"a",
"constant",
"to",
"an",
"interface",
".",
"This",
"method",
"will",
"throw",
"an",
"error",
"if",
"something",
"is",
"not",
"right",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/amd/strict/Interface.js#L174-L195 | train |
nathschmidt/restify-cookies | index.js | parseCookies | function parseCookies(req, res, next) {
var self = this;
var cookieHeader = req.headers.cookie;
if (cookieHeader) {
req.cookies = cookie.parse(cookieHeader);
} else {
req.cookies = {};
}
/**
* Add a cookie to our response. Uses a Set-Cookie header
* per cookie added.
*
* @param {String... | javascript | function parseCookies(req, res, next) {
var self = this;
var cookieHeader = req.headers.cookie;
if (cookieHeader) {
req.cookies = cookie.parse(cookieHeader);
} else {
req.cookies = {};
}
/**
* Add a cookie to our response. Uses a Set-Cookie header
* per cookie added.
*
* @param {String... | [
"function",
"parseCookies",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"cookieHeader",
"=",
"req",
".",
"headers",
".",
"cookie",
";",
"if",
"(",
"cookieHeader",
")",
"{",
"req",
".",
"cookies",
"=",
"cooki... | Parse function to be handed to restify server.use
@param {object} req
@param {object} res
@param {Function} next
@return {undefined} | [
"Parse",
"function",
"to",
"be",
"handed",
"to",
"restify",
"server",
".",
"use"
] | 7aabcc930adc506837e2ce2cae655f997dedf6ec | https://github.com/nathschmidt/restify-cookies/blob/7aabcc930adc506837e2ce2cae655f997dedf6ec/index.js#L20-L70 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/interfaces/manual.js | reportManualError | function reportManualError(err, request, additionalMessage, callback) {
if (isString(request)) {
// no request given
callback = additionalMessage;
additionalMessage = request;
request = undefined;
} else if (isFunction(request)) {
// neither request nor additionalMessage given
... | javascript | function reportManualError(err, request, additionalMessage, callback) {
if (isString(request)) {
// no request given
callback = additionalMessage;
additionalMessage = request;
request = undefined;
} else if (isFunction(request)) {
// neither request nor additionalMessage given
... | [
"function",
"reportManualError",
"(",
"err",
",",
"request",
",",
"additionalMessage",
",",
"callback",
")",
"{",
"if",
"(",
"isString",
"(",
"request",
")",
")",
"{",
"// no request given",
"callback",
"=",
"additionalMessage",
";",
"additionalMessage",
"=",
"r... | The interface for manually reporting errors to the Google Error API in
application code.
@param {Any} err - error information of any type or content. This can be
of any type but better errors will be logged given a valid instance of
Error class.
@param {Object} [request] - an object containing request information. This... | [
"The",
"interface",
"for",
"manually",
"reporting",
"errors",
"to",
"the",
"Google",
"Error",
"API",
"in",
"application",
"code",
"."
] | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/interfaces/manual.js#L56-L90 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | isImmutable | function isImmutable(value) {
return value == null || isBoolean(value) || isNumber(value) || isString(value);
} | javascript | function isImmutable(value) {
return value == null || isBoolean(value) || isNumber(value) || isString(value);
} | [
"function",
"isImmutable",
"(",
"value",
")",
"{",
"return",
"value",
"==",
"null",
"||",
"isBoolean",
"(",
"value",
")",
"||",
"isNumber",
"(",
"value",
")",
"||",
"isString",
"(",
"value",
")",
";",
"}"
] | Checks if a value is immutable.
@param {Mixed} value The value
@return {Boolean} True if it is, false otherwise | [
"Checks",
"if",
"a",
"value",
"is",
"immutable",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L617-L619 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | mixIn | function mixIn(target, objects){
var i = 0,
n = arguments.length,
obj;
while(++i < n){
obj = arguments[i];
if (obj != null) {
forOwn(obj, copyProp, target);
}
}
return target;
} | javascript | function mixIn(target, objects){
var i = 0,
n = arguments.length,
obj;
while(++i < n){
obj = arguments[i];
if (obj != null) {
forOwn(obj, copyProp, target);
}
}
return target;
} | [
"function",
"mixIn",
"(",
"target",
",",
"objects",
")",
"{",
"var",
"i",
"=",
"0",
",",
"n",
"=",
"arguments",
".",
"length",
",",
"obj",
";",
"while",
"(",
"++",
"i",
"<",
"n",
")",
"{",
"obj",
"=",
"arguments",
"[",
"i",
"]",
";",
"if",
"(... | Combine properties from all the objects into first one.
- This method affects target object in place, if you want to create a new Object pass an empty object as first param.
@param {object} target Target Object
@param {...object} objects Objects to be combined (0...n objects).
@return {object} Target Object. | [
"Combine",
"properties",
"from",
"all",
"the",
"objects",
"into",
"first",
"one",
".",
"-",
"This",
"method",
"affects",
"target",
"object",
"in",
"place",
"if",
"you",
"want",
"to",
"create",
"a",
"new",
"Object",
"pass",
"an",
"empty",
"object",
"as",
... | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L793-L804 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | indexOf | function indexOf(arr, item, fromIndex) {
fromIndex = fromIndex || 0;
if (arr == null) {
return -1;
}
var len = arr.length,
i = fromIndex < 0 ? len + fromIndex : fromIndex;
while (i < len) {
// we iterate over sparse items since there is no way... | javascript | function indexOf(arr, item, fromIndex) {
fromIndex = fromIndex || 0;
if (arr == null) {
return -1;
}
var len = arr.length,
i = fromIndex < 0 ? len + fromIndex : fromIndex;
while (i < len) {
// we iterate over sparse items since there is no way... | [
"function",
"indexOf",
"(",
"arr",
",",
"item",
",",
"fromIndex",
")",
"{",
"fromIndex",
"=",
"fromIndex",
"||",
"0",
";",
"if",
"(",
"arr",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"var",
"len",
"=",
"arr",
".",
"length",
",",
"i",
... | Array.indexOf | [
"Array",
".",
"indexOf"
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L841-L860 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | combine | function combine(arr1, arr2) {
if (arr2 == null) {
return arr1;
}
var i = -1, len = arr2.length;
while (++i < len) {
if (indexOf(arr1, arr2[i]) === -1) {
arr1.push(arr2[i]);
}
}
return arr1;
} | javascript | function combine(arr1, arr2) {
if (arr2 == null) {
return arr1;
}
var i = -1, len = arr2.length;
while (++i < len) {
if (indexOf(arr1, arr2[i]) === -1) {
arr1.push(arr2[i]);
}
}
return arr1;
} | [
"function",
"combine",
"(",
"arr1",
",",
"arr2",
")",
"{",
"if",
"(",
"arr2",
"==",
"null",
")",
"{",
"return",
"arr1",
";",
"}",
"var",
"i",
"=",
"-",
"1",
",",
"len",
"=",
"arr2",
".",
"length",
";",
"while",
"(",
"++",
"i",
"<",
"len",
")"... | Combines an array with all the items of another.
Does not allow duplicates and is case and type sensitive. | [
"Combines",
"an",
"array",
"with",
"all",
"the",
"items",
"of",
"another",
".",
"Does",
"not",
"allow",
"duplicates",
"and",
"is",
"case",
"and",
"type",
"sensitive",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L873-L886 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | clone | function clone(val){
switch (kindOf(val)) {
case 'Object':
return cloneObject(val);
case 'Array':
return cloneArray(val);
case 'RegExp':
return cloneRegExp(val);
case 'Date':
return cloneDate(val);
... | javascript | function clone(val){
switch (kindOf(val)) {
case 'Object':
return cloneObject(val);
case 'Array':
return cloneArray(val);
case 'RegExp':
return cloneRegExp(val);
case 'Date':
return cloneDate(val);
... | [
"function",
"clone",
"(",
"val",
")",
"{",
"switch",
"(",
"kindOf",
"(",
"val",
")",
")",
"{",
"case",
"'Object'",
":",
"return",
"cloneObject",
"(",
"val",
")",
";",
"case",
"'Array'",
":",
"return",
"cloneArray",
"(",
"val",
")",
";",
"case",
"'Reg... | Clone native types. | [
"Clone",
"native",
"types",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L928-L941 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | deepClone | function deepClone(val, instanceClone) {
switch ( kindOf(val) ) {
case 'Object':
return cloneObject(val, instanceClone);
case 'Array':
return cloneArray(val, instanceClone);
default:
return clone(val);
}
} | javascript | function deepClone(val, instanceClone) {
switch ( kindOf(val) ) {
case 'Object':
return cloneObject(val, instanceClone);
case 'Array':
return cloneArray(val, instanceClone);
default:
return clone(val);
}
} | [
"function",
"deepClone",
"(",
"val",
",",
"instanceClone",
")",
"{",
"switch",
"(",
"kindOf",
"(",
"val",
")",
")",
"{",
"case",
"'Object'",
":",
"return",
"cloneObject",
"(",
"val",
",",
"instanceClone",
")",
";",
"case",
"'Array'",
":",
"return",
"clon... | Recursively clone native types. | [
"Recursively",
"clone",
"native",
"types",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L981-L990 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | append | function append(arr1, arr2) {
if (arr2 == null) {
return arr1;
}
var pad = arr1.length,
i = -1,
len = arr2.length;
while (++i < len) {
arr1[pad + i] = arr2[i];
}
return arr1;
} | javascript | function append(arr1, arr2) {
if (arr2 == null) {
return arr1;
}
var pad = arr1.length,
i = -1,
len = arr2.length;
while (++i < len) {
arr1[pad + i] = arr2[i];
}
return arr1;
} | [
"function",
"append",
"(",
"arr1",
",",
"arr2",
")",
"{",
"if",
"(",
"arr2",
"==",
"null",
")",
"{",
"return",
"arr1",
";",
"}",
"var",
"pad",
"=",
"arr1",
".",
"length",
",",
"i",
"=",
"-",
"1",
",",
"len",
"=",
"arr2",
".",
"length",
";",
"... | Appends an array to the end of another.
The first array will be modified. | [
"Appends",
"an",
"array",
"to",
"the",
"end",
"of",
"another",
".",
"The",
"first",
"array",
"will",
"be",
"modified",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L1065-L1077 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | bind | function bind(fn, context, args){
var argsArr = slice(arguments, 2); //curried args
return function(){
return fn.apply(context, argsArr.concat(slice(arguments)));
};
} | javascript | function bind(fn, context, args){
var argsArr = slice(arguments, 2); //curried args
return function(){
return fn.apply(context, argsArr.concat(slice(arguments)));
};
} | [
"function",
"bind",
"(",
"fn",
",",
"context",
",",
"args",
")",
"{",
"var",
"argsArr",
"=",
"slice",
"(",
"arguments",
",",
"2",
")",
";",
"//curried args",
"return",
"function",
"(",
")",
"{",
"return",
"fn",
".",
"apply",
"(",
"context",
",",
"arg... | Return a function that will execute in the given context, optionally adding any additional supplied parameters to the beginning of the arguments collection.
@param {Function} fn Function.
@param {object} context Execution context.
@param {rest} args Arguments (0...n arguments).
@return {Function} Wrapped Function... | [
"Return",
"a",
"function",
"that",
"will",
"execute",
"in",
"the",
"given",
"context",
"optionally",
"adding",
"any",
"additional",
"supplied",
"parameters",
"to",
"the",
"beginning",
"of",
"the",
"arguments",
"collection",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L1130-L1135 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | toArray | function toArray(val){
var ret = [],
kind = kindOf(val),
n;
if (val != null) {
if ( val.length == null || kind === 'String' || kind === 'Function' || kind === 'RegExp' || val === _win ) {
//string, regexp, function have .length but user probably just ... | javascript | function toArray(val){
var ret = [],
kind = kindOf(val),
n;
if (val != null) {
if ( val.length == null || kind === 'String' || kind === 'Function' || kind === 'RegExp' || val === _win ) {
//string, regexp, function have .length but user probably just ... | [
"function",
"toArray",
"(",
"val",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
",",
"kind",
"=",
"kindOf",
"(",
"val",
")",
",",
"n",
";",
"if",
"(",
"val",
"!=",
"null",
")",
"{",
"if",
"(",
"val",
".",
"length",
"==",
"null",
"||",
"kind",
"==="... | Convert array-like object into array | [
"Convert",
"array",
"-",
"like",
"object",
"into",
"array"
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L1150-L1171 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | deepMatches | function deepMatches(target, pattern){
if (target && typeof target === 'object') {
if (isArray(target) && isArray(pattern)) {
return matchArray(target, pattern);
} else {
return matchObject(target, pattern);
}
} else {
retur... | javascript | function deepMatches(target, pattern){
if (target && typeof target === 'object') {
if (isArray(target) && isArray(pattern)) {
return matchArray(target, pattern);
} else {
return matchObject(target, pattern);
}
} else {
retur... | [
"function",
"deepMatches",
"(",
"target",
",",
"pattern",
")",
"{",
"if",
"(",
"target",
"&&",
"typeof",
"target",
"===",
"'object'",
")",
"{",
"if",
"(",
"isArray",
"(",
"target",
")",
"&&",
"isArray",
"(",
"pattern",
")",
")",
"{",
"return",
"matchAr... | Recursively check if the objects match. | [
"Recursively",
"check",
"if",
"the",
"objects",
"match",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L1249-L1259 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | difference | function difference(arr) {
var arrs = slice(arguments, 1),
result = filter(unique(arr), function(needle){
return !some(arrs, function(haystack){
return contains(haystack, needle);
});
});
return result;
} | javascript | function difference(arr) {
var arrs = slice(arguments, 1),
result = filter(unique(arr), function(needle){
return !some(arrs, function(haystack){
return contains(haystack, needle);
});
});
return result;
} | [
"function",
"difference",
"(",
"arr",
")",
"{",
"var",
"arrs",
"=",
"slice",
"(",
"arguments",
",",
"1",
")",
",",
"result",
"=",
"filter",
"(",
"unique",
"(",
"arr",
")",
",",
"function",
"(",
"needle",
")",
"{",
"return",
"!",
"some",
"(",
"arrs"... | Return a new Array with elements that aren't present in the other Arrays. | [
"Return",
"a",
"new",
"Array",
"with",
"elements",
"that",
"aren",
"t",
"present",
"in",
"the",
"other",
"Arrays",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L1401-L1409 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | insert | function insert(arr, rest_items) {
var diff = difference(slice(arguments, 1), arr);
if (diff.length) {
Array.prototype.push.apply(arr, diff);
}
return arr.length;
} | javascript | function insert(arr, rest_items) {
var diff = difference(slice(arguments, 1), arr);
if (diff.length) {
Array.prototype.push.apply(arr, diff);
}
return arr.length;
} | [
"function",
"insert",
"(",
"arr",
",",
"rest_items",
")",
"{",
"var",
"diff",
"=",
"difference",
"(",
"slice",
"(",
"arguments",
",",
"1",
")",
",",
"arr",
")",
";",
"if",
"(",
"diff",
".",
"length",
")",
"{",
"Array",
".",
"prototype",
".",
"push"... | Insert item into array if not already present. | [
"Insert",
"item",
"into",
"array",
"if",
"not",
"already",
"present",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L1423-L1429 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | interfaceDescendantOf | function interfaceDescendantOf(interf1, interf2) {
var x,
parents = interf1[$interface].parents;
for (x = parents.length - 1; x >= 0; x -= 1) {
if (parents[x] === interf2) {
return true;
}
if (interfaceDescendantOf(interf1, parents[x])) {
... | javascript | function interfaceDescendantOf(interf1, interf2) {
var x,
parents = interf1[$interface].parents;
for (x = parents.length - 1; x >= 0; x -= 1) {
if (parents[x] === interf2) {
return true;
}
if (interfaceDescendantOf(interf1, parents[x])) {
... | [
"function",
"interfaceDescendantOf",
"(",
"interf1",
",",
"interf2",
")",
"{",
"var",
"x",
",",
"parents",
"=",
"interf1",
"[",
"$interface",
"]",
".",
"parents",
";",
"for",
"(",
"x",
"=",
"parents",
".",
"length",
"-",
"1",
";",
"x",
">=",
"0",
";"... | Check if an interface is descendant of another.
@param {Function} interf1 The interface to be checked
@param {Function} interf2 The interface to be expected as the ancestor
@return {Boolean} True if it's a descendant, false otherwise | [
"Check",
"if",
"an",
"interface",
"is",
"descendant",
"of",
"another",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L2421-L2435 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | instanceOfInterface | function instanceOfInterface(instance, target) {
var x,
interfaces = instance.$static[$class].interfaces;
for (x = interfaces.length - 1; x >= 0; x -= 1) {
if (interfaces[x] === target || interfaceDescendantOf(interfaces[x], target)) {
return true;
}
... | javascript | function instanceOfInterface(instance, target) {
var x,
interfaces = instance.$static[$class].interfaces;
for (x = interfaces.length - 1; x >= 0; x -= 1) {
if (interfaces[x] === target || interfaceDescendantOf(interfaces[x], target)) {
return true;
}
... | [
"function",
"instanceOfInterface",
"(",
"instance",
",",
"target",
")",
"{",
"var",
"x",
",",
"interfaces",
"=",
"instance",
".",
"$static",
"[",
"$class",
"]",
".",
"interfaces",
";",
"for",
"(",
"x",
"=",
"interfaces",
".",
"length",
"-",
"1",
";",
"... | Check if an instance of a class is an instance of an interface.
@param {Object} instance The instance to be checked
@param {Function} target The interface
@return {Boolean} True if it is, false otherwise | [
"Check",
"if",
"an",
"instance",
"of",
"a",
"class",
"is",
"an",
"instance",
"of",
"an",
"interface",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L2445-L2456 | train |
IndigoUnited/js-dejavu | dist/regular/loose/dejavu.js | instanceOf | function instanceOf(instance, target) {
if (!isFunction(target)) {
return false;
}
if (instance instanceof target) {
return true;
}
if (instance && instance.$static && instance.$static[$class] && target && target[$interface]) {
return instanc... | javascript | function instanceOf(instance, target) {
if (!isFunction(target)) {
return false;
}
if (instance instanceof target) {
return true;
}
if (instance && instance.$static && instance.$static[$class] && target && target[$interface]) {
return instanc... | [
"function",
"instanceOf",
"(",
"instance",
",",
"target",
")",
"{",
"if",
"(",
"!",
"isFunction",
"(",
"target",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"instance",
"instanceof",
"target",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(... | Custom instanceOf that also works on interfaces.
@param {Object} instance The instance to be checked
@param {Function} target The target
@return {Boolean} True if it is a valid instance of target, false otherwise | [
"Custom",
"instanceOf",
"that",
"also",
"works",
"on",
"interfaces",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/loose/dejavu.js#L2466-L2480 | train |
IndigoUnited/js-dejavu | dist/amd/strict/lib/functionMeta.js | functionMeta | function functionMeta(func, name) {
var matches = /^function(\s+[a-zA-Z0-9_\$]*)*\s*\(([^\(]*)\)/m.exec(func.toString()),
ret,
split,
optionalReached = false,
length,
x;
// Analyze arguments
if (!matches) {
return null;
... | javascript | function functionMeta(func, name) {
var matches = /^function(\s+[a-zA-Z0-9_\$]*)*\s*\(([^\(]*)\)/m.exec(func.toString()),
ret,
split,
optionalReached = false,
length,
x;
// Analyze arguments
if (!matches) {
return null;
... | [
"function",
"functionMeta",
"(",
"func",
",",
"name",
")",
"{",
"var",
"matches",
"=",
"/",
"^function(\\s+[a-zA-Z0-9_\\$]*)*\\s*\\(([^\\(]*)\\)",
"/",
"m",
".",
"exec",
"(",
"func",
".",
"toString",
"(",
")",
")",
",",
"ret",
",",
"split",
",",
"optionalRea... | Extract meta data from a function.
It returns an object containing the number of normal arguments, the number
of optional arguments, the function signature, the function name and the visibility.
Will return null if the function arguments are invalid.
@param {Function} func The function
@param {String} name The name... | [
"Extract",
"meta",
"data",
"from",
"a",
"function",
".",
"It",
"returns",
"an",
"object",
"containing",
"the",
"number",
"of",
"normal",
"arguments",
"the",
"number",
"of",
"optional",
"arguments",
"the",
"function",
"signature",
"the",
"function",
"name",
"an... | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/amd/strict/lib/functionMeta.js#L19-L68 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/error-handlers/error.js | handleErrorClassError | function handleErrorClassError(err, errorMessage) {
if (err instanceof Error) {
extractFromErrorClass(err, errorMessage);
} else {
handleUnknownAsError(err, errorMessage);
}
} | javascript | function handleErrorClassError(err, errorMessage) {
if (err instanceof Error) {
extractFromErrorClass(err, errorMessage);
} else {
handleUnknownAsError(err, errorMessage);
}
} | [
"function",
"handleErrorClassError",
"(",
"err",
",",
"errorMessage",
")",
"{",
"if",
"(",
"err",
"instanceof",
"Error",
")",
"{",
"extractFromErrorClass",
"(",
"err",
",",
"errorMessage",
")",
";",
"}",
"else",
"{",
"handleUnknownAsError",
"(",
"err",
",",
... | Handles routing and validation for parsing an errorMessage that was
flagged as an instance of the Error class. This function does not
discriminate against regular objects, checking only to see if the err
parameter is itself a basic object and has the function property
hasOwnProperty. Given that the input passes this ba... | [
"Handles",
"routing",
"and",
"validation",
"for",
"parsing",
"an",
"errorMessage",
"that",
"was",
"flagged",
"as",
"an",
"instance",
"of",
"the",
"Error",
"class",
".",
"This",
"function",
"does",
"not",
"discriminate",
"against",
"regular",
"objects",
"checking... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/error-handlers/error.js#L35-L44 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/interfaces/hapi.js | hapiErrorHandler | function hapiErrorHandler(req, err, config) {
var service = '';
var version = '';
if (isObject(config)) {
service = config.getServiceContext().service;
version = config.getServiceContext().version;
}
var em = new ErrorMessage()
.consumeRequestInformation(hapiRequestInformationExtracto... | javascript | function hapiErrorHandler(req, err, config) {
var service = '';
var version = '';
if (isObject(config)) {
service = config.getServiceContext().service;
version = config.getServiceContext().version;
}
var em = new ErrorMessage()
.consumeRequestInformation(hapiRequestInformationExtracto... | [
"function",
"hapiErrorHandler",
"(",
"req",
",",
"err",
",",
"config",
")",
"{",
"var",
"service",
"=",
"''",
";",
"var",
"version",
"=",
"''",
";",
"if",
"(",
"isObject",
"(",
"config",
")",
")",
"{",
"service",
"=",
"config",
".",
"getServiceContext"... | The Hapi error handler function serves simply to create an error message
and begin that error message on the path of correct population.
@function hapiErrorHandler
@param {Object} req - The Hapi request object
@param {Any} err - The error input
@param {Object} config - the env configuration
@returns {ErrorMessage} - a ... | [
"The",
"Hapi",
"error",
"handler",
"function",
"serves",
"simply",
"to",
"create",
"an",
"error",
"message",
"and",
"begin",
"that",
"error",
"message",
"on",
"the",
"path",
"of",
"correct",
"population",
"."
] | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/interfaces/hapi.js#L36-L52 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/interfaces/hapi.js | makeHapiPlugin | function makeHapiPlugin(client, config) {
/**
* The register function serves to attach the hapiErrorHandler to specific
* points in the hapi request-response lifecycle. Namely: it attaches to the
* 'request-error' event in Hapi which is emitted when a plugin or receiver
* throws an error while executing ... | javascript | function makeHapiPlugin(client, config) {
/**
* The register function serves to attach the hapiErrorHandler to specific
* points in the hapi request-response lifecycle. Namely: it attaches to the
* 'request-error' event in Hapi which is emitted when a plugin or receiver
* throws an error while executing ... | [
"function",
"makeHapiPlugin",
"(",
"client",
",",
"config",
")",
"{",
"/**\n * The register function serves to attach the hapiErrorHandler to specific\n * points in the hapi request-response lifecycle. Namely: it attaches to the\n * 'request-error' event in Hapi which is emitted when a plugin ... | Creates a Hapi plugin object which can be used to handle errors in Hapi.
@param {AuthClient} client - an inited auth client instance
@param {NormalizedConfigurationVariables} config - the environmental
configuration
@returns {Object} - the actual Hapi plugin | [
"Creates",
"a",
"Hapi",
"plugin",
"object",
"which",
"can",
"be",
"used",
"to",
"handle",
"errors",
"in",
"Hapi",
"."
] | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/interfaces/hapi.js#L62-L122 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/error-extractors/error.js | extractFromErrorClass | function extractFromErrorClass(err, errorMessage) {
errorMessage.setMessage(err.stack);
if (has(err, 'user')) {
errorMessage.setUser(err.user);
}
if (has(err, 'serviceContext') && isObject(err.serviceContext)) {
errorMessage.setServiceContext(err.serviceContext.service,
... | javascript | function extractFromErrorClass(err, errorMessage) {
errorMessage.setMessage(err.stack);
if (has(err, 'user')) {
errorMessage.setUser(err.user);
}
if (has(err, 'serviceContext') && isObject(err.serviceContext)) {
errorMessage.setServiceContext(err.serviceContext.service,
... | [
"function",
"extractFromErrorClass",
"(",
"err",
",",
"errorMessage",
")",
"{",
"errorMessage",
".",
"setMessage",
"(",
"err",
".",
"stack",
")",
";",
"if",
"(",
"has",
"(",
"err",
",",
"'user'",
")",
")",
"{",
"errorMessage",
".",
"setUser",
"(",
"err",... | Extracts error information from an instance of the Error class and marshals
that information into the provided instance of error message. This function
will check before accessing any part of the error for propety presence but
will not check the types of these property values that is instead work that
is allocated to t... | [
"Extracts",
"error",
"information",
"from",
"an",
"instance",
"of",
"the",
"Error",
"class",
"and",
"marshals",
"that",
"information",
"into",
"the",
"provided",
"instance",
"of",
"error",
"message",
".",
"This",
"function",
"will",
"check",
"before",
"accessing... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/error-extractors/error.js#L33-L47 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/classes/error-message.js | ErrorMessage | function ErrorMessage() {
this.eventTime = (new Date()).toISOString();
this.serviceContext = {service : 'node', version : undefined};
this.message = '';
this.context = {
httpRequest : {
method : '',
url : '',
userAgent : '',
referrer : '',
responseStatusCode : 0,
remoteI... | javascript | function ErrorMessage() {
this.eventTime = (new Date()).toISOString();
this.serviceContext = {service : 'node', version : undefined};
this.message = '';
this.context = {
httpRequest : {
method : '',
url : '',
userAgent : '',
referrer : '',
responseStatusCode : 0,
remoteI... | [
"function",
"ErrorMessage",
"(",
")",
"{",
"this",
".",
"eventTime",
"=",
"(",
"new",
"Date",
"(",
")",
")",
".",
"toISOString",
"(",
")",
";",
"this",
".",
"serviceContext",
"=",
"{",
"service",
":",
"'node'",
",",
"version",
":",
"undefined",
"}",
... | The constructor for ErrorMessage takes no arguments and is solely meant to
to instantiate properties on the instance. Each property should be externally
set using the corresponding set function with the exception of eventTime
which can be set externally but does not need to be since it is inited to
an ISO-8601 complian... | [
"The",
"constructor",
"for",
"ErrorMessage",
"takes",
"no",
"arguments",
"and",
"is",
"solely",
"meant",
"to",
"to",
"instantiate",
"properties",
"on",
"the",
"instance",
".",
"Each",
"property",
"should",
"be",
"externally",
"set",
"using",
"the",
"correspondin... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/classes/error-message.js#L67-L84 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/error-handlers/object.js | handleObjectAsError | function handleObjectAsError(err, errorMessage) {
if (isPlainObject(err)) {
extractFromObject(err, errorMessage);
} else {
handleUnknownAsError(err, errorMessage);
}
} | javascript | function handleObjectAsError(err, errorMessage) {
if (isPlainObject(err)) {
extractFromObject(err, errorMessage);
} else {
handleUnknownAsError(err, errorMessage);
}
} | [
"function",
"handleObjectAsError",
"(",
"err",
",",
"errorMessage",
")",
"{",
"if",
"(",
"isPlainObject",
"(",
"err",
")",
")",
"{",
"extractFromObject",
"(",
"err",
",",
"errorMessage",
")",
";",
"}",
"else",
"{",
"handleUnknownAsError",
"(",
"err",
",",
... | Handles routing and validation for parsing an error that has been indicated
to be of type object. If the value submitted for err passes a basic check
for being of type Object than the input will extracted as such, otherwise the
input will be treated as unknown.
@function handleObjectAsError
@param {Object} err - the er... | [
"Handles",
"routing",
"and",
"validation",
"for",
"parsing",
"an",
"error",
"that",
"has",
"been",
"indicated",
"to",
"be",
"of",
"type",
"object",
".",
"If",
"the",
"value",
"submitted",
"for",
"err",
"passes",
"a",
"basic",
"check",
"for",
"being",
"of",... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/error-handlers/object.js#L34-L43 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/error-parsing-utils.js | extractStructuredCallList | function extractStructuredCallList(structuredStackTrace) {
/**
* A function which walks the structuredStackTrace variable of its parent
* and produces a JSON representation of the array of CallSites.
* @function
* @inner
* @returns {String} - A JSON representation of the array of CallSites
*/
re... | javascript | function extractStructuredCallList(structuredStackTrace) {
/**
* A function which walks the structuredStackTrace variable of its parent
* and produces a JSON representation of the array of CallSites.
* @function
* @inner
* @returns {String} - A JSON representation of the array of CallSites
*/
re... | [
"function",
"extractStructuredCallList",
"(",
"structuredStackTrace",
")",
"{",
"/**\n * A function which walks the structuredStackTrace variable of its parent\n * and produces a JSON representation of the array of CallSites.\n * @function\n * @inner\n * @returns {String} - A JSON representati... | A function which returns a closure which itself creates a JSON representation
of an array of callSites generated by an Error stack trace. Since many errors
may be created and only some requiring a string-ification of the entire
callsite list it advantageous from a performance perspective to evaluate
this string-ificati... | [
"A",
"function",
"which",
"returns",
"a",
"closure",
"which",
"itself",
"creates",
"a",
"JSON",
"representation",
"of",
"an",
"array",
"of",
"callSites",
"generated",
"by",
"an",
"Error",
"stack",
"trace",
".",
"Since",
"many",
"errors",
"may",
"be",
"create... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/error-parsing-utils.js#L33-L65 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/error-parsing-utils.js | prepareStackTraceError | function prepareStackTraceError(err, structuredStackTrace) {
var returnObj = new CustomStackTrace();
var topFrame = {};
if (!Array.isArray(structuredStackTrace)) {
return returnObj;
}
// Get the topframe of the CallSite array
topFrame = structuredStackTrace[0];
returnObj.setFilePath(topFrame.getFil... | javascript | function prepareStackTraceError(err, structuredStackTrace) {
var returnObj = new CustomStackTrace();
var topFrame = {};
if (!Array.isArray(structuredStackTrace)) {
return returnObj;
}
// Get the topframe of the CallSite array
topFrame = structuredStackTrace[0];
returnObj.setFilePath(topFrame.getFil... | [
"function",
"prepareStackTraceError",
"(",
"err",
",",
"structuredStackTrace",
")",
"{",
"var",
"returnObj",
"=",
"new",
"CustomStackTrace",
"(",
")",
";",
"var",
"topFrame",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"structuredStackT... | A function which is built to override the Error.prepareStackTraceError
builtin formatter. This substitution produces a object with the last frames
file-path, line number and function name. Additionally a fourth property,
named stringifyStucturedCallList contains a function which can produce the
entirety of the stack tr... | [
"A",
"function",
"which",
"is",
"built",
"to",
"override",
"the",
"Error",
".",
"prepareStackTraceError",
"builtin",
"formatter",
".",
"This",
"substitution",
"produces",
"a",
"object",
"with",
"the",
"last",
"frames",
"file",
"-",
"path",
"line",
"number",
"a... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/error-parsing-utils.js#L78-L96 | train |
IndigoUnited/js-dejavu | dist/regular/strict/dejavu.js | intersection | function intersection(arr) {
var arrs = slice(arguments, 1),
result = filter(unique(arr), function(needle){
return every(arrs, function(haystack){
return contains(haystack, needle);
});
});
return result;
} | javascript | function intersection(arr) {
var arrs = slice(arguments, 1),
result = filter(unique(arr), function(needle){
return every(arrs, function(haystack){
return contains(haystack, needle);
});
});
return result;
} | [
"function",
"intersection",
"(",
"arr",
")",
"{",
"var",
"arrs",
"=",
"slice",
"(",
"arguments",
",",
"1",
")",
",",
"result",
"=",
"filter",
"(",
"unique",
"(",
"arr",
")",
",",
"function",
"(",
"needle",
")",
"{",
"return",
"every",
"(",
"arrs",
... | Return a new Array with elements common to all Arrays.
- based on underscore.js implementation | [
"Return",
"a",
"new",
"Array",
"with",
"elements",
"common",
"to",
"all",
"Arrays",
".",
"-",
"based",
"on",
"underscore",
".",
"js",
"implementation"
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/strict/dejavu.js#L905-L913 | train |
IndigoUnited/js-dejavu | dist/regular/strict/dejavu.js | randomAccessor | function randomAccessor(caller) {
if (nrAccesses > nrAllowed || !contains(allowed, caller)) {
throw new Error('Can\'t access random identifier.');
}
nrAccesses += 1;
return random;
} | javascript | function randomAccessor(caller) {
if (nrAccesses > nrAllowed || !contains(allowed, caller)) {
throw new Error('Can\'t access random identifier.');
}
nrAccesses += 1;
return random;
} | [
"function",
"randomAccessor",
"(",
"caller",
")",
"{",
"if",
"(",
"nrAccesses",
">",
"nrAllowed",
"||",
"!",
"contains",
"(",
"allowed",
",",
"caller",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Can\\'t access random identifier.'",
")",
";",
"}",
"nrAcce... | Provides access to a random string that allows acceess to some hidden properties
used through this library.
@param {Function} caller The function that is trying to access
@return {String} The random string | [
"Provides",
"access",
"to",
"a",
"random",
"string",
"that",
"allows",
"acceess",
"to",
"some",
"hidden",
"properties",
"used",
"through",
"this",
"library",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/strict/dejavu.js#L1445-L1453 | train |
IndigoUnited/js-dejavu | dist/regular/strict/dejavu.js | fetchCache | function fetchCache(target, cache) {
var x,
length = cache.length,
curr;
for (x = 0; x < length; x += 1) {
curr = cache[x];
if (curr.target === target) {
return curr.inspect;
}
}
return null;
} | javascript | function fetchCache(target, cache) {
var x,
length = cache.length,
curr;
for (x = 0; x < length; x += 1) {
curr = cache[x];
if (curr.target === target) {
return curr.inspect;
}
}
return null;
} | [
"function",
"fetchCache",
"(",
"target",
",",
"cache",
")",
"{",
"var",
"x",
",",
"length",
"=",
"cache",
".",
"length",
",",
"curr",
";",
"for",
"(",
"x",
"=",
"0",
";",
"x",
"<",
"length",
";",
"x",
"+=",
"1",
")",
"{",
"curr",
"=",
"cache",
... | Fetches an already inspected target from the cache.
Returns null if not in the cache.
@param {Object|Function} target The instance or constructor.
@param {Array} cache The cache
@return {Object|Function} The inspected target | [
"Fetches",
"an",
"already",
"inspected",
"target",
"from",
"the",
"cache",
".",
"Returns",
"null",
"if",
"not",
"in",
"the",
"cache",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/strict/dejavu.js#L1578-L1591 | train |
IndigoUnited/js-dejavu | dist/regular/strict/dejavu.js | inspectInstance | function inspectInstance(target, cache) {
// If browser has no define property it means it is too old and
// in that case we return the target itself.
// This could be improved but I think it does not worth the trouble
if (!hasDefineProperty) {
return target;
}
... | javascript | function inspectInstance(target, cache) {
// If browser has no define property it means it is too old and
// in that case we return the target itself.
// This could be improved but I think it does not worth the trouble
if (!hasDefineProperty) {
return target;
}
... | [
"function",
"inspectInstance",
"(",
"target",
",",
"cache",
")",
"{",
"// If browser has no define property it means it is too old and",
"// in that case we return the target itself.",
"// This could be improved but I think it does not worth the trouble",
"if",
"(",
"!",
"hasDefineProper... | Inspects an instance.
@param {Object} target The instance
@param {Array} cache The cache
@return {Object} The inspected instance | [
"Inspects",
"an",
"instance",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/strict/dejavu.js#L1601-L1658 | train |
IndigoUnited/js-dejavu | dist/regular/strict/dejavu.js | inspectConstructor | function inspectConstructor(target, cache) {
// If browser has no define property it means it is too old and
// in that case we return the target itself.
// This could be improved but I think it does not worth the trouble
if (!hasDefineProperty) {
return target;
}
... | javascript | function inspectConstructor(target, cache) {
// If browser has no define property it means it is too old and
// in that case we return the target itself.
// This could be improved but I think it does not worth the trouble
if (!hasDefineProperty) {
return target;
}
... | [
"function",
"inspectConstructor",
"(",
"target",
",",
"cache",
")",
"{",
"// If browser has no define property it means it is too old and",
"// in that case we return the target itself.",
"// This could be improved but I think it does not worth the trouble",
"if",
"(",
"!",
"hasDefinePro... | Inspects an constructor.
@param {Function} target The constructor
@return {Object} The inspected constructor | [
"Inspects",
"an",
"constructor",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/strict/dejavu.js#L1667-L1736 | train |
IndigoUnited/js-dejavu | dist/regular/strict/dejavu.js | protectInstance | function protectInstance(instance) {
var key;
obfuscateProperty(instance, cacheKeyword, { properties: {}, methods: {} });
obfuscateProperty(instance, redefinedCacheKeyword, { properties: {}, methods: {} }); // This is for the inspect
for (key in instance.$static[$class].methods) {
... | javascript | function protectInstance(instance) {
var key;
obfuscateProperty(instance, cacheKeyword, { properties: {}, methods: {} });
obfuscateProperty(instance, redefinedCacheKeyword, { properties: {}, methods: {} }); // This is for the inspect
for (key in instance.$static[$class].methods) {
... | [
"function",
"protectInstance",
"(",
"instance",
")",
"{",
"var",
"key",
";",
"obfuscateProperty",
"(",
"instance",
",",
"cacheKeyword",
",",
"{",
"properties",
":",
"{",
"}",
",",
"methods",
":",
"{",
"}",
"}",
")",
";",
"obfuscateProperty",
"(",
"instance... | Protects an instance.
All its methods and properties will be secured according to their visibility.
@param {Object} instance The instance to be protected | [
"Protects",
"an",
"instance",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/strict/dejavu.js#L3384-L3397 | train |
IndigoUnited/js-dejavu | dist/regular/strict/dejavu.js | protectConstructor | function protectConstructor(constructor) {
var key,
target,
meta,
prototype = constructor.prototype;
obfuscateProperty(constructor, cacheKeyword, { properties: {}, methods: {} });
for (key in constructor[$class].staticMethods) {
protectStaticMeth... | javascript | function protectConstructor(constructor) {
var key,
target,
meta,
prototype = constructor.prototype;
obfuscateProperty(constructor, cacheKeyword, { properties: {}, methods: {} });
for (key in constructor[$class].staticMethods) {
protectStaticMeth... | [
"function",
"protectConstructor",
"(",
"constructor",
")",
"{",
"var",
"key",
",",
"target",
",",
"meta",
",",
"prototype",
"=",
"constructor",
".",
"prototype",
";",
"obfuscateProperty",
"(",
"constructor",
",",
"cacheKeyword",
",",
"{",
"properties",
":",
"{... | Protects a constructor.
All its methods and properties will be secured according to their visibility.
@param {Function} constructor The constructor to be protected | [
"Protects",
"a",
"constructor",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/strict/dejavu.js#L3406-L3427 | train |
IndigoUnited/js-dejavu | dist/regular/strict/dejavu.js | parseAbstracts | function parseAbstracts(abstracts, constructor) {
var optsStatic = { isStatic: true },
key,
value,
unallowed;
// Check argument
if (!isObject(abstracts)) {
throw new Error('$abstracts defined in abstract class "' + constructor.prototype.$name + '"... | javascript | function parseAbstracts(abstracts, constructor) {
var optsStatic = { isStatic: true },
key,
value,
unallowed;
// Check argument
if (!isObject(abstracts)) {
throw new Error('$abstracts defined in abstract class "' + constructor.prototype.$name + '"... | [
"function",
"parseAbstracts",
"(",
"abstracts",
",",
"constructor",
")",
"{",
"var",
"optsStatic",
"=",
"{",
"isStatic",
":",
"true",
"}",
",",
"key",
",",
"value",
",",
"unallowed",
";",
"// Check argument",
"if",
"(",
"!",
"isObject",
"(",
"abstracts",
"... | Parse abstract methods.
@param {Object} abstracts The object that contains the abstract methods
@param {Function} constructor The constructor | [
"Parse",
"abstract",
"methods",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/strict/dejavu.js#L4164-L4223 | train |
IndigoUnited/js-dejavu | dist/regular/strict/dejavu.js | parseInterfaces | function parseInterfaces(interfaces, constructor) {
var interfs = toArray(interfaces),
x = interfs.length,
interf,
key,
value;
for (x -= 1; x >= 0; x -= 1) {
interf = interfs[x];
// Grab methods
for (key in interf[$int... | javascript | function parseInterfaces(interfaces, constructor) {
var interfs = toArray(interfaces),
x = interfs.length,
interf,
key,
value;
for (x -= 1; x >= 0; x -= 1) {
interf = interfs[x];
// Grab methods
for (key in interf[$int... | [
"function",
"parseInterfaces",
"(",
"interfaces",
",",
"constructor",
")",
"{",
"var",
"interfs",
"=",
"toArray",
"(",
"interfaces",
")",
",",
"x",
"=",
"interfs",
".",
"length",
",",
"interf",
",",
"key",
",",
"value",
";",
"for",
"(",
"x",
"-=",
"1",... | Parse interfaces.
@param {Array} interfaces The interfaces
@param {Function} constructor The constructor | [
"Parse",
"interfaces",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/strict/dejavu.js#L4231-L4271 | train |
IndigoUnited/js-dejavu | dist/regular/strict/dejavu.js | createFinalClass | function createFinalClass(params, constructor) {
var def = Class.$create(params, constructor);
def[$class].finalClass = true;
return def;
} | javascript | function createFinalClass(params, constructor) {
var def = Class.$create(params, constructor);
def[$class].finalClass = true;
return def;
} | [
"function",
"createFinalClass",
"(",
"params",
",",
"constructor",
")",
"{",
"var",
"def",
"=",
"Class",
".",
"$create",
"(",
"params",
",",
"constructor",
")",
";",
"def",
"[",
"$class",
"]",
".",
"finalClass",
"=",
"true",
";",
"return",
"def",
";",
... | Create a final class definition.
@param {Object} params An object containing methods and properties
@param {Constructor} [constructor] Assume the passed constructor
@return {Function} The constructor | [
"Create",
"a",
"final",
"class",
"definition",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/regular/strict/dejavu.js#L4828-L4833 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/interfaces/express.js | makeExpressHandler | function makeExpressHandler(client, config) {
/**
* The Express Error Handler function is an interface for the error handler
* stack into the Express architecture.
* @function expressErrorHandler
* @param {Any} err - a error of some type propagated by the express plugin
* stack
* @param {Object} re... | javascript | function makeExpressHandler(client, config) {
/**
* The Express Error Handler function is an interface for the error handler
* stack into the Express architecture.
* @function expressErrorHandler
* @param {Any} err - a error of some type propagated by the express plugin
* stack
* @param {Object} re... | [
"function",
"makeExpressHandler",
"(",
"client",
",",
"config",
")",
"{",
"/**\n * The Express Error Handler function is an interface for the error handler\n * stack into the Express architecture.\n * @function expressErrorHandler\n * @param {Any} err - a error of some type propagated by the... | Returns a function that can be used as an express error handling middleware.
@function makeExpressHandler
@param {AuthClient} client - an inited Auth Client instance
@param {NormalizedConfigurationVariables} config - the environmental
configuration
@returns {expressErrorHandler} - a function that can be used as an exp... | [
"Returns",
"a",
"function",
"that",
"can",
"be",
"used",
"as",
"an",
"express",
"error",
"handling",
"middleware",
"."
] | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/interfaces/express.js#L35-L75 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/request-extractors/manual.js | manualRequestInformationExtractor | function manualRequestInformationExtractor(req) {
var returnObject = new RequestInformationContainer();
if (!isObject(req) || isArray(req) || isFunction(req)) {
return returnObject;
}
if (has(req, 'method')) {
returnObject.setMethod(req.method);
}
if (has(req, 'url')) {
returnObject.setUr... | javascript | function manualRequestInformationExtractor(req) {
var returnObject = new RequestInformationContainer();
if (!isObject(req) || isArray(req) || isFunction(req)) {
return returnObject;
}
if (has(req, 'method')) {
returnObject.setMethod(req.method);
}
if (has(req, 'url')) {
returnObject.setUr... | [
"function",
"manualRequestInformationExtractor",
"(",
"req",
")",
"{",
"var",
"returnObject",
"=",
"new",
"RequestInformationContainer",
"(",
")",
";",
"if",
"(",
"!",
"isObject",
"(",
"req",
")",
"||",
"isArray",
"(",
"req",
")",
"||",
"isFunction",
"(",
"r... | The manualRequestInformationExtractor is meant to take a standard object
and extract request information based on the inclusion of several properties.
This function will check the presence of properties before attempting to
access them on the object but it will not attempt to check for these
properties types as this is... | [
"The",
"manualRequestInformationExtractor",
"is",
"meant",
"to",
"take",
"a",
"standard",
"object",
"and",
"extract",
"request",
"information",
"based",
"on",
"the",
"inclusion",
"of",
"several",
"properties",
".",
"This",
"function",
"will",
"check",
"the",
"pres... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/request-extractors/manual.js#L43-L83 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/configuration.js | function(givenConfig, logger) {
/**
* The _logger property caches the logger instance created at the top-level
* for configuration logging purposes.
* @memberof Configuration
* @private
* @type {Object}
* @defaultvalue Object
*/
this._logger = logger;
/**
* The _reportUncaughtExceptions pr... | javascript | function(givenConfig, logger) {
/**
* The _logger property caches the logger instance created at the top-level
* for configuration logging purposes.
* @memberof Configuration
* @private
* @type {Object}
* @defaultvalue Object
*/
this._logger = logger;
/**
* The _reportUncaughtExceptions pr... | [
"function",
"(",
"givenConfig",
",",
"logger",
")",
"{",
"/**\n * The _logger property caches the logger instance created at the top-level\n * for configuration logging purposes.\n * @memberof Configuration\n * @private\n * @type {Object}\n * @defaultvalue Object\n */",
"this",
".",
... | The Configuration constructor function initializes several internal
properties on the Configuration instance and accepts a runtime-given
configuration object which may be used by the Configuration instance
depending on the initialization transaction that occurs with the meta-data
service.
@class Configuration
@classdes... | [
"The",
"Configuration",
"constructor",
"function",
"initializes",
"several",
"internal",
"properties",
"on",
"the",
"Configuration",
"instance",
"and",
"accepts",
"a",
"runtime",
"-",
"given",
"configuration",
"object",
"which",
"may",
"be",
"used",
"by",
"the",
"... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/configuration.js#L52-L177 | train | |
GoogleCloudPlatform/cloud-errors-nodejs | lib/interfaces/restify.js | restifyErrorHandler | function restifyErrorHandler(client, config, err, em) {
var svc = config.getServiceContext();
em.setServiceContext(svc.service, svc.version);
errorHandlerRouter(err, em);
client.sendError(em);
} | javascript | function restifyErrorHandler(client, config, err, em) {
var svc = config.getServiceContext();
em.setServiceContext(svc.service, svc.version);
errorHandlerRouter(err, em);
client.sendError(em);
} | [
"function",
"restifyErrorHandler",
"(",
"client",
",",
"config",
",",
"err",
",",
"em",
")",
"{",
"var",
"svc",
"=",
"config",
".",
"getServiceContext",
"(",
")",
";",
"em",
".",
"setServiceContext",
"(",
"svc",
".",
"service",
",",
"svc",
".",
"version"... | The restifyErrorHandler is responsible for taking the captured error, setting
the serviceContext property on the corresponding ErrorMessage instance,
routing the captured error to the right handler so that it can be correctly
marshaled into the ErrorMessage instance and then attempting to send it to
the Stackdriver API... | [
"The",
"restifyErrorHandler",
"is",
"responsible",
"for",
"taking",
"the",
"captured",
"error",
"setting",
"the",
"serviceContext",
"property",
"on",
"the",
"corresponding",
"ErrorMessage",
"instance",
"routing",
"the",
"captured",
"error",
"to",
"the",
"right",
"ha... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/interfaces/restify.js#L40-L47 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/interfaces/restify.js | restifyRequestFinishHandler | function restifyRequestFinishHandler(client, config, req, res) {
var em;
if (res._body instanceof Error ||
res.statusCode > 309 && res.statusCode < 512) {
em = new ErrorMessage().consumeRequestInformation(
expressRequestInformationExtractor(req, res));
restifyErrorHandler(client, config, res... | javascript | function restifyRequestFinishHandler(client, config, req, res) {
var em;
if (res._body instanceof Error ||
res.statusCode > 309 && res.statusCode < 512) {
em = new ErrorMessage().consumeRequestInformation(
expressRequestInformationExtractor(req, res));
restifyErrorHandler(client, config, res... | [
"function",
"restifyRequestFinishHandler",
"(",
"client",
",",
"config",
",",
"req",
",",
"res",
")",
"{",
"var",
"em",
";",
"if",
"(",
"res",
".",
"_body",
"instanceof",
"Error",
"||",
"res",
".",
"statusCode",
">",
"309",
"&&",
"res",
".",
"statusCode"... | The restifyRequestFinishHandler will be called once the response has emitted
the `finish` event and is now in its finalized state. This function will
attempt to determine whether or not the body of response is an instance of
the Error class or its status codes indicate that the response ended in an
error state. If eith... | [
"The",
"restifyRequestFinishHandler",
"will",
"be",
"called",
"once",
"the",
"response",
"has",
"emitted",
"the",
"finish",
"event",
"and",
"is",
"now",
"in",
"its",
"finalized",
"state",
".",
"This",
"function",
"will",
"attempt",
"to",
"determine",
"whether",
... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/interfaces/restify.js#L64-L74 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/interfaces/restify.js | restifyRequestHandler | function restifyRequestHandler(client, config, req, res, next) {
var listener = {};
if (isObject(res) && isFunction(res.on) && isFunction(res.removeListener)) {
listener = function() {
restifyRequestFinishHandler(client, config, req, res);
res.removeListener('finish', listener);
};
res.o... | javascript | function restifyRequestHandler(client, config, req, res, next) {
var listener = {};
if (isObject(res) && isFunction(res.on) && isFunction(res.removeListener)) {
listener = function() {
restifyRequestFinishHandler(client, config, req, res);
res.removeListener('finish', listener);
};
res.o... | [
"function",
"restifyRequestHandler",
"(",
"client",
",",
"config",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"listener",
"=",
"{",
"}",
";",
"if",
"(",
"isObject",
"(",
"res",
")",
"&&",
"isFunction",
"(",
"res",
".",
"on",
")",
"&&",
"... | The restifyRequestHandler attaches the restifyRequestFinishHandler to each
responses 'finish' event wherein the callback function will determine
whether or not the response is an error response or not. The finish event is
used since the restify response object will not have any error information
contained within it unt... | [
"The",
"restifyRequestHandler",
"attaches",
"the",
"restifyRequestFinishHandler",
"to",
"each",
"responses",
"finish",
"event",
"wherein",
"the",
"callback",
"function",
"will",
"determine",
"whether",
"or",
"not",
"the",
"response",
"is",
"an",
"error",
"response",
... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/interfaces/restify.js#L94-L109 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/request-extractors/express.js | extractRemoteAddressFromRequest | function extractRemoteAddressFromRequest(req) {
if (typeof req.header('x-forwarded-for') !== 'undefined') {
return req.header('x-forwarded-for');
} else if (isObject(req.connection)) {
return req.connection.remoteAddress;
}
return '';
} | javascript | function extractRemoteAddressFromRequest(req) {
if (typeof req.header('x-forwarded-for') !== 'undefined') {
return req.header('x-forwarded-for');
} else if (isObject(req.connection)) {
return req.connection.remoteAddress;
}
return '';
} | [
"function",
"extractRemoteAddressFromRequest",
"(",
"req",
")",
"{",
"if",
"(",
"typeof",
"req",
".",
"header",
"(",
"'x-forwarded-for'",
")",
"!==",
"'undefined'",
")",
"{",
"return",
"req",
".",
"header",
"(",
"'x-forwarded-for'",
")",
";",
"}",
"else",
"i... | This function checks for the presence of an `x-forwarded-for` header on the
request to check for remote address forwards, if that is header is not
present in the request then the function will attempt to extract the remote
address from the express request object.
@function extractRemoteAddressFromRequest
@param {Object... | [
"This",
"function",
"checks",
"for",
"the",
"presence",
"of",
"an",
"x",
"-",
"forwarded",
"-",
"for",
"header",
"on",
"the",
"request",
"to",
"check",
"for",
"remote",
"address",
"forwards",
"if",
"that",
"is",
"header",
"is",
"not",
"present",
"in",
"t... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/request-extractors/express.js#L33-L44 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/request-extractors/express.js | expressRequestInformationExtractor | function expressRequestInformationExtractor(req, res) {
var returnObject = new RequestInformationContainer();
if (!isObject(req) || !isFunction(req.header) || !isObject(res)) {
return returnObject;
}
returnObject.setMethod(req.method)
.setUrl(req.url)
.setUserAgent(req.header('user-agent'))
... | javascript | function expressRequestInformationExtractor(req, res) {
var returnObject = new RequestInformationContainer();
if (!isObject(req) || !isFunction(req.header) || !isObject(res)) {
return returnObject;
}
returnObject.setMethod(req.method)
.setUrl(req.url)
.setUserAgent(req.header('user-agent'))
... | [
"function",
"expressRequestInformationExtractor",
"(",
"req",
",",
"res",
")",
"{",
"var",
"returnObject",
"=",
"new",
"RequestInformationContainer",
"(",
")",
";",
"if",
"(",
"!",
"isObject",
"(",
"req",
")",
"||",
"!",
"isFunction",
"(",
"req",
".",
"heade... | The expressRequestInformationExtractor is a function which is made to extract
request information from a express request object. This function will do a
basic check for type and method presence but will not check for the presence
of properties on the request object.
@function expressRequestInformationExtractor
@param {... | [
"The",
"expressRequestInformationExtractor",
"is",
"a",
"function",
"which",
"is",
"made",
"to",
"extract",
"request",
"information",
"from",
"a",
"express",
"request",
"object",
".",
"This",
"function",
"will",
"do",
"a",
"basic",
"check",
"for",
"type",
"and",... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/request-extractors/express.js#L57-L74 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/error-handlers/number.js | handleNumberAsError | function handleNumberAsError(err, errorMessage) {
var fauxError = new Error();
var errChecked = fauxError.stack;
if (isNumber(err) && isFunction(err.toString)) {
errChecked = err.toString();
}
errorMessage.setMessage(errChecked);
} | javascript | function handleNumberAsError(err, errorMessage) {
var fauxError = new Error();
var errChecked = fauxError.stack;
if (isNumber(err) && isFunction(err.toString)) {
errChecked = err.toString();
}
errorMessage.setMessage(errChecked);
} | [
"function",
"handleNumberAsError",
"(",
"err",
",",
"errorMessage",
")",
"{",
"var",
"fauxError",
"=",
"new",
"Error",
"(",
")",
";",
"var",
"errChecked",
"=",
"fauxError",
".",
"stack",
";",
"if",
"(",
"isNumber",
"(",
"err",
")",
"&&",
"isFunction",
"(... | Handles routing and validation for parsing an error which has been indicated
to be of type Number. This handler will manufacture a new Error to create
a stack-trace for submission to the Error API and will attempt to caste the
given number to a string for submission to the Error API.
@function handleNumberAsError
@para... | [
"Handles",
"routing",
"and",
"validation",
"for",
"parsing",
"an",
"error",
"which",
"has",
"been",
"indicated",
"to",
"be",
"of",
"type",
"Number",
".",
"This",
"handler",
"will",
"manufacture",
"a",
"new",
"Error",
"to",
"create",
"a",
"stack",
"-",
"tra... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/error-handlers/number.js#L33-L43 | train |
mattkrick/fast-bitset | app/BitSet.js | _msb | function _msb(word) {
word |= word >> 1;
word |= word >> 2;
word |= word >> 4;
word |= word >> 8;
word |= word >> 16;
word = (word >> 1) + 1;
return multiplyDeBruijnBitPosition[(word * 0x077CB531) >>> 27];
} | javascript | function _msb(word) {
word |= word >> 1;
word |= word >> 2;
word |= word >> 4;
word |= word >> 8;
word |= word >> 16;
word = (word >> 1) + 1;
return multiplyDeBruijnBitPosition[(word * 0x077CB531) >>> 27];
} | [
"function",
"_msb",
"(",
"word",
")",
"{",
"word",
"|=",
"word",
">>",
"1",
";",
"word",
"|=",
"word",
">>",
"2",
";",
"word",
"|=",
"word",
">>",
"4",
";",
"word",
"|=",
"word",
">>",
"8",
";",
"word",
"|=",
"word",
">>",
"16",
";",
"word",
... | Returns the least signifcant bit, or 0 if none set, so a prior check to see if the word > 0 is required
@param word the current array
@returns {number} the index of the most significant bit in the current array
@private | [
"Returns",
"the",
"least",
"signifcant",
"bit",
"or",
"0",
"if",
"none",
"set",
"so",
"a",
"prior",
"check",
"to",
"see",
"if",
"the",
"word",
">",
"0",
"is",
"required"
] | 14c7510ab4ebe1a4f8576b9c5d266f6e8a72a615 | https://github.com/mattkrick/fast-bitset/blob/14c7510ab4ebe1a4f8576b9c5d266f6e8a72a615/app/BitSet.js#L577-L585 | train |
IndigoUnited/js-dejavu | dist/node/strict/Class.js | doMember | function doMember(func) {
/*jshint validthis:true*/
func = func || this;
// Check if it is a named func already
if (func[$name]) {
return func;
}
var caller = process._dejavu.caller;
// Check if outside the instance/class
if (!caller) {
... | javascript | function doMember(func) {
/*jshint validthis:true*/
func = func || this;
// Check if it is a named func already
if (func[$name]) {
return func;
}
var caller = process._dejavu.caller;
// Check if outside the instance/class
if (!caller) {
... | [
"function",
"doMember",
"(",
"func",
")",
"{",
"/*jshint validthis:true*/",
"func",
"=",
"func",
"||",
"this",
";",
"// Check if it is a named func already",
"if",
"(",
"func",
"[",
"$name",
"]",
")",
"{",
"return",
"func",
";",
"}",
"var",
"caller",
"=",
"p... | Marks a function as part of the class.
@param {Function} func The function | [
"Marks",
"a",
"function",
"as",
"part",
"of",
"the",
"class",
"."
] | b251d5e8508bb05854081968528e6a3b2ec68d33 | https://github.com/IndigoUnited/js-dejavu/blob/b251d5e8508bb05854081968528e6a3b2ec68d33/dist/node/strict/Class.js#L1347-L1373 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/error-router.js | errorHandlerRouter | function errorHandlerRouter(err, em) {
if (err instanceof Error) {
handleErrorClassError(err, em);
return;
}
switch (typeof err) {
case 'object':
handleObjectAsError(err, em);
break;
case 'string':
handleStringAsError(err, em);
break;
case 'number':
handleNumberAsError(err... | javascript | function errorHandlerRouter(err, em) {
if (err instanceof Error) {
handleErrorClassError(err, em);
return;
}
switch (typeof err) {
case 'object':
handleObjectAsError(err, em);
break;
case 'string':
handleStringAsError(err, em);
break;
case 'number':
handleNumberAsError(err... | [
"function",
"errorHandlerRouter",
"(",
"err",
",",
"em",
")",
"{",
"if",
"(",
"err",
"instanceof",
"Error",
")",
"{",
"handleErrorClassError",
"(",
"err",
",",
"em",
")",
";",
"return",
";",
"}",
"switch",
"(",
"typeof",
"err",
")",
"{",
"case",
"'obje... | The Error handler router is responsible for taking an error of some type and
and Error message container, analyzing the type of the error and routing it
to the proper handler so that the error information can be marshaled into the
the error message container.
@function errorHandlerRouter
@param {Any} err - the error in... | [
"The",
"Error",
"handler",
"router",
"is",
"responsible",
"for",
"taking",
"an",
"error",
"of",
"some",
"type",
"and",
"and",
"Error",
"message",
"container",
"analyzing",
"the",
"type",
"of",
"the",
"error",
"and",
"routing",
"it",
"to",
"the",
"proper",
... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/error-router.js#L35-L61 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/error-handlers/string.js | handleStringAsError | function handleStringAsError(err, errorMessage) {
var fauxError = new Error();
var fullStack = fauxError.stack.split('\n');
var cleanedStack = fullStack.slice(0, 1).concat(fullStack.slice(4));
var errChecked = '';
if (isString(err)) {
// Replace the generic error message with the user-provided string
... | javascript | function handleStringAsError(err, errorMessage) {
var fauxError = new Error();
var fullStack = fauxError.stack.split('\n');
var cleanedStack = fullStack.slice(0, 1).concat(fullStack.slice(4));
var errChecked = '';
if (isString(err)) {
// Replace the generic error message with the user-provided string
... | [
"function",
"handleStringAsError",
"(",
"err",
",",
"errorMessage",
")",
"{",
"var",
"fauxError",
"=",
"new",
"Error",
"(",
")",
";",
"var",
"fullStack",
"=",
"fauxError",
".",
"stack",
".",
"split",
"(",
"'\\n'",
")",
";",
"var",
"cleanedStack",
"=",
"f... | Handles validation of an error which has been indicated to be of type String.
This function will create a new instance of the Error class to produce a
stack trace for submission to the API and check to confirm that the given
value is of type string.
@function handleStringAsError
@param {String} err - the String indicat... | [
"Handles",
"validation",
"of",
"an",
"error",
"which",
"has",
"been",
"indicated",
"to",
"be",
"of",
"type",
"String",
".",
"This",
"function",
"will",
"create",
"a",
"new",
"instance",
"of",
"the",
"Error",
"class",
"to",
"produce",
"a",
"stack",
"trace",... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/error-handlers/string.js#L31-L45 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/google-apis/auth-client.js | RequestHandler | function RequestHandler(config, logger) {
this._request = commonDiag.utils.authorizedRequestFactory(SCOPES, {
keyFile: config.getKeyFilename(),
credentials: config.getCredentials()
});
this._config = config;
this._logger = logger;
} | javascript | function RequestHandler(config, logger) {
this._request = commonDiag.utils.authorizedRequestFactory(SCOPES, {
keyFile: config.getKeyFilename(),
credentials: config.getCredentials()
});
this._config = config;
this._logger = logger;
} | [
"function",
"RequestHandler",
"(",
"config",
",",
"logger",
")",
"{",
"this",
".",
"_request",
"=",
"commonDiag",
".",
"utils",
".",
"authorizedRequestFactory",
"(",
"SCOPES",
",",
"{",
"keyFile",
":",
"config",
".",
"getKeyFilename",
"(",
")",
",",
"credent... | The RequestHandler constructor initializes several properties on the
RequestHandler instance and create a new request factory for requesting
against the Error Reporting API.
@param {Configuration} config - The configuration instance
@param {Object} logger - the logger instance
@class RequestHandler
@classdesc The Reque... | [
"The",
"RequestHandler",
"constructor",
"initializes",
"several",
"properties",
"on",
"the",
"RequestHandler",
"instance",
"and",
"create",
"a",
"new",
"request",
"factory",
"for",
"requesting",
"against",
"the",
"Error",
"Reporting",
"API",
"."
] | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/google-apis/auth-client.js#L55-L62 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/google-apis/auth-client.js | getErrorReportURL | function getErrorReportURL(projectId, key) {
var url = [API, projectId, 'events:report'].join('/');
if (isString(key)) {
url += '?key=' + key;
}
return url;
} | javascript | function getErrorReportURL(projectId, key) {
var url = [API, projectId, 'events:report'].join('/');
if (isString(key)) {
url += '?key=' + key;
}
return url;
} | [
"function",
"getErrorReportURL",
"(",
"projectId",
",",
"key",
")",
"{",
"var",
"url",
"=",
"[",
"API",
",",
"projectId",
",",
"'events:report'",
"]",
".",
"join",
"(",
"'/'",
")",
";",
"if",
"(",
"isString",
"(",
"key",
")",
")",
"{",
"url",
"+=",
... | Compute the URL that errors should be reported to given the projectId and
optional key.
@param {String} projectId - the project id of the application.
@param {String|Null} [key] - the API key used to authenticate against the
service in place of application default credentials.
@returns {String} computed URL that the er... | [
"Compute",
"the",
"URL",
"that",
"errors",
"should",
"be",
"reported",
"to",
"given",
"the",
"projectId",
"and",
"optional",
"key",
"."
] | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/google-apis/auth-client.js#L73-L79 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/interfaces/uncaught.js | handlerSetup | function handlerSetup(client, config) {
/**
* The actual exception handler creates a new instance of `ErrorMessage`,
* extracts infomation from the propagated `Error` and marshals it into the
* `ErrorMessage` instance, attempts to send this `ErrorMessage` instance to
* the Stackdriver Error Reporting API.... | javascript | function handlerSetup(client, config) {
/**
* The actual exception handler creates a new instance of `ErrorMessage`,
* extracts infomation from the propagated `Error` and marshals it into the
* `ErrorMessage` instance, attempts to send this `ErrorMessage` instance to
* the Stackdriver Error Reporting API.... | [
"function",
"handlerSetup",
"(",
"client",
",",
"config",
")",
"{",
"/**\n * The actual exception handler creates a new instance of `ErrorMessage`,\n * extracts infomation from the propagated `Error` and marshals it into the\n * `ErrorMessage` instance, attempts to send this `ErrorMessage` ins... | If the configuraiton allows, install an uncaught exception handler that will
report the uncaught error to the API and then terminate the process.
@function handlerSetup
@param {AuthClient} client - the API client for communication with the
Stackdriver Error API
@param {Configuration} config - the init configuration
@re... | [
"If",
"the",
"configuraiton",
"allows",
"install",
"an",
"uncaught",
"exception",
"handler",
"that",
"will",
"report",
"the",
"uncaught",
"error",
"to",
"the",
"API",
"and",
"then",
"terminate",
"the",
"process",
"."
] | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/interfaces/uncaught.js#L40-L66 | train |
GoogleCloudPlatform/cloud-errors-nodejs | lib/interfaces/uncaught.js | uncaughtExceptionHandler | function uncaughtExceptionHandler(err) {
var em = new ErrorMessage();
errorHandlerRouter(err, em);
client.sendError(em, handleProcessExit);
setTimeout(handleProcessExit, 2000);
} | javascript | function uncaughtExceptionHandler(err) {
var em = new ErrorMessage();
errorHandlerRouter(err, em);
client.sendError(em, handleProcessExit);
setTimeout(handleProcessExit, 2000);
} | [
"function",
"uncaughtExceptionHandler",
"(",
"err",
")",
"{",
"var",
"em",
"=",
"new",
"ErrorMessage",
"(",
")",
";",
"errorHandlerRouter",
"(",
"err",
",",
"em",
")",
";",
"client",
".",
"sendError",
"(",
"em",
",",
"handleProcessExit",
")",
";",
"setTime... | The actual exception handler creates a new instance of `ErrorMessage`,
extracts infomation from the propagated `Error` and marshals it into the
`ErrorMessage` instance, attempts to send this `ErrorMessage` instance to
the Stackdriver Error Reporting API. Subsequently the process is
terminated.
@function uncaughtExcepti... | [
"The",
"actual",
"exception",
"handler",
"creates",
"a",
"new",
"instance",
"of",
"ErrorMessage",
"extracts",
"infomation",
"from",
"the",
"propagated",
"Error",
"and",
"marshals",
"it",
"into",
"the",
"ErrorMessage",
"instance",
"attempts",
"to",
"send",
"this",
... | fda2218759cd8754a096dbe437e8a668321f5ba6 | https://github.com/GoogleCloudPlatform/cloud-errors-nodejs/blob/fda2218759cd8754a096dbe437e8a668321f5ba6/lib/interfaces/uncaught.js#L52-L58 | train |
tiaanduplessis/react-native-modest-storage | src/index.js | get | function get (key, def) {
if (Array.isArray(key)) {
return AsyncStorage.multiGet(key)
.then((values) => values.map(([_, value]) => {
return useDefault(def, value) ? def : parse(value)
}))
.then(results => Promise.all(results))
}
return AsyncStorage.getItem(key).then(value => useDefa... | javascript | function get (key, def) {
if (Array.isArray(key)) {
return AsyncStorage.multiGet(key)
.then((values) => values.map(([_, value]) => {
return useDefault(def, value) ? def : parse(value)
}))
.then(results => Promise.all(results))
}
return AsyncStorage.getItem(key).then(value => useDefa... | [
"function",
"get",
"(",
"key",
",",
"def",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"key",
")",
")",
"{",
"return",
"AsyncStorage",
".",
"multiGet",
"(",
"key",
")",
".",
"then",
"(",
"(",
"values",
")",
"=>",
"values",
".",
"map",
"(",... | Retreive value from AsyncStorage based on key.
Wrapper around getItem & multiGet.
@param {String, Array} key Key to lookup
@param {Any} def Default value
@returns {Promise} value of key
@example
storage.get('foo').then(console.log).catch(console.error) | [
"Retreive",
"value",
"from",
"AsyncStorage",
"based",
"on",
"key",
".",
"Wrapper",
"around",
"getItem",
"&",
"multiGet",
"."
] | 95e21cba4f917b27d198fbed0ef9676790163cd9 | https://github.com/tiaanduplessis/react-native-modest-storage/blob/95e21cba4f917b27d198fbed0ef9676790163cd9/src/index.js#L34-L44 | train |
tiaanduplessis/react-native-modest-storage | src/index.js | set | function set (key, value) {
if (Array.isArray(key)) {
const items = key.map(([key, value]) => [key, JSON.stringify(value)])
return AsyncStorage.multiSet(items)
}
return AsyncStorage.setItem(key, JSON.stringify(value))
} | javascript | function set (key, value) {
if (Array.isArray(key)) {
const items = key.map(([key, value]) => [key, JSON.stringify(value)])
return AsyncStorage.multiSet(items)
}
return AsyncStorage.setItem(key, JSON.stringify(value))
} | [
"function",
"set",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"key",
")",
")",
"{",
"const",
"items",
"=",
"key",
".",
"map",
"(",
"(",
"[",
"key",
",",
"value",
"]",
")",
"=>",
"[",
"key",
",",
"JSON",
".",
... | Persist a value to AsyncStorage.
Wrapper around setItem & multiSet.
@param {String, Array} key for value
@param {Any} value to persist
@returns {Promise} | [
"Persist",
"a",
"value",
"to",
"AsyncStorage",
".",
"Wrapper",
"around",
"setItem",
"&",
"multiSet",
"."
] | 95e21cba4f917b27d198fbed0ef9676790163cd9 | https://github.com/tiaanduplessis/react-native-modest-storage/blob/95e21cba4f917b27d198fbed0ef9676790163cd9/src/index.js#L53-L60 | train |
tiaanduplessis/react-native-modest-storage | src/index.js | update | function update (key, value) {
if (Array.isArray(key)) {
return AsyncStorage.multiMerge(key.map(([key, val]) => [key, JSON.stringify(val)]))
}
return AsyncStorage.mergeItem(key, JSON.stringify(value))
} | javascript | function update (key, value) {
if (Array.isArray(key)) {
return AsyncStorage.multiMerge(key.map(([key, val]) => [key, JSON.stringify(val)]))
}
return AsyncStorage.mergeItem(key, JSON.stringify(value))
} | [
"function",
"update",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"key",
")",
")",
"{",
"return",
"AsyncStorage",
".",
"multiMerge",
"(",
"key",
".",
"map",
"(",
"(",
"[",
"key",
",",
"val",
"]",
")",
"=>",
"[",
... | Update key with value by merging.
Wrapper around mergeItem & multiMerge.
@param {String, Array} key for value
@param {any} value to update
@returns {Promise} | [
"Update",
"key",
"with",
"value",
"by",
"merging",
".",
"Wrapper",
"around",
"mergeItem",
"&",
"multiMerge",
"."
] | 95e21cba4f917b27d198fbed0ef9676790163cd9 | https://github.com/tiaanduplessis/react-native-modest-storage/blob/95e21cba4f917b27d198fbed0ef9676790163cd9/src/index.js#L69-L75 | train |
Yodata/yodata | packages/cli/lib/util/print-result.js | transformResponse | function transformResponse(value, options, context) {
if (options.transform === true) {
assert.func(context.transform, 'context.transform')
return context.transform(value)
}
return value
} | javascript | function transformResponse(value, options, context) {
if (options.transform === true) {
assert.func(context.transform, 'context.transform')
return context.transform(value)
}
return value
} | [
"function",
"transformResponse",
"(",
"value",
",",
"options",
",",
"context",
")",
"{",
"if",
"(",
"options",
".",
"transform",
"===",
"true",
")",
"{",
"assert",
".",
"func",
"(",
"context",
".",
"transform",
",",
"'context.transform'",
")",
"return",
"c... | If options.transform is true, transform the result with context.transform
@param {*} value
@param {object} options
@param {boolean} options.transform
@param {object} context
@param {function} [context.transform] - transformation handler | [
"If",
"options",
".",
"transform",
"is",
"true",
"transform",
"the",
"result",
"with",
"context",
".",
"transform"
] | d7aedd03e49ce5da6e45ab821f54b16d4d4409df | https://github.com/Yodata/yodata/blob/d7aedd03e49ce5da6e45ab821f54b16d4d4409df/packages/cli/lib/util/print-result.js#L56-L63 | train |
Yodata/yodata | packages/client/lib/event/publish.js | publish | async function publish(props) {
const message = getData(props)
return createClient()
.post('/publish/', {
json: true,
body: message
})
} | javascript | async function publish(props) {
const message = getData(props)
return createClient()
.post('/publish/', {
json: true,
body: message
})
} | [
"async",
"function",
"publish",
"(",
"props",
")",
"{",
"const",
"message",
"=",
"getData",
"(",
"props",
")",
"return",
"createClient",
"(",
")",
".",
"post",
"(",
"'/publish/'",
",",
"{",
"json",
":",
"true",
",",
"body",
":",
"message",
"}",
")",
... | publish an event
@param {object} props
@param {string} [props.recipient]
@param {string} [props.topic]
@param {object} [props.data]
@param {string} [props.filepath]
@returns {Promise} | [
"publish",
"an",
"event"
] | d7aedd03e49ce5da6e45ab821f54b16d4d4409df | https://github.com/Yodata/yodata/blob/d7aedd03e49ce5da6e45ab821f54b16d4d4409df/packages/client/lib/event/publish.js#L18-L25 | train |
linzjs/linz | middleware/configList.js | function (records, cb) {
// loop through each record
async.each(records, function (record, recordDone) {
// loop through each field
async.each(Object.keys(req.linz.configList.fields), function (field, fieldDone) {
req.lin... | javascript | function (records, cb) {
// loop through each record
async.each(records, function (record, recordDone) {
// loop through each field
async.each(Object.keys(req.linz.configList.fields), function (field, fieldDone) {
req.lin... | [
"function",
"(",
"records",
",",
"cb",
")",
"{",
"// loop through each record",
"async",
".",
"each",
"(",
"records",
",",
"function",
"(",
"record",
",",
"recordDone",
")",
"{",
"// loop through each field",
"async",
".",
"each",
"(",
"Object",
".",
"keys",
... | apply renderer to values of each configs | [
"apply",
"renderer",
"to",
"values",
"of",
"each",
"configs"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/configList.js#L85-L119 | train | |
linzjs/linz | lib/formtools/renderers-list.js | grid | function grid (data, callback) {
linz.app.render(linz.api.views.viewPath('modelIndex/grid.jade'), data, (err, html) => {
if (err) {
return callback(err);
}
return callback(null, html);
});
} | javascript | function grid (data, callback) {
linz.app.render(linz.api.views.viewPath('modelIndex/grid.jade'), data, (err, html) => {
if (err) {
return callback(err);
}
return callback(null, html);
});
} | [
"function",
"grid",
"(",
"data",
",",
"callback",
")",
"{",
"linz",
".",
"app",
".",
"render",
"(",
"linz",
".",
"api",
".",
"views",
".",
"viewPath",
"(",
"'modelIndex/grid.jade'",
")",
",",
"data",
",",
"(",
"err",
",",
"html",
")",
"=>",
"{",
"i... | Grid list renderer.
@param {Object} data Data passed to the template.
@param {Function} callback Callback function.
@return {String} Rendered HTML content. | [
"Grid",
"list",
"renderer",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/lib/formtools/renderers-list.js#L11-L23 | train |
linzjs/linz | middleware/recordOverview.js | function (cb) {
let actions = req.linz.model.linz.formtools.overview.actions;
if (!actions.length) {
return cb(null);
}
parseDisabledProperties(req.linz.record, actions)
.then((parsedAction... | javascript | function (cb) {
let actions = req.linz.model.linz.formtools.overview.actions;
if (!actions.length) {
return cb(null);
}
parseDisabledProperties(req.linz.record, actions)
.then((parsedAction... | [
"function",
"(",
"cb",
")",
"{",
"let",
"actions",
"=",
"req",
".",
"linz",
".",
"model",
".",
"linz",
".",
"formtools",
".",
"overview",
".",
"actions",
";",
"if",
"(",
"!",
"actions",
".",
"length",
")",
"{",
"return",
"cb",
"(",
"null",
")",
"... | Check if we need to process custom actions. | [
"Check",
"if",
"we",
"need",
"to",
"process",
"custom",
"actions",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/recordOverview.js#L24-L42 | train | |
linzjs/linz | middleware/recordOverview.js | function (cb) {
let footerActions = req.linz.model.linz.formtools.overview.footerActions;
if (!footerActions.length) {
return cb();
}
parseDisabledProperties(req.linz.record, footerActions)
... | javascript | function (cb) {
let footerActions = req.linz.model.linz.formtools.overview.footerActions;
if (!footerActions.length) {
return cb();
}
parseDisabledProperties(req.linz.record, footerActions)
... | [
"function",
"(",
"cb",
")",
"{",
"let",
"footerActions",
"=",
"req",
".",
"linz",
".",
"model",
".",
"linz",
".",
"formtools",
".",
"overview",
".",
"footerActions",
";",
"if",
"(",
"!",
"footerActions",
".",
"length",
")",
"{",
"return",
"cb",
"(",
... | Check if we need to process custom footer actions. | [
"Check",
"if",
"we",
"need",
"to",
"process",
"custom",
"footer",
"actions",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/recordOverview.js#L45-L63 | train | |
Yodata/yodata | packages/cli/lib/util/create-response-handler.js | createResponseHandler | function createResponseHandler(fn, key, context) {
// Assert.func(fn,'createResponseHandler:fn')
return function (props) {
const param = key ? props[key] : props
print(fn(param), props, context)
}
} | javascript | function createResponseHandler(fn, key, context) {
// Assert.func(fn,'createResponseHandler:fn')
return function (props) {
const param = key ? props[key] : props
print(fn(param), props, context)
}
} | [
"function",
"createResponseHandler",
"(",
"fn",
",",
"key",
",",
"context",
")",
"{",
"// Assert.func(fn,'createResponseHandler:fn')",
"return",
"function",
"(",
"props",
")",
"{",
"const",
"param",
"=",
"key",
"?",
"props",
"[",
"key",
"]",
":",
"props",
"pri... | Creates an async response handler
@param {function} fn - function to be called
@param {string} [key] - function will be called with props[key] if not specified, the function will be called with the props object
@param {object} [context] - handlers used in print
@returns | [
"Creates",
"an",
"async",
"response",
"handler"
] | d7aedd03e49ce5da6e45ab821f54b16d4d4409df | https://github.com/Yodata/yodata/blob/d7aedd03e49ce5da6e45ab821f54b16d4d4409df/packages/cli/lib/util/create-response-handler.js#L14-L20 | train |
linzjs/linz | lib/api/configs.js | get | function get (configName, copy) {
if (copy) {
return clone(linz.get('configs')[configName]);
}
return linz.get('configs')[configName];
} | javascript | function get (configName, copy) {
if (copy) {
return clone(linz.get('configs')[configName]);
}
return linz.get('configs')[configName];
} | [
"function",
"get",
"(",
"configName",
",",
"copy",
")",
"{",
"if",
"(",
"copy",
")",
"{",
"return",
"clone",
"(",
"linz",
".",
"get",
"(",
"'configs'",
")",
"[",
"configName",
"]",
")",
";",
"}",
"return",
"linz",
".",
"get",
"(",
"'configs'",
")",... | Get linz config by reference or by cloning a copy
@param {String} configName Name of config
@param {Boolean} copy Specify if result should be a cloned copy or by reference. Default to return a reference.
@return {Object} Config object either by a cloned copy or by reference | [
"Get",
"linz",
"config",
"by",
"reference",
"or",
"by",
"cloning",
"a",
"copy"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/lib/api/configs.js#L11-L18 | train |
linzjs/linz | lib/api/configs.js | permissions | function permissions (user, configName, callback) {
return get(configName).schema.statics.getPermissions(user, callback);
} | javascript | function permissions (user, configName, callback) {
return get(configName).schema.statics.getPermissions(user, callback);
} | [
"function",
"permissions",
"(",
"user",
",",
"configName",
",",
"callback",
")",
"{",
"return",
"get",
"(",
"configName",
")",
".",
"schema",
".",
"statics",
".",
"getPermissions",
"(",
"user",
",",
"callback",
")",
";",
"}"
] | Retrieve the permissions DSL for a config
@param {Object} user The user to which the permissions DSL should be customised
@param {String} configName The name of the config
@param {Function} callback A callback to return the permissions DSL to
@return {Void} | [
"Retrieve",
"the",
"permissions",
"DSL",
"for",
"a",
"config"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/lib/api/configs.js#L48-L50 | train |
linzjs/linz | lib/api/configs.js | form | function form (req, configName, callback) {
return get(configName).schema.statics.getForm(req, callback);
} | javascript | function form (req, configName, callback) {
return get(configName).schema.statics.getForm(req, callback);
} | [
"function",
"form",
"(",
"req",
",",
"configName",
",",
"callback",
")",
"{",
"return",
"get",
"(",
"configName",
")",
".",
"schema",
".",
"statics",
".",
"getForm",
"(",
"req",
",",
"callback",
")",
";",
"}"
] | Retrieve the form DSL for a config
@param {Object} req A HTTP request object which should be used to customise the DSL
@param {String} configName The name of the config
@param {Function} callback A callback to return the form DSL to
@return {Void} | [
"Retrieve",
"the",
"form",
"DSL",
"for",
"a",
"config"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/lib/api/configs.js#L59-L61 | train |
linzjs/linz | lib/api/configs.js | overview | function overview (req, configName, callback) {
return get(configName).schema.statics.getOverview(req, callback);
} | javascript | function overview (req, configName, callback) {
return get(configName).schema.statics.getOverview(req, callback);
} | [
"function",
"overview",
"(",
"req",
",",
"configName",
",",
"callback",
")",
"{",
"return",
"get",
"(",
"configName",
")",
".",
"schema",
".",
"statics",
".",
"getOverview",
"(",
"req",
",",
"callback",
")",
";",
"}"
] | Retrieve the overview DSL for a config
@param {Object} req A HTTP request object which can be used to customise the DSL
@param {String} configName The name of the config
@param {Function} callback A callback to return the overview DSL to
@return {Void} | [
"Retrieve",
"the",
"overview",
"DSL",
"for",
"a",
"config"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/lib/api/configs.js#L70-L72 | train |
linzjs/linz | lib/api/configs.js | labels | function labels (configName, callback) {
if (callback) {
return get(configName).schema.statics.getLabels(callback);
}
return get(configName).schema.statics.getLabels();
} | javascript | function labels (configName, callback) {
if (callback) {
return get(configName).schema.statics.getLabels(callback);
}
return get(configName).schema.statics.getLabels();
} | [
"function",
"labels",
"(",
"configName",
",",
"callback",
")",
"{",
"if",
"(",
"callback",
")",
"{",
"return",
"get",
"(",
"configName",
")",
".",
"schema",
".",
"statics",
".",
"getLabels",
"(",
"callback",
")",
";",
"}",
"return",
"get",
"(",
"config... | Retrieve the labels for a config
@param {String} configName The name of the config
@param {Function} callback An optional callback to return the labels object to
@return {Void} | [
"Retrieve",
"the",
"labels",
"for",
"a",
"config"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/lib/api/configs.js#L80-L87 | train |
linzjs/linz | middleware/_modelIndex.js | handleQueryError | function handleQueryError (err) {
queryErrorCount++;
// Something has gone terribly wrong. Break from loop.
if (queryErrorCount > 1) {
// Reset all filters.
session.list.formData = {};
// Notify the user that an error has occured.
req.linz.noti... | javascript | function handleQueryError (err) {
queryErrorCount++;
// Something has gone terribly wrong. Break from loop.
if (queryErrorCount > 1) {
// Reset all filters.
session.list.formData = {};
// Notify the user that an error has occured.
req.linz.noti... | [
"function",
"handleQueryError",
"(",
"err",
")",
"{",
"queryErrorCount",
"++",
";",
"// Something has gone terribly wrong. Break from loop.",
"if",
"(",
"queryErrorCount",
">",
"1",
")",
"{",
"// Reset all filters.",
"session",
".",
"list",
".",
"formData",
"=",
"{",
... | This method should be executed when a query error is returned.
It will abort the current query and return the results of the previous query instead.
@return {Void} | [
"This",
"method",
"should",
"be",
"executed",
"when",
"a",
"query",
"error",
"is",
"returned",
".",
"It",
"will",
"abort",
"the",
"current",
"query",
"and",
"return",
"the",
"results",
"of",
"the",
"previous",
"query",
"instead",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L32-L73 | train |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
formtoolsAPI.list.renderToolbarItems(req, res, req.params.model, function (err, result) {
if (err) {
return cb(err);
}
req.linz.model.list.toolbarItems = result;
return cb(null);
... | javascript | function (cb) {
formtoolsAPI.list.renderToolbarItems(req, res, req.params.model, function (err, result) {
if (err) {
return cb(err);
}
req.linz.model.list.toolbarItems = result;
return cb(null);
... | [
"function",
"(",
"cb",
")",
"{",
"formtoolsAPI",
".",
"list",
".",
"renderToolbarItems",
"(",
"req",
",",
"res",
",",
"req",
".",
"params",
".",
"model",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"c... | check if there are toolbar items required | [
"check",
"if",
"there",
"are",
"toolbar",
"items",
"required"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L102-L116 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
// check if we need to render the filters
if (!Object.keys(req.linz.model.list.filters).length) {
return cb(null);
}
formtoolsAPI.list.renderFilters(req, req.params.model, function (err, result) {
... | javascript | function (cb) {
// check if we need to render the filters
if (!Object.keys(req.linz.model.list.filters).length) {
return cb(null);
}
formtoolsAPI.list.renderFilters(req, req.params.model, function (err, result) {
... | [
"function",
"(",
"cb",
")",
"{",
"// check if we need to render the filters",
"if",
"(",
"!",
"Object",
".",
"keys",
"(",
"req",
".",
"linz",
".",
"model",
".",
"list",
".",
"filters",
")",
".",
"length",
")",
"{",
"return",
"cb",
"(",
"null",
")",
";"... | render the filters | [
"render",
"the",
"filters"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L119-L137 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
const filters = req.linz.model.list.filters;
const formData = session.list.formData;
// Make sure we have some filters.
if (!filters) {
return cb(null);
}
// Find the alwaysOn filters, ... | javascript | function (cb) {
const filters = req.linz.model.list.filters;
const formData = session.list.formData;
// Make sure we have some filters.
if (!filters) {
return cb(null);
}
// Find the alwaysOn filters, ... | [
"function",
"(",
"cb",
")",
"{",
"const",
"filters",
"=",
"req",
".",
"linz",
".",
"model",
".",
"list",
".",
"filters",
";",
"const",
"formData",
"=",
"session",
".",
"list",
".",
"formData",
";",
"// Make sure we have some filters.",
"if",
"(",
"!",
"f... | Add in alwaysOn filters that have default values, that aren't already present. | [
"Add",
"in",
"alwaysOn",
"filters",
"that",
"have",
"default",
"values",
"that",
"aren",
"t",
"already",
"present",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L140-L188 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
req.linz.model.list.activeFilters = {};
// check if there are any filters in the form post
if (!session.list.formData.selectedFilters) {
return cb(null);
}
formtoolsAPI.list.getActiveFilters(req, sessi... | javascript | function (cb) {
req.linz.model.list.activeFilters = {};
// check if there are any filters in the form post
if (!session.list.formData.selectedFilters) {
return cb(null);
}
formtoolsAPI.list.getActiveFilters(req, sessi... | [
"function",
"(",
"cb",
")",
"{",
"req",
".",
"linz",
".",
"model",
".",
"list",
".",
"activeFilters",
"=",
"{",
"}",
";",
"// check if there are any filters in the form post",
"if",
"(",
"!",
"session",
".",
"list",
".",
"formData",
".",
"selectedFilters",
"... | render the active filters | [
"render",
"the",
"active",
"filters"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L191-L211 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
// check if there are any filters in the form post
if (!session.list.formData.selectedFilters) {
return cb(null);
}
formtoolsAPI.list.renderSearchFilters(req, session.list.formData.selectedFilters.split(','), session.l... | javascript | function (cb) {
// check if there are any filters in the form post
if (!session.list.formData.selectedFilters) {
return cb(null);
}
formtoolsAPI.list.renderSearchFilters(req, session.list.formData.selectedFilters.split(','), session.l... | [
"function",
"(",
"cb",
")",
"{",
"// check if there are any filters in the form post",
"if",
"(",
"!",
"session",
".",
"list",
".",
"formData",
".",
"selectedFilters",
")",
"{",
"return",
"cb",
"(",
"null",
")",
";",
"}",
"formtoolsAPI",
".",
"list",
".",
"r... | get the filters | [
"get",
"the",
"filters"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L214-L233 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
if (!session.list.formData.search || !session.list.formData.search.length || !req.linz.model.list.search || !Array.isArray(req.linz.model.list.search)) {
return cb(null);
}
// Default the `$and` key.
if (!filters.$and)... | javascript | function (cb) {
if (!session.list.formData.search || !session.list.formData.search.length || !req.linz.model.list.search || !Array.isArray(req.linz.model.list.search)) {
return cb(null);
}
// Default the `$and` key.
if (!filters.$and)... | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"!",
"session",
".",
"list",
".",
"formData",
".",
"search",
"||",
"!",
"session",
".",
"list",
".",
"formData",
".",
"search",
".",
"length",
"||",
"!",
"req",
".",
"linz",
".",
"model",
".",
"list",
"... | add the seach filters | [
"add",
"the",
"seach",
"filters"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L236-L267 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
req.linz.model.getQuery(req, filters, function (err, result) {
if (err) {
return cb(err);
}
query = result;
return cb(null);
});
} | javascript | function (cb) {
req.linz.model.getQuery(req, filters, function (err, result) {
if (err) {
return cb(err);
}
query = result;
return cb(null);
});
} | [
"function",
"(",
"cb",
")",
"{",
"req",
".",
"linz",
".",
"model",
".",
"getQuery",
"(",
"req",
",",
"filters",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"cb",
"(",
"err",
")",
";",
"}",
"query"... | create the query | [
"create",
"the",
"query"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L270-L284 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
let fields = Object.keys(req.linz.model.list.fields);
// Work in the title field
linz.api.model.titleField(req.params.model, 'title', (err, titleField) => {
if (err) {
return cb(err);
}
... | javascript | function (cb) {
let fields = Object.keys(req.linz.model.list.fields);
// Work in the title field
linz.api.model.titleField(req.params.model, 'title', (err, titleField) => {
if (err) {
return cb(err);
}
... | [
"function",
"(",
"cb",
")",
"{",
"let",
"fields",
"=",
"Object",
".",
"keys",
"(",
"req",
".",
"linz",
".",
"model",
".",
"list",
".",
"fields",
")",
";",
"// Work in the title field",
"linz",
".",
"api",
".",
"model",
".",
"titleField",
"(",
"req",
... | minimise the fields we're selecting | [
"minimise",
"the",
"fields",
"we",
"re",
"selecting"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L287-L313 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
req.linz.model.getCount(req, query, function (err, countQuery) {
if (err) {
return cb(err);
}
countQuery.exec(function (countQueryErr, count) {
// A query error has occured, le... | javascript | function (cb) {
req.linz.model.getCount(req, query, function (err, countQuery) {
if (err) {
return cb(err);
}
countQuery.exec(function (countQueryErr, count) {
// A query error has occured, le... | [
"function",
"(",
"cb",
")",
"{",
"req",
".",
"linz",
".",
"model",
".",
"getCount",
"(",
"req",
",",
"query",
",",
"function",
"(",
"err",
",",
"countQuery",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"cb",
"(",
"err",
")",
";",
"}",
"coun... | get page total | [
"get",
"page",
"total"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L316-L347 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
const getDefaultOrder = field => field.defaultOrder.toLowerCase() === 'desc' ? '-' : '';
if (!session.list.formData.sort && req.linz.model.list.sortBy.length) {
req.linz.model.list.sortingBy = req.linz.model.list.sortBy[0];
// s... | javascript | function (cb) {
const getDefaultOrder = field => field.defaultOrder.toLowerCase() === 'desc' ? '-' : '';
if (!session.list.formData.sort && req.linz.model.list.sortBy.length) {
req.linz.model.list.sortingBy = req.linz.model.list.sortBy[0];
// s... | [
"function",
"(",
"cb",
")",
"{",
"const",
"getDefaultOrder",
"=",
"field",
"=>",
"field",
".",
"defaultOrder",
".",
"toLowerCase",
"(",
")",
"===",
"'desc'",
"?",
"'-'",
":",
"''",
";",
"if",
"(",
"!",
"session",
".",
"list",
".",
"formData",
".",
"s... | find the docs | [
"find",
"the",
"docs"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L350-L408 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
// skip this if canEdit is not define for model
if (!mongooseRecords[0].canEdit) {
return cb(null);
}
async.each(Object.keys(mongooseRecords), function (index, recordDone) {
mongooseRecords[index].... | javascript | function (cb) {
// skip this if canEdit is not define for model
if (!mongooseRecords[0].canEdit) {
return cb(null);
}
async.each(Object.keys(mongooseRecords), function (index, recordDone) {
mongooseRecords[index].... | [
"function",
"(",
"cb",
")",
"{",
"// skip this if canEdit is not define for model",
"if",
"(",
"!",
"mongooseRecords",
"[",
"0",
"]",
".",
"canEdit",
")",
"{",
"return",
"cb",
"(",
"null",
")",
";",
"}",
"async",
".",
"each",
"(",
"Object",
".",
"keys",
... | check if each doc can be edited | [
"check",
"if",
"each",
"doc",
"can",
"be",
"edited"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L411-L438 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
// loop through each record
async.each(Object.keys(records), function (index, recordDone) {
// store the rendered content into a separate property
records[index]['rendered'] = {};
// loop through each field
... | javascript | function (cb) {
// loop through each record
async.each(Object.keys(records), function (index, recordDone) {
// store the rendered content into a separate property
records[index]['rendered'] = {};
// loop through each field
... | [
"function",
"(",
"cb",
")",
"{",
"// loop through each record",
"async",
".",
"each",
"(",
"Object",
".",
"keys",
"(",
"records",
")",
",",
"function",
"(",
"index",
",",
"recordDone",
")",
"{",
"// store the rendered content into a separate property",
"records",
... | create the values for the datalists for each doc | [
"create",
"the",
"values",
"for",
"the",
"datalists",
"for",
"each",
"doc"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L528-L604 | train | |
linzjs/linz | middleware/_modelIndex.js | function (cb) {
if (!req.linz.model.list.recordActions.length) {
return cb(null);
}
async.each(req.linz.model.list.recordActions, function (action, actionDone) {
if (!action.disabled) {
return actionDone(n... | javascript | function (cb) {
if (!req.linz.model.list.recordActions.length) {
return cb(null);
}
async.each(req.linz.model.list.recordActions, function (action, actionDone) {
if (!action.disabled) {
return actionDone(n... | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"!",
"req",
".",
"linz",
".",
"model",
".",
"list",
".",
"recordActions",
".",
"length",
")",
"{",
"return",
"cb",
"(",
"null",
")",
";",
"}",
"async",
".",
"each",
"(",
"req",
".",
"linz",
".",
"mode... | check if we need to process each record again record actions | [
"check",
"if",
"we",
"need",
"to",
"process",
"each",
"record",
"again",
"record",
"actions"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/_modelIndex.js#L607-L650 | train | |
linzjs/linz | public/js/multiselect.min.js | function() {
this.$button = $(this.options.templates.button).addClass(this.options.buttonClass);
// Adopt active state.
if (this.$select.prop('disabled')) {
this.disable();
}
else {
this.enable();
}
// ... | javascript | function() {
this.$button = $(this.options.templates.button).addClass(this.options.buttonClass);
// Adopt active state.
if (this.$select.prop('disabled')) {
this.disable();
}
else {
this.enable();
}
// ... | [
"function",
"(",
")",
"{",
"this",
".",
"$button",
"=",
"$",
"(",
"this",
".",
"options",
".",
"templates",
".",
"button",
")",
".",
"addClass",
"(",
"this",
".",
"options",
".",
"buttonClass",
")",
";",
"// Adopt active state.",
"if",
"(",
"this",
"."... | Builds the button of the multiselect. | [
"Builds",
"the",
"button",
"of",
"the",
"multiselect",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/public/js/multiselect.min.js#L251-L279 | train | |
linzjs/linz | public/js/multiselect.min.js | function() {
// Build ul.
this.$ul = $(this.options.templates.ul);
if (this.options.dropRight) {
this.$ul.addClass('pull-right');
}
// Set max height of dropdown menu to activate auto scrollbar.
if (this.options.maxHeight) {
... | javascript | function() {
// Build ul.
this.$ul = $(this.options.templates.ul);
if (this.options.dropRight) {
this.$ul.addClass('pull-right');
}
// Set max height of dropdown menu to activate auto scrollbar.
if (this.options.maxHeight) {
... | [
"function",
"(",
")",
"{",
"// Build ul.",
"this",
".",
"$ul",
"=",
"$",
"(",
"this",
".",
"options",
".",
"templates",
".",
"ul",
")",
";",
"if",
"(",
"this",
".",
"options",
".",
"dropRight",
")",
"{",
"this",
".",
"$ul",
".",
"addClass",
"(",
... | Builds the ul representing the dropdown menu. | [
"Builds",
"the",
"ul",
"representing",
"the",
"dropdown",
"menu",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/public/js/multiselect.min.js#L284-L304 | train | |
linzjs/linz | public/js/multiselect.min.js | function(group) {
var groupName = $(group).prop('label');
// Add a header for the group.
var $li = $(this.options.templates.liGroup);
$('label', $li).text(groupName);
this.$ul.append($li);
if ($(group).is(':disabled')) {
$li.addC... | javascript | function(group) {
var groupName = $(group).prop('label');
// Add a header for the group.
var $li = $(this.options.templates.liGroup);
$('label', $li).text(groupName);
this.$ul.append($li);
if ($(group).is(':disabled')) {
$li.addC... | [
"function",
"(",
"group",
")",
"{",
"var",
"groupName",
"=",
"$",
"(",
"group",
")",
".",
"prop",
"(",
"'label'",
")",
";",
"// Add a header for the group.",
"var",
"$li",
"=",
"$",
"(",
"this",
".",
"options",
".",
"templates",
".",
"liGroup",
")",
";... | Creates an optgroup.
@param {jQuery} group | [
"Creates",
"an",
"optgroup",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/public/js/multiselect.min.js#L568-L585 | train | |
linzjs/linz | public/js/multiselect.min.js | function() {
var alreadyHasSelectAll = this.hasSelectAll();
if (!alreadyHasSelectAll && this.options.includeSelectAllOption && this.options.multiple
&& $('option', this.$select).length > this.options.includeSelectAllIfMoreThan) {
// Check whether to add a di... | javascript | function() {
var alreadyHasSelectAll = this.hasSelectAll();
if (!alreadyHasSelectAll && this.options.includeSelectAllOption && this.options.multiple
&& $('option', this.$select).length > this.options.includeSelectAllIfMoreThan) {
// Check whether to add a di... | [
"function",
"(",
")",
"{",
"var",
"alreadyHasSelectAll",
"=",
"this",
".",
"hasSelectAll",
"(",
")",
";",
"if",
"(",
"!",
"alreadyHasSelectAll",
"&&",
"this",
".",
"options",
".",
"includeSelectAllOption",
"&&",
"this",
".",
"options",
".",
"multiple",
"&&",... | Build the selct all.
Checks if a select all has already been created. | [
"Build",
"the",
"selct",
"all",
".",
"Checks",
"if",
"a",
"select",
"all",
"has",
"already",
"been",
"created",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/public/js/multiselect.min.js#L591-L619 | train | |
linzjs/linz | public/js/multiselect.min.js | function() {
$('option', this.$select).each($.proxy(function(index, element) {
var $input = $('li input', this.$ul).filter(function() {
return $(this).val() === $(element).val();
});
if ($(element).is(':selected')) {
$i... | javascript | function() {
$('option', this.$select).each($.proxy(function(index, element) {
var $input = $('li input', this.$ul).filter(function() {
return $(this).val() === $(element).val();
});
if ($(element).is(':selected')) {
$i... | [
"function",
"(",
")",
"{",
"$",
"(",
"'option'",
",",
"this",
".",
"$select",
")",
".",
"each",
"(",
"$",
".",
"proxy",
"(",
"function",
"(",
"index",
",",
"element",
")",
"{",
"var",
"$input",
"=",
"$",
"(",
"'li input'",
",",
"this",
".",
"$ul"... | Refreshs the multiselect based on the selected options of the select. | [
"Refreshs",
"the",
"multiselect",
"based",
"on",
"the",
"selected",
"options",
"of",
"the",
"select",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/public/js/multiselect.min.js#L703-L741 | train | |
linzjs/linz | public/js/multiselect.min.js | function() {
this.$ul.html('');
// Important to distinguish between radios and checkboxes.
this.options.multiple = this.$select.attr('multiple') === "multiple";
this.buildSelectAll();
this.buildDropdownOptions();
this.buildFilter();
... | javascript | function() {
this.$ul.html('');
// Important to distinguish between radios and checkboxes.
this.options.multiple = this.$select.attr('multiple') === "multiple";
this.buildSelectAll();
this.buildDropdownOptions();
this.buildFilter();
... | [
"function",
"(",
")",
"{",
"this",
".",
"$ul",
".",
"html",
"(",
"''",
")",
";",
"// Important to distinguish between radios and checkboxes.",
"this",
".",
"options",
".",
"multiple",
"=",
"this",
".",
"$select",
".",
"attr",
"(",
"'multiple'",
")",
"===",
"... | Rebuild the plugin.
Rebuilds the dropdown, the filter and the select all option. | [
"Rebuild",
"the",
"plugin",
".",
"Rebuilds",
"the",
"dropdown",
"the",
"filter",
"and",
"the",
"select",
"all",
"option",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/public/js/multiselect.min.js#L875-L891 | train | |
linzjs/linz | public/js/multiselect.min.js | function (value) {
var options = $('option', this.$select);
var valueToCompare = value.toString();
for (var i = 0; i < options.length; i = i + 1) {
var option = options[i];
if (option.value === valueToCompare) {
return $(option);
... | javascript | function (value) {
var options = $('option', this.$select);
var valueToCompare = value.toString();
for (var i = 0; i < options.length; i = i + 1) {
var option = options[i];
if (option.value === valueToCompare) {
return $(option);
... | [
"function",
"(",
"value",
")",
"{",
"var",
"options",
"=",
"$",
"(",
"'option'",
",",
"this",
".",
"$select",
")",
";",
"var",
"valueToCompare",
"=",
"value",
".",
"toString",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"optio... | Gets a select option by its value.
@param {String} value
@returns {jQuery} | [
"Gets",
"a",
"select",
"option",
"by",
"its",
"value",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/public/js/multiselect.min.js#L1019-L1030 | train | |
ssbc/ssb-blobs | inject.js | hasLegacy | function hasLegacy (hashes) {
var ary = Object.keys(hashes).filter(function (k) {
return hashes[k] < 0
})
if(ary.length)
peer.blobs.has(ary, function (err, haves) {
if(err) drain.abort(err) //ERROR: abort this stream.
else haves.forEach(function (have, i) {
... | javascript | function hasLegacy (hashes) {
var ary = Object.keys(hashes).filter(function (k) {
return hashes[k] < 0
})
if(ary.length)
peer.blobs.has(ary, function (err, haves) {
if(err) drain.abort(err) //ERROR: abort this stream.
else haves.forEach(function (have, i) {
... | [
"function",
"hasLegacy",
"(",
"hashes",
")",
"{",
"var",
"ary",
"=",
"Object",
".",
"keys",
"(",
"hashes",
")",
".",
"filter",
"(",
"function",
"(",
"k",
")",
"{",
"return",
"hashes",
"[",
"k",
"]",
"<",
"0",
"}",
")",
"if",
"(",
"ary",
".",
"l... | so we can abort it when we get an error. | [
"so",
"we",
"can",
"abort",
"it",
"when",
"we",
"get",
"an",
"error",
"."
] | 6ce1c7a46a602deb3d160023e673d9999775aa7a | https://github.com/ssbc/ssb-blobs/blob/6ce1c7a46a602deb3d160023e673d9999775aa7a/inject.js#L171-L182 | train |
linzjs/linz | middleware/modelExport.js | function (exports) {
var exp = undefined;
// retrieve the export object
exports.forEach(function (_export) {
// Linz's default export function is called export
if (_export.action && _export.action === 'export') {
exp = _export;
}
});
// if the export object c... | javascript | function (exports) {
var exp = undefined;
// retrieve the export object
exports.forEach(function (_export) {
// Linz's default export function is called export
if (_export.action && _export.action === 'export') {
exp = _export;
}
});
// if the export object c... | [
"function",
"(",
"exports",
")",
"{",
"var",
"exp",
"=",
"undefined",
";",
"// retrieve the export object",
"exports",
".",
"forEach",
"(",
"function",
"(",
"_export",
")",
"{",
"// Linz's default export function is called export",
"if",
"(",
"_export",
".",
"action... | this will retrieve the export object, using Linz's default export handler amongst custom export handlers this is based on the knowledge that only Linz's default export handler can have an `action` of `export` `exports` should be model.list.export | [
"this",
"will",
"retrieve",
"the",
"export",
"object",
"using",
"Linz",
"s",
"default",
"export",
"handler",
"amongst",
"custom",
"export",
"handlers",
"this",
"is",
"based",
"on",
"the",
"knowledge",
"that",
"only",
"Linz",
"s",
"default",
"export",
"handler"... | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/middleware/modelExport.js#L224-L245 | train | |
linzjs/linz | lib/versions/renderers/overview.js | function (cb) {
model.VersionedModel.find({ refId: record._id }, 'dateCreated modifiedBy', { lean: 1, sort: { dateCreated: -1 } }, function (err, result) {
return cb(err, result);
});
} | javascript | function (cb) {
model.VersionedModel.find({ refId: record._id }, 'dateCreated modifiedBy', { lean: 1, sort: { dateCreated: -1 } }, function (err, result) {
return cb(err, result);
});
} | [
"function",
"(",
"cb",
")",
"{",
"model",
".",
"VersionedModel",
".",
"find",
"(",
"{",
"refId",
":",
"record",
".",
"_id",
"}",
",",
"'dateCreated modifiedBy'",
",",
"{",
"lean",
":",
"1",
",",
"sort",
":",
"{",
"dateCreated",
":",
"-",
"1",
"}",
... | get a list of all the versions from the archived | [
"get",
"a",
"list",
"of",
"all",
"the",
"versions",
"from",
"the",
"archived"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/lib/versions/renderers/overview.js#L11-L17 | train | |
linzjs/linz | lib/api/permissions.js | hasPermission | function hasPermission (user, context, permission, cb) {
var _context = context;
/**
* Support three types of permissions:
* - navigation
* - models and model
* - configs and config
*
* Context can either be an object, or a string. If context is a string, no other data need be passe... | javascript | function hasPermission (user, context, permission, cb) {
var _context = context;
/**
* Support three types of permissions:
* - navigation
* - models and model
* - configs and config
*
* Context can either be an object, or a string. If context is a string, no other data need be passe... | [
"function",
"hasPermission",
"(",
"user",
",",
"context",
",",
"permission",
",",
"cb",
")",
"{",
"var",
"_context",
"=",
"context",
";",
"/**\n * Support three types of permissions:\n * - navigation\n * - models and model\n * - configs and config\n *\n * Co... | Determine if a user has access to a route, model or config
@param {object} user The user object in which the context of the permission should be based.
@param {String|object} context The context for the permission. One of 'models', 'configs', {type:'model', model:{object}} or {type:'config': con... | [
"Determine",
"if",
"a",
"user",
"has",
"access",
"to",
"a",
"route",
"model",
"or",
"config"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/lib/api/permissions.js#L11-L47 | train |
linzjs/linz | public/js/utils.js | addLoadEvent | function addLoadEvent (func) {
if (window.attachEvent) {
return window.attachEvent('onload', func);
}
if (window.addEventListener) {
return window.addEventListener('load', func, false);
}
return document.addEventListener('load', func, false);
} | javascript | function addLoadEvent (func) {
if (window.attachEvent) {
return window.attachEvent('onload', func);
}
if (window.addEventListener) {
return window.addEventListener('load', func, false);
}
return document.addEventListener('load', func, false);
} | [
"function",
"addLoadEvent",
"(",
"func",
")",
"{",
"if",
"(",
"window",
".",
"attachEvent",
")",
"{",
"return",
"window",
".",
"attachEvent",
"(",
"'onload'",
",",
"func",
")",
";",
"}",
"if",
"(",
"window",
".",
"addEventListener",
")",
"{",
"return",
... | Append instead of replace the onload process. | [
"Append",
"instead",
"of",
"replace",
"the",
"onload",
"process",
"."
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/public/js/utils.js#L10-L22 | train |
Yodata/yodata | packages/context-sdk/lib/transform/index.js | transform | async function transform({ datapath, filepath, inverse = false }) {
assert.string(datapath)
assert.string(filepath)
const data = await loadData(datapath)
const contextdoc = await loadData(filepath)
assert.object(data)
assert.object(contextdoc)
const result = new Context(contextdoc).use(viewPlugin).map(data)
ret... | javascript | async function transform({ datapath, filepath, inverse = false }) {
assert.string(datapath)
assert.string(filepath)
const data = await loadData(datapath)
const contextdoc = await loadData(filepath)
assert.object(data)
assert.object(contextdoc)
const result = new Context(contextdoc).use(viewPlugin).map(data)
ret... | [
"async",
"function",
"transform",
"(",
"{",
"datapath",
",",
"filepath",
",",
"inverse",
"=",
"false",
"}",
")",
"{",
"assert",
".",
"string",
"(",
"datapath",
")",
"assert",
".",
"string",
"(",
"filepath",
")",
"const",
"data",
"=",
"await",
"loadData",... | transforms data at datapath with context at filepath
@param {object} props
@param {string} props.datapath - path to data
@param {string} [props.filepath] - path to context definition file
@param {boolean} [props.inverse] - true for outbound (subscription) transformation
@returns | [
"transforms",
"data",
"at",
"datapath",
"with",
"context",
"at",
"filepath"
] | d7aedd03e49ce5da6e45ab821f54b16d4d4409df | https://github.com/Yodata/yodata/blob/d7aedd03e49ce5da6e45ab821f54b16d4d4409df/packages/context-sdk/lib/transform/index.js#L18-L27 | train |
linzjs/linz | lib/api/formtools/list.js | renderFilters | function renderFilters (req, modelName, cb) {
if (!req) {
throw new Error('req is required.');
}
if (typeof modelName !== 'string' || !modelName.length) {
throw new Error('modelName is required and must be of type String and cannot be empty.');
}
linz.api.model.list(req, modelName... | javascript | function renderFilters (req, modelName, cb) {
if (!req) {
throw new Error('req is required.');
}
if (typeof modelName !== 'string' || !modelName.length) {
throw new Error('modelName is required and must be of type String and cannot be empty.');
}
linz.api.model.list(req, modelName... | [
"function",
"renderFilters",
"(",
"req",
",",
"modelName",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"req",
")",
"{",
"throw",
"new",
"Error",
"(",
"'req is required.'",
")",
";",
"}",
"if",
"(",
"typeof",
"modelName",
"!==",
"'string'",
"||",
"!",
"modelNa... | Get list filter settings and execute render method to obtain the HTML markup
@param {String} req A HTTP request object.
@param {String} modelName Name of model
@param {Function} cb Callback function
@return {Object} or undefined
@api public | [
"Get",
"list",
"filter",
"settings",
"and",
"execute",
"render",
"method",
"to",
"obtain",
"the",
"HTML",
"markup"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/lib/api/formtools/list.js#L64-L107 | train |
linzjs/linz | lib/api/formtools/list.js | renderSearchFilters | function renderSearchFilters(req, fieldNames, data, modelName, cb) {
if (!req) {
throw new Error('req is required.');
}
if (!Array.isArray(fieldNames) || !fieldNames.length) {
throw new Error('fieldNames is required and must be of type Array and cannot be empty.');
}
if (typeof mo... | javascript | function renderSearchFilters(req, fieldNames, data, modelName, cb) {
if (!req) {
throw new Error('req is required.');
}
if (!Array.isArray(fieldNames) || !fieldNames.length) {
throw new Error('fieldNames is required and must be of type Array and cannot be empty.');
}
if (typeof mo... | [
"function",
"renderSearchFilters",
"(",
"req",
",",
"fieldNames",
",",
"data",
",",
"modelName",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"req",
")",
"{",
"throw",
"new",
"Error",
"(",
"'req is required.'",
")",
";",
"}",
"if",
"(",
"!",
"Array",
".",
"i... | Get search filters as a mongodb query
@param {Array} fieldNames Field names
@param {Object} data Form data
@param {String} modelName Name of model
@param {Function} cb Callback function
@return {Object} or undefined
@api public | [
"Get",
"search",
"filters",
"as",
"a",
"mongodb",
"query"
] | 0ac03e722747406d29f9e1eed7e96b6be04456e8 | https://github.com/linzjs/linz/blob/0ac03e722747406d29f9e1eed7e96b6be04456e8/lib/api/formtools/list.js#L118-L186 | 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.