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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ckknight/escort | lib/escort.js | function (text, value) {
var valueLength = value.length;
if (text.length < valueLength) {
return false;
}
return text.substring(0, valueLength) === value;
} | javascript | function (text, value) {
var valueLength = value.length;
if (text.length < valueLength) {
return false;
}
return text.substring(0, valueLength) === value;
} | [
"function",
"(",
"text",
",",
"value",
")",
"{",
"var",
"valueLength",
"=",
"value",
".",
"length",
";",
"if",
"(",
"text",
".",
"length",
"<",
"valueLength",
")",
"{",
"return",
"false",
";",
"}",
"return",
"text",
".",
"substring",
"(",
"0",
",",
... | Determine whether text starts with value.
@param {String} text the text to check if value is the beginning part of the string.
@param {String} value the potential value of the start of the string.
@return {Boolean}
@api private
@example startsWith("hey there", "hey") === true
@example startsWith("hey there", "hello")... | [
"Determine",
"whether",
"text",
"starts",
"with",
"value",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort.js#L244-L251 | train | |
ckknight/escort | lib/escort.js | function (array, c, depth) {
var start = array.length - (array.length / Math.pow(2, depth));
for (var i = start, len = array.length; i < len; i += 1) {
array[i] += c;
}
} | javascript | function (array, c, depth) {
var start = array.length - (array.length / Math.pow(2, depth));
for (var i = start, len = array.length; i < len; i += 1) {
array[i] += c;
}
} | [
"function",
"(",
"array",
",",
"c",
",",
"depth",
")",
"{",
"var",
"start",
"=",
"array",
".",
"length",
"-",
"(",
"array",
".",
"length",
"/",
"Math",
".",
"pow",
"(",
"2",
",",
"depth",
")",
")",
";",
"for",
"(",
"var",
"i",
"=",
"start",
"... | Add a char to certain elements of an array.
@param {Array} array An array of strings
@param {String} c A string to add to each string
@param {Number} depth The current binary tree depth to add to.
@api private | [
"Add",
"a",
"char",
"to",
"certain",
"elements",
"of",
"an",
"array",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort.js#L261-L266 | train | |
ckknight/escort | lib/escort.js | function (array) {
var set = {};
var result = [];
for (var i = 0, len = array.length; i < len; i += 1) {
var item = array[i];
if (!Object.prototype.hasOwnProperty.call(set, item)) {
set[item] = true;
result.push(item);
}
... | javascript | function (array) {
var set = {};
var result = [];
for (var i = 0, len = array.length; i < len; i += 1) {
var item = array[i];
if (!Object.prototype.hasOwnProperty.call(set, item)) {
set[item] = true;
result.push(item);
}
... | [
"function",
"(",
"array",
")",
"{",
"var",
"set",
"=",
"{",
"}",
";",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"array",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"+=",
"1",
")",
"{",
"va... | Return an array with only distinct elements.
This assumes that the elements of an array have their uniqueness determined by their String value.
@param {Array} array The array to iterate over.
@return {Array} An array with distinct elements.
@api private
@example distinct(["a", "b", "c", "a", "a", "c"]) => ["a", "b", ... | [
"Return",
"an",
"array",
"with",
"only",
"distinct",
"elements",
".",
"This",
"assumes",
"that",
"the",
"elements",
"of",
"an",
"array",
"have",
"their",
"uniqueness",
"determined",
"by",
"their",
"String",
"value",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort.js#L278-L291 | train | |
ckknight/escort | lib/escort.js | function (routes) {
if (!Array.isArray(routes)) {
routes = [routes];
}
var result = [];
routes.forEach(function (route) {
if (route.indexOf('[') === -1) {
result.push(route);
return;
}
var immediateResult ... | javascript | function (routes) {
if (!Array.isArray(routes)) {
routes = [routes];
}
var result = [];
routes.forEach(function (route) {
if (route.indexOf('[') === -1) {
result.push(route);
return;
}
var immediateResult ... | [
"function",
"(",
"routes",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"routes",
")",
")",
"{",
"routes",
"=",
"[",
"routes",
"]",
";",
"}",
"var",
"result",
"=",
"[",
"]",
";",
"routes",
".",
"forEach",
"(",
"function",
"(",
"route",... | Parse all potential optional routes out of the provided String or Array.
@param {Array} routes an array of routes, or a String which is a single route.
@return {Array} the parsed-out array of optional routes.
@api private
@example parseOptionalRoutes("/same") => ["/same"]
@example parseOptionalRoutes("/[optional]") =... | [
"Parse",
"all",
"potential",
"optional",
"routes",
"out",
"of",
"the",
"provided",
"String",
"or",
"Array",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort.js#L308-L360 | train | |
ckknight/escort | lib/escort.js | function (bind, prefix) {
return function (path, callback) {
var prefixedPath = prefix + path;
validatePath(prefixedPath);
var innerMethods = spawn(escort.prototype, {
bind: function (routeName, route, descriptor) {
if (arguments.length ===... | javascript | function (bind, prefix) {
return function (path, callback) {
var prefixedPath = prefix + path;
validatePath(prefixedPath);
var innerMethods = spawn(escort.prototype, {
bind: function (routeName, route, descriptor) {
if (arguments.length ===... | [
"function",
"(",
"bind",
",",
"prefix",
")",
"{",
"return",
"function",
"(",
"path",
",",
"callback",
")",
"{",
"var",
"prefixedPath",
"=",
"prefix",
"+",
"path",
";",
"validatePath",
"(",
"prefixedPath",
")",
";",
"var",
"innerMethods",
"=",
"spawn",
"(... | Make the submount function for the escort Object.
@param {Function} bind the bind function for the current escort Object.
@param {String} prefix the route prefix for the submount.
@api private
@example makeSubmountFunction("/forums") | [
"Make",
"the",
"submount",
"function",
"for",
"the",
"escort",
"Object",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort.js#L399-L421 | train | |
ckknight/escort | lib/escort.js | function (req, res) {
return function (err) {
if (err) {
res.writeHead(500);
res.end(err.toString());
} else {
res.writeHead(404);
res.end();
}
};
} | javascript | function (req, res) {
return function (err) {
if (err) {
res.writeHead(500);
res.end(err.toString());
} else {
res.writeHead(404);
res.end();
}
};
} | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"return",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"res",
".",
"writeHead",
"(",
"500",
")",
";",
"res",
".",
"end",
"(",
"err",
".",
"toString",
"(",
")",
")",
";",
"}",
"els... | A handler for calling the next middleware module if for some reason one isn't provided.
@param {Error} err An error, if it occurred.
@api private | [
"A",
"handler",
"for",
"calling",
"the",
"next",
"middleware",
"module",
"if",
"for",
"some",
"reason",
"one",
"isn",
"t",
"provided",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort.js#L442-L452 | train | |
ckknight/escort | lib/escort.js | function (object) {
ACCEPTABLE_METHODS.forEach(function (method) {
/**
* Bind the provided route with a specific method to the callback provided.
* Since you cannot specify a route more than once, it is required to use bind to provide multiple methods.
*
... | javascript | function (object) {
ACCEPTABLE_METHODS.forEach(function (method) {
/**
* Bind the provided route with a specific method to the callback provided.
* Since you cannot specify a route more than once, it is required to use bind to provide multiple methods.
*
... | [
"function",
"(",
"object",
")",
"{",
"ACCEPTABLE_METHODS",
".",
"forEach",
"(",
"function",
"(",
"method",
")",
"{",
"/**\n * Bind the provided route with a specific method to the callback provided.\n * Since you cannot specify a route more than once, it is requir... | Attach all the helper HTTP and WebDAV methods as helper functions which will
ultimately call bind on the provided object.
@param {Object} object the Object to attach the methods to.
@api private | [
"Attach",
"all",
"the",
"helper",
"HTTP",
"and",
"WebDAV",
"methods",
"as",
"helper",
"functions",
"which",
"will",
"ultimately",
"call",
"bind",
"on",
"the",
"provided",
"object",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort.js#L461-L501 | train | |
ckknight/escort | lib/escort.js | function (value, length) {
value = String(value);
var numMissing = length - value.length;
var prefix = "";
while (numMissing > 0) {
prefix += "0";
numMissing -= 1;
}
return prefix + value;
} | javascript | function (value, length) {
value = String(value);
var numMissing = length - value.length;
var prefix = "";
while (numMissing > 0) {
prefix += "0";
numMissing -= 1;
}
return prefix + value;
} | [
"function",
"(",
"value",
",",
"length",
")",
"{",
"value",
"=",
"String",
"(",
"value",
")",
";",
"var",
"numMissing",
"=",
"length",
"-",
"value",
".",
"length",
";",
"var",
"prefix",
"=",
"\"\"",
";",
"while",
"(",
"numMissing",
">",
"0",
")",
"... | Pad a value by prepending zeroes until it reaches a specified length.
@param {String} value the current string or number.
@param {Number} length the size wanted for the value.
@return {String} a string of at least the provided length.
@api private
@example zeroPad(50, 4) == "0050"
@example zeroPad("123", 4) == "0123" | [
"Pad",
"a",
"value",
"by",
"prepending",
"zeroes",
"until",
"it",
"reaches",
"a",
"specified",
"length",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort.js#L1216-L1225 | train | |
ckknight/escort | lib/escort.js | function (args) {
if (!args) {
args = {};
}
var fixedDigits = args.fixedDigits;
var min = args.min;
var max = args.max;
if (min === undefined) {
min = null;
}
if (max === undefine... | javascript | function (args) {
if (!args) {
args = {};
}
var fixedDigits = args.fixedDigits;
var min = args.min;
var max = args.max;
if (min === undefined) {
min = null;
}
if (max === undefine... | [
"function",
"(",
"args",
")",
"{",
"if",
"(",
"!",
"args",
")",
"{",
"args",
"=",
"{",
"}",
";",
"}",
"var",
"fixedDigits",
"=",
"args",
".",
"fixedDigits",
";",
"var",
"min",
"=",
"args",
".",
"min",
";",
"var",
"max",
"=",
"args",
".",
"max",... | A converter that accepts a numeric string.
This does not support negative values.
@example routes.get("/users/{id:int}", function(req, res, params) { })
@example routes.get("/archive/{year:int({fixedDigits: 4})}", function(req, res, params) { })
@example routes.get("/users/{id:int({min: 1})}", function(req, res) { })
... | [
"A",
"converter",
"that",
"accepts",
"a",
"numeric",
"string",
".",
"This",
"does",
"not",
"support",
"negative",
"values",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort.js#L1237-L1257 | train | |
ckknight/escort | lib/escort.js | function () {
var args = Array.prototype.slice.call(arguments, 0);
if (args.length < 1) {
throw new Error("Must specify at least one argument to AnyConverter");
}
var values = {};
for (var i = 0, len = args.length; i < len; i += 1)... | javascript | function () {
var args = Array.prototype.slice.call(arguments, 0);
if (args.length < 1) {
throw new Error("Must specify at least one argument to AnyConverter");
}
var values = {};
for (var i = 0, len = args.length; i < len; i += 1)... | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"if",
"(",
"args",
".",
"length",
"<",
"1",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Must specify at least on... | A converter that matches one of the items provided.
@example routes.get("/pages/{pageName:any('about', 'help', 'contact')}", function(req, res, params) { }) | [
"A",
"converter",
"that",
"matches",
"one",
"of",
"the",
"items",
"provided",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort.js#L1308-L1325 | train | |
engineer-andrew/Angular-Tree-View | src/eaTreeView.factory.js | function(state, datasetId, items, matchFound, nestingLevel, stopExpandingParents) {
// initialize whatever wasn't passed to a default value
datasetId = datasetId || 'default';
items = items || concealed.items[datasetId];
matchFound = matchFound || false;
nesti... | javascript | function(state, datasetId, items, matchFound, nestingLevel, stopExpandingParents) {
// initialize whatever wasn't passed to a default value
datasetId = datasetId || 'default';
items = items || concealed.items[datasetId];
matchFound = matchFound || false;
nesti... | [
"function",
"(",
"state",
",",
"datasetId",
",",
"items",
",",
"matchFound",
",",
"nestingLevel",
",",
"stopExpandingParents",
")",
"{",
"// initialize whatever wasn't passed to a default value",
"datasetId",
"=",
"datasetId",
"||",
"'default'",
";",
"items",
"=",
"it... | set the active item and expand all ancestors of the active item | [
"set",
"the",
"active",
"item",
"and",
"expand",
"all",
"ancestors",
"of",
"the",
"active",
"item"
] | 4a7398057f36290568203c5cb1a3d23f633cc15e | https://github.com/engineer-andrew/Angular-Tree-View/blob/4a7398057f36290568203c5cb1a3d23f633cc15e/src/eaTreeView.factory.js#L30-L66 | train | |
lucsorel/markdown-image-loader | index.js | requirifyImageReference | function requirifyImageReference(markdownImageReference) {
const [, mdImageStart, mdImagePath, optionalMdTitle, mdImageEnd ] = imagePathRE.exec(markdownImageReference) || []
if (!mdImagePath) {
return JSON.stringify(markdownImageReference)
} else {
const imageRequest = loaderUtils.stringifyRequest(
... | javascript | function requirifyImageReference(markdownImageReference) {
const [, mdImageStart, mdImagePath, optionalMdTitle, mdImageEnd ] = imagePathRE.exec(markdownImageReference) || []
if (!mdImagePath) {
return JSON.stringify(markdownImageReference)
} else {
const imageRequest = loaderUtils.stringifyRequest(
... | [
"function",
"requirifyImageReference",
"(",
"markdownImageReference",
")",
"{",
"const",
"[",
",",
"mdImageStart",
",",
"mdImagePath",
",",
"optionalMdTitle",
",",
"mdImageEnd",
"]",
"=",
"imagePathRE",
".",
"exec",
"(",
"markdownImageReference",
")",
"||",
"[",
"... | converts the image path in the markdowned-image syntax into a require statement, or stringify the given content | [
"converts",
"the",
"image",
"path",
"in",
"the",
"markdowned",
"-",
"image",
"syntax",
"into",
"a",
"require",
"statement",
"or",
"stringify",
"the",
"given",
"content"
] | e3272fab82a2f3de858425792401c2f2f37ab6b1 | https://github.com/lucsorel/markdown-image-loader/blob/e3272fab82a2f3de858425792401c2f2f37ab6b1/index.js#L7-L20 | train |
m59peacemaker/svelte-modal | build/Modal.js | checkPointerDown | function checkPointerDown(e) {
if (config.clickOutsideDeactivates && !container.contains(e.target)) {
deactivate({ returnFocus: false });
}
} | javascript | function checkPointerDown(e) {
if (config.clickOutsideDeactivates && !container.contains(e.target)) {
deactivate({ returnFocus: false });
}
} | [
"function",
"checkPointerDown",
"(",
"e",
")",
"{",
"if",
"(",
"config",
".",
"clickOutsideDeactivates",
"&&",
"!",
"container",
".",
"contains",
"(",
"e",
".",
"target",
")",
")",
"{",
"deactivate",
"(",
"{",
"returnFocus",
":",
"false",
"}",
")",
";",
... | This needs to be done on mousedown and touchstart instead of click so that it precedes the focus event | [
"This",
"needs",
"to",
"be",
"done",
"on",
"mousedown",
"and",
"touchstart",
"instead",
"of",
"click",
"so",
"that",
"it",
"precedes",
"the",
"focus",
"event"
] | 7f30bed0fabea376faa3e531dbfdb11b141eb548 | https://github.com/m59peacemaker/svelte-modal/blob/7f30bed0fabea376faa3e531dbfdb11b141eb548/build/Modal.js#L733-L737 | train |
wala/jsdelta | src/transformations.js | applyTransformers | function applyTransformers(options, state, file) {
var transformationSucceededAtLeastOnce = false;
if (options.transformations && state.ext == "js") {
options.transformations.forEach(function (transformation) {
transformationSucceededAtLeastOnce |= transformAndTest(transformation, options, s... | javascript | function applyTransformers(options, state, file) {
var transformationSucceededAtLeastOnce = false;
if (options.transformations && state.ext == "js") {
options.transformations.forEach(function (transformation) {
transformationSucceededAtLeastOnce |= transformAndTest(transformation, options, s... | [
"function",
"applyTransformers",
"(",
"options",
",",
"state",
",",
"file",
")",
"{",
"var",
"transformationSucceededAtLeastOnce",
"=",
"false",
";",
"if",
"(",
"options",
".",
"transformations",
"&&",
"state",
".",
"ext",
"==",
"\"js\"",
")",
"{",
"options",
... | Applies all the custom transformers.
Returns true iff any of the transformations made the predicate true. | [
"Applies",
"all",
"the",
"custom",
"transformers",
"."
] | 355febea1ee23e9e909ba2bfa087ffb2499a3295 | https://github.com/wala/jsdelta/blob/355febea1ee23e9e909ba2bfa087ffb2499a3295/src/transformations.js#L61-L69 | train |
asgerf/tscheck | tscore.js | TObject | function TObject(qname, meta) {
this.qname = qname;
this.properties = new Map;
this.modules = new Map;
this.calls = []
this.types = new Map;
this.supers = []
this.typeParameters = []
this.brand = null;
this.meta = {
kind: meta.kind,
origin: meta.origin,
isEnum: f... | javascript | function TObject(qname, meta) {
this.qname = qname;
this.properties = new Map;
this.modules = new Map;
this.calls = []
this.types = new Map;
this.supers = []
this.typeParameters = []
this.brand = null;
this.meta = {
kind: meta.kind,
origin: meta.origin,
isEnum: f... | [
"function",
"TObject",
"(",
"qname",
",",
"meta",
")",
"{",
"this",
".",
"qname",
"=",
"qname",
";",
"this",
".",
"properties",
"=",
"new",
"Map",
";",
"this",
".",
"modules",
"=",
"new",
"Map",
";",
"this",
".",
"calls",
"=",
"[",
"]",
"this",
"... | Object type. | [
"Object",
"type",
"."
] | 7bf73cba5d85ec96fda3f4bda20e47b194de6e08 | https://github.com/asgerf/tscheck/blob/7bf73cba5d85ec96fda3f4bda20e47b194de6e08/tscore.js#L130-L144 | train |
asgerf/tscheck | tscore.js | addModuleMember | function addModuleMember(member, moduleObject, qname) {
current_node = member;
var topLevel = qname === '';
if (member instanceof TypeScript.FunctionDeclaration) {
var obj = moduleObject.getMember(member.name.text())
if (obj instanceof TObject) {
obj.calls.push(parseFunctionType(member))
} el... | javascript | function addModuleMember(member, moduleObject, qname) {
current_node = member;
var topLevel = qname === '';
if (member instanceof TypeScript.FunctionDeclaration) {
var obj = moduleObject.getMember(member.name.text())
if (obj instanceof TObject) {
obj.calls.push(parseFunctionType(member))
} el... | [
"function",
"addModuleMember",
"(",
"member",
",",
"moduleObject",
",",
"qname",
")",
"{",
"current_node",
"=",
"member",
";",
"var",
"topLevel",
"=",
"qname",
"===",
"''",
";",
"if",
"(",
"member",
"instanceof",
"TypeScript",
".",
"FunctionDeclaration",
")",
... | Some names are resolved before merging, others after. Type parameters must be resolved before merging, because merging generic interfaces requires alpha-renaming of type parameters. Names defined in modules must be resolved after merging, because the whole module type is not available until then. | [
"Some",
"names",
"are",
"resolved",
"before",
"merging",
"others",
"after",
".",
"Type",
"parameters",
"must",
"be",
"resolved",
"before",
"merging",
"because",
"merging",
"generic",
"interfaces",
"requires",
"alpha",
"-",
"renaming",
"of",
"type",
"parameters",
... | 7bf73cba5d85ec96fda3f4bda20e47b194de6e08 | https://github.com/asgerf/tscheck/blob/7bf73cba5d85ec96fda3f4bda20e47b194de6e08/tscore.js#L239-L303 | train |
asgerf/tscheck | tscore.js | resolveReference | function resolveReference(x, isModule) {
if (x instanceof TReference) {
if (isBuiltin(x.name))
return new TBuiltin(x.name)
if (x.resolution)
return x.resolution
if (x.resolving)
throw new TypeError("Cyclic reference involving " + x)
x.resolving = true
var t = lookupInScope(x.scope, x.... | javascript | function resolveReference(x, isModule) {
if (x instanceof TReference) {
if (isBuiltin(x.name))
return new TBuiltin(x.name)
if (x.resolution)
return x.resolution
if (x.resolving)
throw new TypeError("Cyclic reference involving " + x)
x.resolving = true
var t = lookupInScope(x.scope, x.... | [
"function",
"resolveReference",
"(",
"x",
",",
"isModule",
")",
"{",
"if",
"(",
"x",
"instanceof",
"TReference",
")",
"{",
"if",
"(",
"isBuiltin",
"(",
"x",
".",
"name",
")",
")",
"return",
"new",
"TBuiltin",
"(",
"x",
".",
"name",
")",
"if",
"(",
... | Resolves a TReference or TMember to a TQualifiedReference | [
"Resolves",
"a",
"TReference",
"or",
"TMember",
"to",
"a",
"TQualifiedReference"
] | 7bf73cba5d85ec96fda3f4bda20e47b194de6e08 | https://github.com/asgerf/tscheck/blob/7bf73cba5d85ec96fda3f4bda20e47b194de6e08/tscore.js#L962-L1015 | train |
asgerf/tscheck | tscore.js | resolveType | function resolveType(x) {
if (x instanceof TReference) {
return resolveReference(x)
} else if (x instanceof TMember) {
return resolveReference(x)
} else if (x instanceof TObject) {
if (x.qname)
return new TQualifiedReference(x.qname) // can happen if a qname was synthesized by resolveReferenc... | javascript | function resolveType(x) {
if (x instanceof TReference) {
return resolveReference(x)
} else if (x instanceof TMember) {
return resolveReference(x)
} else if (x instanceof TObject) {
if (x.qname)
return new TQualifiedReference(x.qname) // can happen if a qname was synthesized by resolveReferenc... | [
"function",
"resolveType",
"(",
"x",
")",
"{",
"if",
"(",
"x",
"instanceof",
"TReference",
")",
"{",
"return",
"resolveReference",
"(",
"x",
")",
"}",
"else",
"if",
"(",
"x",
"instanceof",
"TMember",
")",
"{",
"return",
"resolveReference",
"(",
"x",
")",... | Recursively builds a type where all references have been resolved | [
"Recursively",
"builds",
"a",
"type",
"where",
"all",
"references",
"have",
"been",
"resolved"
] | 7bf73cba5d85ec96fda3f4bda20e47b194de6e08 | https://github.com/asgerf/tscheck/blob/7bf73cba5d85ec96fda3f4bda20e47b194de6e08/tscore.js#L1018-L1048 | train |
asgerf/tscheck | tscheck.js | hasBrand | function hasBrand(value, brand) {
var ctor = lookupPath(brand, function() { return null })
if (!ctor || typeof ctor !== 'object')
return null;
var proto = lookupObject(ctor.key).propertyMap.get('prototype')
if (!proto || !proto.value || typeof proto.value !== 'object')
return null;
while (value && typeof value... | javascript | function hasBrand(value, brand) {
var ctor = lookupPath(brand, function() { return null })
if (!ctor || typeof ctor !== 'object')
return null;
var proto = lookupObject(ctor.key).propertyMap.get('prototype')
if (!proto || !proto.value || typeof proto.value !== 'object')
return null;
while (value && typeof value... | [
"function",
"hasBrand",
"(",
"value",
",",
"brand",
")",
"{",
"var",
"ctor",
"=",
"lookupPath",
"(",
"brand",
",",
"function",
"(",
")",
"{",
"return",
"null",
"}",
")",
"if",
"(",
"!",
"ctor",
"||",
"typeof",
"ctor",
"!==",
"'object'",
")",
"return"... | Returns true if brand is satisfied, false if brand is not satisfied, or null if brand prototype could not be found. | [
"Returns",
"true",
"if",
"brand",
"is",
"satisfied",
"false",
"if",
"brand",
"is",
"not",
"satisfied",
"or",
"null",
"if",
"brand",
"prototype",
"could",
"not",
"be",
"found",
"."
] | 7bf73cba5d85ec96fda3f4bda20e47b194de6e08 | https://github.com/asgerf/tscheck/blob/7bf73cba5d85ec96fda3f4bda20e47b194de6e08/tscheck.js#L984-L997 | train |
asgerf/tscheck | tscheck.js | getEnclosingFunction | function getEnclosingFunction(node) {
while (node.type !== 'FunctionDeclaration' &&
node.type !== 'FunctionExpression' &&
node.type !== 'Program') {
node = node.$parent;
}
return node;
} | javascript | function getEnclosingFunction(node) {
while (node.type !== 'FunctionDeclaration' &&
node.type !== 'FunctionExpression' &&
node.type !== 'Program') {
node = node.$parent;
}
return node;
} | [
"function",
"getEnclosingFunction",
"(",
"node",
")",
"{",
"while",
"(",
"node",
".",
"type",
"!==",
"'FunctionDeclaration'",
"&&",
"node",
".",
"type",
"!==",
"'FunctionExpression'",
"&&",
"node",
".",
"type",
"!==",
"'Program'",
")",
"{",
"node",
"=",
"nod... | Returns the function or program immediately enclosing the given node, possibly the node itself. | [
"Returns",
"the",
"function",
"or",
"program",
"immediately",
"enclosing",
"the",
"given",
"node",
"possibly",
"the",
"node",
"itself",
"."
] | 7bf73cba5d85ec96fda3f4bda20e47b194de6e08 | https://github.com/asgerf/tscheck/blob/7bf73cba5d85ec96fda3f4bda20e47b194de6e08/tscheck.js#L1526-L1533 | train |
asgerf/tscheck | tscheck.js | getEnclosingScope | function getEnclosingScope(node) {
while (node.type !== 'FunctionDeclaration' &&
node.type !== 'FunctionExpression' &&
node.type !== 'CatchClause' &&
node.type !== 'Program') {
node = node.$parent;
}
return node;
} | javascript | function getEnclosingScope(node) {
while (node.type !== 'FunctionDeclaration' &&
node.type !== 'FunctionExpression' &&
node.type !== 'CatchClause' &&
node.type !== 'Program') {
node = node.$parent;
}
return node;
} | [
"function",
"getEnclosingScope",
"(",
"node",
")",
"{",
"while",
"(",
"node",
".",
"type",
"!==",
"'FunctionDeclaration'",
"&&",
"node",
".",
"type",
"!==",
"'FunctionExpression'",
"&&",
"node",
".",
"type",
"!==",
"'CatchClause'",
"&&",
"node",
".",
"type",
... | Returns the function, program or catch clause immediately enclosing the given node, possibly the node itself. | [
"Returns",
"the",
"function",
"program",
"or",
"catch",
"clause",
"immediately",
"enclosing",
"the",
"given",
"node",
"possibly",
"the",
"node",
"itself",
"."
] | 7bf73cba5d85ec96fda3f4bda20e47b194de6e08 | https://github.com/asgerf/tscheck/blob/7bf73cba5d85ec96fda3f4bda20e47b194de6e08/tscheck.js#L1536-L1544 | train |
fengyuanchen/is-vue-component | dist/is-vue-component.esm.js | isElement | function isElement(value) {
return isNonNullObject(value) && value.nodeType === 1 && toString.call(value).indexOf('Element') > -1;
} | javascript | function isElement(value) {
return isNonNullObject(value) && value.nodeType === 1 && toString.call(value).indexOf('Element') > -1;
} | [
"function",
"isElement",
"(",
"value",
")",
"{",
"return",
"isNonNullObject",
"(",
"value",
")",
"&&",
"value",
".",
"nodeType",
"===",
"1",
"&&",
"toString",
".",
"call",
"(",
"value",
")",
".",
"indexOf",
"(",
"'Element'",
")",
">",
"-",
"1",
";",
... | Check if the given value is an element.
@param {*} value - The value to check.
@returns {boolean} Returns `true` if the given value is an element, else `false`. | [
"Check",
"if",
"the",
"given",
"value",
"is",
"an",
"element",
"."
] | 0bf281b28a87899d104f6d528ccbf6272c43d6b9 | https://github.com/fengyuanchen/is-vue-component/blob/0bf281b28a87899d104f6d528ccbf6272c43d6b9/dist/is-vue-component.esm.js#L70-L72 | train |
fengyuanchen/is-vue-component | dist/is-vue-component.esm.js | isVueComponent | function isVueComponent(value) {
return isPlainObject(value) && (isNonEmptyString(value.template) || isFunction(value.render) || isNonEmptyString(value.el) || isElement(value.el) || isVueComponent(value.extends) || isNonEmptyArray(value.mixins) && value.mixins.some(function (val) {
return isVueComponent(val);
}... | javascript | function isVueComponent(value) {
return isPlainObject(value) && (isNonEmptyString(value.template) || isFunction(value.render) || isNonEmptyString(value.el) || isElement(value.el) || isVueComponent(value.extends) || isNonEmptyArray(value.mixins) && value.mixins.some(function (val) {
return isVueComponent(val);
}... | [
"function",
"isVueComponent",
"(",
"value",
")",
"{",
"return",
"isPlainObject",
"(",
"value",
")",
"&&",
"(",
"isNonEmptyString",
"(",
"value",
".",
"template",
")",
"||",
"isFunction",
"(",
"value",
".",
"render",
")",
"||",
"isNonEmptyString",
"(",
"value... | Check if the given value is a valid Vue component.
@param {*} value - The value to check.
@returns {boolean} Returns `true` if the given value is a valid Vue component, else `false`. | [
"Check",
"if",
"the",
"given",
"value",
"is",
"a",
"valid",
"Vue",
"component",
"."
] | 0bf281b28a87899d104f6d528ccbf6272c43d6b9 | https://github.com/fengyuanchen/is-vue-component/blob/0bf281b28a87899d104f6d528ccbf6272c43d6b9/dist/is-vue-component.esm.js#L79-L83 | train |
kevincennis/logbro | lib/logbro.js | initialize | function initialize() {
var flags = [];
Object.keys( levels ).forEach(function( type, level ) {
var method = type.toLowerCase();
exports[ method ] = log.bind( exports, type, level, false );
exports[ method ].json = log.bind( exports, type, level, true );
if ( new RegExp( '\\b' + type + '\\b', 'i' )... | javascript | function initialize() {
var flags = [];
Object.keys( levels ).forEach(function( type, level ) {
var method = type.toLowerCase();
exports[ method ] = log.bind( exports, type, level, false );
exports[ method ].json = log.bind( exports, type, level, true );
if ( new RegExp( '\\b' + type + '\\b', 'i' )... | [
"function",
"initialize",
"(",
")",
"{",
"var",
"flags",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"levels",
")",
".",
"forEach",
"(",
"function",
"(",
"type",
",",
"level",
")",
"{",
"var",
"method",
"=",
"type",
".",
"toLowerCase",
"(",
")"... | set loglevel based on NODE_DEBUG env variable and create exported methods | [
"set",
"loglevel",
"based",
"on",
"NODE_DEBUG",
"env",
"variable",
"and",
"create",
"exported",
"methods"
] | f06d5c774de1e2ae94bb67f15457757530f061a1 | https://github.com/kevincennis/logbro/blob/f06d5c774de1e2ae94bb67f15457757530f061a1/lib/logbro.js#L31-L44 | train |
kevincennis/logbro | lib/logbro.js | format | function format( type, args ) {
var now = new Date().toISOString(),
tmpl = '[%s] %s: %s\n',
msg;
msg = args[ 0 ] instanceof Error ? args[ 0 ].stack :
util.format.apply( util, args );
return util.format( tmpl, now, type, msg );
} | javascript | function format( type, args ) {
var now = new Date().toISOString(),
tmpl = '[%s] %s: %s\n',
msg;
msg = args[ 0 ] instanceof Error ? args[ 0 ].stack :
util.format.apply( util, args );
return util.format( tmpl, now, type, msg );
} | [
"function",
"format",
"(",
"type",
",",
"args",
")",
"{",
"var",
"now",
"=",
"new",
"Date",
"(",
")",
".",
"toISOString",
"(",
")",
",",
"tmpl",
"=",
"'[%s] %s: %s\\n'",
",",
"msg",
";",
"msg",
"=",
"args",
"[",
"0",
"]",
"instanceof",
"Error",
"?"... | format log messages | [
"format",
"log",
"messages"
] | f06d5c774de1e2ae94bb67f15457757530f061a1 | https://github.com/kevincennis/logbro/blob/f06d5c774de1e2ae94bb67f15457757530f061a1/lib/logbro.js#L47-L56 | train |
xiaoyann/deploy-kit | bin/parse.js | readConfig | function readConfig() {
let options = {}
let cFile = ''
if (program.config) {
cFile = path.resolve(cwd, program.config)
if (fs.existsSync(cFile)) {
Object.assign(config, require(cFile))
} else {
console.warn(`Cannot find configuration file ${program.config}`)
process.exit()
}
... | javascript | function readConfig() {
let options = {}
let cFile = ''
if (program.config) {
cFile = path.resolve(cwd, program.config)
if (fs.existsSync(cFile)) {
Object.assign(config, require(cFile))
} else {
console.warn(`Cannot find configuration file ${program.config}`)
process.exit()
}
... | [
"function",
"readConfig",
"(",
")",
"{",
"let",
"options",
"=",
"{",
"}",
"let",
"cFile",
"=",
"''",
"if",
"(",
"program",
".",
"config",
")",
"{",
"cFile",
"=",
"path",
".",
"resolve",
"(",
"cwd",
",",
"program",
".",
"config",
")",
"if",
"(",
"... | read configuration from local file | [
"read",
"configuration",
"from",
"local",
"file"
] | df1fe0ac2dba02d78661ffbbe7c92e4c23aaed03 | https://github.com/xiaoyann/deploy-kit/blob/df1fe0ac2dba02d78661ffbbe7c92e4c23aaed03/bin/parse.js#L57-L92 | train |
vphantom/js-jrpc | jrpc.js | shutdown | function shutdown() {
var instance = this;
instance.active = false;
instance.transmitter = null;
instance.remoteTimeout = 0;
instance.localTimeout = 0;
instance.localComponents = {};
instance.remoteComponents = {};
instance.outbox.requests.length = 0;
instance.outbox.responses.length = 0;
instance.... | javascript | function shutdown() {
var instance = this;
instance.active = false;
instance.transmitter = null;
instance.remoteTimeout = 0;
instance.localTimeout = 0;
instance.localComponents = {};
instance.remoteComponents = {};
instance.outbox.requests.length = 0;
instance.outbox.responses.length = 0;
instance.... | [
"function",
"shutdown",
"(",
")",
"{",
"var",
"instance",
"=",
"this",
";",
"instance",
".",
"active",
"=",
"false",
";",
"instance",
".",
"transmitter",
"=",
"null",
";",
"instance",
".",
"remoteTimeout",
"=",
"0",
";",
"instance",
".",
"localTimeout",
... | Semi-destructor for limbo conditions
When we lose connection permanently, we help garbage collection by removing
as many references as we can, including cancelling any outstanding timers.
We may still get some callbacks, but they will immediately return.
@return {undefined} No return value | [
"Semi",
"-",
"destructor",
"for",
"limbo",
"conditions"
] | d9f4c040418b24b92dafc124613bd699015e620e | https://github.com/vphantom/js-jrpc/blob/d9f4c040418b24b92dafc124613bd699015e620e/jrpc.js#L77-L102 | train |
vphantom/js-jrpc | jrpc.js | confirmTransmit | function confirmTransmit(outpacket, err) {
if (this.active && err) {
// Roll it all back into outbox (which may not be empty anymore)
if (outpacket.responses.length > 0) {
Array.prototype.push.apply(this.outbox.responses, outpacket.responses);
}
if (outpacket.requests.length > 0) {
Array.p... | javascript | function confirmTransmit(outpacket, err) {
if (this.active && err) {
// Roll it all back into outbox (which may not be empty anymore)
if (outpacket.responses.length > 0) {
Array.prototype.push.apply(this.outbox.responses, outpacket.responses);
}
if (outpacket.requests.length > 0) {
Array.p... | [
"function",
"confirmTransmit",
"(",
"outpacket",
",",
"err",
")",
"{",
"if",
"(",
"this",
".",
"active",
"&&",
"err",
")",
"{",
"// Roll it all back into outbox (which may not be empty anymore)",
"if",
"(",
"outpacket",
".",
"responses",
".",
"length",
">",
"0",
... | Handle transmission errors
@type {JRPC~transmitConfirmCallback}
@param {Object} outpacket Outbox data of the attempted transmission
@param {boolean} err Anything non-falsey means an error occured
@return {undefined} No return value | [
"Handle",
"transmission",
"errors"
] | d9f4c040418b24b92dafc124613bd699015e620e | https://github.com/vphantom/js-jrpc/blob/d9f4c040418b24b92dafc124613bd699015e620e/jrpc.js#L207-L217 | train |
vphantom/js-jrpc | jrpc.js | receive | function receive(msg) {
var requests = [];
var responses = [];
if (!this.active) {
return this;
}
// If we got JSON, parse it
if (typeof msg === 'string') {
try {
msg = JSON.parse(msg);
} catch (e) {
// The specification doesn't force us to respond in error, ignoring
return t... | javascript | function receive(msg) {
var requests = [];
var responses = [];
if (!this.active) {
return this;
}
// If we got JSON, parse it
if (typeof msg === 'string') {
try {
msg = JSON.parse(msg);
} catch (e) {
// The specification doesn't force us to respond in error, ignoring
return t... | [
"function",
"receive",
"(",
"msg",
")",
"{",
"var",
"requests",
"=",
"[",
"]",
";",
"var",
"responses",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"this",
".",
"active",
")",
"{",
"return",
"this",
";",
"}",
"// If we got JSON, parse it",
"if",
"(",
"typeof... | Handle incoming message
@param {string} msg JSON message to parse
@return {JRPC} This instance, for chaining | [
"Handle",
"incoming",
"message"
] | d9f4c040418b24b92dafc124613bd699015e620e | https://github.com/vphantom/js-jrpc/blob/d9f4c040418b24b92dafc124613bd699015e620e/jrpc.js#L226-L275 | train |
vphantom/js-jrpc | jrpc.js | upgrade | function upgrade() {
if (!this.active) {
return this;
}
return this.call(
'system.listComponents',
this.localComponents,
(function(err, result) {
if (!err && typeof result === 'object') {
this.remoteComponents = result;
this.remoteComponents['system._upgraded'] = true;
... | javascript | function upgrade() {
if (!this.active) {
return this;
}
return this.call(
'system.listComponents',
this.localComponents,
(function(err, result) {
if (!err && typeof result === 'object') {
this.remoteComponents = result;
this.remoteComponents['system._upgraded'] = true;
... | [
"function",
"upgrade",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"active",
")",
"{",
"return",
"this",
";",
"}",
"return",
"this",
".",
"call",
"(",
"'system.listComponents'",
",",
"this",
".",
"localComponents",
",",
"(",
"function",
"(",
"err",
","... | Handshake to discover remote extended capabilities
@return {JRPC} This instance, for chaining | [
"Handshake",
"to",
"discover",
"remote",
"extended",
"capabilities"
] | d9f4c040418b24b92dafc124613bd699015e620e | https://github.com/vphantom/js-jrpc/blob/d9f4c040418b24b92dafc124613bd699015e620e/jrpc.js#L282-L296 | train |
vphantom/js-jrpc | jrpc.js | call | function call(methodName, params, next) {
var request = {
jsonrpc: '2.0',
method : methodName
};
if (!this.active) {
return this;
}
if (typeof params === 'function') {
next = params;
params = null;
}
if (
'system._upgraded' in this.remoteComponents
&& !(methodName in this.re... | javascript | function call(methodName, params, next) {
var request = {
jsonrpc: '2.0',
method : methodName
};
if (!this.active) {
return this;
}
if (typeof params === 'function') {
next = params;
params = null;
}
if (
'system._upgraded' in this.remoteComponents
&& !(methodName in this.re... | [
"function",
"call",
"(",
"methodName",
",",
"params",
",",
"next",
")",
"{",
"var",
"request",
"=",
"{",
"jsonrpc",
":",
"'2.0'",
",",
"method",
":",
"methodName",
"}",
";",
"if",
"(",
"!",
"this",
".",
"active",
")",
"{",
"return",
"this",
";",
"}... | Client side
Queue up a remote method call
@param {string} methodName Name of method to call
@param {(Object|Array|null)} [params] Parameters
@param {JRPC~receiveCallback} [next] Callback to receive result
@return {JRPC} This instance, for chaining | [
"Client",
"side",
"Queue",
"up",
"a",
"remote",
"method",
"call"
] | d9f4c040418b24b92dafc124613bd699015e620e | https://github.com/vphantom/js-jrpc/blob/d9f4c040418b24b92dafc124613bd699015e620e/jrpc.js#L310-L376 | train |
vphantom/js-jrpc | jrpc.js | deliverResponse | function deliverResponse(res) {
var err = false;
var result = null;
if (this.active && 'id' in res && res['id'] in this.outTimers) {
clearTimeout(this.outTimers[res['id']]); // Passing true instead of a timeout is safe
delete this.outTimers[res['id']];
} else {
// Silently ignoring second response... | javascript | function deliverResponse(res) {
var err = false;
var result = null;
if (this.active && 'id' in res && res['id'] in this.outTimers) {
clearTimeout(this.outTimers[res['id']]); // Passing true instead of a timeout is safe
delete this.outTimers[res['id']];
} else {
// Silently ignoring second response... | [
"function",
"deliverResponse",
"(",
"res",
")",
"{",
"var",
"err",
"=",
"false",
";",
"var",
"result",
"=",
"null",
";",
"if",
"(",
"this",
".",
"active",
"&&",
"'id'",
"in",
"res",
"&&",
"res",
"[",
"'id'",
"]",
"in",
"this",
".",
"outTimers",
")"... | Callback invoked when remote results are ready
@callback JRPC~receiveCallback
@param {boolean} err True if the result is an error or unavailable
@param {Object} result The result from the remote method
@return {undefined} No return value
Deliver a received result
@param {Object} res The single result to ... | [
"Callback",
"invoked",
"when",
"remote",
"results",
"are",
"ready"
] | d9f4c040418b24b92dafc124613bd699015e620e | https://github.com/vphantom/js-jrpc/blob/d9f4c040418b24b92dafc124613bd699015e620e/jrpc.js#L396-L418 | train |
vphantom/js-jrpc | jrpc.js | expose | function expose(subject, callback) {
var name;
if (!this.active) {
return this;
}
if (typeof subject === 'string') {
this.localComponents[subject] = true;
this.exposed[subject] = callback;
} else if (typeof subject === 'object') {
for (name in subject) {
if (subject.hasOwnProperty(name... | javascript | function expose(subject, callback) {
var name;
if (!this.active) {
return this;
}
if (typeof subject === 'string') {
this.localComponents[subject] = true;
this.exposed[subject] = callback;
} else if (typeof subject === 'object') {
for (name in subject) {
if (subject.hasOwnProperty(name... | [
"function",
"expose",
"(",
"subject",
",",
"callback",
")",
"{",
"var",
"name",
";",
"if",
"(",
"!",
"this",
".",
"active",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"typeof",
"subject",
"===",
"'string'",
")",
"{",
"this",
".",
"localComponen... | Server side
Expose a single or collection of methods to remote end
@param {(Object|String)} subject Name of method or direct object
@param {JRPC~serviceCallback} [callback] Callback to handle requests
@return {JRPC} This instance, for chaining | [
"Server",
"side",
"Expose",
"a",
"single",
"or",
"collection",
"of",
"methods",
"to",
"remote",
"end"
] | d9f4c040418b24b92dafc124613bd699015e620e | https://github.com/vphantom/js-jrpc/blob/d9f4c040418b24b92dafc124613bd699015e620e/jrpc.js#L431-L451 | train |
vphantom/js-jrpc | jrpc.js | serveRequest | function serveRequest(request) {
var id = null;
var params = null;
if (!this.active || typeof request !== 'object' || request === null) {
return;
}
if (!(typeof request.jsonrpc === 'string' && request.jsonrpc === '2.0')) {
return;
}
id = (typeof request.id !== 'undefined' ? request.id : null);
... | javascript | function serveRequest(request) {
var id = null;
var params = null;
if (!this.active || typeof request !== 'object' || request === null) {
return;
}
if (!(typeof request.jsonrpc === 'string' && request.jsonrpc === '2.0')) {
return;
}
id = (typeof request.id !== 'undefined' ? request.id : null);
... | [
"function",
"serveRequest",
"(",
"request",
")",
"{",
"var",
"id",
"=",
"null",
";",
"var",
"params",
"=",
"null",
";",
"if",
"(",
"!",
"this",
".",
"active",
"||",
"typeof",
"request",
"!==",
"'object'",
"||",
"request",
"===",
"null",
")",
"{",
"re... | Callback invoked to handle calls to our side's methods
@callback JRPC~serviceCallback
@param {(Object|Array|null)} params Parameters received
@param {JRPC~serviceResultCallback} next Callback to send your result
@return {undefined} No return value
Serve a request we received
@param {Object} request Reque... | [
"Callback",
"invoked",
"to",
"handle",
"calls",
"to",
"our",
"side",
"s",
"methods"
] | d9f4c040418b24b92dafc124613bd699015e620e | https://github.com/vphantom/js-jrpc/blob/d9f4c040418b24b92dafc124613bd699015e620e/jrpc.js#L471-L536 | train |
vphantom/js-jrpc | jrpc.js | sendResponse | function sendResponse(id, err, result) {
var response = {
jsonrpc: '2.0',
id : id
};
if (id === null) {
return;
}
if (this.active && id in this.localTimers) {
clearTimeout(this.localTimers[id]); // Passing true instead of a timeout is safe
delete this.localTimers[id];
} else {
... | javascript | function sendResponse(id, err, result) {
var response = {
jsonrpc: '2.0',
id : id
};
if (id === null) {
return;
}
if (this.active && id in this.localTimers) {
clearTimeout(this.localTimers[id]); // Passing true instead of a timeout is safe
delete this.localTimers[id];
} else {
... | [
"function",
"sendResponse",
"(",
"id",
",",
"err",
",",
"result",
")",
"{",
"var",
"response",
"=",
"{",
"jsonrpc",
":",
"'2.0'",
",",
"id",
":",
"id",
"}",
";",
"if",
"(",
"id",
"===",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
"... | Handle local method results
@type {JRPC~serviceResultCallback}
@param {number} id Serial number, bound, no need to supply
@param {boolean} err Anything non-falsey means error and is sent
@param {Object} result Any result you wish to produce
@return {undefined} No return value | [
"Handle",
"local",
"method",
"results"
] | d9f4c040418b24b92dafc124613bd699015e620e | https://github.com/vphantom/js-jrpc/blob/d9f4c040418b24b92dafc124613bd699015e620e/jrpc.js#L549-L603 | train |
ckknight/escort | lib/escort-client.js | function (route, converters) {
var literals = route.literals;
var params = route.params;
var conv = [];
var fun = "";
fun += "var generate = function (params) {\n";
fun += " if (arguments.length === 1 && typeof params === 'object' && params.constructo... | javascript | function (route, converters) {
var literals = route.literals;
var params = route.params;
var conv = [];
var fun = "";
fun += "var generate = function (params) {\n";
fun += " if (arguments.length === 1 && typeof params === 'object' && params.constructo... | [
"function",
"(",
"route",
",",
"converters",
")",
"{",
"var",
"literals",
"=",
"route",
".",
"literals",
";",
"var",
"params",
"=",
"route",
".",
"params",
";",
"var",
"conv",
"=",
"[",
"]",
";",
"var",
"fun",
"=",
"\"\"",
";",
"fun",
"+=",
"\"var ... | Dynamically create a url-generation function.
@param {Object} route A descriptor for the route in question
@param {Object} converters A map of converter name to converter factory.
@return {Function} A function which will generate a URL.
@api private
@example generateUrlFunction({ literals: ["/prefix"], params: [ { na... | [
"Dynamically",
"create",
"a",
"url",
"-",
"generation",
"function",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort-client.js#L40-L92 | train | |
ckknight/escort | lib/escort-client.js | function (routes, converters) {
var staticRoute, dynamicRoute;
// we traverse backwards because the beginning ones take precedence and thus can override.
for (var i = routes.length - 1; i >= 0; i -= 1) {
var route = routes[i];
if (route.path) {
... | javascript | function (routes, converters) {
var staticRoute, dynamicRoute;
// we traverse backwards because the beginning ones take precedence and thus can override.
for (var i = routes.length - 1; i >= 0; i -= 1) {
var route = routes[i];
if (route.path) {
... | [
"function",
"(",
"routes",
",",
"converters",
")",
"{",
"var",
"staticRoute",
",",
"dynamicRoute",
";",
"// we traverse backwards because the beginning ones take precedence and thus can override.",
"for",
"(",
"var",
"i",
"=",
"routes",
".",
"length",
"-",
"1",
";",
"... | Generate a URL function based on the provided routes.
@param {Array} routes An array of route descriptors
@param {Object} converters A map of type to converter factory.
@return {Function} A function that will generate a URL, or null if routes is blank.
@api private | [
"Generate",
"a",
"URL",
"function",
"based",
"on",
"the",
"provided",
"routes",
"."
] | 6afbe01d48881b7eaf092e7c2307ebd8ee65497e | https://github.com/ckknight/escort/blob/6afbe01d48881b7eaf092e7c2307ebd8ee65497e/lib/escort-client.js#L102-L140 | train | |
wala/jsdelta | src/file_util.js | getTempFileName | function getTempFileName(state) {
var fn = state.tmp_dir + "/delta_js_" + state.round + "." + state.ext;
state.round++;
return fn;
} | javascript | function getTempFileName(state) {
var fn = state.tmp_dir + "/delta_js_" + state.round + "." + state.ext;
state.round++;
return fn;
} | [
"function",
"getTempFileName",
"(",
"state",
")",
"{",
"var",
"fn",
"=",
"state",
".",
"tmp_dir",
"+",
"\"/delta_js_\"",
"+",
"state",
".",
"round",
"+",
"\".\"",
"+",
"state",
".",
"ext",
";",
"state",
".",
"round",
"++",
";",
"return",
"fn",
";",
"... | get name of current test case | [
"get",
"name",
"of",
"current",
"test",
"case"
] | 355febea1ee23e9e909ba2bfa087ffb2499a3295 | https://github.com/wala/jsdelta/blob/355febea1ee23e9e909ba2bfa087ffb2499a3295/src/file_util.js#L8-L12 | train |
wala/jsdelta | src/file_util.js | copyToOut | function copyToOut(src, out, multiFileMode) {
try {
fs.copySync(src, out);
fs.statSync(out)
return out;
} catch (err) {
}
} | javascript | function copyToOut(src, out, multiFileMode) {
try {
fs.copySync(src, out);
fs.statSync(out)
return out;
} catch (err) {
}
} | [
"function",
"copyToOut",
"(",
"src",
",",
"out",
",",
"multiFileMode",
")",
"{",
"try",
"{",
"fs",
".",
"copySync",
"(",
"src",
",",
"out",
")",
";",
"fs",
".",
"statSync",
"(",
"out",
")",
"return",
"out",
";",
"}",
"catch",
"(",
"err",
")",
"{"... | Return path to file if copy was successful. Return undefined otherwise. | [
"Return",
"path",
"to",
"file",
"if",
"copy",
"was",
"successful",
".",
"Return",
"undefined",
"otherwise",
"."
] | 355febea1ee23e9e909ba2bfa087ffb2499a3295 | https://github.com/wala/jsdelta/blob/355febea1ee23e9e909ba2bfa087ffb2499a3295/src/file_util.js#L62-L69 | train |
WebReflection/es-class | build/es-class.max.amd.js | function (method) {
var
str = '' + method,
i = str.indexOf(SUPER)
;
return i < 0 ?
false :
isBoundary(str.charCodeAt(i - 1)) &&
isBoundary(str.charCodeAt(i + 5));
} | javascript | function (method) {
var
str = '' + method,
i = str.indexOf(SUPER)
;
return i < 0 ?
false :
isBoundary(str.charCodeAt(i - 1)) &&
isBoundary(str.charCodeAt(i + 5));
} | [
"function",
"(",
"method",
")",
"{",
"var",
"str",
"=",
"''",
"+",
"method",
",",
"i",
"=",
"str",
".",
"indexOf",
"(",
"SUPER",
")",
";",
"return",
"i",
"<",
"0",
"?",
"false",
":",
"isBoundary",
"(",
"str",
".",
"charCodeAt",
"(",
"i",
"-",
"... | all other JS engines should be just fine | [
"all",
"other",
"JS",
"engines",
"should",
"be",
"just",
"fine"
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L159-L168 | train | |
WebReflection/es-class | build/es-class.max.amd.js | addMixins | function addMixins(mixins, target, inherits, isNOTExtendingNative) {
for (var
source,
init = [],
i = 0; i < mixins.length; i++
) {
source = transformMixin(mixins[i]);
if (hOP.call(source, INIT)) {
init.push(source[INIT]);
}
copyOwn(source, target, inherits, fals... | javascript | function addMixins(mixins, target, inherits, isNOTExtendingNative) {
for (var
source,
init = [],
i = 0; i < mixins.length; i++
) {
source = transformMixin(mixins[i]);
if (hOP.call(source, INIT)) {
init.push(source[INIT]);
}
copyOwn(source, target, inherits, fals... | [
"function",
"addMixins",
"(",
"mixins",
",",
"target",
",",
"inherits",
",",
"isNOTExtendingNative",
")",
"{",
"for",
"(",
"var",
"source",
",",
"init",
"=",
"[",
"]",
",",
"i",
"=",
"0",
";",
"i",
"<",
"mixins",
".",
"length",
";",
"i",
"++",
")",... | copy all imported enumerable methods and properties | [
"copy",
"all",
"imported",
"enumerable",
"methods",
"and",
"properties"
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L219-L232 | train |
WebReflection/es-class | build/es-class.max.amd.js | copyMerged | function copyMerged(source, target) {
for (var
key, descriptor, value, tvalue,
names = oK(source),
i = 0; i < names.length; i++
) {
key = names[i];
descriptor = gOPD(source, key);
// target already has this property
if (hOP.call(target, key)) {
// verify the des... | javascript | function copyMerged(source, target) {
for (var
key, descriptor, value, tvalue,
names = oK(source),
i = 0; i < names.length; i++
) {
key = names[i];
descriptor = gOPD(source, key);
// target already has this property
if (hOP.call(target, key)) {
// verify the des... | [
"function",
"copyMerged",
"(",
"source",
",",
"target",
")",
"{",
"for",
"(",
"var",
"key",
",",
"descriptor",
",",
"value",
",",
"tvalue",
",",
"names",
"=",
"oK",
"(",
"source",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"names",
".",
"length",
";... | given two objects, performs a deep copy per each property not present in the target otherwise merges, without overwriting, all properties within the object | [
"given",
"two",
"objects",
"performs",
"a",
"deep",
"copy",
"per",
"each",
"property",
"not",
"present",
"in",
"the",
"target",
"otherwise",
"merges",
"without",
"overwriting",
"all",
"properties",
"within",
"the",
"object"
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L256-L292 | train |
WebReflection/es-class | build/es-class.max.amd.js | copyOwn | function copyOwn(source, target, inherits, publicStatic, allowInit, isNOTExtendingNative) {
for (var
key,
noFunctionCheck = typeof source !== 'function',
names = oK(source),
i = 0; i < names.length; i++
) {
key = names[i];
if (
(noFunctionCheck || indexOf.call(nativeF... | javascript | function copyOwn(source, target, inherits, publicStatic, allowInit, isNOTExtendingNative) {
for (var
key,
noFunctionCheck = typeof source !== 'function',
names = oK(source),
i = 0; i < names.length; i++
) {
key = names[i];
if (
(noFunctionCheck || indexOf.call(nativeF... | [
"function",
"copyOwn",
"(",
"source",
",",
"target",
",",
"inherits",
",",
"publicStatic",
",",
"allowInit",
",",
"isNOTExtendingNative",
")",
"{",
"for",
"(",
"var",
"key",
",",
"noFunctionCheck",
"=",
"typeof",
"source",
"!==",
"'function'",
",",
"names",
... | configure source own properties in the target | [
"configure",
"source",
"own",
"properties",
"in",
"the",
"target"
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L295-L313 | train |
WebReflection/es-class | build/es-class.max.amd.js | copyValueIfObject | function copyValueIfObject(where, how) {
var what = where[VALUE];
if (isObject(what)) {
where[VALUE] = how(what);
}
} | javascript | function copyValueIfObject(where, how) {
var what = where[VALUE];
if (isObject(what)) {
where[VALUE] = how(what);
}
} | [
"function",
"copyValueIfObject",
"(",
"where",
",",
"how",
")",
"{",
"var",
"what",
"=",
"where",
"[",
"VALUE",
"]",
";",
"if",
"(",
"isObject",
"(",
"what",
")",
")",
"{",
"where",
"[",
"VALUE",
"]",
"=",
"how",
"(",
"what",
")",
";",
"}",
"}"
] | shortcut to copy objects into descriptor.value | [
"shortcut",
"to",
"copy",
"objects",
"into",
"descriptor",
".",
"value"
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L316-L321 | train |
WebReflection/es-class | build/es-class.max.amd.js | createConstructor | function createConstructor(hasParentPrototype, parent) {
var Class = function Class() {};
return hasParentPrototype && ('' + parent) !== ('' + Class) ?
function Class() {
return parent.apply(this, arguments);
} :
Class
;
} | javascript | function createConstructor(hasParentPrototype, parent) {
var Class = function Class() {};
return hasParentPrototype && ('' + parent) !== ('' + Class) ?
function Class() {
return parent.apply(this, arguments);
} :
Class
;
} | [
"function",
"createConstructor",
"(",
"hasParentPrototype",
",",
"parent",
")",
"{",
"var",
"Class",
"=",
"function",
"Class",
"(",
")",
"{",
"}",
";",
"return",
"hasParentPrototype",
"&&",
"(",
"''",
"+",
"parent",
")",
"!==",
"(",
"''",
"+",
"Class",
"... | return the right constructor analyzing the parent. if the parent is empty there is no need to call it. | [
"return",
"the",
"right",
"constructor",
"analyzing",
"the",
"parent",
".",
"if",
"the",
"parent",
"is",
"empty",
"there",
"is",
"no",
"need",
"to",
"call",
"it",
"."
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L326-L334 | train |
WebReflection/es-class | build/es-class.max.amd.js | define | function define(target, key, value, publicStatic) {
var configurable = isConfigurable(key, publicStatic);
defineProperty(target, key, {
enumerable: false, // was: publicStatic,
configurable: configurable,
writable: configurable,
value: value
});
} | javascript | function define(target, key, value, publicStatic) {
var configurable = isConfigurable(key, publicStatic);
defineProperty(target, key, {
enumerable: false, // was: publicStatic,
configurable: configurable,
writable: configurable,
value: value
});
} | [
"function",
"define",
"(",
"target",
",",
"key",
",",
"value",
",",
"publicStatic",
")",
"{",
"var",
"configurable",
"=",
"isConfigurable",
"(",
"key",
",",
"publicStatic",
")",
";",
"defineProperty",
"(",
"target",
",",
"key",
",",
"{",
"enumerable",
":",... | common defineProperty wrapper | [
"common",
"defineProperty",
"wrapper"
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L337-L345 | train |
WebReflection/es-class | build/es-class.max.amd.js | isNotASpecialKey | function isNotASpecialKey(key, allowInit) {
return key !== CONSTRUCTOR &&
key !== EXTENDS &&
key !== IMPLEMENTS &&
// Blackberry 7 and old WebKit bug only:
// user defined functions have
// enumerable prototype and constructor
key !== PROTOT... | javascript | function isNotASpecialKey(key, allowInit) {
return key !== CONSTRUCTOR &&
key !== EXTENDS &&
key !== IMPLEMENTS &&
// Blackberry 7 and old WebKit bug only:
// user defined functions have
// enumerable prototype and constructor
key !== PROTOT... | [
"function",
"isNotASpecialKey",
"(",
"key",
",",
"allowInit",
")",
"{",
"return",
"key",
"!==",
"CONSTRUCTOR",
"&&",
"key",
"!==",
"EXTENDS",
"&&",
"key",
"!==",
"IMPLEMENTS",
"&&",
"// Blackberry 7 and old WebKit bug only:",
"// user defined functions have",
"// enum... | verifies a key is not special for the class | [
"verifies",
"a",
"key",
"is",
"not",
"special",
"for",
"the",
"class"
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L364-L376 | train |
WebReflection/es-class | build/es-class.max.amd.js | isPublicStatic | function isPublicStatic(key) {
for(var c, i = 0; i < key.length; i++) {
c = key.charCodeAt(i);
if ((c < 65 || 90 < c) && c !== 95) {
return false;
}
}
return true;
} | javascript | function isPublicStatic(key) {
for(var c, i = 0; i < key.length; i++) {
c = key.charCodeAt(i);
if ((c < 65 || 90 < c) && c !== 95) {
return false;
}
}
return true;
} | [
"function",
"isPublicStatic",
"(",
"key",
")",
"{",
"for",
"(",
"var",
"c",
",",
"i",
"=",
"0",
";",
"i",
"<",
"key",
".",
"length",
";",
"i",
"++",
")",
"{",
"c",
"=",
"key",
".",
"charCodeAt",
"(",
"i",
")",
";",
"if",
"(",
"(",
"c",
"<",... | verifies the entire string is upper case and contains eventually an underscore used to avoid RegExp for non RegExp aware environment | [
"verifies",
"the",
"entire",
"string",
"is",
"upper",
"case",
"and",
"contains",
"eventually",
"an",
"underscore",
"used",
"to",
"avoid",
"RegExp",
"for",
"non",
"RegExp",
"aware",
"environment"
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L387-L395 | train |
WebReflection/es-class | build/es-class.max.amd.js | transformMixin | function transformMixin(trait) {
if (isObject(trait)) return trait;
else {
var i, key, keys, object, proto;
if (trait.isClass) {
if (trait.length) {
warn((trait.name || 'Class') + ' should not expect arguments');
}
for (
object = {init: trait},
p... | javascript | function transformMixin(trait) {
if (isObject(trait)) return trait;
else {
var i, key, keys, object, proto;
if (trait.isClass) {
if (trait.length) {
warn((trait.name || 'Class') + ' should not expect arguments');
}
for (
object = {init: trait},
p... | [
"function",
"transformMixin",
"(",
"trait",
")",
"{",
"if",
"(",
"isObject",
"(",
"trait",
")",
")",
"return",
"trait",
";",
"else",
"{",
"var",
"i",
",",
"key",
",",
"keys",
",",
"object",
",",
"proto",
";",
"if",
"(",
"trait",
".",
"isClass",
")"... | will eventually convert classes or constructors into trait objects, before assigning them as such | [
"will",
"eventually",
"convert",
"classes",
"or",
"constructors",
"into",
"trait",
"objects",
"before",
"assigning",
"them",
"as",
"such"
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L399-L443 | train |
WebReflection/es-class | build/es-class.max.amd.js | setProperty | function setProperty(inherits, target, key, descriptor, publicStatic, isNOTExtendingNative) {
var
hasValue = hOP.call(descriptor, VALUE),
configurable,
value
;
if (publicStatic) {
if (hOP.call(target, key)) {
// in case the value is not a static one
if (
inh... | javascript | function setProperty(inherits, target, key, descriptor, publicStatic, isNOTExtendingNative) {
var
hasValue = hOP.call(descriptor, VALUE),
configurable,
value
;
if (publicStatic) {
if (hOP.call(target, key)) {
// in case the value is not a static one
if (
inh... | [
"function",
"setProperty",
"(",
"inherits",
",",
"target",
",",
"key",
",",
"descriptor",
",",
"publicStatic",
",",
"isNOTExtendingNative",
")",
"{",
"var",
"hasValue",
"=",
"hOP",
".",
"call",
"(",
"descriptor",
",",
"VALUE",
")",
",",
"configurable",
",",
... | set a property via defineProperty using a common descriptor only if properties where not defined yet. If publicStatic is true, properties are both non configurable and non writable | [
"set",
"a",
"property",
"via",
"defineProperty",
"using",
"a",
"common",
"descriptor",
"only",
"if",
"properties",
"where",
"not",
"defined",
"yet",
".",
"If",
"publicStatic",
"is",
"true",
"properties",
"are",
"both",
"non",
"configurable",
"and",
"non",
"wri... | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L448-L485 | train |
WebReflection/es-class | build/es-class.max.amd.js | verifyImplementations | function verifyImplementations(interfaces, target) {
for (var
current,
key,
i = 0; i < interfaces.length; i++
) {
current = interfaces[i];
for (key in current) {
if (hOP.call(current, key) && !hOP.call(target, key)) {
warn(key.toString() + ' is not implemented');
... | javascript | function verifyImplementations(interfaces, target) {
for (var
current,
key,
i = 0; i < interfaces.length; i++
) {
current = interfaces[i];
for (key in current) {
if (hOP.call(current, key) && !hOP.call(target, key)) {
warn(key.toString() + ' is not implemented');
... | [
"function",
"verifyImplementations",
"(",
"interfaces",
",",
"target",
")",
"{",
"for",
"(",
"var",
"current",
",",
"key",
",",
"i",
"=",
"0",
";",
"i",
"<",
"interfaces",
".",
"length",
";",
"i",
"++",
")",
"{",
"current",
"=",
"interfaces",
"[",
"i... | basic check against expected properties or methods used when `implements` is used | [
"basic",
"check",
"against",
"expected",
"properties",
"or",
"methods",
"used",
"when",
"implements",
"is",
"used"
] | 8e3f3b65a67955d11e15820e8f44e2cdaac4bd50 | https://github.com/WebReflection/es-class/blob/8e3f3b65a67955d11e15820e8f44e2cdaac4bd50/build/es-class.max.amd.js#L489-L502 | train |
yoshuawuyts/vel | index.js | vel | function vel (rend) {
assert.equal(typeof rend, 'function')
var update = null
render.toString = toString
render.render = render
render.vtree = vtree
return render
// render the element's vdom tree to DOM nodes
// which can be mounted on the DOM
// any? -> DOMNode
function render (state) {
if (... | javascript | function vel (rend) {
assert.equal(typeof rend, 'function')
var update = null
render.toString = toString
render.render = render
render.vtree = vtree
return render
// render the element's vdom tree to DOM nodes
// which can be mounted on the DOM
// any? -> DOMNode
function render (state) {
if (... | [
"function",
"vel",
"(",
"rend",
")",
"{",
"assert",
".",
"equal",
"(",
"typeof",
"rend",
",",
"'function'",
")",
"var",
"update",
"=",
"null",
"render",
".",
"toString",
"=",
"toString",
"render",
".",
"render",
"=",
"render",
"render",
".",
"vtree",
"... | initialize a new virtual element fn -> null | [
"initialize",
"a",
"new",
"virtual",
"element",
"fn",
"-",
">",
"null"
] | 7c8b701da8a034937150b76974754d6c0fb1aef0 | https://github.com/yoshuawuyts/vel/blob/7c8b701da8a034937150b76974754d6c0fb1aef0/index.js#L18-L48 | train |
yoshuawuyts/vel | index.js | render | function render (state) {
if (update) return update(state)
const loop = mainLoop(state, renderFn(rend), vdom)
update = loop.update
return loop.target
} | javascript | function render (state) {
if (update) return update(state)
const loop = mainLoop(state, renderFn(rend), vdom)
update = loop.update
return loop.target
} | [
"function",
"render",
"(",
"state",
")",
"{",
"if",
"(",
"update",
")",
"return",
"update",
"(",
"state",
")",
"const",
"loop",
"=",
"mainLoop",
"(",
"state",
",",
"renderFn",
"(",
"rend",
")",
",",
"vdom",
")",
"update",
"=",
"loop",
".",
"update",
... | render the element's vdom tree to DOM nodes which can be mounted on the DOM any? -> DOMNode | [
"render",
"the",
"element",
"s",
"vdom",
"tree",
"to",
"DOM",
"nodes",
"which",
"can",
"be",
"mounted",
"on",
"the",
"DOM",
"any?",
"-",
">",
"DOMNode"
] | 7c8b701da8a034937150b76974754d6c0fb1aef0 | https://github.com/yoshuawuyts/vel/blob/7c8b701da8a034937150b76974754d6c0fb1aef0/index.js#L30-L35 | train |
DanielBaulig/chat.io | lib/chat.io.js | disconnect | function disconnect(socket) {
if (socket.namespace.name === '') return socket.disconnect();
socket.packet({type:'disconnect'});
socket.manager.onLeave(socket, socket.namespace.name);
socket.$emit('disconnect', 'booted');
} | javascript | function disconnect(socket) {
if (socket.namespace.name === '') return socket.disconnect();
socket.packet({type:'disconnect'});
socket.manager.onLeave(socket, socket.namespace.name);
socket.$emit('disconnect', 'booted');
} | [
"function",
"disconnect",
"(",
"socket",
")",
"{",
"if",
"(",
"socket",
".",
"namespace",
".",
"name",
"===",
"''",
")",
"return",
"socket",
".",
"disconnect",
"(",
")",
";",
"socket",
".",
"packet",
"(",
"{",
"type",
":",
"'disconnect'",
"}",
")",
"... | hack until socket.disconnect is fixed | [
"hack",
"until",
"socket",
".",
"disconnect",
"is",
"fixed"
] | cd99c6ccd90487bfab459c45a375a192f7baf242 | https://github.com/DanielBaulig/chat.io/blob/cd99c6ccd90487bfab459c45a375a192f7baf242/lib/chat.io.js#L13-L18 | train |
feross/location-history | index.js | back | function back (self, cb, cancel) {
if (!cb) cb = noop
if (self._back.length === 0 || self._pending) return cb(null)
var previous = self._back.pop()
var current = self.current()
load(self, previous, done)
function done (err) {
if (err) return cb(err)
if (!cancel) self._forward.push(current)
sel... | javascript | function back (self, cb, cancel) {
if (!cb) cb = noop
if (self._back.length === 0 || self._pending) return cb(null)
var previous = self._back.pop()
var current = self.current()
load(self, previous, done)
function done (err) {
if (err) return cb(err)
if (!cancel) self._forward.push(current)
sel... | [
"function",
"back",
"(",
"self",
",",
"cb",
",",
"cancel",
")",
"{",
"if",
"(",
"!",
"cb",
")",
"cb",
"=",
"noop",
"if",
"(",
"self",
".",
"_back",
".",
"length",
"===",
"0",
"||",
"self",
".",
"_pending",
")",
"return",
"cb",
"(",
"null",
")",... | Goes back to the previous screen If 'cancel' is true, removes the current screen from history If 'cancel' if false, the user can return by going forward | [
"Goes",
"back",
"to",
"the",
"previous",
"screen",
"If",
"cancel",
"is",
"true",
"removes",
"the",
"current",
"screen",
"from",
"history",
"If",
"cancel",
"if",
"false",
"the",
"user",
"can",
"return",
"by",
"going",
"forward"
] | b20392494dc0aef81afd4b4102dbd2da74d5ab7a | https://github.com/feross/location-history/blob/b20392494dc0aef81afd4b4102dbd2da74d5ab7a/index.js#L39-L54 | train |
dcodeIO/colour.js | colour.js | addProperty | function addProperty(col, func) {
// Exposed on top of the namespace
colour[col] = function(str) {
return func.apply(str);
};
// And on top of all strings
try {
String.prototype.__defineGetter__(col, func);
definedGetters[col] = func;
}... | javascript | function addProperty(col, func) {
// Exposed on top of the namespace
colour[col] = function(str) {
return func.apply(str);
};
// And on top of all strings
try {
String.prototype.__defineGetter__(col, func);
definedGetters[col] = func;
}... | [
"function",
"addProperty",
"(",
"col",
",",
"func",
")",
"{",
"// Exposed on top of the namespace",
"colour",
"[",
"col",
"]",
"=",
"function",
"(",
"str",
")",
"{",
"return",
"func",
".",
"apply",
"(",
"str",
")",
";",
"}",
";",
"// And on top of all string... | Prototypes the string object to have additional properties that wraps the current string in colours when accessed.
@param {string} col Colour / property name
@param {function(string):string} func Wrapper function
@private | [
"Prototypes",
"the",
"string",
"object",
"to",
"have",
"additional",
"properties",
"that",
"wraps",
"the",
"current",
"string",
"in",
"colours",
"when",
"accessed",
"."
] | 66a2f044ac9d8b1ae12062dbbc434c621c08368f | https://github.com/dcodeIO/colour.js/blob/66a2f044ac9d8b1ae12062dbbc434c621c08368f/colour.js#L136-L146 | train |
dcodeIO/colour.js | colour.js | stylize | function stylize(str, style) {
if (colour.mode == 'console') {
return consoleStyles[style][0] + str + consoleStyles[style][1];
} else if (colour.mode == 'browser') {
return browserStyles[style][0] + str + browserStyles[style][1];
} else if (colour.mode == 'browser-css') {... | javascript | function stylize(str, style) {
if (colour.mode == 'console') {
return consoleStyles[style][0] + str + consoleStyles[style][1];
} else if (colour.mode == 'browser') {
return browserStyles[style][0] + str + browserStyles[style][1];
} else if (colour.mode == 'browser-css') {... | [
"function",
"stylize",
"(",
"str",
",",
"style",
")",
"{",
"if",
"(",
"colour",
".",
"mode",
"==",
"'console'",
")",
"{",
"return",
"consoleStyles",
"[",
"style",
"]",
"[",
"0",
"]",
"+",
"str",
"+",
"consoleStyles",
"[",
"style",
"]",
"[",
"1",
"]... | Applies a style to a string.
@param {string} str String to stylize
@param {string} style Style to apply
@returns {string}
@private | [
"Applies",
"a",
"style",
"to",
"a",
"string",
"."
] | 66a2f044ac9d8b1ae12062dbbc434c621c08368f | https://github.com/dcodeIO/colour.js/blob/66a2f044ac9d8b1ae12062dbbc434c621c08368f/colour.js#L198-L207 | train |
dcodeIO/colour.js | colour.js | applyTheme | function applyTheme(theme) {
Object.keys(theme).forEach(function(prop) {
if (prototypeBlacklist.indexOf(prop) >= 0) {
return;
}
if (typeof theme[prop] == 'string') {
// Multiple colours white-space seperated #45, e.g. "red bold", #18
... | javascript | function applyTheme(theme) {
Object.keys(theme).forEach(function(prop) {
if (prototypeBlacklist.indexOf(prop) >= 0) {
return;
}
if (typeof theme[prop] == 'string') {
// Multiple colours white-space seperated #45, e.g. "red bold", #18
... | [
"function",
"applyTheme",
"(",
"theme",
")",
"{",
"Object",
".",
"keys",
"(",
"theme",
")",
".",
"forEach",
"(",
"function",
"(",
"prop",
")",
"{",
"if",
"(",
"prototypeBlacklist",
".",
"indexOf",
"(",
"prop",
")",
">=",
"0",
")",
"{",
"return",
";",... | Applies a theme.
@param {!Object} theme Theme to apply | [
"Applies",
"a",
"theme",
"."
] | 66a2f044ac9d8b1ae12062dbbc434c621c08368f | https://github.com/dcodeIO/colour.js/blob/66a2f044ac9d8b1ae12062dbbc434c621c08368f/colour.js#L233-L250 | train |
dcodeIO/colour.js | colour.js | sequencer | function sequencer(map) {
return function () {
if (this == undefined) return "";
var i=0;
return String.prototype.split.apply(this, [""]).map(map).join("");
};
} | javascript | function sequencer(map) {
return function () {
if (this == undefined) return "";
var i=0;
return String.prototype.split.apply(this, [""]).map(map).join("");
};
} | [
"function",
"sequencer",
"(",
"map",
")",
"{",
"return",
"function",
"(",
")",
"{",
"if",
"(",
"this",
"==",
"undefined",
")",
"return",
"\"\"",
";",
"var",
"i",
"=",
"0",
";",
"return",
"String",
".",
"prototype",
".",
"split",
".",
"apply",
"(",
... | Extends a mapper with the current index inside the string as a second argument.
@param {function(string, number):string} map Sequencing function
@returns {function(string):string} Wrapped sequencer
@private | [
"Extends",
"a",
"mapper",
"with",
"the",
"current",
"index",
"inside",
"the",
"string",
"as",
"a",
"second",
"argument",
"."
] | 66a2f044ac9d8b1ae12062dbbc434c621c08368f | https://github.com/dcodeIO/colour.js/blob/66a2f044ac9d8b1ae12062dbbc434c621c08368f/colour.js#L282-L288 | train |
sequitur/blotter | lib/engine.js | choiceListener | function choiceListener(index) {
return function (event) {
event.preventDefault();
if (choicesAnimating) return;
clearChoiceListeners();
story.ChooseChoiceIndex(index);
saveGame(index);
clearOldChoices().then(() => progressGame());
}
} | javascript | function choiceListener(index) {
return function (event) {
event.preventDefault();
if (choicesAnimating) return;
clearChoiceListeners();
story.ChooseChoiceIndex(index);
saveGame(index);
clearOldChoices().then(() => progressGame());
}
} | [
"function",
"choiceListener",
"(",
"index",
")",
"{",
"return",
"function",
"(",
"event",
")",
"{",
"event",
".",
"preventDefault",
"(",
")",
";",
"if",
"(",
"choicesAnimating",
")",
"return",
";",
"clearChoiceListeners",
"(",
")",
";",
"story",
".",
"Choo... | Create a listener function to attach to one of the li elements that represents a player choice. | [
"Create",
"a",
"listener",
"function",
"to",
"attach",
"to",
"one",
"of",
"the",
"li",
"elements",
"that",
"represents",
"a",
"player",
"choice",
"."
] | f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830 | https://github.com/sequitur/blotter/blob/f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830/lib/engine.js#L212-L221 | train |
sequitur/blotter | lib/engine.js | createChoiceListener | function createChoiceListener(li, index) {
li.clickListener = choiceListener(index);
li.addEventListener('click', li.clickListener);
li.clearListener = (function () {
this.removeEventListener('click', this.clickListener);
}).bind(li);
} | javascript | function createChoiceListener(li, index) {
li.clickListener = choiceListener(index);
li.addEventListener('click', li.clickListener);
li.clearListener = (function () {
this.removeEventListener('click', this.clickListener);
}).bind(li);
} | [
"function",
"createChoiceListener",
"(",
"li",
",",
"index",
")",
"{",
"li",
".",
"clickListener",
"=",
"choiceListener",
"(",
"index",
")",
";",
"li",
".",
"addEventListener",
"(",
"'click'",
",",
"li",
".",
"clickListener",
")",
";",
"li",
".",
"clearLis... | Attach that listener to the element. | [
"Attach",
"that",
"listener",
"to",
"the",
"element",
"."
] | f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830 | https://github.com/sequitur/blotter/blob/f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830/lib/engine.js#L246-L252 | train |
sequitur/blotter | lib/engine.js | clearChoiceListeners | function clearChoiceListeners() {
const lis = document.querySelectorAll('li');
Array.from(lis).forEach(li => {
if (li.clearListener) li.clearListener();
})
} | javascript | function clearChoiceListeners() {
const lis = document.querySelectorAll('li');
Array.from(lis).forEach(li => {
if (li.clearListener) li.clearListener();
})
} | [
"function",
"clearChoiceListeners",
"(",
")",
"{",
"const",
"lis",
"=",
"document",
".",
"querySelectorAll",
"(",
"'li'",
")",
";",
"Array",
".",
"from",
"(",
"lis",
")",
".",
"forEach",
"(",
"li",
"=>",
"{",
"if",
"(",
"li",
".",
"clearListener",
")",... | Clean up event listeners from choices once one of them was selected. | [
"Clean",
"up",
"event",
"listeners",
"from",
"choices",
"once",
"one",
"of",
"them",
"was",
"selected",
"."
] | f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830 | https://github.com/sequitur/blotter/blob/f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830/lib/engine.js#L255-L260 | train |
sequitur/blotter | lib/engine.js | createChoiceUl | function createChoiceUl () {
const lis = story.currentChoices
.map(choice => {
const li = document.createElement('li');
li.innerHTML = choice.text;
createChoiceListener(li, choice.index);
return li;
});
const ul = document.createElement('ul');
Array.from(lis).forEach(li => ul.appen... | javascript | function createChoiceUl () {
const lis = story.currentChoices
.map(choice => {
const li = document.createElement('li');
li.innerHTML = choice.text;
createChoiceListener(li, choice.index);
return li;
});
const ul = document.createElement('ul');
Array.from(lis).forEach(li => ul.appen... | [
"function",
"createChoiceUl",
"(",
")",
"{",
"const",
"lis",
"=",
"story",
".",
"currentChoices",
".",
"map",
"(",
"choice",
"=>",
"{",
"const",
"li",
"=",
"document",
".",
"createElement",
"(",
"'li'",
")",
";",
"li",
".",
"innerHTML",
"=",
"choice",
... | Create the ul element that contains a batch of choices. | [
"Create",
"the",
"ul",
"element",
"that",
"contains",
"a",
"batch",
"of",
"choices",
"."
] | f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830 | https://github.com/sequitur/blotter/blob/f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830/lib/engine.js#L263-L275 | train |
sequitur/blotter | lib/engine.js | placeChoices | function placeChoices () {
const ul = createChoiceUl();
ul.addEventListener('animationend', () => choicesAnimating = false);
choicesAnimating = true;
choiceDiv.appendChild(ul);
} | javascript | function placeChoices () {
const ul = createChoiceUl();
ul.addEventListener('animationend', () => choicesAnimating = false);
choicesAnimating = true;
choiceDiv.appendChild(ul);
} | [
"function",
"placeChoices",
"(",
")",
"{",
"const",
"ul",
"=",
"createChoiceUl",
"(",
")",
";",
"ul",
".",
"addEventListener",
"(",
"'animationend'",
",",
"(",
")",
"=>",
"choicesAnimating",
"=",
"false",
")",
";",
"choicesAnimating",
"=",
"true",
";",
"ch... | Insert a choice list into the container div. | [
"Insert",
"a",
"choice",
"list",
"into",
"the",
"container",
"div",
"."
] | f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830 | https://github.com/sequitur/blotter/blob/f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830/lib/engine.js#L278-L283 | train |
sequitur/blotter | lib/engine.js | clearOldChoices | function clearOldChoices () {
const oldChoices = choiceDiv.querySelector('.choices.current');
return new Promise(resolve => {
oldChoices.addEventListener('transitionend', () => {
oldChoices.remove();
resolve();
});
oldChoices.className = "choices old";
})
} | javascript | function clearOldChoices () {
const oldChoices = choiceDiv.querySelector('.choices.current');
return new Promise(resolve => {
oldChoices.addEventListener('transitionend', () => {
oldChoices.remove();
resolve();
});
oldChoices.className = "choices old";
})
} | [
"function",
"clearOldChoices",
"(",
")",
"{",
"const",
"oldChoices",
"=",
"choiceDiv",
".",
"querySelector",
"(",
"'.choices.current'",
")",
";",
"return",
"new",
"Promise",
"(",
"resolve",
"=>",
"{",
"oldChoices",
".",
"addEventListener",
"(",
"'transitionend'",
... | Mark used choice lists as old and remove them from the view. | [
"Mark",
"used",
"choice",
"lists",
"as",
"old",
"and",
"remove",
"them",
"from",
"the",
"view",
"."
] | f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830 | https://github.com/sequitur/blotter/blob/f2f22e6ff95e6e0c19ea2c3d939bad63b2de6830/lib/engine.js#L286-L295 | train |
wala/jsdelta | src/delta_multi.js | deltaDebugFiles | function deltaDebugFiles(file) {
try {
logging.increaseIndentation();
state.fileUnderTest = file;
logging.logTargetChange(file, state.tmpDir);
// try removing fileUnderTest completely
var backup = makeBackupFileName();
fs.renameSync(file, ... | javascript | function deltaDebugFiles(file) {
try {
logging.increaseIndentation();
state.fileUnderTest = file;
logging.logTargetChange(file, state.tmpDir);
// try removing fileUnderTest completely
var backup = makeBackupFileName();
fs.renameSync(file, ... | [
"function",
"deltaDebugFiles",
"(",
"file",
")",
"{",
"try",
"{",
"logging",
".",
"increaseIndentation",
"(",
")",
";",
"state",
".",
"fileUnderTest",
"=",
"file",
";",
"logging",
".",
"logTargetChange",
"(",
"file",
",",
"state",
".",
"tmpDir",
")",
";",
... | Recursively pass through the file-hierarchy and invoke delta_single.main on all files
@return boolean true if at least one reduction was performed successfully. | [
"Recursively",
"pass",
"through",
"the",
"file",
"-",
"hierarchy",
"and",
"invoke",
"delta_single",
".",
"main",
"on",
"all",
"files"
] | 355febea1ee23e9e909ba2bfa087ffb2499a3295 | https://github.com/wala/jsdelta/blob/355febea1ee23e9e909ba2bfa087ffb2499a3295/src/delta_multi.js#L127-L159 | train |
ariatemplates/hashspace | docs/libs/jx.js | function () {
var http = false;
// Use IE's ActiveX items to load the file.
if (typeof ActiveXObject != 'undefined') {
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http = new ActiveXObject("Micro... | javascript | function () {
var http = false;
// Use IE's ActiveX items to load the file.
if (typeof ActiveXObject != 'undefined') {
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http = new ActiveXObject("Micro... | [
"function",
"(",
")",
"{",
"var",
"http",
"=",
"false",
";",
"// Use IE's ActiveX items to load the file.",
"if",
"(",
"typeof",
"ActiveXObject",
"!=",
"'undefined'",
")",
"{",
"try",
"{",
"http",
"=",
"new",
"ActiveXObject",
"(",
"\"Msxml2.XMLHTTP\"",
")",
";",... | Create a xmlHttpRequest object - this is the constructor. | [
"Create",
"a",
"xmlHttpRequest",
"object",
"-",
"this",
"is",
"the",
"constructor",
"."
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/docs/libs/jx.js#L7-L29 | train | |
mljs/fft | src/FFTUtils.js | ifft2DArray | function ifft2DArray(ft, ftRows, ftCols) {
var tempTransform = new Array(ftRows * ftCols);
var nRows = ftRows / 2;
var nCols = (ftCols - 1) * 2;
// reverse transform columns
FFT.init(nRows);
var tmpCols = {re: new Array(nRows), im: new Array(nRows)};
var iRow, iCol;
for (iCol = 0; iCol <... | javascript | function ifft2DArray(ft, ftRows, ftCols) {
var tempTransform = new Array(ftRows * ftCols);
var nRows = ftRows / 2;
var nCols = (ftCols - 1) * 2;
// reverse transform columns
FFT.init(nRows);
var tmpCols = {re: new Array(nRows), im: new Array(nRows)};
var iRow, iCol;
for (iCol = 0; iCol <... | [
"function",
"ifft2DArray",
"(",
"ft",
",",
"ftRows",
",",
"ftCols",
")",
"{",
"var",
"tempTransform",
"=",
"new",
"Array",
"(",
"ftRows",
"*",
"ftCols",
")",
";",
"var",
"nRows",
"=",
"ftRows",
"/",
"2",
";",
"var",
"nCols",
"=",
"(",
"ftCols",
"-",
... | Calculates the inverse of a 2D Fourier transform
@param ft
@param ftRows
@param ftCols
@return | [
"Calculates",
"the",
"inverse",
"of",
"a",
"2D",
"Fourier",
"transform"
] | 436ff9535ded13393f359b50d55c68e94e2e8d51 | https://github.com/mljs/fft/blob/436ff9535ded13393f359b50d55c68e94e2e8d51/src/FFTUtils.js#L13-L57 | train |
mljs/fft | src/FFTUtils.js | convolute2DI | function convolute2DI(ftSignal, ftFilter, ftRows, ftCols) {
var re, im;
for (var iRow = 0; iRow < ftRows / 2; iRow++) {
for (var iCol = 0; iCol < ftCols; iCol++) {
//
re = ftSignal[(iRow * 2) * ftCols + iCol]
* ftFilter[(iRow * 2) * ftCols + iCol]
... | javascript | function convolute2DI(ftSignal, ftFilter, ftRows, ftCols) {
var re, im;
for (var iRow = 0; iRow < ftRows / 2; iRow++) {
for (var iCol = 0; iCol < ftCols; iCol++) {
//
re = ftSignal[(iRow * 2) * ftCols + iCol]
* ftFilter[(iRow * 2) * ftCols + iCol]
... | [
"function",
"convolute2DI",
"(",
"ftSignal",
",",
"ftFilter",
",",
"ftRows",
",",
"ftCols",
")",
"{",
"var",
"re",
",",
"im",
";",
"for",
"(",
"var",
"iRow",
"=",
"0",
";",
"iRow",
"<",
"ftRows",
"/",
"2",
";",
"iRow",
"++",
")",
"{",
"for",
"(",... | In place version of convolute 2D
@param ftSignal
@param ftFilter
@param ftRows
@param ftCols
@return | [
"In",
"place",
"version",
"of",
"convolute",
"2D"
] | 436ff9535ded13393f359b50d55c68e94e2e8d51 | https://github.com/mljs/fft/blob/436ff9535ded13393f359b50d55c68e94e2e8d51/src/FFTUtils.js#L187-L205 | train |
mljs/fft | src/FFTUtils.js | crop | function crop(data, rows, cols, nRows, nCols) {
if (rows === nRows && cols === nCols) {
//Do nothing. Returns the same input!!! Be careful
return data;
}
var output = new Array(nCols * nRows);
var shiftR = Math.floor((rows - nRows) / 2);
var shiftC = Math.floor((cols - nCols) / 2)... | javascript | function crop(data, rows, cols, nRows, nCols) {
if (rows === nRows && cols === nCols) {
//Do nothing. Returns the same input!!! Be careful
return data;
}
var output = new Array(nCols * nRows);
var shiftR = Math.floor((rows - nRows) / 2);
var shiftC = Math.floor((cols - nCols) / 2)... | [
"function",
"crop",
"(",
"data",
",",
"rows",
",",
"cols",
",",
"nRows",
",",
"nCols",
")",
"{",
"if",
"(",
"rows",
"===",
"nRows",
"&&",
"cols",
"===",
"nCols",
")",
"{",
"//Do nothing. Returns the same input!!! Be careful",
"return",
"data",
";",
"}",
"v... | Crop the given matrix to fit the corresponding number of rows and columns | [
"Crop",
"the",
"given",
"matrix",
"to",
"fit",
"the",
"corresponding",
"number",
"of",
"rows",
"and",
"columns"
] | 436ff9535ded13393f359b50d55c68e94e2e8d51 | https://github.com/mljs/fft/blob/436ff9535ded13393f359b50d55c68e94e2e8d51/src/FFTUtils.js#L295-L316 | train |
ariatemplates/hashspace | hsp/rt/cptwrapper.js | function (Cptfn) {
if (!Cptfn || Cptfn.constructor !== Function) {
log.error("[CptWrapper] Invalid Component constructor!");
} else {
this.cpt = new Cptfn();
this.nodeInstance = null; // reference to set the node instance adirty when an attribute changes
t... | javascript | function (Cptfn) {
if (!Cptfn || Cptfn.constructor !== Function) {
log.error("[CptWrapper] Invalid Component constructor!");
} else {
this.cpt = new Cptfn();
this.nodeInstance = null; // reference to set the node instance adirty when an attribute changes
t... | [
"function",
"(",
"Cptfn",
")",
"{",
"if",
"(",
"!",
"Cptfn",
"||",
"Cptfn",
".",
"constructor",
"!==",
"Function",
")",
"{",
"log",
".",
"error",
"(",
"\"[CptWrapper] Invalid Component constructor!\"",
")",
";",
"}",
"else",
"{",
"this",
".",
"cpt",
"=",
... | Observer constructor.
@param Cptfn {Function} the component constructor | [
"Observer",
"constructor",
"."
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptwrapper.js#L96-L151 | train | |
ariatemplates/hashspace | hsp/rt/cptwrapper.js | function (change) {
var chg = change, cpt = this.cpt;
if (change.constructor === Array) {
if (change.length > 0) {
chg = change[0];
} else {
log.error('[CptNode] Invalid change - nbr of changes: '+change.length);
return;
... | javascript | function (change) {
var chg = change, cpt = this.cpt;
if (change.constructor === Array) {
if (change.length > 0) {
chg = change[0];
} else {
log.error('[CptNode] Invalid change - nbr of changes: '+change.length);
return;
... | [
"function",
"(",
"change",
")",
"{",
"var",
"chg",
"=",
"change",
",",
"cpt",
"=",
"this",
".",
"cpt",
";",
"if",
"(",
"change",
".",
"constructor",
"===",
"Array",
")",
"{",
"if",
"(",
"change",
".",
"length",
">",
"0",
")",
"{",
"chg",
"=",
"... | Check if not already in event handler stack and call the change event handler | [
"Check",
"if",
"not",
"already",
"in",
"event",
"handler",
"stack",
"and",
"call",
"the",
"change",
"event",
"handler"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptwrapper.js#L276-L348 | train | |
ariatemplates/hashspace | hsp/rt/cptwrapper.js | createCptWrapper | function createCptWrapper(Ctl, cptArgs) {
var cw = new CptWrapper(Ctl), att, t, v; // will also create a new controller instance
if (cptArgs) {
var cpt=cw.cpt, ni=cptArgs.nodeInstance;
if (ni.isCptComponent || ni.isCptAttElement) {
// set the nodeInstance reference on the component
... | javascript | function createCptWrapper(Ctl, cptArgs) {
var cw = new CptWrapper(Ctl), att, t, v; // will also create a new controller instance
if (cptArgs) {
var cpt=cw.cpt, ni=cptArgs.nodeInstance;
if (ni.isCptComponent || ni.isCptAttElement) {
// set the nodeInstance reference on the component
... | [
"function",
"createCptWrapper",
"(",
"Ctl",
",",
"cptArgs",
")",
"{",
"var",
"cw",
"=",
"new",
"CptWrapper",
"(",
"Ctl",
")",
",",
"att",
",",
"t",
",",
"v",
";",
"// will also create a new controller instance",
"if",
"(",
"cptArgs",
")",
"{",
"var",
"cpt"... | Create a Component wrapper and initialize it correctly according to the attributes passed as arguments
@param {Object} cptArgs the component arguments
e.g. { nodeInstance:x, $attributes:{att1:{}, att2:{}}, $content:[] } | [
"Create",
"a",
"Component",
"wrapper",
"and",
"initialize",
"it",
"correctly",
"according",
"to",
"the",
"attributes",
"passed",
"as",
"arguments"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptwrapper.js#L388-L428 | train |
fardog/node-xkcd-password | index.js | XKCDPassword | function XKCDPassword() {
if (!(this instanceof XKCDPassword)) return new XKCDPassword()
var self = this
events.EventEmitter.call(self)
self.wordlist = null
self.wordfile = null
// if we've got a wordlist at the ready
self.ready = false
self.initialized = false
return this
} | javascript | function XKCDPassword() {
if (!(this instanceof XKCDPassword)) return new XKCDPassword()
var self = this
events.EventEmitter.call(self)
self.wordlist = null
self.wordfile = null
// if we've got a wordlist at the ready
self.ready = false
self.initialized = false
return this
} | [
"function",
"XKCDPassword",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"XKCDPassword",
")",
")",
"return",
"new",
"XKCDPassword",
"(",
")",
"var",
"self",
"=",
"this",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"self",
")",
"self",
... | Creates the password generator.
@constructor
@since 0.0.1
@returns {Generator} the word generator | [
"Creates",
"the",
"password",
"generator",
"."
] | a45ec266a7489977b83e9cdf48239e7adf269271 | https://github.com/fardog/node-xkcd-password/blob/a45ec266a7489977b83e9cdf48239e7adf269271/index.js#L34-L49 | train |
mljs/fft | src/fftlib.js | fft2d | function fft2d(re, im) {
var tre = [],
tim = [],
i = 0;
// x-axis
for (var y = 0; y < _n; y++) {
i = y * _n;
for (var x1 = 0; x1 < _n; x1++) {
tre[x1] = re[x1 + i];
tim[x1] = im[x1 + i];
}
fft1d(tre, tim);
for (var x2 = 0; x2 < ... | javascript | function fft2d(re, im) {
var tre = [],
tim = [],
i = 0;
// x-axis
for (var y = 0; y < _n; y++) {
i = y * _n;
for (var x1 = 0; x1 < _n; x1++) {
tre[x1] = re[x1 + i];
tim[x1] = im[x1 + i];
}
fft1d(tre, tim);
for (var x2 = 0; x2 < ... | [
"function",
"fft2d",
"(",
"re",
",",
"im",
")",
"{",
"var",
"tre",
"=",
"[",
"]",
",",
"tim",
"=",
"[",
"]",
",",
"i",
"=",
"0",
";",
"// x-axis",
"for",
"(",
"var",
"y",
"=",
"0",
";",
"y",
"<",
"_n",
";",
"y",
"++",
")",
"{",
"i",
"="... | 2D-FFT Not very useful if the number of rows have to be equal to cols | [
"2D",
"-",
"FFT",
"Not",
"very",
"useful",
"if",
"the",
"number",
"of",
"rows",
"have",
"to",
"be",
"equal",
"to",
"cols"
] | 436ff9535ded13393f359b50d55c68e94e2e8d51 | https://github.com/mljs/fft/blob/436ff9535ded13393f359b50d55c68e94e2e8d51/src/fftlib.js#L42-L73 | train |
mljs/fft | src/fftlib.js | ifft2d | function ifft2d(re, im) {
var tre = [],
tim = [],
i = 0;
// x-axis
for (var y = 0; y < _n; y++) {
i = y * _n;
for (var x1 = 0; x1 < _n; x1++) {
tre[x1] = re[x1 + i];
tim[x1] = im[x1 + i];
}
ifft1d(tre, tim);
for (var x2 = 0; x2 ... | javascript | function ifft2d(re, im) {
var tre = [],
tim = [],
i = 0;
// x-axis
for (var y = 0; y < _n; y++) {
i = y * _n;
for (var x1 = 0; x1 < _n; x1++) {
tre[x1] = re[x1 + i];
tim[x1] = im[x1 + i];
}
ifft1d(tre, tim);
for (var x2 = 0; x2 ... | [
"function",
"ifft2d",
"(",
"re",
",",
"im",
")",
"{",
"var",
"tre",
"=",
"[",
"]",
",",
"tim",
"=",
"[",
"]",
",",
"i",
"=",
"0",
";",
"// x-axis",
"for",
"(",
"var",
"y",
"=",
"0",
";",
"y",
"<",
"_n",
";",
"y",
"++",
")",
"{",
"i",
"=... | 2D-IFFT | [
"2D",
"-",
"IFFT"
] | 436ff9535ded13393f359b50d55c68e94e2e8d51 | https://github.com/mljs/fft/blob/436ff9535ded13393f359b50d55c68e94e2e8d51/src/fftlib.js#L76-L107 | train |
ariatemplates/hashspace | hsp/compiler/jsgenerator/processors.js | formatExpression | function formatExpression (expression, firstIndex, walker) {
var category = expression.category, codeStmts, code = '', nextIndex = firstIndex;
var exprIndex = firstIndex;
var expAst;
if (category === 'jsexptext') {
//compile the expression to detect errors and parse-out identifiers
try ... | javascript | function formatExpression (expression, firstIndex, walker) {
var category = expression.category, codeStmts, code = '', nextIndex = firstIndex;
var exprIndex = firstIndex;
var expAst;
if (category === 'jsexptext') {
//compile the expression to detect errors and parse-out identifiers
try ... | [
"function",
"formatExpression",
"(",
"expression",
",",
"firstIndex",
",",
"walker",
")",
"{",
"var",
"category",
"=",
"expression",
".",
"category",
",",
"codeStmts",
",",
"code",
"=",
"''",
",",
"nextIndex",
"=",
"firstIndex",
";",
"var",
"exprIndex",
"=",... | Formats an expression according to its category.
@param {Object} expression the expression to format.
@param {Integer} firstIndex index of the expression.
@param {TemplateWalker} walker the template walker instance.
@return {Object} the expression string and the next expression index that can be used | [
"Formats",
"an",
"expression",
"according",
"to",
"its",
"category",
"."
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/compiler/jsgenerator/processors.js#L343-L377 | train |
ariatemplates/hashspace | hsp/compiler/jsgenerator/processors.js | formatTextBlock | function formatTextBlock (node, nextExprIndex, walker) {
var content = node.content, item, exprArray = [], args = [], index = 0; // idx is the index in the $text array
// (=args)
for (var i = 0; i < content.length; i++) {
it... | javascript | function formatTextBlock (node, nextExprIndex, walker) {
var content = node.content, item, exprArray = [], args = [], index = 0; // idx is the index in the $text array
// (=args)
for (var i = 0; i < content.length; i++) {
it... | [
"function",
"formatTextBlock",
"(",
"node",
",",
"nextExprIndex",
",",
"walker",
")",
"{",
"var",
"content",
"=",
"node",
".",
"content",
",",
"item",
",",
"exprArray",
"=",
"[",
"]",
",",
"args",
"=",
"[",
"]",
",",
"index",
"=",
"0",
";",
"// idx i... | Format the textblock content for textblock and attribute nodes.
@param {Node} node the current Node object as built by the treebuilder.
@param {Integer} nextExprIndex the index of the next expression.
@param {TreeWalker} walker the template walker instance.
@return {Object} a snippet of Javascript code built from the n... | [
"Format",
"the",
"textblock",
"content",
"for",
"textblock",
"and",
"attribute",
"nodes",
"."
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/compiler/jsgenerator/processors.js#L386-L434 | train |
ariatemplates/hashspace | hsp/rt/log.js | formatValue | function formatValue(v,depth) {
if (depth===undefined || depth===null) {
depth=1;
}
var tp=typeof(v), val;
if (v===null) {
return "null";
} else if (v===undefined) {
return "undefined";
} else if (tp==='object') {
if (depth>0) {
var properties=[];
... | javascript | function formatValue(v,depth) {
if (depth===undefined || depth===null) {
depth=1;
}
var tp=typeof(v), val;
if (v===null) {
return "null";
} else if (v===undefined) {
return "undefined";
} else if (tp==='object') {
if (depth>0) {
var properties=[];
... | [
"function",
"formatValue",
"(",
"v",
",",
"depth",
")",
"{",
"if",
"(",
"depth",
"===",
"undefined",
"||",
"depth",
"===",
"null",
")",
"{",
"depth",
"=",
"1",
";",
"}",
"var",
"tp",
"=",
"typeof",
"(",
"v",
")",
",",
"val",
";",
"if",
"(",
"v"... | Format a JS entity for the log
@param v {Object} the value to format
@param depth {Number} the formatting of objects and arrays (default: 1) | [
"Format",
"a",
"JS",
"entity",
"for",
"the",
"log"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/log.js#L248-L306 | train |
ariatemplates/hashspace | hsp/expressions/manipulator.js | function(scope, defaultValue) {
var val = evaluator(tree, scope);
if( typeof defaultValue === 'undefined') {
return val;
} else {
return (val === undefined || val === null || val != val) ? defaultValue : val;
}
} | javascript | function(scope, defaultValue) {
var val = evaluator(tree, scope);
if( typeof defaultValue === 'undefined') {
return val;
} else {
return (val === undefined || val === null || val != val) ? defaultValue : val;
}
} | [
"function",
"(",
"scope",
",",
"defaultValue",
")",
"{",
"var",
"val",
"=",
"evaluator",
"(",
"tree",
",",
"scope",
")",
";",
"if",
"(",
"typeof",
"defaultValue",
"===",
"'undefined'",
")",
"{",
"return",
"val",
";",
"}",
"else",
"{",
"return",
"(",
... | Evaluates an expression against a scope
@param scope
@return {*} - value of an expression in a given scope | [
"Evaluates",
"an",
"expression",
"against",
"a",
"scope"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/expressions/manipulator.js#L38-L45 | train | |
ariatemplates/hashspace | hsp/expressions/manipulator.js | function(scope, newValue) {
if (!isAssignable) {
throw new Error('Expression "' + input + '" is not assignable');
}
if (tree.a === 'idn') {
json.set(scope, tree.v, newValue);
} else if (tree.a === 'bnr') {
json.set(evaluator... | javascript | function(scope, newValue) {
if (!isAssignable) {
throw new Error('Expression "' + input + '" is not assignable');
}
if (tree.a === 'idn') {
json.set(scope, tree.v, newValue);
} else if (tree.a === 'bnr') {
json.set(evaluator... | [
"function",
"(",
"scope",
",",
"newValue",
")",
"{",
"if",
"(",
"!",
"isAssignable",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Expression \"'",
"+",
"input",
"+",
"'\" is not assignable'",
")",
";",
"}",
"if",
"(",
"tree",
".",
"a",
"===",
"'idn'",
")"... | Sets value of an expression on a scope. Not all expressions
are assignable.
@param scope - scope that should be modified
@param {*} a new value for a given expression and scope | [
"Sets",
"value",
"of",
"an",
"expression",
"on",
"a",
"scope",
".",
"Not",
"all",
"expressions",
"are",
"assignable",
"."
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/expressions/manipulator.js#L52-L62 | train | |
sbisbee/sag-js | src/server.private.js | setURLParameter | function setURLParameter(url, key, value) {
if(typeof url !== 'string') {
throw new Error('URLs must be a string');
}
if(urlUtils) {
//node.js
url = urlUtils.parse(url);
url.search = ((url.search) ? url.search + '&' : '?') + key + '=' + value;
url = urlUtils.format(url);
}
else {
//... | javascript | function setURLParameter(url, key, value) {
if(typeof url !== 'string') {
throw new Error('URLs must be a string');
}
if(urlUtils) {
//node.js
url = urlUtils.parse(url);
url.search = ((url.search) ? url.search + '&' : '?') + key + '=' + value;
url = urlUtils.format(url);
}
else {
//... | [
"function",
"setURLParameter",
"(",
"url",
",",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"url",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'URLs must be a string'",
")",
";",
"}",
"if",
"(",
"urlUtils",
")",
"{",
"//node.js",
... | Adds a query param to a URL. | [
"Adds",
"a",
"query",
"param",
"to",
"a",
"URL",
"."
] | f9aa69d07e2e6320894bb63859ff293c2285a586 | https://github.com/sbisbee/sag-js/blob/f9aa69d07e2e6320894bb63859ff293c2285a586/src/server.private.js#L242-L265 | train |
vigneshshanmugam/js-cpa | lib/hash.js | hashcons | function hashcons(node) {
const keys = t.VISITOR_KEYS[node.type];
if (!keys) return;
let hash = hashcode(node);
for (const key of keys) {
const subNode = node[key];
if (Array.isArray(subNode)) {
for (const child of subNode) {
if (child) {
hash += hashcons(child);
}
... | javascript | function hashcons(node) {
const keys = t.VISITOR_KEYS[node.type];
if (!keys) return;
let hash = hashcode(node);
for (const key of keys) {
const subNode = node[key];
if (Array.isArray(subNode)) {
for (const child of subNode) {
if (child) {
hash += hashcons(child);
}
... | [
"function",
"hashcons",
"(",
"node",
")",
"{",
"const",
"keys",
"=",
"t",
".",
"VISITOR_KEYS",
"[",
"node",
".",
"type",
"]",
";",
"if",
"(",
"!",
"keys",
")",
"return",
";",
"let",
"hash",
"=",
"hashcode",
"(",
"node",
")",
";",
"for",
"(",
"con... | Hashconsing - return the hash of an ASTNode computed recursively
@param {ASTNode} node | [
"Hashconsing",
"-",
"return",
"the",
"hash",
"of",
"an",
"ASTNode",
"computed",
"recursively"
] | ebcc5952ecc1909cbe5e3ca69a974409b65ccdf8 | https://github.com/vigneshshanmugam/js-cpa/blob/ebcc5952ecc1909cbe5e3ca69a974409b65ccdf8/lib/hash.js#L12-L33 | train |
ariatemplates/hashspace | hsp/compiler/jsgenerator/jsvalidator/validator.js | formatError | function formatError (error, input) {
var message = error.toString().replace(/\s*\(\d*\:\d*\)\s*$/i, ''); // remove line number / col number
var beforeMatch = ('' + input.slice(0, error.pos)).match(/.*$/i);
var afterMatch = ('' + input.slice(error.pos)).match(/.*/i);
var before = beforeMatch ? beforeMa... | javascript | function formatError (error, input) {
var message = error.toString().replace(/\s*\(\d*\:\d*\)\s*$/i, ''); // remove line number / col number
var beforeMatch = ('' + input.slice(0, error.pos)).match(/.*$/i);
var afterMatch = ('' + input.slice(error.pos)).match(/.*/i);
var before = beforeMatch ? beforeMa... | [
"function",
"formatError",
"(",
"error",
",",
"input",
")",
"{",
"var",
"message",
"=",
"error",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"/",
"\\s*\\(\\d*\\:\\d*\\)\\s*$",
"/",
"i",
",",
"''",
")",
";",
"// remove line number / col number",
"var",
"b... | Formats the error as an error structure with line extract information.
@param {Object} error the exception.
@param {String} input the Javascript string.
@return {Object} the structured error. | [
"Formats",
"the",
"error",
"as",
"an",
"error",
"structure",
"with",
"line",
"extract",
"information",
"."
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/compiler/jsgenerator/jsvalidator/validator.js#L34-L65 | train |
bbx10/node-htu21d | index.js | raspi_i2c_devname | function raspi_i2c_devname()
{
try {
var revisionBuffer = fs.readFileSync('/sys/module/bcm2708/parameters/boardrev');
var revisionInt = parseInt(revisionBuffer.toString(), 10);
//console.log('Raspberry Pi board revision: ', revisionInt);
// Older boards use i2c-0, newer boards use i2... | javascript | function raspi_i2c_devname()
{
try {
var revisionBuffer = fs.readFileSync('/sys/module/bcm2708/parameters/boardrev');
var revisionInt = parseInt(revisionBuffer.toString(), 10);
//console.log('Raspberry Pi board revision: ', revisionInt);
// Older boards use i2c-0, newer boards use i2... | [
"function",
"raspi_i2c_devname",
"(",
")",
"{",
"try",
"{",
"var",
"revisionBuffer",
"=",
"fs",
".",
"readFileSync",
"(",
"'/sys/module/bcm2708/parameters/boardrev'",
")",
";",
"var",
"revisionInt",
"=",
"parseInt",
"(",
"revisionBuffer",
".",
"toString",
"(",
")"... | If the system is a Raspberry Pi return the correct i2c device name. Else return empty string. | [
"If",
"the",
"system",
"is",
"a",
"Raspberry",
"Pi",
"return",
"the",
"correct",
"i2c",
"device",
"name",
".",
"Else",
"return",
"empty",
"string",
"."
] | 135e81b53ab5e98282cb16ea9d27ce193dc9bf0a | https://github.com/bbx10/node-htu21d/blob/135e81b53ab5e98282cb16ea9d27ce193dc9bf0a/index.js#L154-L177 | train |
ariatemplates/hashspace | hsp/rt/cptcomponent.js | function() {
// determine if cpt supports template arguments
if (this.template) {
// as template can be changed dynamically we have to sync the constructor
this.ctlConstuctor=this.template.controllerConstructor;
}
var ctlProto=this.ctlConstuctor.prototype;
this.ctlAttributes=ctlProto.$at... | javascript | function() {
// determine if cpt supports template arguments
if (this.template) {
// as template can be changed dynamically we have to sync the constructor
this.ctlConstuctor=this.template.controllerConstructor;
}
var ctlProto=this.ctlConstuctor.prototype;
this.ctlAttributes=ctlProto.$at... | [
"function",
"(",
")",
"{",
"// determine if cpt supports template arguments",
"if",
"(",
"this",
".",
"template",
")",
"{",
"// as template can be changed dynamically we have to sync the constructor",
"this",
".",
"ctlConstuctor",
"=",
"this",
".",
"template",
".",
"control... | Process and retrieve the component arguments that are needed to init the component template | [
"Process",
"and",
"retrieve",
"the",
"component",
"arguments",
"that",
"are",
"needed",
"to",
"init",
"the",
"component",
"template"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptcomponent.js#L61-L110 | train | |
ariatemplates/hashspace | hsp/rt/cptcomponent.js | function(localPropOnly) {
if (this.ctlWrapper) {
this.ctlWrapper.$dispose();
this.ctlWrapper=null;
this.controller=null;
}
this.ctlAttributes=null;
this.cleanObjectProperties(localPropOnly);
this.ctlConstuctor=null;
var tpa=this.tplAttributes;
if (tpa) {
for (var k in... | javascript | function(localPropOnly) {
if (this.ctlWrapper) {
this.ctlWrapper.$dispose();
this.ctlWrapper=null;
this.controller=null;
}
this.ctlAttributes=null;
this.cleanObjectProperties(localPropOnly);
this.ctlConstuctor=null;
var tpa=this.tplAttributes;
if (tpa) {
for (var k in... | [
"function",
"(",
"localPropOnly",
")",
"{",
"if",
"(",
"this",
".",
"ctlWrapper",
")",
"{",
"this",
".",
"ctlWrapper",
".",
"$dispose",
"(",
")",
";",
"this",
".",
"ctlWrapper",
"=",
"null",
";",
"this",
".",
"controller",
"=",
"null",
";",
"}",
"thi... | Safely cut all dependencies before object is deleted
@param {Boolean} localPropOnly if true only local properties will be deleted (optional)
must be used when a new instance is created to adapt to a path change | [
"Safely",
"cut",
"all",
"dependencies",
"before",
"object",
"is",
"deleted"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptcomponent.js#L140-L172 | train | |
ariatemplates/hashspace | hsp/rt/cptcomponent.js | function () {
this.attEltNodes=null;
this._attGenerators=null;
// determine the possible template attribute names
var tpAttNames={}, ca=this.ctlAttributes, defaultTplAtt=null, lastTplAtt=null, count=0;
for (var k in ca) {
if (ca.hasOwnProperty(k) && ca[k].type==="template") {
// k is ... | javascript | function () {
this.attEltNodes=null;
this._attGenerators=null;
// determine the possible template attribute names
var tpAttNames={}, ca=this.ctlAttributes, defaultTplAtt=null, lastTplAtt=null, count=0;
for (var k in ca) {
if (ca.hasOwnProperty(k) && ca[k].type==="template") {
// k is ... | [
"function",
"(",
")",
"{",
"this",
".",
"attEltNodes",
"=",
"null",
";",
"this",
".",
"_attGenerators",
"=",
"null",
";",
"// determine the possible template attribute names",
"var",
"tpAttNames",
"=",
"{",
"}",
",",
"ca",
"=",
"this",
".",
"ctlAttributes",
",... | Load the component sub-nodes that correspond to template attributes | [
"Load",
"the",
"component",
"sub",
"-",
"nodes",
"that",
"correspond",
"to",
"template",
"attributes"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptcomponent.js#L177-L255 | train | |
ariatemplates/hashspace | hsp/rt/cptcomponent.js | function (defaultTplAtt) {
if (!this.children) {
return;
}
// TODO memoize result at prototype level to avoid processing this multiple times
var ct=this.getCptContentType(), loadCpts=true;
if (ct==="ERROR") {
loadCpts=false;
log.error(this.info+" Component content cannot mix attr... | javascript | function (defaultTplAtt) {
if (!this.children) {
return;
}
// TODO memoize result at prototype level to avoid processing this multiple times
var ct=this.getCptContentType(), loadCpts=true;
if (ct==="ERROR") {
loadCpts=false;
log.error(this.info+" Component content cannot mix attr... | [
"function",
"(",
"defaultTplAtt",
")",
"{",
"if",
"(",
"!",
"this",
".",
"children",
")",
"{",
"return",
";",
"}",
"// TODO memoize result at prototype level to avoid processing this multiple times",
"var",
"ct",
"=",
"this",
".",
"getCptContentType",
"(",
")",
",",... | Check if a default attribute element has to be created and create one if necessary | [
"Check",
"if",
"a",
"default",
"attribute",
"element",
"has",
"to",
"be",
"created",
"and",
"create",
"one",
"if",
"necessary"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptcomponent.js#L260-L298 | train | |
ariatemplates/hashspace | hsp/rt/cptcomponent.js | function() {
var aen=this.attEltNodes;
if (!aen) {
return null;
}
var attElts=[], cta=this.ctlAttributes;
for (var i=0,sz=aen.length; sz>i;i++) {
aen[i].registerAttElements(attElts);
}
// check that all elements are valid (i.e. have valid names)
var nm, elt, ok, elts=[], cte=... | javascript | function() {
var aen=this.attEltNodes;
if (!aen) {
return null;
}
var attElts=[], cta=this.ctlAttributes;
for (var i=0,sz=aen.length; sz>i;i++) {
aen[i].registerAttElements(attElts);
}
// check that all elements are valid (i.e. have valid names)
var nm, elt, ok, elts=[], cte=... | [
"function",
"(",
")",
"{",
"var",
"aen",
"=",
"this",
".",
"attEltNodes",
";",
"if",
"(",
"!",
"aen",
")",
"{",
"return",
"null",
";",
"}",
"var",
"attElts",
"=",
"[",
"]",
",",
"cta",
"=",
"this",
".",
"ctlAttributes",
";",
"for",
"(",
"var",
... | Retrieve all child attribute elements
and update the tplAttributes and childElements collections | [
"Retrieve",
"all",
"child",
"attribute",
"elements",
"and",
"update",
"the",
"tplAttributes",
"and",
"childElements",
"collections"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptcomponent.js#L304-L344 | train | |
ariatemplates/hashspace | hsp/rt/cptcomponent.js | function() {
var ce=this.childElements;
if (!ce || !ce.length) {
return;
}
var cw;
for (var i=0,sz=ce.length;sz>i;i++) {
cw=ce[i].ctlWrapper;
if (cw && !cw.initialized) {
cw.init(null,this.controller);
}
}
} | javascript | function() {
var ce=this.childElements;
if (!ce || !ce.length) {
return;
}
var cw;
for (var i=0,sz=ce.length;sz>i;i++) {
cw=ce[i].ctlWrapper;
if (cw && !cw.initialized) {
cw.init(null,this.controller);
}
}
} | [
"function",
"(",
")",
"{",
"var",
"ce",
"=",
"this",
".",
"childElements",
";",
"if",
"(",
"!",
"ce",
"||",
"!",
"ce",
".",
"length",
")",
"{",
"return",
";",
"}",
"var",
"cw",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"sz",
"=",
"ce",
".... | Initializes the attribute elements of type component that have not been
already initialized | [
"Initializes",
"the",
"attribute",
"elements",
"of",
"type",
"component",
"that",
"have",
"not",
"been",
"already",
"initialized"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptcomponent.js#L350-L362 | train | |
ariatemplates/hashspace | hsp/rt/cptcomponent.js | function (evt) {
var evh = this.evtHandlers, et = evt.type;
if (evh) {
for (var i = 0, sz = evh.length; sz > i; i++) {
if (evh[i].evtType === et) {
evh[i].executeCb(evt, this.eh, this.parent.vscope);
break;
}
}
}
} | javascript | function (evt) {
var evh = this.evtHandlers, et = evt.type;
if (evh) {
for (var i = 0, sz = evh.length; sz > i; i++) {
if (evh[i].evtType === et) {
evh[i].executeCb(evt, this.eh, this.parent.vscope);
break;
}
}
}
} | [
"function",
"(",
"evt",
")",
"{",
"var",
"evh",
"=",
"this",
".",
"evtHandlers",
",",
"et",
"=",
"evt",
".",
"type",
";",
"if",
"(",
"evh",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"sz",
"=",
"evh",
".",
"length",
";",
"sz",
">",
"i... | Callback called by the controller observer when the controller raises an event | [
"Callback",
"called",
"by",
"the",
"controller",
"observer",
"when",
"the",
"controller",
"raises",
"an",
"event"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptcomponent.js#L382-L392 | train | |
ariatemplates/hashspace | hsp/rt/cptcomponent.js | function (prevNode, newNode) {
if (prevNode === newNode) {
return;
}
TNode.replaceNodeBy.call(this,prevNode, newNode);
var aen=this.attEltNodes;
if (aen) {
for (var i=0,sz=aen.length; sz>i;i++) {
aen[i].replaceNodeBy(prevNode, newNode);
}
}... | javascript | function (prevNode, newNode) {
if (prevNode === newNode) {
return;
}
TNode.replaceNodeBy.call(this,prevNode, newNode);
var aen=this.attEltNodes;
if (aen) {
for (var i=0,sz=aen.length; sz>i;i++) {
aen[i].replaceNodeBy(prevNode, newNode);
}
}... | [
"function",
"(",
"prevNode",
",",
"newNode",
")",
"{",
"if",
"(",
"prevNode",
"===",
"newNode",
")",
"{",
"return",
";",
"}",
"TNode",
".",
"replaceNodeBy",
".",
"call",
"(",
"this",
",",
"prevNode",
",",
"newNode",
")",
";",
"var",
"aen",
"=",
"this... | Recursively replace the DOM node by another node if it matches the preNode passed as argument | [
"Recursively",
"replace",
"the",
"DOM",
"node",
"by",
"another",
"node",
"if",
"it",
"matches",
"the",
"preNode",
"passed",
"as",
"argument"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptcomponent.js#L397-L408 | train | |
ariatemplates/hashspace | hsp/rt/cptcomponent.js | function() {
var c=[], ce=this.childElements, celts=this.ctlElements, eltType;
if (ce && ce.length) {
for (var i=0, sz=ce.length;sz>i;i++) {
eltType=celts[ce[i].name].type;
if (eltType==="component") {
c.push(ce[i].controller);
} else if (eltType==="template") {
... | javascript | function() {
var c=[], ce=this.childElements, celts=this.ctlElements, eltType;
if (ce && ce.length) {
for (var i=0, sz=ce.length;sz>i;i++) {
eltType=celts[ce[i].name].type;
if (eltType==="component") {
c.push(ce[i].controller);
} else if (eltType==="template") {
... | [
"function",
"(",
")",
"{",
"var",
"c",
"=",
"[",
"]",
",",
"ce",
"=",
"this",
".",
"childElements",
",",
"celts",
"=",
"this",
".",
"ctlElements",
",",
"eltType",
";",
"if",
"(",
"ce",
"&&",
"ce",
".",
"length",
")",
"{",
"for",
"(",
"var",
"i"... | Calculate the content array that will be set on component's controller | [
"Calculate",
"the",
"content",
"array",
"that",
"will",
"be",
"set",
"on",
"component",
"s",
"controller"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptcomponent.js#L413-L428 | train | |
ariatemplates/hashspace | hsp/rt/cptcomponent.js | function () {
if (this.edirty) {
var en=this.attEltNodes;
if (en) {
for (var i=0,sz=en.length; sz>i; i++) {
en[i].refresh();
}
// if content changed we have to rebuild childElements
this.retrieveAttElements();
... | javascript | function () {
if (this.edirty) {
var en=this.attEltNodes;
if (en) {
for (var i=0,sz=en.length; sz>i; i++) {
en[i].refresh();
}
// if content changed we have to rebuild childElements
this.retrieveAttElements();
... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"edirty",
")",
"{",
"var",
"en",
"=",
"this",
".",
"attEltNodes",
";",
"if",
"(",
"en",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"sz",
"=",
"en",
".",
"length",
";",
"sz",
">",
"i",... | Refresh the sub-template arguments and the child nodes, if needed | [
"Refresh",
"the",
"sub",
"-",
"template",
"arguments",
"and",
"the",
"child",
"nodes",
"if",
"needed"
] | 24cb510288566eba0e33ff55949adb54c0a89fac | https://github.com/ariatemplates/hashspace/blob/24cb510288566eba0e33ff55949adb54c0a89fac/hsp/rt/cptcomponent.js#L433-L456 | train | |
floridoo/scarab | lib/routing.js | getAction | function getAction(controllerName, actionName) {
controllerName = controllerName.camelize();
var controller = app.controllers[controllerName];
if (controller === undefined && app.models[controllerName])
controller = defaultController;
if (controller)
return controller[actionName || 'index'];
else
re... | javascript | function getAction(controllerName, actionName) {
controllerName = controllerName.camelize();
var controller = app.controllers[controllerName];
if (controller === undefined && app.models[controllerName])
controller = defaultController;
if (controller)
return controller[actionName || 'index'];
else
re... | [
"function",
"getAction",
"(",
"controllerName",
",",
"actionName",
")",
"{",
"controllerName",
"=",
"controllerName",
".",
"camelize",
"(",
")",
";",
"var",
"controller",
"=",
"app",
".",
"controllers",
"[",
"controllerName",
"]",
";",
"if",
"(",
"controller",... | Find the action function based on controller name and action name.
If no controller but a model is found, the default controller is taken.
@param {String} controllerName controller name
@param {String} actionName action name
@return {Function} action function | [
"Find",
"the",
"action",
"function",
"based",
"on",
"controller",
"name",
"and",
"action",
"name",
".",
"If",
"no",
"controller",
"but",
"a",
"model",
"is",
"found",
"the",
"default",
"controller",
"is",
"taken",
"."
] | 377ebd79563b8fa654bb18324aed00d72500e7f6 | https://github.com/floridoo/scarab/blob/377ebd79563b8fa654bb18324aed00d72500e7f6/lib/routing.js#L18-L28 | train |
floridoo/scarab | lib/routing.js | addSingleRoute | function addSingleRoute(verb, routePath, controllerName, actionName) {
// add controller and action fields to the request
var reqExtender = function(req, res, next) {
req.controller = controllerName;
req.action = actionName || 'index';
next();
};
var params = [routePath, reqExtender];
params = param... | javascript | function addSingleRoute(verb, routePath, controllerName, actionName) {
// add controller and action fields to the request
var reqExtender = function(req, res, next) {
req.controller = controllerName;
req.action = actionName || 'index';
next();
};
var params = [routePath, reqExtender];
params = param... | [
"function",
"addSingleRoute",
"(",
"verb",
",",
"routePath",
",",
"controllerName",
",",
"actionName",
")",
"{",
"// add controller and action fields to the request",
"var",
"reqExtender",
"=",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"req",
".",... | adds a single route
@param {String} verb HTTP verb
@param {String} routePath routing path
@param {String} controllerName controller name
@param {String} actionName action name | [
"adds",
"a",
"single",
"route"
] | 377ebd79563b8fa654bb18324aed00d72500e7f6 | https://github.com/floridoo/scarab/blob/377ebd79563b8fa654bb18324aed00d72500e7f6/lib/routing.js#L37-L50 | train |
floridoo/scarab | lib/routing.js | function(req, res, next) {
req.controller = controllerName;
req.action = actionName || 'index';
next();
} | javascript | function(req, res, next) {
req.controller = controllerName;
req.action = actionName || 'index';
next();
} | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"req",
".",
"controller",
"=",
"controllerName",
";",
"req",
".",
"action",
"=",
"actionName",
"||",
"'index'",
";",
"next",
"(",
")",
";",
"}"
] | add controller and action fields to the request | [
"add",
"controller",
"and",
"action",
"fields",
"to",
"the",
"request"
] | 377ebd79563b8fa654bb18324aed00d72500e7f6 | https://github.com/floridoo/scarab/blob/377ebd79563b8fa654bb18324aed00d72500e7f6/lib/routing.js#L39-L43 | train | |
floridoo/scarab | lib/routing.js | getPolicies | function getPolicies(controller, action) {
var policies = config.policies;
var currentPolicies = [];
if (policies[controller] && policies[controller][action]) {
currentPolicies = policies[controller][action];
} else if (Object.isString(policies[controller])) {
currentPolicies = policies[controller];
} e... | javascript | function getPolicies(controller, action) {
var policies = config.policies;
var currentPolicies = [];
if (policies[controller] && policies[controller][action]) {
currentPolicies = policies[controller][action];
} else if (Object.isString(policies[controller])) {
currentPolicies = policies[controller];
} e... | [
"function",
"getPolicies",
"(",
"controller",
",",
"action",
")",
"{",
"var",
"policies",
"=",
"config",
".",
"policies",
";",
"var",
"currentPolicies",
"=",
"[",
"]",
";",
"if",
"(",
"policies",
"[",
"controller",
"]",
"&&",
"policies",
"[",
"controller",... | gets the policies in effect for a given controller and action
@param {String} controller
@param {String} action
@return {Array} policies | [
"gets",
"the",
"policies",
"in",
"effect",
"for",
"a",
"given",
"controller",
"and",
"action"
] | 377ebd79563b8fa654bb18324aed00d72500e7f6 | https://github.com/floridoo/scarab/blob/377ebd79563b8fa654bb18324aed00d72500e7f6/lib/routing.js#L58-L84 | train |
floridoo/scarab | lib/routing.js | addResourceRoute | function addResourceRoute(routePath, controllerName) {
resourceRouting.forEach(function(route) {
var actionPath = route.path.replace(':controller', controllerName);
route.verbs.forEach(function (verb) {
addSingleRoute(verb, actionPath, controllerName, route.target.action);
});
});
} | javascript | function addResourceRoute(routePath, controllerName) {
resourceRouting.forEach(function(route) {
var actionPath = route.path.replace(':controller', controllerName);
route.verbs.forEach(function (verb) {
addSingleRoute(verb, actionPath, controllerName, route.target.action);
});
});
} | [
"function",
"addResourceRoute",
"(",
"routePath",
",",
"controllerName",
")",
"{",
"resourceRouting",
".",
"forEach",
"(",
"function",
"(",
"route",
")",
"{",
"var",
"actionPath",
"=",
"route",
".",
"path",
".",
"replace",
"(",
"':controller'",
",",
"controlle... | add a resource route
@param {String} routePath route path
@param {String} controllerName controller name | [
"add",
"a",
"resource",
"route"
] | 377ebd79563b8fa654bb18324aed00d72500e7f6 | https://github.com/floridoo/scarab/blob/377ebd79563b8fa654bb18324aed00d72500e7f6/lib/routing.js#L108-L115 | 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.