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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
skerit/json-dry | lib/json-dry.js | registerUndrier | function registerUndrier(constructor, fnc, options) {
var path;
if (typeof constructor == 'function') {
path = constructor.name;
} else {
path = constructor;
}
undriers[path] = {
fnc : fnc,
options : options || {}
};
} | javascript | function registerUndrier(constructor, fnc, options) {
var path;
if (typeof constructor == 'function') {
path = constructor.name;
} else {
path = constructor;
}
undriers[path] = {
fnc : fnc,
options : options || {}
};
} | [
"function",
"registerUndrier",
"(",
"constructor",
",",
"fnc",
",",
"options",
")",
"{",
"var",
"path",
";",
"if",
"(",
"typeof",
"constructor",
"==",
"'function'",
")",
"{",
"path",
"=",
"constructor",
".",
"name",
";",
"}",
"else",
"{",
"path",
"=",
... | Register an undrier
@author Jelle De Loecker <jelle@develry.be>
@since 1.0.0
@version 1.0.0
@param {Function|String} constructor What constructor to listen to
@param {Function} fnc
@param {Object} options | [
"Register",
"an",
"undrier"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L631-L645 | train |
skerit/json-dry | lib/json-dry.js | findClass | function findClass(value) {
var constructor,
ns;
// Return nothing for falsy values
if (!value) {
return null;
}
// Look for a regular class when it's just a string
if (typeof value == 'string') {
if (exports.Classes[value]) {
return exports.Classes[value];
}
return null;
}
if (value.path)... | javascript | function findClass(value) {
var constructor,
ns;
// Return nothing for falsy values
if (!value) {
return null;
}
// Look for a regular class when it's just a string
if (typeof value == 'string') {
if (exports.Classes[value]) {
return exports.Classes[value];
}
return null;
}
if (value.path)... | [
"function",
"findClass",
"(",
"value",
")",
"{",
"var",
"constructor",
",",
"ns",
";",
"// Return nothing for falsy values",
"if",
"(",
"!",
"value",
")",
"{",
"return",
"null",
";",
"}",
"// Look for a regular class when it's just a string",
"if",
"(",
"typeof",
... | Find a class
@author Jelle De Loecker <jelle@develry.be>
@since 1.0.0
@version 1.0.9
@param {String} value The name of the class | [
"Find",
"a",
"class"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L687-L738 | train |
skerit/json-dry | lib/json-dry.js | regenerateArray | function regenerateArray(root, holder, current, seen, retrieve, undry_paths, old, current_path) {
var length = current.length,
temp,
i;
for (i = 0; i < length; i++) {
// Only regenerate if it's not yet seen
if (!seen.get(current[i])) {
temp = current_path.slice(0);
temp.push(i);
current[i] ... | javascript | function regenerateArray(root, holder, current, seen, retrieve, undry_paths, old, current_path) {
var length = current.length,
temp,
i;
for (i = 0; i < length; i++) {
// Only regenerate if it's not yet seen
if (!seen.get(current[i])) {
temp = current_path.slice(0);
temp.push(i);
current[i] ... | [
"function",
"regenerateArray",
"(",
"root",
",",
"holder",
",",
"current",
",",
"seen",
",",
"retrieve",
",",
"undry_paths",
",",
"old",
",",
"current_path",
")",
"{",
"var",
"length",
"=",
"current",
".",
"length",
",",
"temp",
",",
"i",
";",
"for",
"... | Regenerate an array
@author Jelle De Loecker <jelle@develry.be>
@since 0.1.4
@version 1.0.8
@return {Array} | [
"Regenerate",
"an",
"array"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L749-L767 | train |
skerit/json-dry | lib/json-dry.js | regenerateObject | function regenerateObject(root, holder, current, seen, retrieve, undry_paths, old, current_path) {
var path,
temp,
key;
for (key in current) {
if (current.hasOwnProperty(key)) {
// Only regenerate if it's not already seen
if (!seen.get(current[key])) {
path = current_path.slice(0);
path.pu... | javascript | function regenerateObject(root, holder, current, seen, retrieve, undry_paths, old, current_path) {
var path,
temp,
key;
for (key in current) {
if (current.hasOwnProperty(key)) {
// Only regenerate if it's not already seen
if (!seen.get(current[key])) {
path = current_path.slice(0);
path.pu... | [
"function",
"regenerateObject",
"(",
"root",
",",
"holder",
",",
"current",
",",
"seen",
",",
"retrieve",
",",
"undry_paths",
",",
"old",
",",
"current_path",
")",
"{",
"var",
"path",
",",
"temp",
",",
"key",
";",
"for",
"(",
"key",
"in",
"current",
")... | Regenerate an object
@author Jelle De Loecker <jelle@develry.be>
@since 0.1.4
@version 1.0.11
@return {Object} | [
"Regenerate",
"an",
"object"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L778-L807 | train |
skerit/json-dry | lib/json-dry.js | regenerate | function regenerate(root, holder, current, seen, retrieve, undry_paths, old, current_path) {
var temp;
if (current && typeof current == 'object') {
// Remember this object has been regenerated already
seen.set(current, true);
if (current instanceof Array) {
return regenerateArray(root, holder, current, se... | javascript | function regenerate(root, holder, current, seen, retrieve, undry_paths, old, current_path) {
var temp;
if (current && typeof current == 'object') {
// Remember this object has been regenerated already
seen.set(current, true);
if (current instanceof Array) {
return regenerateArray(root, holder, current, se... | [
"function",
"regenerate",
"(",
"root",
",",
"holder",
",",
"current",
",",
"seen",
",",
"retrieve",
",",
"undry_paths",
",",
"old",
",",
"current_path",
")",
"{",
"var",
"temp",
";",
"if",
"(",
"current",
"&&",
"typeof",
"current",
"==",
"'object'",
")",... | Regenerate a value
@author Jelle De Loecker <jelle@develry.be>
@since 0.1.4
@version 1.0.8
@return {Mixed} | [
"Regenerate",
"a",
"value"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L818-L881 | train |
skerit/json-dry | lib/json-dry.js | getFromOld | function getFromOld(old, pieces) {
var length = pieces.length,
result,
path,
rest,
i;
for (i = 0; i < length; i++) {
path = pieces.slice(0, length - i).join('.');
result = old[path];
if (typeof result != 'undefined') {
if (i == 0) {
return result;
}
rest = pieces.slice(pie... | javascript | function getFromOld(old, pieces) {
var length = pieces.length,
result,
path,
rest,
i;
for (i = 0; i < length; i++) {
path = pieces.slice(0, length - i).join('.');
result = old[path];
if (typeof result != 'undefined') {
if (i == 0) {
return result;
}
rest = pieces.slice(pie... | [
"function",
"getFromOld",
"(",
"old",
",",
"pieces",
")",
"{",
"var",
"length",
"=",
"pieces",
".",
"length",
",",
"result",
",",
"path",
",",
"rest",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
... | Find path in an "old" object
@author Jelle De Loecker <jelle@develry.be>
@since 1.0.10
@version 1.0.10
@param {Object} old The object to look in
@param {Array} pieces The path to look for
@return {Mixed} | [
"Find",
"path",
"in",
"an",
"old",
"object"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L895-L923 | train |
skerit/json-dry | lib/json-dry.js | retrieveFromPath | function retrieveFromPath(current, keys) {
var length = keys.length,
prev,
key,
i;
// Keys [''] always means the root
if (length == 1 && keys[0] === '') {
return current;
}
for (i = 0; i < length; i++) {
key = keys[i];
// Normalize the key
if (typeof key == 'number') {
// Allow
} el... | javascript | function retrieveFromPath(current, keys) {
var length = keys.length,
prev,
key,
i;
// Keys [''] always means the root
if (length == 1 && keys[0] === '') {
return current;
}
for (i = 0; i < length; i++) {
key = keys[i];
// Normalize the key
if (typeof key == 'number') {
// Allow
} el... | [
"function",
"retrieveFromPath",
"(",
"current",
",",
"keys",
")",
"{",
"var",
"length",
"=",
"keys",
".",
"length",
",",
"prev",
",",
"key",
",",
"i",
";",
"// Keys [''] always means the root",
"if",
"(",
"length",
"==",
"1",
"&&",
"keys",
"[",
"0",
"]",... | Retrieve from path.
Set the given value, but only if the containing object exists.
@author Jelle De Loecker <jelle@develry.be>
@since 0.1.4
@version 1.0.10
@param {Object} current The object to look in
@param {Array} keys The path to look for
@param {Mixed} value Optional value to ... | [
"Retrieve",
"from",
"path",
".",
"Set",
"the",
"given",
"value",
"but",
"only",
"if",
"the",
"containing",
"object",
"exists",
"."
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L939-L975 | train |
skerit/json-dry | lib/json-dry.js | fromPath | function fromPath(obj, path) {
var pieces,
here,
len,
i;
if (typeof path == 'string') {
pieces = path.split('.');
} else {
pieces = path;
}
here = obj;
// Go over every piece in the path
for (i = 0; i < pieces.length; i++) {
if (here != null) {
if (here.hasOwnProperty(pieces[i])) {
... | javascript | function fromPath(obj, path) {
var pieces,
here,
len,
i;
if (typeof path == 'string') {
pieces = path.split('.');
} else {
pieces = path;
}
here = obj;
// Go over every piece in the path
for (i = 0; i < pieces.length; i++) {
if (here != null) {
if (here.hasOwnProperty(pieces[i])) {
... | [
"function",
"fromPath",
"(",
"obj",
",",
"path",
")",
"{",
"var",
"pieces",
",",
"here",
",",
"len",
",",
"i",
";",
"if",
"(",
"typeof",
"path",
"==",
"'string'",
")",
"{",
"pieces",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
";",
"}",
"else",
... | Extract something from an object by the path
@author Jelle De Loecker <jelle@develry.be>
@since 0.1.0
@version 1.0.0
@param {Object} obj
@param {String} path
@return {Mixed} | [
"Extract",
"something",
"from",
"an",
"object",
"by",
"the",
"path"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L989-L1018 | train |
skerit/json-dry | lib/json-dry.js | setPath | function setPath(obj, keys, value, force) {
var here,
i;
here = obj;
for (i = 0; i < keys.length - 1; i++) {
if (here != null) {
if (here.hasOwnProperty(keys[i])) {
here = here[keys[i]];
} else {
if (force && here[keys[i]] == null) {
here[keys[i]] = {};
here = here[keys[i]];
c... | javascript | function setPath(obj, keys, value, force) {
var here,
i;
here = obj;
for (i = 0; i < keys.length - 1; i++) {
if (here != null) {
if (here.hasOwnProperty(keys[i])) {
here = here[keys[i]];
} else {
if (force && here[keys[i]] == null) {
here[keys[i]] = {};
here = here[keys[i]];
c... | [
"function",
"setPath",
"(",
"obj",
",",
"keys",
",",
"value",
",",
"force",
")",
"{",
"var",
"here",
",",
"i",
";",
"here",
"=",
"obj",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
"-",
"1",
";",
"i",
"++",
")",
"{"... | Set something on the given path
@author Jelle De Loecker <jelle@develry.be>
@since 1.0.0
@version 1.0.2
@param {Object} obj
@param {Array} path
@param {Boolean} force If a piece of the path doesn't exist, create it
@return {Mixed} | [
"Set",
"something",
"on",
"the",
"given",
"path"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L1033-L1058 | train |
skerit/json-dry | lib/json-dry.js | toDryObject | function toDryObject(value, replacer) {
var root = {'': value};
return createDryReplacer(root, replacer)(root, '', value);
} | javascript | function toDryObject(value, replacer) {
var root = {'': value};
return createDryReplacer(root, replacer)(root, '', value);
} | [
"function",
"toDryObject",
"(",
"value",
",",
"replacer",
")",
"{",
"var",
"root",
"=",
"{",
"''",
":",
"value",
"}",
";",
"return",
"createDryReplacer",
"(",
"root",
",",
"replacer",
")",
"(",
"root",
",",
"''",
",",
"value",
")",
";",
"}"
] | Convert an object to a DRY object, ready for stringifying
@author Jelle De Loecker <jelle@develry.be>
@since 1.0.0
@version 1.0.0
@param {Object} value
@param {Function} replacer
@return {Object} | [
"Convert",
"an",
"object",
"to",
"a",
"DRY",
"object",
"ready",
"for",
"stringifying"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L1072-L1075 | train |
skerit/json-dry | lib/json-dry.js | stringify | function stringify(value, replacer, space) {
return JSON.stringify(toDryObject(value, replacer), null, space);
} | javascript | function stringify(value, replacer, space) {
return JSON.stringify(toDryObject(value, replacer), null, space);
} | [
"function",
"stringify",
"(",
"value",
",",
"replacer",
",",
"space",
")",
"{",
"return",
"JSON",
".",
"stringify",
"(",
"toDryObject",
"(",
"value",
",",
"replacer",
")",
",",
"null",
",",
"space",
")",
";",
"}"
] | Convert directly to a string
@author Jelle De Loecker <jelle@develry.be>
@since 1.0.0
@version 1.0.0
@param {Object} value
@param {Function} replacer
@return {Object} | [
"Convert",
"directly",
"to",
"a",
"string"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L1089-L1091 | train |
skerit/json-dry | lib/json-dry.js | walk | function walk(obj, fnc, result) {
var is_root,
keys,
key,
ret,
i;
if (!result) {
is_root = true;
if (Array.isArray(obj)) {
result = [];
} else {
result = {};
}
}
keys = Object.keys(obj);
for (i = 0; i < keys.length; i++) {
key = keys[i];
if (typeof obj[key] == 'object' &... | javascript | function walk(obj, fnc, result) {
var is_root,
keys,
key,
ret,
i;
if (!result) {
is_root = true;
if (Array.isArray(obj)) {
result = [];
} else {
result = {};
}
}
keys = Object.keys(obj);
for (i = 0; i < keys.length; i++) {
key = keys[i];
if (typeof obj[key] == 'object' &... | [
"function",
"walk",
"(",
"obj",
",",
"fnc",
",",
"result",
")",
"{",
"var",
"is_root",
",",
"keys",
",",
"key",
",",
"ret",
",",
"i",
";",
"if",
"(",
"!",
"result",
")",
"{",
"is_root",
"=",
"true",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",... | Map an object
@author Jelle De Loecker <jelle@develry.be>
@since 0.4.2
@version 1.0.0
@param {Object} obj The object to walk over
@param {Function} fnc The function to perform on every entry
@param {Object} result The object to add to
@return {Object} | [
"Map",
"an",
"object"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L1106-L1147 | train |
skerit/json-dry | lib/json-dry.js | parse | function parse(object, reviver) {
var undry_paths = new Map(),
retrieve = {},
reviver,
result,
holder,
entry,
temp,
seen,
path,
key,
old = {};
// Create the reviver function
reviver = generateReviver(reviver, undry_paths);
if (typeof object == 'string') {
ob... | javascript | function parse(object, reviver) {
var undry_paths = new Map(),
retrieve = {},
reviver,
result,
holder,
entry,
temp,
seen,
path,
key,
old = {};
// Create the reviver function
reviver = generateReviver(reviver, undry_paths);
if (typeof object == 'string') {
ob... | [
"function",
"parse",
"(",
"object",
",",
"reviver",
")",
"{",
"var",
"undry_paths",
"=",
"new",
"Map",
"(",
")",
",",
"retrieve",
"=",
"{",
"}",
",",
"reviver",
",",
"result",
",",
"holder",
",",
"entry",
",",
"temp",
",",
"seen",
",",
"path",
",",... | Convert from a dried object
@author Jelle De Loecker <jelle@develry.be>
@since 1.0.0
@version 1.0.4
@param {Object} value
@return {Object} | [
"Convert",
"from",
"a",
"dried",
"object"
] | f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546 | https://github.com/skerit/json-dry/blob/f20fd8e4aa3bcfe133f3c1a5b5b6ea3aa7060546/lib/json-dry.js#L1160-L1272 | train |
KrisSiegel/msngr.js | msngr.js | function () {
var inputs = Array.prototype.slice.call(arguments, 0);
return external.message.apply(this, inputs);
} | javascript | function () {
var inputs = Array.prototype.slice.call(arguments, 0);
return external.message.apply(this, inputs);
} | [
"function",
"(",
")",
"{",
"var",
"inputs",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"return",
"external",
".",
"message",
".",
"apply",
"(",
"this",
",",
"inputs",
")",
";",
"}"
] | The external function that holds all external APIs | [
"The",
"external",
"function",
"that",
"holds",
"all",
"external",
"APIs"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L14-L18 | train | |
KrisSiegel/msngr.js | msngr.js | function (type, item, hard) {
if (hard) {
return harderTypes[type](getType(item), item);
}
return (getType(item) === simpleTypes[type]);
} | javascript | function (type, item, hard) {
if (hard) {
return harderTypes[type](getType(item), item);
}
return (getType(item) === simpleTypes[type]);
} | [
"function",
"(",
"type",
",",
"item",
",",
"hard",
")",
"{",
"if",
"(",
"hard",
")",
"{",
"return",
"harderTypes",
"[",
"type",
"]",
"(",
"getType",
"(",
"item",
")",
",",
"item",
")",
";",
"}",
"return",
"(",
"getType",
"(",
"item",
")",
"===",
... | Check a type against an input | [
"Check",
"a",
"type",
"against",
"an",
"input"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L109-L114 | train | |
KrisSiegel/msngr.js | msngr.js | function (type, item) {
switch(type) {
case simpleTypes.undefined:
case simpleTypes.null:
return true;
case simpleTypes.string:
if (item.trim().length === 0) {
return true;
}
return false;
... | javascript | function (type, item) {
switch(type) {
case simpleTypes.undefined:
case simpleTypes.null:
return true;
case simpleTypes.string:
if (item.trim().length === 0) {
return true;
}
return false;
... | [
"function",
"(",
"type",
",",
"item",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"simpleTypes",
".",
"undefined",
":",
"case",
"simpleTypes",
".",
"null",
":",
"return",
"true",
";",
"case",
"simpleTypes",
".",
"string",
":",
"if",
"(",
"item",... | Check an object for empiness | [
"Check",
"an",
"object",
"for",
"empiness"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L117-L134 | train | |
KrisSiegel/msngr.js | msngr.js | function (inputs) {
var props = { };
// Create a function to call with simple and hard types
// This is done so simple types don't need to check for hard types
var generateProps = function (types, hard) {
for (var t in types) {
if (types.hasOwnProperty(t)) {
... | javascript | function (inputs) {
var props = { };
// Create a function to call with simple and hard types
// This is done so simple types don't need to check for hard types
var generateProps = function (types, hard) {
for (var t in types) {
if (types.hasOwnProperty(t)) {
... | [
"function",
"(",
"inputs",
")",
"{",
"var",
"props",
"=",
"{",
"}",
";",
"// Create a function to call with simple and hard types",
"// This is done so simple types don't need to check for hard types",
"var",
"generateProps",
"=",
"function",
"(",
"types",
",",
"hard",
")",... | Bulld the properties that the is function returns for testing values | [
"Bulld",
"the",
"properties",
"that",
"the",
"is",
"function",
"returns",
"for",
"testing",
"values"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L137-L189 | train | |
KrisSiegel/msngr.js | msngr.js | function (types, hard) {
for (var t in types) {
if (types.hasOwnProperty(t)) {
(function (prop) {
Object.defineProperty(props, prop, {
get: function () {
for (var i = 0; i < inputs.length;... | javascript | function (types, hard) {
for (var t in types) {
if (types.hasOwnProperty(t)) {
(function (prop) {
Object.defineProperty(props, prop, {
get: function () {
for (var i = 0; i < inputs.length;... | [
"function",
"(",
"types",
",",
"hard",
")",
"{",
"for",
"(",
"var",
"t",
"in",
"types",
")",
"{",
"if",
"(",
"types",
".",
"hasOwnProperty",
"(",
"t",
")",
")",
"{",
"(",
"function",
"(",
"prop",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"p... | Create a function to call with simple and hard types This is done so simple types don't need to check for hard types | [
"Create",
"a",
"function",
"to",
"call",
"with",
"simple",
"and",
"hard",
"types",
"This",
"is",
"done",
"so",
"simple",
"types",
"don",
"t",
"need",
"to",
"check",
"for",
"hard",
"types"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L142-L159 | train | |
KrisSiegel/msngr.js | msngr.js | function (obj1, obj2, overwrite) {
if (obj1 === undefined || obj1 === null) { return obj2; };
if (obj2 === undefined || obj2 === null) { return obj1; };
var obj1Type = external.is(obj1).getType();
var obj2Type = external.is(obj2).getType();
var exceptionMsg;
if (accepta... | javascript | function (obj1, obj2, overwrite) {
if (obj1 === undefined || obj1 === null) { return obj2; };
if (obj2 === undefined || obj2 === null) { return obj1; };
var obj1Type = external.is(obj1).getType();
var obj2Type = external.is(obj2).getType();
var exceptionMsg;
if (accepta... | [
"function",
"(",
"obj1",
",",
"obj2",
",",
"overwrite",
")",
"{",
"if",
"(",
"obj1",
"===",
"undefined",
"||",
"obj1",
"===",
"null",
")",
"{",
"return",
"obj2",
";",
"}",
";",
"if",
"(",
"obj2",
"===",
"undefined",
"||",
"obj2",
"===",
"null",
")"... | Merge two items together and return the result | [
"Merge",
"two",
"items",
"together",
"and",
"return",
"the",
"result"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L428-L476 | train | |
KrisSiegel/msngr.js | msngr.js | function(arr, value) {
var inx = arr.indexOf(value);
var endIndex = arr.length - 1;
if (inx !== endIndex) {
var temp = arr[endIndex];
arr[endIndex] = arr[inx];
arr[inx] = temp;
}
arr.pop();
} | javascript | function(arr, value) {
var inx = arr.indexOf(value);
var endIndex = arr.length - 1;
if (inx !== endIndex) {
var temp = arr[endIndex];
arr[endIndex] = arr[inx];
arr[inx] = temp;
}
arr.pop();
} | [
"function",
"(",
"arr",
",",
"value",
")",
"{",
"var",
"inx",
"=",
"arr",
".",
"indexOf",
"(",
"value",
")",
";",
"var",
"endIndex",
"=",
"arr",
".",
"length",
"-",
"1",
";",
"if",
"(",
"inx",
"!==",
"endIndex",
")",
"{",
"var",
"temp",
"=",
"a... | A more efficient element removal from an array in cases where the array is large | [
"A",
"more",
"efficient",
"element",
"removal",
"from",
"an",
"array",
"in",
"cases",
"where",
"the",
"array",
"is",
"large"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L651-L660 | train | |
KrisSiegel/msngr.js | msngr.js | function (uses, payload, message) {
var results = [];
var keys = (uses || []);
for (var i = 0; i < forced.length; ++i) {
if (keys.indexOf(forced[i]) === -1) {
keys.push(forced[i]);
}
}
for (var i = 0; i < keys.length; ++i) {
if... | javascript | function (uses, payload, message) {
var results = [];
var keys = (uses || []);
for (var i = 0; i < forced.length; ++i) {
if (keys.indexOf(forced[i]) === -1) {
keys.push(forced[i]);
}
}
for (var i = 0; i < keys.length; ++i) {
if... | [
"function",
"(",
"uses",
",",
"payload",
",",
"message",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"var",
"keys",
"=",
"(",
"uses",
"||",
"[",
"]",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"forced",
".",
"length",
";",... | gets a listing of middlewares | [
"gets",
"a",
"listing",
"of",
"middlewares"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L858-L877 | train | |
KrisSiegel/msngr.js | msngr.js | function (uses, payload, message, callback) {
var middles = getMiddlewares(uses, payload, message);
internal.executer(middles).series(function (result) {
return callback(internal.merge.apply(this, [payload].concat(result)));
});
} | javascript | function (uses, payload, message, callback) {
var middles = getMiddlewares(uses, payload, message);
internal.executer(middles).series(function (result) {
return callback(internal.merge.apply(this, [payload].concat(result)));
});
} | [
"function",
"(",
"uses",
",",
"payload",
",",
"message",
",",
"callback",
")",
"{",
"var",
"middles",
"=",
"getMiddlewares",
"(",
"uses",
",",
"payload",
",",
"message",
")",
";",
"internal",
".",
"executer",
"(",
"middles",
")",
".",
"series",
"(",
"f... | Expose method to the internal API for testing Executes middlewares | [
"Expose",
"method",
"to",
"the",
"internal",
"API",
"for",
"testing",
"Executes",
"middlewares"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L882-L887 | train | |
KrisSiegel/msngr.js | msngr.js | function (msgOrIds, payload, callback) {
var ids = (external.is(msgOrIds).array) ? msgOrIds : messageIndex.query(msgOrIds);
if (ids.length > 0) {
var methods = [];
var toDrop = [];
for (var i = 0; i < ids.length; ++i) {
var msg = (external.is(msgOrIds... | javascript | function (msgOrIds, payload, callback) {
var ids = (external.is(msgOrIds).array) ? msgOrIds : messageIndex.query(msgOrIds);
if (ids.length > 0) {
var methods = [];
var toDrop = [];
for (var i = 0; i < ids.length; ++i) {
var msg = (external.is(msgOrIds... | [
"function",
"(",
"msgOrIds",
",",
"payload",
",",
"callback",
")",
"{",
"var",
"ids",
"=",
"(",
"external",
".",
"is",
"(",
"msgOrIds",
")",
".",
"array",
")",
"?",
"msgOrIds",
":",
"messageIndex",
".",
"query",
"(",
"msgOrIds",
")",
";",
"if",
"(",
... | An explicit emit | [
"An",
"explicit",
"emit"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L897-L927 | train | |
dy/image-output | fixture/index.js | drawToCanvas | function drawToCanvas({data, width, height}) {
if (typeof document === 'undefined') return null
var canvas = document.createElement('canvas')
canvas.width = width
canvas.height = height
var context = canvas.getContext('2d')
var idata = context.createImageData(canvas.width, canvas.height)
for ... | javascript | function drawToCanvas({data, width, height}) {
if (typeof document === 'undefined') return null
var canvas = document.createElement('canvas')
canvas.width = width
canvas.height = height
var context = canvas.getContext('2d')
var idata = context.createImageData(canvas.width, canvas.height)
for ... | [
"function",
"drawToCanvas",
"(",
"{",
"data",
",",
"width",
",",
"height",
"}",
")",
"{",
"if",
"(",
"typeof",
"document",
"===",
"'undefined'",
")",
"return",
"null",
"var",
"canvas",
"=",
"document",
".",
"createElement",
"(",
"'canvas'",
")",
"canvas",
... | draw buffer on the canvas | [
"draw",
"buffer",
"on",
"the",
"canvas"
] | 19ba289cf3d67c2893d3247d918cd4134ae1afc1 | https://github.com/dy/image-output/blob/19ba289cf3d67c2893d3247d918cd4134ae1afc1/fixture/index.js#L30-L43 | train |
enricostara/telegram-tl-node | lib/builder/type-builder.js | inheritsTlSchema | function inheritsTlSchema(constructor, superTlSchema) {
var NewType = buildType('abstract', superTlSchema);
util.inherits(constructor, NewType);
constructor.s_ = NewType;
constructor.super_ = NewType.super_;
constructor.util = NewType.util;
constructor.requireTypeByName = NewType.requireTypeByNa... | javascript | function inheritsTlSchema(constructor, superTlSchema) {
var NewType = buildType('abstract', superTlSchema);
util.inherits(constructor, NewType);
constructor.s_ = NewType;
constructor.super_ = NewType.super_;
constructor.util = NewType.util;
constructor.requireTypeByName = NewType.requireTypeByNa... | [
"function",
"inheritsTlSchema",
"(",
"constructor",
",",
"superTlSchema",
")",
"{",
"var",
"NewType",
"=",
"buildType",
"(",
"'abstract'",
",",
"superTlSchema",
")",
";",
"util",
".",
"inherits",
"(",
"constructor",
",",
"NewType",
")",
";",
"constructor",
"."... | Extend the 'constructor' with the Type generated by the 'superTLSchema' | [
"Extend",
"the",
"constructor",
"with",
"the",
"Type",
"generated",
"by",
"the",
"superTLSchema"
] | 8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7 | https://github.com/enricostara/telegram-tl-node/blob/8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7/lib/builder/type-builder.js#L26-L35 | train |
enricostara/telegram-tl-node | lib/builder/type-builder.js | buildTypeFunction | function buildTypeFunction(module, tlSchema) {
var methodName = tlSchema.method;
// Start creating the body of the new Type function
var body =
'\tvar self = arguments.callee;\n' +
'\tvar callback = options.callback;\n' +
'\tvar channel = options.channel;\n' +
'\tif (!channel... | javascript | function buildTypeFunction(module, tlSchema) {
var methodName = tlSchema.method;
// Start creating the body of the new Type function
var body =
'\tvar self = arguments.callee;\n' +
'\tvar callback = options.callback;\n' +
'\tvar channel = options.channel;\n' +
'\tif (!channel... | [
"function",
"buildTypeFunction",
"(",
"module",
",",
"tlSchema",
")",
"{",
"var",
"methodName",
"=",
"tlSchema",
".",
"method",
";",
"// Start creating the body of the new Type function",
"var",
"body",
"=",
"'\\tvar self = arguments.callee;\\n'",
"+",
"'\\tvar callback = o... | Build a new `TypeLanguage` function parsing the `TL-Schema method` | [
"Build",
"a",
"new",
"TypeLanguage",
"function",
"parsing",
"the",
"TL",
"-",
"Schema",
"method"
] | 8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7 | https://github.com/enricostara/telegram-tl-node/blob/8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7/lib/builder/type-builder.js#L81-L111 | train |
enricostara/telegram-tl-node | lib/builder/constructor-builder.js | registerTypeById | function registerTypeById(type) {
if (registryLogger.isDebugEnabled()) {
registryLogger.debug('Register Type \'%s\' by id [%s]', type.typeName, type.id);
}
if(type.id) {
typeById[type.id] = type;
}
return type;
} | javascript | function registerTypeById(type) {
if (registryLogger.isDebugEnabled()) {
registryLogger.debug('Register Type \'%s\' by id [%s]', type.typeName, type.id);
}
if(type.id) {
typeById[type.id] = type;
}
return type;
} | [
"function",
"registerTypeById",
"(",
"type",
")",
"{",
"if",
"(",
"registryLogger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"registryLogger",
".",
"debug",
"(",
"'Register Type \\'%s\\' by id [%s]'",
",",
"type",
".",
"typeName",
",",
"type",
".",
"id",
")"... | Register a Type constructor by id | [
"Register",
"a",
"Type",
"constructor",
"by",
"id"
] | 8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7 | https://github.com/enricostara/telegram-tl-node/blob/8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7/lib/builder/constructor-builder.js#L321-L329 | train |
enricostara/telegram-tl-node | lib/builder/constructor-builder.js | requireTypeFromBuffer | function requireTypeFromBuffer(buffer) {
var typeId = buffer.slice(0, 4).toString('hex');
var type = typeById[typeId];
if (!type) {
var msg = 'Unable to retrieve a Type by Id [' + typeId + ']';
registryLogger.error(msg);
throw new Error(msg);
}
if (registryLogger.isDebugEnabl... | javascript | function requireTypeFromBuffer(buffer) {
var typeId = buffer.slice(0, 4).toString('hex');
var type = typeById[typeId];
if (!type) {
var msg = 'Unable to retrieve a Type by Id [' + typeId + ']';
registryLogger.error(msg);
throw new Error(msg);
}
if (registryLogger.isDebugEnabl... | [
"function",
"requireTypeFromBuffer",
"(",
"buffer",
")",
"{",
"var",
"typeId",
"=",
"buffer",
".",
"slice",
"(",
"0",
",",
"4",
")",
".",
"toString",
"(",
"'hex'",
")",
";",
"var",
"type",
"=",
"typeById",
"[",
"typeId",
"]",
";",
"if",
"(",
"!",
"... | Retrieve a Type constructor reading the id from buffer | [
"Retrieve",
"a",
"Type",
"constructor",
"reading",
"the",
"id",
"from",
"buffer"
] | 8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7 | https://github.com/enricostara/telegram-tl-node/blob/8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7/lib/builder/constructor-builder.js#L332-L344 | train |
enricostara/telegram-tl-node | lib/builder/constructor-builder.js | registerTypeByName | function registerTypeByName(type) {
if (registryLogger.isDebugEnabled()) {
registryLogger.debug('Register Type \'%s\' by name [%s]', type.id, type.typeName);
}
typeByName[type.typeName] = type;
return type;
} | javascript | function registerTypeByName(type) {
if (registryLogger.isDebugEnabled()) {
registryLogger.debug('Register Type \'%s\' by name [%s]', type.id, type.typeName);
}
typeByName[type.typeName] = type;
return type;
} | [
"function",
"registerTypeByName",
"(",
"type",
")",
"{",
"if",
"(",
"registryLogger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"registryLogger",
".",
"debug",
"(",
"'Register Type \\'%s\\' by name [%s]'",
",",
"type",
".",
"id",
",",
"type",
".",
"typeName",
... | Register a Type constructor by name | [
"Register",
"a",
"Type",
"constructor",
"by",
"name"
] | 8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7 | https://github.com/enricostara/telegram-tl-node/blob/8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7/lib/builder/constructor-builder.js#L350-L356 | train |
enricostara/telegram-tl-node | lib/builder/constructor-builder.js | requireTypeByName | function requireTypeByName(typeName) {
var type = typeByName[typeName];
if (!type) {
var msg = 'Unable to retrieve a Type by Name [' + typeName + ']';
registryLogger.error(msg);
throw new Error(msg);
}
if (registryLogger.isDebugEnabled()) {
registryLogger.debug('Require T... | javascript | function requireTypeByName(typeName) {
var type = typeByName[typeName];
if (!type) {
var msg = 'Unable to retrieve a Type by Name [' + typeName + ']';
registryLogger.error(msg);
throw new Error(msg);
}
if (registryLogger.isDebugEnabled()) {
registryLogger.debug('Require T... | [
"function",
"requireTypeByName",
"(",
"typeName",
")",
"{",
"var",
"type",
"=",
"typeByName",
"[",
"typeName",
"]",
";",
"if",
"(",
"!",
"type",
")",
"{",
"var",
"msg",
"=",
"'Unable to retrieve a Type by Name ['",
"+",
"typeName",
"+",
"']'",
";",
"registry... | Retrieve a Type constructor by name | [
"Retrieve",
"a",
"Type",
"constructor",
"by",
"name"
] | 8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7 | https://github.com/enricostara/telegram-tl-node/blob/8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7/lib/builder/constructor-builder.js#L359-L370 | train |
enricostara/telegram-tl-node | lib/utility.js | toPrintable | function toPrintable(exclude, noColor) {
var str = '{ ' + ( this._typeName ? 'T:' + this._typeName.bold : '');
if (typeof exclude !== 'object') {
noColor = exclude;
exclude = {};
}
for (var prop in this) {
if ('_' !== prop.charAt(0) && exclude[prop] !== true) {
var pa... | javascript | function toPrintable(exclude, noColor) {
var str = '{ ' + ( this._typeName ? 'T:' + this._typeName.bold : '');
if (typeof exclude !== 'object') {
noColor = exclude;
exclude = {};
}
for (var prop in this) {
if ('_' !== prop.charAt(0) && exclude[prop] !== true) {
var pa... | [
"function",
"toPrintable",
"(",
"exclude",
",",
"noColor",
")",
"{",
"var",
"str",
"=",
"'{ '",
"+",
"(",
"this",
".",
"_typeName",
"?",
"'T:'",
"+",
"this",
".",
"_typeName",
".",
"bold",
":",
"''",
")",
";",
"if",
"(",
"typeof",
"exclude",
"!==",
... | Return a printable state of the object | [
"Return",
"a",
"printable",
"state",
"of",
"the",
"object"
] | 8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7 | https://github.com/enricostara/telegram-tl-node/blob/8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7/lib/utility.js#L18-L35 | train |
enricostara/telegram-tl-node | lib/utility.js | stringValue2Buffer | function stringValue2Buffer(stringValue, byteLength) {
if ((stringValue).slice(0, 2) === '0x') {
var input = stringValue.slice(2);
var length = input.length;
var buffers = [];
var j = 0;
for (var i = length; i > 0 && j < byteLength; i -= 2) {
buffers.push(new Buff... | javascript | function stringValue2Buffer(stringValue, byteLength) {
if ((stringValue).slice(0, 2) === '0x') {
var input = stringValue.slice(2);
var length = input.length;
var buffers = [];
var j = 0;
for (var i = length; i > 0 && j < byteLength; i -= 2) {
buffers.push(new Buff... | [
"function",
"stringValue2Buffer",
"(",
"stringValue",
",",
"byteLength",
")",
"{",
"if",
"(",
"(",
"stringValue",
")",
".",
"slice",
"(",
"0",
",",
"2",
")",
"===",
"'0x'",
")",
"{",
"var",
"input",
"=",
"stringValue",
".",
"slice",
"(",
"2",
")",
";... | Convert a string value to buffer | [
"Convert",
"a",
"string",
"value",
"to",
"buffer"
] | 8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7 | https://github.com/enricostara/telegram-tl-node/blob/8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7/lib/utility.js#L70-L92 | train |
enricostara/telegram-tl-node | lib/utility.js | buffer2StringValue | function buffer2StringValue(buffer) {
var length = buffer.length;
var output = '0x';
for (var i = length; i > 0; i--) {
output += buffer.slice(i - 1, i).toString('hex');
}
return output;
} | javascript | function buffer2StringValue(buffer) {
var length = buffer.length;
var output = '0x';
for (var i = length; i > 0; i--) {
output += buffer.slice(i - 1, i).toString('hex');
}
return output;
} | [
"function",
"buffer2StringValue",
"(",
"buffer",
")",
"{",
"var",
"length",
"=",
"buffer",
".",
"length",
";",
"var",
"output",
"=",
"'0x'",
";",
"for",
"(",
"var",
"i",
"=",
"length",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"output",
"+=",
... | Convert a buffer value to string | [
"Convert",
"a",
"buffer",
"value",
"to",
"string"
] | 8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7 | https://github.com/enricostara/telegram-tl-node/blob/8aa73dab03f0be18dfa74f81bec2ee94dec5c9e7/lib/utility.js#L107-L114 | train |
themost-framework/themost | modules/@themost/web/types.js | HttpViewEngine | function HttpViewEngine(context) {
if (this.constructor === HttpViewEngine.prototype.constructor) {
throw new AbstractClassError();
}
/**
* @name HttpViewEngine#context
* @type HttpContext
* @description Gets or sets an instance of HttpContext that represents the current HTTP context.... | javascript | function HttpViewEngine(context) {
if (this.constructor === HttpViewEngine.prototype.constructor) {
throw new AbstractClassError();
}
/**
* @name HttpViewEngine#context
* @type HttpContext
* @description Gets or sets an instance of HttpContext that represents the current HTTP context.... | [
"function",
"HttpViewEngine",
"(",
"context",
")",
"{",
"if",
"(",
"this",
".",
"constructor",
"===",
"HttpViewEngine",
".",
"prototype",
".",
"constructor",
")",
"{",
"throw",
"new",
"AbstractClassError",
"(",
")",
";",
"}",
"/**\n * @name HttpViewEngine#cont... | Abstract view engine class
@class HttpViewEngine
@param {HttpContext} context
@constructor
@augments {SequentialEventEmitter} | [
"Abstract",
"view",
"engine",
"class"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/types.js#L48-L71 | train |
mikechabot/maybe-baby | lib/index.js | isValidPath | function isValidPath(path) {
if (path === null || path === undefined) return false;
return typeof path === 'string' && path.length > 0;
} | javascript | function isValidPath(path) {
if (path === null || path === undefined) return false;
return typeof path === 'string' && path.length > 0;
} | [
"function",
"isValidPath",
"(",
"path",
")",
"{",
"if",
"(",
"path",
"===",
"null",
"||",
"path",
"===",
"undefined",
")",
"return",
"false",
";",
"return",
"typeof",
"path",
"===",
"'string'",
"&&",
"path",
".",
"length",
">",
"0",
";",
"}"
] | Determine whether a path argument is valid
@param path
@return {boolean} | [
"Determine",
"whether",
"a",
"path",
"argument",
"is",
"valid"
] | 0da4c062ca77162537208f34edd452f563eeae06 | https://github.com/mikechabot/maybe-baby/blob/0da4c062ca77162537208f34edd452f563eeae06/lib/index.js#L18-L21 | train |
themost-framework/themost | modules/@themost/web/handlers/view.js | queryController | function queryController(requestUri) {
try {
if (requestUri === undefined)
return null;
//split path
var segments = requestUri.pathname.split('/');
//put an exception for root controller
//maybe this is unnecessary exception but we need to search for root controll... | javascript | function queryController(requestUri) {
try {
if (requestUri === undefined)
return null;
//split path
var segments = requestUri.pathname.split('/');
//put an exception for root controller
//maybe this is unnecessary exception but we need to search for root controll... | [
"function",
"queryController",
"(",
"requestUri",
")",
"{",
"try",
"{",
"if",
"(",
"requestUri",
"===",
"undefined",
")",
"return",
"null",
";",
"//split path",
"var",
"segments",
"=",
"requestUri",
".",
"pathname",
".",
"split",
"(",
"'/'",
")",
";",
"//p... | Gets the controller of the given url
@param {string|*} requestUri - A string that represents the url we want to parse.
@private | [
"Gets",
"the",
"controller",
"of",
"the",
"given",
"url"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/handlers/view.js#L674-L692 | train |
themost-framework/themost | modules/@themost/xml/common.js | XmlCommon | function XmlCommon() {
//constants
this.DOM_ELEMENT_NODE = 1;
this.DOM_ATTRIBUTE_NODE = 2;
this.DOM_TEXT_NODE = 3;
this.DOM_CDATA_SECTION_NODE = 4;
// noinspection JSUnusedGlobalSymbols
this.DOM_ENTITY_REFERENCE_NODE = 5;
// noinspection JSUnusedGlobalSymbols
this.DOM_ENTITY_NODE = 6... | javascript | function XmlCommon() {
//constants
this.DOM_ELEMENT_NODE = 1;
this.DOM_ATTRIBUTE_NODE = 2;
this.DOM_TEXT_NODE = 3;
this.DOM_CDATA_SECTION_NODE = 4;
// noinspection JSUnusedGlobalSymbols
this.DOM_ENTITY_REFERENCE_NODE = 5;
// noinspection JSUnusedGlobalSymbols
this.DOM_ENTITY_NODE = 6... | [
"function",
"XmlCommon",
"(",
")",
"{",
"//constants",
"this",
".",
"DOM_ELEMENT_NODE",
"=",
"1",
";",
"this",
".",
"DOM_ATTRIBUTE_NODE",
"=",
"2",
";",
"this",
".",
"DOM_TEXT_NODE",
"=",
"3",
";",
"this",
".",
"DOM_CDATA_SECTION_NODE",
"=",
"4",
";",
"// ... | XML Common Functions and Constants
@class
@constructor | [
"XML",
"Common",
"Functions",
"and",
"Constants"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/xml/common.js#L17-L173 | train |
themost-framework/themost | modules/@themost/web/mvc.js | HttpViewResult | function HttpViewResult(name, data)
{
this.name = name;
this.data = data===undefined? []: data;
this.contentType = 'text/html;charset=utf-8';
this.contentEncoding = 'utf8';
} | javascript | function HttpViewResult(name, data)
{
this.name = name;
this.data = data===undefined? []: data;
this.contentType = 'text/html;charset=utf-8';
this.contentEncoding = 'utf8';
} | [
"function",
"HttpViewResult",
"(",
"name",
",",
"data",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"data",
"=",
"data",
"===",
"undefined",
"?",
"[",
"]",
":",
"data",
";",
"this",
".",
"contentType",
"=",
"'text/html;charset=utf-8'",
... | Represents a class that is used to render a view.
@class
@param {*=} name - The name of the view.
@param {*=} data - The data that are going to be used to render the view.
@augments HttpResult | [
"Represents",
"a",
"class",
"that",
"is",
"used",
"to",
"render",
"a",
"view",
"."
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/mvc.js#L648-L654 | train |
themost-framework/themost | modules/@themost/web/mvc.js | HttpViewContext | function HttpViewContext(context) {
/**
* Gets or sets the body of the current view
* @type {String}
*/
this.body='';
/**
* Gets or sets the title of the page if the view will be fully rendered
* @type {String}
*/
this.title='';
/**
* Gets or sets the view layout p... | javascript | function HttpViewContext(context) {
/**
* Gets or sets the body of the current view
* @type {String}
*/
this.body='';
/**
* Gets or sets the title of the page if the view will be fully rendered
* @type {String}
*/
this.title='';
/**
* Gets or sets the view layout p... | [
"function",
"HttpViewContext",
"(",
"context",
")",
"{",
"/**\n * Gets or sets the body of the current view\n * @type {String}\n */",
"this",
".",
"body",
"=",
"''",
";",
"/**\n * Gets or sets the title of the page if the view will be fully rendered\n * @type {String}\n... | Encapsulates information that is related to rendering a view.
@class
@param {HttpContext} context
@property {DataModel} model
@property {HtmlViewHelper} html
@constructor
@augments {SequentialEventEmitter} | [
"Encapsulates",
"information",
"that",
"is",
"related",
"to",
"rendering",
"a",
"view",
"."
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/mvc.js#L1041-L1099 | train |
themost-framework/themost | modules/@themost/web/engines/pagedown/Markdown.extra.js | sanitizeHtml | function sanitizeHtml(html, whitelist) {
return html.replace(/<[^>]*>?/gi, function(tag) {
return tag.match(whitelist) ? tag : '';
});
} | javascript | function sanitizeHtml(html, whitelist) {
return html.replace(/<[^>]*>?/gi, function(tag) {
return tag.match(whitelist) ? tag : '';
});
} | [
"function",
"sanitizeHtml",
"(",
"html",
",",
"whitelist",
")",
"{",
"return",
"html",
".",
"replace",
"(",
"/",
"<[^>]*>?",
"/",
"gi",
",",
"function",
"(",
"tag",
")",
"{",
"return",
"tag",
".",
"match",
"(",
"whitelist",
")",
"?",
"tag",
":",
"''"... | Sanitize html, removing tags that aren't in the whitelist | [
"Sanitize",
"html",
"removing",
"tags",
"that",
"aren",
"t",
"in",
"the",
"whitelist"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/engines/pagedown/Markdown.extra.js#L48-L52 | train |
themost-framework/themost | modules/@themost/web/engines/pagedown/Markdown.extra.js | union | function union(x, y) {
var obj = {};
for (var i = 0; i < x.length; i++)
obj[x[i]] = x[i];
for (i = 0; i < y.length; i++)
obj[y[i]] = y[i];
var res = [];
for (var k in obj) {
if (obj.hasOwnProperty(k))
res.push(obj[k]);
}... | javascript | function union(x, y) {
var obj = {};
for (var i = 0; i < x.length; i++)
obj[x[i]] = x[i];
for (i = 0; i < y.length; i++)
obj[y[i]] = y[i];
var res = [];
for (var k in obj) {
if (obj.hasOwnProperty(k))
res.push(obj[k]);
}... | [
"function",
"union",
"(",
"x",
",",
"y",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"x",
".",
"length",
";",
"i",
"++",
")",
"obj",
"[",
"x",
"[",
"i",
"]",
"]",
"=",
"x",
"[",
"i",
"]... | Merge two arrays, keeping only unique elements. | [
"Merge",
"two",
"arrays",
"keeping",
"only",
"unique",
"elements",
"."
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/engines/pagedown/Markdown.extra.js#L55-L67 | train |
themost-framework/themost | modules/@themost/web/engines/pagedown/Markdown.extra.js | removeAnchors | function removeAnchors(text) {
if(text.charAt(0) == '\x02')
text = text.substr(1);
if(text.charAt(text.length - 1) == '\x03')
text = text.substr(0, text.length - 1);
return text;
} | javascript | function removeAnchors(text) {
if(text.charAt(0) == '\x02')
text = text.substr(1);
if(text.charAt(text.length - 1) == '\x03')
text = text.substr(0, text.length - 1);
return text;
} | [
"function",
"removeAnchors",
"(",
"text",
")",
"{",
"if",
"(",
"text",
".",
"charAt",
"(",
"0",
")",
"==",
"'\\x02'",
")",
"text",
"=",
"text",
".",
"substr",
"(",
"1",
")",
";",
"if",
"(",
"text",
".",
"charAt",
"(",
"text",
".",
"length",
"-",
... | Remove STX and ETX sentinels. | [
"Remove",
"STX",
"and",
"ETX",
"sentinels",
"."
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/engines/pagedown/Markdown.extra.js#L82-L88 | train |
themost-framework/themost | modules/@themost/web/engines/pagedown/Markdown.extra.js | convertAll | function convertAll(text, extra) {
var result = extra.blockGamutHookCallback(text);
// We need to perform these operations since we skip the steps in the converter
result = unescapeSpecialChars(result);
result = result.replace(/~D/g, "$$").replace(/~T/g, "~");
result = extra.prev... | javascript | function convertAll(text, extra) {
var result = extra.blockGamutHookCallback(text);
// We need to perform these operations since we skip the steps in the converter
result = unescapeSpecialChars(result);
result = result.replace(/~D/g, "$$").replace(/~T/g, "~");
result = extra.prev... | [
"function",
"convertAll",
"(",
"text",
",",
"extra",
")",
"{",
"var",
"result",
"=",
"extra",
".",
"blockGamutHookCallback",
"(",
"text",
")",
";",
"// We need to perform these operations since we skip the steps in the converter",
"result",
"=",
"unescapeSpecialChars",
"(... | Convert internal markdown using the stock pagedown converter | [
"Convert",
"internal",
"markdown",
"using",
"the",
"stock",
"pagedown",
"converter"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/engines/pagedown/Markdown.extra.js#L96-L103 | train |
themost-framework/themost | modules/@themost/common/errors.js | AccessDeniedError | function AccessDeniedError(message, innerMessage, model) {
AccessDeniedError.super_.bind(this)('EACCESS', ('Access Denied' || message) , innerMessage, model);
this.statusCode = 401;
} | javascript | function AccessDeniedError(message, innerMessage, model) {
AccessDeniedError.super_.bind(this)('EACCESS', ('Access Denied' || message) , innerMessage, model);
this.statusCode = 401;
} | [
"function",
"AccessDeniedError",
"(",
"message",
",",
"innerMessage",
",",
"model",
")",
"{",
"AccessDeniedError",
".",
"super_",
".",
"bind",
"(",
"this",
")",
"(",
"'EACCESS'",
",",
"(",
"'Access Denied'",
"||",
"message",
")",
",",
"innerMessage",
",",
"m... | Thrown when a data object operation is denied
@param {string=} message - The error message
@param {string=} innerMessage - The error inner message
@param {string=} model - The target model
@constructor
@extends DataError | [
"Thrown",
"when",
"a",
"data",
"object",
"operation",
"is",
"denied"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/common/errors.js#L342-L345 | train |
themost-framework/themost | modules/@themost/common/errors.js | UniqueConstraintError | function UniqueConstraintError(message, innerMessage, model) {
UniqueConstraintError.super_.bind(this)('EUNQ', message || 'A unique constraint violated', innerMessage, model);
} | javascript | function UniqueConstraintError(message, innerMessage, model) {
UniqueConstraintError.super_.bind(this)('EUNQ', message || 'A unique constraint violated', innerMessage, model);
} | [
"function",
"UniqueConstraintError",
"(",
"message",
",",
"innerMessage",
",",
"model",
")",
"{",
"UniqueConstraintError",
".",
"super_",
".",
"bind",
"(",
"this",
")",
"(",
"'EUNQ'",
",",
"message",
"||",
"'A unique constraint violated'",
",",
"innerMessage",
","... | Thrown when a unique constraint is being violated
@param {string=} message - The error message
@param {string=} innerMessage - The error inner message
@param {string=} model - The target model
@constructor
@extends DataError | [
"Thrown",
"when",
"a",
"unique",
"constraint",
"is",
"being",
"violated"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/common/errors.js#L356-L358 | train |
themost-framework/themost | modules/@themost/web/handlers/querystring.js | caseInsensitiveAttribute | function caseInsensitiveAttribute(name) {
if (typeof name === 'string') {
if (this[name])
return this[name];
//otherwise make a case insensitive search
var re = new RegExp('^' + name + '$','i');
var p = Object.keys(this).filter(function(x) { return re.test(x); })[0];
... | javascript | function caseInsensitiveAttribute(name) {
if (typeof name === 'string') {
if (this[name])
return this[name];
//otherwise make a case insensitive search
var re = new RegExp('^' + name + '$','i');
var p = Object.keys(this).filter(function(x) { return re.test(x); })[0];
... | [
"function",
"caseInsensitiveAttribute",
"(",
"name",
")",
"{",
"if",
"(",
"typeof",
"name",
"===",
"'string'",
")",
"{",
"if",
"(",
"this",
"[",
"name",
"]",
")",
"return",
"this",
"[",
"name",
"]",
";",
"//otherwise make a case insensitive search",
"var",
"... | Provides a case insensitive attribute getter
@param name
@returns {*}
@private | [
"Provides",
"a",
"case",
"insensitive",
"attribute",
"getter"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/handlers/querystring.js#L17-L27 | train |
themost-framework/themost | modules/@themost/query/expressions.js | MethodCallExpression | function MethodCallExpression(name, args) {
/**
* Gets or sets the name of this method
* @type {String}
*/
this.name = name;
/**
* Gets or sets an array that represents the method arguments
* @type {Array}
*/
this.args = [];
if (_.isArray(args))
this.args = args... | javascript | function MethodCallExpression(name, args) {
/**
* Gets or sets the name of this method
* @type {String}
*/
this.name = name;
/**
* Gets or sets an array that represents the method arguments
* @type {Array}
*/
this.args = [];
if (_.isArray(args))
this.args = args... | [
"function",
"MethodCallExpression",
"(",
"name",
",",
"args",
")",
"{",
"/**\n * Gets or sets the name of this method\n * @type {String}\n */",
"this",
".",
"name",
"=",
"name",
";",
"/**\n * Gets or sets an array that represents the method arguments\n * @type {Arra... | Creates a method call expression
@class
@constructor | [
"Creates",
"a",
"method",
"call",
"expression"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/query/expressions.js#L212-L225 | train |
themost-framework/themost | modules/@themost/web/http-route.js | HttpRoute | function HttpRoute(route) {
if (typeof route === 'string') {
this.route = { url:route };
}
else if (typeof route === 'object') {
this.route = route;
}
this.routeData = { };
this.patterns = {
int:function() {
return "^[1-9]([0-9]*)$";
},
boolea... | javascript | function HttpRoute(route) {
if (typeof route === 'string') {
this.route = { url:route };
}
else if (typeof route === 'object') {
this.route = route;
}
this.routeData = { };
this.patterns = {
int:function() {
return "^[1-9]([0-9]*)$";
},
boolea... | [
"function",
"HttpRoute",
"(",
"route",
")",
"{",
"if",
"(",
"typeof",
"route",
"===",
"'string'",
")",
"{",
"this",
".",
"route",
"=",
"{",
"url",
":",
"route",
"}",
";",
"}",
"else",
"if",
"(",
"typeof",
"route",
"===",
"'object'",
")",
"{",
"this... | HttpRoute class provides routing functionality to HTTP requests
@class
@constructor
@param {string|*=} route - A formatted string or an object which represents an HTTP route response url (e.g. /pages/:name.html, /user/edit.html). | [
"HttpRoute",
"class",
"provides",
"routing",
"functionality",
"to",
"HTTP",
"requests"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/http-route.js#L20-L80 | train |
themost-framework/themost | modules/@themost/xml/xpath.js | xpathSort | function xpathSort(input, sort) {
if (sort.length === 0) {
return;
}
var sortlist = [];
var i;
for (i = 0; i < input.contextSize(); ++i) {
var node = input.nodelist[i];
var sortitem = {node: node, key: []};
var context = input.clone(node, 0, [node]);
for (var... | javascript | function xpathSort(input, sort) {
if (sort.length === 0) {
return;
}
var sortlist = [];
var i;
for (i = 0; i < input.contextSize(); ++i) {
var node = input.nodelist[i];
var sortitem = {node: node, key: []};
var context = input.clone(node, 0, [node]);
for (var... | [
"function",
"xpathSort",
"(",
"input",
",",
"sort",
")",
"{",
"if",
"(",
"sort",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"var",
"sortlist",
"=",
"[",
"]",
";",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"input... | Utility function to sort a list of nodes. eslint-disable-next-line no-unused-vars | [
"Utility",
"function",
"to",
"sort",
"a",
"list",
"of",
"nodes",
".",
"eslint",
"-",
"disable",
"-",
"next",
"-",
"line",
"no",
"-",
"unused",
"-",
"vars"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/xml/xpath.js#L2435-L2475 | train |
themost-framework/themost | modules/@themost/xml/xpath.js | xpathEval | function xpathEval(select, context, ns) {
var str = select;
if (ns !== undefined) {
if (context.node)
str = context.node.prepare(select, ns);
}
//parse statement
var expr = xpathParse(str);
//and return value
return expr.evaluate(context);
} | javascript | function xpathEval(select, context, ns) {
var str = select;
if (ns !== undefined) {
if (context.node)
str = context.node.prepare(select, ns);
}
//parse statement
var expr = xpathParse(str);
//and return value
return expr.evaluate(context);
} | [
"function",
"xpathEval",
"(",
"select",
",",
"context",
",",
"ns",
")",
"{",
"var",
"str",
"=",
"select",
";",
"if",
"(",
"ns",
"!==",
"undefined",
")",
"{",
"if",
"(",
"context",
".",
"node",
")",
"str",
"=",
"context",
".",
"node",
".",
"prepare"... | Parses and then evaluates the given XPath expression in the given input context.
@param {String} select
@param {ExprContext} context
@param {Array=} ns
@returns {Object} | [
"Parses",
"and",
"then",
"evaluates",
"the",
"given",
"XPath",
"expression",
"in",
"the",
"given",
"input",
"context",
"."
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/xml/xpath.js#L2509-L2519 | train |
themost-framework/themost | modules/@themost/data/types.js | DataModelMigration | function DataModelMigration() {
/**
* Gets an array that contains the definition of fields that are going to be added
* @type {Array}
*/
this.add = [];
/**
* Gets an array that contains a collection of constraints which are going to be added
* @type {Array}
*/
this.constrai... | javascript | function DataModelMigration() {
/**
* Gets an array that contains the definition of fields that are going to be added
* @type {Array}
*/
this.add = [];
/**
* Gets an array that contains a collection of constraints which are going to be added
* @type {Array}
*/
this.constrai... | [
"function",
"DataModelMigration",
"(",
")",
"{",
"/**\n * Gets an array that contains the definition of fields that are going to be added\n * @type {Array}\n */",
"this",
".",
"add",
"=",
"[",
"]",
";",
"/**\n * Gets an array that contains a collection of constraints which ... | Represents a model migration scheme against data adapters
@class
@constructor
@ignore | [
"Represents",
"a",
"model",
"migration",
"scheme",
"against",
"data",
"adapters"
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/data/types.js#L448-L494 | train |
themost-framework/themost | modules/@themost/xml/util.js | removeFromArray | function removeFromArray(array, value, opt_notype) {
var shift = 0;
for (var i = 0; i < array.length; ++i) {
if (array[i] === value || (opt_notype && array[i] === value)) {
array.splice(i--, 1);
shift++;
}
}
return shift;
} | javascript | function removeFromArray(array, value, opt_notype) {
var shift = 0;
for (var i = 0; i < array.length; ++i) {
if (array[i] === value || (opt_notype && array[i] === value)) {
array.splice(i--, 1);
shift++;
}
}
return shift;
} | [
"function",
"removeFromArray",
"(",
"array",
",",
"value",
",",
"opt_notype",
")",
"{",
"var",
"shift",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"array",
"[",
"... | Removes value from array. Returns the number of instances of value
that were removed from array. | [
"Removes",
"value",
"from",
"array",
".",
"Returns",
"the",
"number",
"of",
"instances",
"of",
"value",
"that",
"were",
"removed",
"from",
"array",
"."
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/xml/util.js#L77-L86 | train |
themost-framework/themost | modules/@themost/web/cache.js | DefaultCacheStrategy | function DefaultCacheStrategy(app) {
DefaultCacheStrategy.super_.bind(this)(app);
//set absoluteExpiration (from application configuration)
var expiration = CACHE_ABSOLUTE_EXPIRATION;
var absoluteExpiration = LangUtils.parseInt(app.getConfiguration().getSourceAt('settings/cache/absoluteExpiration'));
... | javascript | function DefaultCacheStrategy(app) {
DefaultCacheStrategy.super_.bind(this)(app);
//set absoluteExpiration (from application configuration)
var expiration = CACHE_ABSOLUTE_EXPIRATION;
var absoluteExpiration = LangUtils.parseInt(app.getConfiguration().getSourceAt('settings/cache/absoluteExpiration'));
... | [
"function",
"DefaultCacheStrategy",
"(",
"app",
")",
"{",
"DefaultCacheStrategy",
".",
"super_",
".",
"bind",
"(",
"this",
")",
"(",
"app",
")",
";",
"//set absoluteExpiration (from application configuration)",
"var",
"expiration",
"=",
"CACHE_ABSOLUTE_EXPIRATION",
";",... | Implements the cache for a data application.
@class HttpCache
@param {HttpApplication} app
@constructor | [
"Implements",
"the",
"cache",
"for",
"a",
"data",
"application",
"."
] | 9dc13791faf3cbaf6ea01432e262791196ccffdb | https://github.com/themost-framework/themost/blob/9dc13791faf3cbaf6ea01432e262791196ccffdb/modules/@themost/web/cache.js#L95-L106 | train |
ozantunca/locally | dist/locally.js | _remove | function _remove(key) {
var i = _keys.indexOf(key)
if (i > -1) {
ls.removeItem(key);
_keys.splice(_keys.indexOf(key), 1);
delete _config[key];
}
} | javascript | function _remove(key) {
var i = _keys.indexOf(key)
if (i > -1) {
ls.removeItem(key);
_keys.splice(_keys.indexOf(key), 1);
delete _config[key];
}
} | [
"function",
"_remove",
"(",
"key",
")",
"{",
"var",
"i",
"=",
"_keys",
".",
"indexOf",
"(",
"key",
")",
"if",
"(",
"i",
">",
"-",
"1",
")",
"{",
"ls",
".",
"removeItem",
"(",
"key",
")",
";",
"_keys",
".",
"splice",
"(",
"_keys",
".",
"indexOf"... | Removes a value from localStorage | [
"Removes",
"a",
"value",
"from",
"localStorage"
] | 30d7fdde3606744c3e8941d0b929ad6b68e5c26d | https://github.com/ozantunca/locally/blob/30d7fdde3606744c3e8941d0b929ad6b68e5c26d/dist/locally.js#L223-L230 | train |
vend/vend-number | dist/vend-number.js | _executeOperation | function _executeOperation(operation, values) {
/**
* Run passed method if value passed is not NaN, otherwise throw a TypeError.
*
* @private
* @method _ifValid
*
* @param value {Number}
* A value to check is not NaN before running method on.
*
* @param method {Function}
* ... | javascript | function _executeOperation(operation, values) {
/**
* Run passed method if value passed is not NaN, otherwise throw a TypeError.
*
* @private
* @method _ifValid
*
* @param value {Number}
* A value to check is not NaN before running method on.
*
* @param method {Function}
* ... | [
"function",
"_executeOperation",
"(",
"operation",
",",
"values",
")",
"{",
"/**\n * Run passed method if value passed is not NaN, otherwise throw a TypeError.\n *\n * @private\n * @method _ifValid\n *\n * @param value {Number}\n * A value to check is not NaN before running meth... | Executes VendNumber calculation operation on an array of values.
@private
@method _executeOperation
@param operation {String}
The operation to perform on the VendNumber.
@param values {Array}
A list of values to perform the operation on (any length).
@return {Number} The final result or 0 if invalid. | [
"Executes",
"VendNumber",
"calculation",
"operation",
"on",
"an",
"array",
"of",
"values",
"."
] | ef15190aee827d4036d3487dfe4ece15b4c5d13f | https://github.com/vend/vend-number/blob/ef15190aee827d4036d3487dfe4ece15b4c5d13f/dist/vend-number.js#L220-L275 | train |
Helpmonks/haraka-plugin-mongodb | index.js | parseSubaddress | function parseSubaddress(user) {
var parsed = {
username: user
};
if (user.indexOf('+')) {
parsed.username = user.split('+')[0];
parsed.subaddress = user.split('+')[1];
}
return parsed;
} | javascript | function parseSubaddress(user) {
var parsed = {
username: user
};
if (user.indexOf('+')) {
parsed.username = user.split('+')[0];
parsed.subaddress = user.split('+')[1];
}
return parsed;
} | [
"function",
"parseSubaddress",
"(",
"user",
")",
"{",
"var",
"parsed",
"=",
"{",
"username",
":",
"user",
"}",
";",
"if",
"(",
"user",
".",
"indexOf",
"(",
"'+'",
")",
")",
"{",
"parsed",
".",
"username",
"=",
"user",
".",
"split",
"(",
"'+'",
")",... | Parse the address - Useful for checking usernames in rcpt_to | [
"Parse",
"the",
"address",
"-",
"Useful",
"for",
"checking",
"usernames",
"in",
"rcpt_to"
] | d0e468faca5bd585723b970bbc2d7a7bd4cdf15a | https://github.com/Helpmonks/haraka-plugin-mongodb/blob/d0e468faca5bd585723b970bbc2d7a7bd4cdf15a/index.js#L398-L407 | train |
makinacorpus/Leaflet.Spin | example/leaflet/src/geo/LatLngBounds.js | function (bufferRatio) { // (Number) -> LatLngBounds
var sw = this._southWest,
ne = this._northEast,
heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,
widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
return new L.LatLngBounds(
new L.LatLng(sw.lat - heightBuffer, sw.ln... | javascript | function (bufferRatio) { // (Number) -> LatLngBounds
var sw = this._southWest,
ne = this._northEast,
heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,
widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
return new L.LatLngBounds(
new L.LatLng(sw.lat - heightBuffer, sw.ln... | [
"function",
"(",
"bufferRatio",
")",
"{",
"// (Number) -> LatLngBounds\r",
"var",
"sw",
"=",
"this",
".",
"_southWest",
",",
"ne",
"=",
"this",
".",
"_northEast",
",",
"heightBuffer",
"=",
"Math",
".",
"abs",
"(",
"sw",
".",
"lat",
"-",
"ne",
".",
"lat",... | extend the bounds by a percentage | [
"extend",
"the",
"bounds",
"by",
"a",
"percentage"
] | 321db91ddcc2e78e561bd04446f4e458180f8d3d | https://github.com/makinacorpus/Leaflet.Spin/blob/321db91ddcc2e78e561bd04446f4e458180f8d3d/example/leaflet/src/geo/LatLngBounds.js#L46-L55 | train | |
pelias/wof-pip-service | src/components/extractFields.js | getAbbr | function getAbbr(wofData) {
const iso2 = getPropertyValue(wofData, 'wof:country');
// sometimes there are codes set to XX which cause an exception so check if it's a valid ISO2 code
if (iso2 !== false && iso3166.is2(iso2)) {
return iso3166.to3(iso2);
}
return null;
} | javascript | function getAbbr(wofData) {
const iso2 = getPropertyValue(wofData, 'wof:country');
// sometimes there are codes set to XX which cause an exception so check if it's a valid ISO2 code
if (iso2 !== false && iso3166.is2(iso2)) {
return iso3166.to3(iso2);
}
return null;
} | [
"function",
"getAbbr",
"(",
"wofData",
")",
"{",
"const",
"iso2",
"=",
"getPropertyValue",
"(",
"wofData",
",",
"'wof:country'",
")",
";",
"// sometimes there are codes set to XX which cause an exception so check if it's a valid ISO2 code",
"if",
"(",
"iso2",
"!==",
"false"... | Return the ISO3 country code where available
@param {object} wofData
@returns {null|string} | [
"Return",
"the",
"ISO3",
"country",
"code",
"where",
"available"
] | 2be8c4f4553e695e595a68e4e7e3b486fb402e51 | https://github.com/pelias/wof-pip-service/blob/2be8c4f4553e695e595a68e4e7e3b486fb402e51/src/components/extractFields.js#L48-L57 | train |
pelias/wof-pip-service | src/components/extractFields.js | getPropertyValue | function getPropertyValue(wofData, property) {
if (wofData.properties.hasOwnProperty(property)) {
// if the value is an array, return the first item
if (wofData.properties[property] instanceof Array) {
return wofData.properties[property][0];
}
// otherwise just return the value as is
retu... | javascript | function getPropertyValue(wofData, property) {
if (wofData.properties.hasOwnProperty(property)) {
// if the value is an array, return the first item
if (wofData.properties[property] instanceof Array) {
return wofData.properties[property][0];
}
// otherwise just return the value as is
retu... | [
"function",
"getPropertyValue",
"(",
"wofData",
",",
"property",
")",
"{",
"if",
"(",
"wofData",
".",
"properties",
".",
"hasOwnProperty",
"(",
"property",
")",
")",
"{",
"// if the value is an array, return the first item",
"if",
"(",
"wofData",
".",
"properties",
... | Get the string value of the property or false if not found
@param {object} wofData
@param {string} property
@returns {boolean|string} | [
"Get",
"the",
"string",
"value",
"of",
"the",
"property",
"or",
"false",
"if",
"not",
"found"
] | 2be8c4f4553e695e595a68e4e7e3b486fb402e51 | https://github.com/pelias/wof-pip-service/blob/2be8c4f4553e695e595a68e4e7e3b486fb402e51/src/components/extractFields.js#L80-L93 | train |
pelias/wof-pip-service | src/components/getLocalizedName.js | getName | function getName(wofData) {
// if this is a US county, use the qs:a2_alt for county
// eg - wof:name = 'Lancaster' and qs:a2_alt = 'Lancaster County', use latter
if (isUsCounty(wofData)) {
return getPropertyValue(wofData, 'qs:a2_alt');
}
// attempt to use the following in order of priority and fallback ... | javascript | function getName(wofData) {
// if this is a US county, use the qs:a2_alt for county
// eg - wof:name = 'Lancaster' and qs:a2_alt = 'Lancaster County', use latter
if (isUsCounty(wofData)) {
return getPropertyValue(wofData, 'qs:a2_alt');
}
// attempt to use the following in order of priority and fallback ... | [
"function",
"getName",
"(",
"wofData",
")",
"{",
"// if this is a US county, use the qs:a2_alt for county",
"// eg - wof:name = 'Lancaster' and qs:a2_alt = 'Lancaster County', use latter",
"if",
"(",
"isUsCounty",
"(",
"wofData",
")",
")",
"{",
"return",
"getPropertyValue",
"(",
... | Return the localized name or default name for the given record
@param {object} wofData
@returns {false|string} | [
"Return",
"the",
"localized",
"name",
"or",
"default",
"name",
"for",
"the",
"given",
"record"
] | 2be8c4f4553e695e595a68e4e7e3b486fb402e51 | https://github.com/pelias/wof-pip-service/blob/2be8c4f4553e695e595a68e4e7e3b486fb402e51/src/components/getLocalizedName.js#L12-L26 | train |
pelias/wof-pip-service | src/components/getLocalizedName.js | getOfficialLangName | function getOfficialLangName(wofData, langProperty) {
var languages = wofData.properties[langProperty];
// convert to array in case it is just a string
if (!(languages instanceof Array)) {
languages = [languages];
}
if (languages.length > 1) {
logger.silly(`more than one ${langProperty} specified`,
... | javascript | function getOfficialLangName(wofData, langProperty) {
var languages = wofData.properties[langProperty];
// convert to array in case it is just a string
if (!(languages instanceof Array)) {
languages = [languages];
}
if (languages.length > 1) {
logger.silly(`more than one ${langProperty} specified`,
... | [
"function",
"getOfficialLangName",
"(",
"wofData",
",",
"langProperty",
")",
"{",
"var",
"languages",
"=",
"wofData",
".",
"properties",
"[",
"langProperty",
"]",
";",
"// convert to array in case it is just a string",
"if",
"(",
"!",
"(",
"languages",
"instanceof",
... | Returns the property name of the name to be used
according to the language specification
example:
if wofData[langProperty] === ['rus']
then return 'name:rus_x_preferred'
example with multiple values:
if wofData[langProperty] === ['rus','ukr','eng']
then return 'name:rus_x_preferred'
@param {object} wofData
@param {s... | [
"Returns",
"the",
"property",
"name",
"of",
"the",
"name",
"to",
"be",
"used",
"according",
"to",
"the",
"language",
"specification"
] | 2be8c4f4553e695e595a68e4e7e3b486fb402e51 | https://github.com/pelias/wof-pip-service/blob/2be8c4f4553e695e595a68e4e7e3b486fb402e51/src/components/getLocalizedName.js#L51-L66 | train |
pelias/wof-pip-service | src/worker.js | messageHandler | function messageHandler( msg ) {
switch (msg.type) {
case 'load' : return handleLoadMsg(msg);
case 'search' : return handleSearch(msg);
case 'lookupById': return handleLookupById(msg);
default : logger.error('Unknown message:', msg);
}
} | javascript | function messageHandler( msg ) {
switch (msg.type) {
case 'load' : return handleLoadMsg(msg);
case 'search' : return handleSearch(msg);
case 'lookupById': return handleLookupById(msg);
default : logger.error('Unknown message:', msg);
}
} | [
"function",
"messageHandler",
"(",
"msg",
")",
"{",
"switch",
"(",
"msg",
".",
"type",
")",
"{",
"case",
"'load'",
":",
"return",
"handleLoadMsg",
"(",
"msg",
")",
";",
"case",
"'search'",
":",
"return",
"handleSearch",
"(",
"msg",
")",
";",
"case",
"'... | Respond to messages from the parent process | [
"Respond",
"to",
"messages",
"from",
"the",
"parent",
"process"
] | 2be8c4f4553e695e595a68e4e7e3b486fb402e51 | https://github.com/pelias/wof-pip-service/blob/2be8c4f4553e695e595a68e4e7e3b486fb402e51/src/worker.js#L23-L30 | train |
pelias/wof-pip-service | src/worker.js | search | function search( latLon ){
var poly = context.adminLookup.search( latLon.longitude, latLon.latitude );
return (poly === undefined) ? {} : poly.properties;
} | javascript | function search( latLon ){
var poly = context.adminLookup.search( latLon.longitude, latLon.latitude );
return (poly === undefined) ? {} : poly.properties;
} | [
"function",
"search",
"(",
"latLon",
")",
"{",
"var",
"poly",
"=",
"context",
".",
"adminLookup",
".",
"search",
"(",
"latLon",
".",
"longitude",
",",
"latLon",
".",
"latitude",
")",
";",
"return",
"(",
"poly",
"===",
"undefined",
")",
"?",
"{",
"}",
... | Search `adminLookup` for `latLon`. | [
"Search",
"adminLookup",
"for",
"latLon",
"."
] | 2be8c4f4553e695e595a68e4e7e3b486fb402e51 | https://github.com/pelias/wof-pip-service/blob/2be8c4f4553e695e595a68e4e7e3b486fb402e51/src/worker.js#L78-L82 | train |
p0o/steem-bot | src/responder.js | extractUsernameFromLink | function extractUsernameFromLink(steemitLink) {
if (isValidSteemitLink(steemitLink)) {
const usernamePos = steemitLink.search(/\/@.+\//);
if (usernamePos === -1) return;
const firstPart = steemitLink.slice(usernamePos + 2); // adding 2 to remove "/@"
return firstPart.slice(0, firstPart.search('/'));
... | javascript | function extractUsernameFromLink(steemitLink) {
if (isValidSteemitLink(steemitLink)) {
const usernamePos = steemitLink.search(/\/@.+\//);
if (usernamePos === -1) return;
const firstPart = steemitLink.slice(usernamePos + 2); // adding 2 to remove "/@"
return firstPart.slice(0, firstPart.search('/'));
... | [
"function",
"extractUsernameFromLink",
"(",
"steemitLink",
")",
"{",
"if",
"(",
"isValidSteemitLink",
"(",
"steemitLink",
")",
")",
"{",
"const",
"usernamePos",
"=",
"steemitLink",
".",
"search",
"(",
"/",
"\\/@.+\\/",
"/",
")",
";",
"if",
"(",
"usernamePos",
... | Should input a full steemit article link and return the username of the author
@param {string} steemitLink | [
"Should",
"input",
"a",
"full",
"steemit",
"article",
"link",
"and",
"return",
"the",
"username",
"of",
"the",
"author"
] | 289347319954f1a654c256e713fe514af79363bc | https://github.com/p0o/steem-bot/blob/289347319954f1a654c256e713fe514af79363bc/src/responder.js#L43-L51 | train |
p0o/steem-bot | src/responder.js | extractPermlinkFromLink | function extractPermlinkFromLink(steemitLink) {
if (isValidSteemitLink(steemitLink)) {
const usernamePos = steemitLink.search(/\/@.+\//);
if (usernamePos === -1) return;
const firstPart = steemitLink.slice(usernamePos + 1); // adding 1 to remove the first "/"
return firstPart.slice(firstPart.search('... | javascript | function extractPermlinkFromLink(steemitLink) {
if (isValidSteemitLink(steemitLink)) {
const usernamePos = steemitLink.search(/\/@.+\//);
if (usernamePos === -1) return;
const firstPart = steemitLink.slice(usernamePos + 1); // adding 1 to remove the first "/"
return firstPart.slice(firstPart.search('... | [
"function",
"extractPermlinkFromLink",
"(",
"steemitLink",
")",
"{",
"if",
"(",
"isValidSteemitLink",
"(",
"steemitLink",
")",
")",
"{",
"const",
"usernamePos",
"=",
"steemitLink",
".",
"search",
"(",
"/",
"\\/@.+\\/",
"/",
")",
";",
"if",
"(",
"usernamePos",
... | Should input a full steemit article link and return the permlink of the article
@param {string} steemitLink | [
"Should",
"input",
"a",
"full",
"steemit",
"article",
"link",
"and",
"return",
"the",
"permlink",
"of",
"the",
"article"
] | 289347319954f1a654c256e713fe514af79363bc | https://github.com/p0o/steem-bot/blob/289347319954f1a654c256e713fe514af79363bc/src/responder.js#L57-L65 | train |
austinkelleher/giphy-api | index.js | _handleErr | function _handleErr (err, callback) {
if (callback) {
return callback(err);
} else if (promisesExist) {
return Promise.reject(err);
} else {
throw new Error(err);
}
} | javascript | function _handleErr (err, callback) {
if (callback) {
return callback(err);
} else if (promisesExist) {
return Promise.reject(err);
} else {
throw new Error(err);
}
} | [
"function",
"_handleErr",
"(",
"err",
",",
"callback",
")",
"{",
"if",
"(",
"callback",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"if",
"(",
"promisesExist",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"err",
")",
";",... | Error handler that supports promises and callbacks
@param err {String} - Error message
@param callback | [
"Error",
"handler",
"that",
"supports",
"promises",
"and",
"callbacks"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L27-L35 | train |
austinkelleher/giphy-api | index.js | function (options, callback) {
if (!options) {
return _handleErr('Search phrase cannot be empty.', callback);
}
return this._request({
api: options.api || 'gifs',
endpoint: 'search',
query: typeof options === 'string' ? {
q: options
} : options
}, callback);
} | javascript | function (options, callback) {
if (!options) {
return _handleErr('Search phrase cannot be empty.', callback);
}
return this._request({
api: options.api || 'gifs',
endpoint: 'search',
query: typeof options === 'string' ? {
q: options
} : options
}, callback);
} | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"return",
"_handleErr",
"(",
"'Search phrase cannot be empty.'",
",",
"callback",
")",
";",
"}",
"return",
"this",
".",
"_request",
"(",
"{",
"api",
":",
"options",... | Search all Giphy gifs by word or phrase
@param options Giphy API search options
options.q {String} - search query term or phrase
options.limit {Number} - (optional) number of results to return, maximum 100. Default 25.
options.offset {Number} - (optional) results offset, defaults to 0.
options.rating {String}- limit r... | [
"Search",
"all",
"Giphy",
"gifs",
"by",
"word",
"or",
"phrase"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L72-L84 | train | |
austinkelleher/giphy-api | index.js | function (id, callback) {
var idIsArr = Array.isArray(id);
if (!id || (idIsArr && id.length === 0)) {
return _handleErr('Id required for id API call', callback);
}
// If an array of Id's was passed, generate a comma delimited string for
// the query string.
if (idIsArr) {
id = id.j... | javascript | function (id, callback) {
var idIsArr = Array.isArray(id);
if (!id || (idIsArr && id.length === 0)) {
return _handleErr('Id required for id API call', callback);
}
// If an array of Id's was passed, generate a comma delimited string for
// the query string.
if (idIsArr) {
id = id.j... | [
"function",
"(",
"id",
",",
"callback",
")",
"{",
"var",
"idIsArr",
"=",
"Array",
".",
"isArray",
"(",
"id",
")",
";",
"if",
"(",
"!",
"id",
"||",
"(",
"idIsArr",
"&&",
"id",
".",
"length",
"===",
"0",
")",
")",
"{",
"return",
"_handleErr",
"(",
... | Search all Giphy gifs for a single Id or an array of Id's
@param id {String} - Single Giphy gif string Id or array of string Id's
@param callback | [
"Search",
"all",
"Giphy",
"gifs",
"for",
"a",
"single",
"Id",
"or",
"an",
"array",
"of",
"Id",
"s"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L92-L111 | train | |
austinkelleher/giphy-api | index.js | function (options, callback) {
if (!options) {
return _handleErr('Translate phrase cannot be empty.', callback);
}
return this._request({
api: options.api || 'gifs',
endpoint: 'translate',
query: typeof options === 'string' ? {
s: options
} : options
}, callback);
... | javascript | function (options, callback) {
if (!options) {
return _handleErr('Translate phrase cannot be empty.', callback);
}
return this._request({
api: options.api || 'gifs',
endpoint: 'translate',
query: typeof options === 'string' ? {
s: options
} : options
}, callback);
... | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"return",
"_handleErr",
"(",
"'Translate phrase cannot be empty.'",
",",
"callback",
")",
";",
"}",
"return",
"this",
".",
"_request",
"(",
"{",
"api",
":",
"option... | Search for Giphy gifs by phrase with Gify vocabulary
@param options Giphy API translate options
options.s {String} - term or phrase to translate into a GIF
options.rating {String} - limit results to those rated (y,g, pg, pg-13 or r).
options.fmt {String} - (optional) return results in html or json format (useful for v... | [
"Search",
"for",
"Giphy",
"gifs",
"by",
"phrase",
"with",
"Gify",
"vocabulary"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L121-L133 | train | |
austinkelleher/giphy-api | index.js | function (options, callback) {
var reqOptions = {
api: (options ? options.api : null) || 'gifs',
endpoint: 'random'
};
if (typeof options === 'string') {
reqOptions.query = {
tag: options
};
} else if (typeof options === 'object') {
reqOptions.query = options;
... | javascript | function (options, callback) {
var reqOptions = {
api: (options ? options.api : null) || 'gifs',
endpoint: 'random'
};
if (typeof options === 'string') {
reqOptions.query = {
tag: options
};
} else if (typeof options === 'object') {
reqOptions.query = options;
... | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"var",
"reqOptions",
"=",
"{",
"api",
":",
"(",
"options",
"?",
"options",
".",
"api",
":",
"null",
")",
"||",
"'gifs'",
",",
"endpoint",
":",
"'random'",
"}",
";",
"if",
"(",
"typeof",
"options"... | Fetch random gif filtered by tag
@param options Giphy API random options
options.tag {String} - the GIF tag to limit randomness by
options.rating {String} - limit results to those rated (y,g, pg, pg-13 or r).
options.fmt {Stirng} - (optional) return results in html or json format (useful for viewing responses as GIFs ... | [
"Fetch",
"random",
"gif",
"filtered",
"by",
"tag"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L143-L160 | train | |
austinkelleher/giphy-api | index.js | function (options, callback) {
var reqOptions = {
endpoint: 'trending'
};
reqOptions.api = (options ? options.api : null) || 'gifs';
// Cleanup so we don't add this to our query
if (options) {
delete options.api;
}
if (typeof options === 'object' &&
Object.keys(options).... | javascript | function (options, callback) {
var reqOptions = {
endpoint: 'trending'
};
reqOptions.api = (options ? options.api : null) || 'gifs';
// Cleanup so we don't add this to our query
if (options) {
delete options.api;
}
if (typeof options === 'object' &&
Object.keys(options).... | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"var",
"reqOptions",
"=",
"{",
"endpoint",
":",
"'trending'",
"}",
";",
"reqOptions",
".",
"api",
"=",
"(",
"options",
"?",
"options",
".",
"api",
":",
"null",
")",
"||",
"'gifs'",
";",
"// Cleanup... | Fetch trending gifs
@param options Giphy API random options
options.limit {Number} - (optional) limits the number of results returned. By default returns 25 results.
options.rating {String} - limit results to those rated (y,g, pg, pg-13 or r).
options.fmt {String} - (optional) return results in html or json format (us... | [
"Fetch",
"trending",
"gifs"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L170-L190 | train | |
austinkelleher/giphy-api | index.js | function (options, callback) {
if (!callback && !promisesExist) {
throw new Error('Callback must be provided if promises are unavailable');
}
var endpoint = '';
if (options.endpoint) {
endpoint = '/' + options.endpoint;
}
var query;
var self = this;
if (typeof options.quer... | javascript | function (options, callback) {
if (!callback && !promisesExist) {
throw new Error('Callback must be provided if promises are unavailable');
}
var endpoint = '';
if (options.endpoint) {
endpoint = '/' + options.endpoint;
}
var query;
var self = this;
if (typeof options.quer... | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"callback",
"&&",
"!",
"promisesExist",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Callback must be provided if promises are unavailable'",
")",
";",
"}",
"var",
"endpoint",
"=",
"''",
";",
... | Prepares the HTTP request and query string for the Giphy API
@param options
options.endpoint {String} - The API endpoint e.g. search
options.query {String|Object} Query string parameters. If these are left
out then we default to an empty string. If this is passed as a string,
we default to the 'q' query string field u... | [
"Prepares",
"the",
"HTTP",
"request",
"and",
"query",
"string",
"for",
"the",
"Giphy",
"API"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L201-L261 | train | |
Ap0c/node-omxplayer | index.js | spawnPlayer | function spawnPlayer (src, out, loop, initialVolume, showOsd) {
let args = buildArgs(src, out, loop, initialVolume, showOsd);
console.log('args for omxplayer:', args);
let omxProcess = spawn('omxplayer', args);
open = true;
omxProcess.stdin.setEncoding('utf-8');
omxProcess.on('close', updateStatus);
om... | javascript | function spawnPlayer (src, out, loop, initialVolume, showOsd) {
let args = buildArgs(src, out, loop, initialVolume, showOsd);
console.log('args for omxplayer:', args);
let omxProcess = spawn('omxplayer', args);
open = true;
omxProcess.stdin.setEncoding('utf-8');
omxProcess.on('close', updateStatus);
om... | [
"function",
"spawnPlayer",
"(",
"src",
",",
"out",
",",
"loop",
",",
"initialVolume",
",",
"showOsd",
")",
"{",
"let",
"args",
"=",
"buildArgs",
"(",
"src",
",",
"out",
",",
"loop",
",",
"initialVolume",
",",
"showOsd",
")",
";",
"console",
".",
"log",... | Spawns the omxplayer process. | [
"Spawns",
"the",
"omxplayer",
"process",
"."
] | 0ee6f30f23008e80b0dfe892bb84166c2e8a6922 | https://github.com/Ap0c/node-omxplayer/blob/0ee6f30f23008e80b0dfe892bb84166c2e8a6922/index.js#L84-L100 | train |
arvydas/blinkstick-node | blinkstick.js | BlinkStick | function BlinkStick (device, serialNumber, manufacturer, product) {
if (isWin) {
if (device) {
this.device = new usb.HID(device);
this.serial = serialNumber;
this.manufacturer = manufacturer;
this.product = product;
}
} else {
if (device) ... | javascript | function BlinkStick (device, serialNumber, manufacturer, product) {
if (isWin) {
if (device) {
this.device = new usb.HID(device);
this.serial = serialNumber;
this.manufacturer = manufacturer;
this.product = product;
}
} else {
if (device) ... | [
"function",
"BlinkStick",
"(",
"device",
",",
"serialNumber",
",",
"manufacturer",
",",
"product",
")",
"{",
"if",
"(",
"isWin",
")",
"{",
"if",
"(",
"device",
")",
"{",
"this",
".",
"device",
"=",
"new",
"usb",
".",
"HID",
"(",
"device",
")",
";",
... | Initialize new BlinkStick device
@class BlinkStick
@constructor
@param {Object} device The USB device as returned from "usb" package.
@param {String} [serialNumber] Serial number of the device. Used only in Windows.
@param {String} [manufacturer] Manufacturer of the device. Used only in Windows.
@param {String} [produ... | [
"Initialize",
"new",
"BlinkStick",
"device"
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L190-L218 | train |
arvydas/blinkstick-node | blinkstick.js | _determineReportId | function _determineReportId(ledCount)
{
var reportId = 9;
var maxLeds = 64;
if (ledCount < 8 * 3) {
reportId = 6;
maxLeds = 8;
} else if (ledCount < 16 * 3) {
reportId = 7;
maxLeds = 16;
} else if (ledCount < 32 * 3) {
reportId = 8;
maxLeds = 32;
... | javascript | function _determineReportId(ledCount)
{
var reportId = 9;
var maxLeds = 64;
if (ledCount < 8 * 3) {
reportId = 6;
maxLeds = 8;
} else if (ledCount < 16 * 3) {
reportId = 7;
maxLeds = 16;
} else if (ledCount < 32 * 3) {
reportId = 8;
maxLeds = 32;
... | [
"function",
"_determineReportId",
"(",
"ledCount",
")",
"{",
"var",
"reportId",
"=",
"9",
";",
"var",
"maxLeds",
"=",
"64",
";",
"if",
"(",
"ledCount",
"<",
"8",
"*",
"3",
")",
"{",
"reportId",
"=",
"6",
";",
"maxLeds",
"=",
"8",
";",
"}",
"else",
... | Determines report ID and number of LEDs for the report
@private
@method _determineReportId
@return {object} data.reportId and data.ledCount | [
"Determines",
"report",
"ID",
"and",
"number",
"of",
"LEDs",
"for",
"the",
"report"
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L379-L396 | train |
arvydas/blinkstick-node | blinkstick.js | getInfoBlock | function getInfoBlock (device, location, callback) {
getFeatureReport(location, 33, function (err, buffer) {
if (typeof(err) !== 'undefined')
{
callback(err);
return;
}
var result = '',
i, l;
for (i = 1, l = buffer.length; i < l; i++) {
... | javascript | function getInfoBlock (device, location, callback) {
getFeatureReport(location, 33, function (err, buffer) {
if (typeof(err) !== 'undefined')
{
callback(err);
return;
}
var result = '',
i, l;
for (i = 1, l = buffer.length; i < l; i++) {
... | [
"function",
"getInfoBlock",
"(",
"device",
",",
"location",
",",
"callback",
")",
"{",
"getFeatureReport",
"(",
"location",
",",
"33",
",",
"function",
"(",
"err",
",",
"buffer",
")",
"{",
"if",
"(",
"typeof",
"(",
"err",
")",
"!==",
"'undefined'",
")",
... | Get an infoblock from a device.
@private
@static
@method getInfoBlock
@param {BlinkStick} device Device from which to get the value.
@param {Number} location Address to seek the data.
@param {Function} callback Callback to which to pass the value. | [
"Get",
"an",
"infoblock",
"from",
"a",
"device",
"."
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L775-L793 | train |
arvydas/blinkstick-node | blinkstick.js | opt | function opt(options, name, defaultValue){
return options && options[name]!==undefined ? options[name] : defaultValue;
} | javascript | function opt(options, name, defaultValue){
return options && options[name]!==undefined ? options[name] : defaultValue;
} | [
"function",
"opt",
"(",
"options",
",",
"name",
",",
"defaultValue",
")",
"{",
"return",
"options",
"&&",
"options",
"[",
"name",
"]",
"!==",
"undefined",
"?",
"options",
"[",
"name",
"]",
":",
"defaultValue",
";",
"}"
] | Get default value from options
@private
@static
@method opt
@param {Object} options Option object to operate on
@param {String} name The name of the parameter
@param {Object} defaultValue Default value if name is not found in option object | [
"Get",
"default",
"value",
"from",
"options"
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L808-L810 | train |
arvydas/blinkstick-node | blinkstick.js | setInfoBlock | function setInfoBlock (device, location, data, callback) {
var i,
l = Math.min(data.length, 33),
buffer = new Buffer(33);
buffer[0] = 0;
for (i = 0; i < l; i++) buffer[i + 1] = data.charCodeAt(i);
for (i = l; i < 33; i++) buffer[i + 1] = 0;
setFeatureReport(location, buffer, callback);
} | javascript | function setInfoBlock (device, location, data, callback) {
var i,
l = Math.min(data.length, 33),
buffer = new Buffer(33);
buffer[0] = 0;
for (i = 0; i < l; i++) buffer[i + 1] = data.charCodeAt(i);
for (i = l; i < 33; i++) buffer[i + 1] = 0;
setFeatureReport(location, buffer, callback);
} | [
"function",
"setInfoBlock",
"(",
"device",
",",
"location",
",",
"data",
",",
"callback",
")",
"{",
"var",
"i",
",",
"l",
"=",
"Math",
".",
"min",
"(",
"data",
".",
"length",
",",
"33",
")",
",",
"buffer",
"=",
"new",
"Buffer",
"(",
"33",
")",
";... | Sets an infoblock on a device.
@private
@static
@method setInfoBlock
@param {BlinkStick} device Device on which to set the value.
@param {Number} location Address to seek the data.
@param {String} data The value to push to the device. Should be <= 32 chars.
@param {Function} callback Callback to which to pass the valu... | [
"Sets",
"an",
"infoblock",
"on",
"a",
"device",
"."
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L823-L833 | train |
arvydas/blinkstick-node | blinkstick.js | findBlinkSticks | function findBlinkSticks (filter) {
if (filter === undefined) filter = function () { return true; };
var result = [], device, i, devices;
if (isWin) {
devices = usb.devices();
for (i in devices) {
device = devices[i];
if (device.vendorId === VENDOR_ID &&
... | javascript | function findBlinkSticks (filter) {
if (filter === undefined) filter = function () { return true; };
var result = [], device, i, devices;
if (isWin) {
devices = usb.devices();
for (i in devices) {
device = devices[i];
if (device.vendorId === VENDOR_ID &&
... | [
"function",
"findBlinkSticks",
"(",
"filter",
")",
"{",
"if",
"(",
"filter",
"===",
"undefined",
")",
"filter",
"=",
"function",
"(",
")",
"{",
"return",
"true",
";",
"}",
";",
"var",
"result",
"=",
"[",
"]",
",",
"device",
",",
"i",
",",
"devices",
... | Find BlinkSticks using a filter.
@method findBlinkSticks
@param {Function} [filter] Filter function.
@return {Array} BlickStick objects. | [
"Find",
"BlinkSticks",
"using",
"a",
"filter",
"."
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L1257-L1289 | train |
arvydas/blinkstick-node | blinkstick.js | function () {
if (isWin) {
var devices = findBlinkSticks();
return devices.length > 0 ? devices[0] : null;
} else {
var device = usb.findByIds(VENDOR_ID, PRODUCT_ID);
if (device) return new BlinkStick(device);
}
} | javascript | function () {
if (isWin) {
var devices = findBlinkSticks();
return devices.length > 0 ? devices[0] : null;
} else {
var device = usb.findByIds(VENDOR_ID, PRODUCT_ID);
if (device) return new BlinkStick(device);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"isWin",
")",
"{",
"var",
"devices",
"=",
"findBlinkSticks",
"(",
")",
";",
"return",
"devices",
".",
"length",
">",
"0",
"?",
"devices",
"[",
"0",
"]",
":",
"null",
";",
"}",
"else",
"{",
"var",
"device",
"=... | Find first attached BlinkStick.
@example
var blinkstick = require('blinkstick');
var led = blinkstick.findFirst();
@static
@method findFirst
@return {BlinkStick|undefined} The first BlinkStick, if found. | [
"Find",
"first",
"attached",
"BlinkStick",
"."
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L1420-L1429 | train | |
arvydas/blinkstick-node | blinkstick.js | function (callback) {
var result = [];
var devices = findBlinkSticks();
var i = 0;
var finder = function() {
if (i == devices.length) {
if (callback) callback(result);
} else {
devices[i].getSerial(function (err, serial) {
... | javascript | function (callback) {
var result = [];
var devices = findBlinkSticks();
var i = 0;
var finder = function() {
if (i == devices.length) {
if (callback) callback(result);
} else {
devices[i].getSerial(function (err, serial) {
... | [
"function",
"(",
"callback",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"devices",
"=",
"findBlinkSticks",
"(",
")",
";",
"var",
"i",
"=",
"0",
";",
"var",
"finder",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"i",
"==",
"devices",
".",... | Returns the serial numbers of all attached BlinkStick devices.
@static
@method findAllSerials
@param {Function} callback Callback when all serials have been collected
@return {Array} Serial numbers. | [
"Returns",
"the",
"serial",
"numbers",
"of",
"all",
"attached",
"BlinkStick",
"devices",
"."
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L1460-L1480 | train | |
arvydas/blinkstick-node | blinkstick.js | function (serial, callback) {
var result = [];
var devices = findBlinkSticks();
var i = 0;
var finder = function() {
if (i == devices.length) {
if (callback) callback();
} else {
devices[i].getSerial(function (err, serialNumber) ... | javascript | function (serial, callback) {
var result = [];
var devices = findBlinkSticks();
var i = 0;
var finder = function() {
if (i == devices.length) {
if (callback) callback();
} else {
devices[i].getSerial(function (err, serialNumber) ... | [
"function",
"(",
"serial",
",",
"callback",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"devices",
"=",
"findBlinkSticks",
"(",
")",
";",
"var",
"i",
"=",
"0",
";",
"var",
"finder",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"i",
"==",
... | Find BlinkStick device based on serial number.
@static
@method findBySerial
@param {Number} serial Serial number.
@param {Function} callback Callback when BlinkStick has been found | [
"Find",
"BlinkStick",
"device",
"based",
"on",
"serial",
"number",
"."
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L1493-L1516 | train | |
allenai/hierplane | src/module/helpers.js | getAllChildSpans | function getAllChildSpans(node) {
return (
Array.isArray(node.children)
? node.children
.map(n => (n.spans || []).concat(getAllChildSpans(n)))
.reduce((all, arr) => all.concat(arr))
: []
);
} | javascript | function getAllChildSpans(node) {
return (
Array.isArray(node.children)
? node.children
.map(n => (n.spans || []).concat(getAllChildSpans(n)))
.reduce((all, arr) => all.concat(arr))
: []
);
} | [
"function",
"getAllChildSpans",
"(",
"node",
")",
"{",
"return",
"(",
"Array",
".",
"isArray",
"(",
"node",
".",
"children",
")",
"?",
"node",
".",
"children",
".",
"map",
"(",
"n",
"=>",
"(",
"n",
".",
"spans",
"||",
"[",
"]",
")",
".",
"concat",
... | Returns all children of the provided node, including those that are descendents of the node's
children.
@param {Node} node
@return {Span[]} | [
"Returns",
"all",
"children",
"of",
"the",
"provided",
"node",
"including",
"those",
"that",
"are",
"descendents",
"of",
"the",
"node",
"s",
"children",
"."
] | a907bdd7740a0b2fe517afb06b8419ac9aa1dcd0 | https://github.com/allenai/hierplane/blob/a907bdd7740a0b2fe517afb06b8419ac9aa1dcd0/src/module/helpers.js#L212-L220 | train |
allenai/hierplane | bin/build.js | compileJavascript | function compileJavascript(filePath) {
const jsPath = filePath || 'src';
const babelPath = which.sync('babel');
const outFile =
jsPath.endsWith('.js')
? `--out-file ${jsPath.replace('src/', 'dist/')}`
: `-d dist`;
console.log(chalk.cyan(`compling javascript ${chalk.magenta(jsPath)}`));
cp.exec... | javascript | function compileJavascript(filePath) {
const jsPath = filePath || 'src';
const babelPath = which.sync('babel');
const outFile =
jsPath.endsWith('.js')
? `--out-file ${jsPath.replace('src/', 'dist/')}`
: `-d dist`;
console.log(chalk.cyan(`compling javascript ${chalk.magenta(jsPath)}`));
cp.exec... | [
"function",
"compileJavascript",
"(",
"filePath",
")",
"{",
"const",
"jsPath",
"=",
"filePath",
"||",
"'src'",
";",
"const",
"babelPath",
"=",
"which",
".",
"sync",
"(",
"'babel'",
")",
";",
"const",
"outFile",
"=",
"jsPath",
".",
"endsWith",
"(",
"'.js'",... | Compiles Javascript, using Babel, to a consistent runtime that isn't dependent on a JSX parser
or future ECMA targets.
@param {String} [jsPath=src] Path to the file(s) to compile. If a directory is specified, all
*.js files in that directory are compiled.
@return {undefined} | [
"Compiles",
"Javascript",
"using",
"Babel",
"to",
"a",
"consistent",
"runtime",
"that",
"isn",
"t",
"dependent",
"on",
"a",
"JSX",
"parser",
"or",
"future",
"ECMA",
"targets",
"."
] | a907bdd7740a0b2fe517afb06b8419ac9aa1dcd0 | https://github.com/allenai/hierplane/blob/a907bdd7740a0b2fe517afb06b8419ac9aa1dcd0/bin/build.js#L89-L99 | train |
allenai/hierplane | bin/build.js | compileLess | function compileLess() {
console.log(chalk.cyan(`compiling ${chalk.magenta('src/less/hierplane.less')}`));
cp.execSync(`${which.sync('lessc')} --clean-css --autoprefix="last 2 versions" src/less/hierplane.less dist/static/hierplane.min.css`);
console.log(chalk.green(`wrote ${chalk.magenta('dist/static/hierplane.m... | javascript | function compileLess() {
console.log(chalk.cyan(`compiling ${chalk.magenta('src/less/hierplane.less')}`));
cp.execSync(`${which.sync('lessc')} --clean-css --autoprefix="last 2 versions" src/less/hierplane.less dist/static/hierplane.min.css`);
console.log(chalk.green(`wrote ${chalk.magenta('dist/static/hierplane.m... | [
"function",
"compileLess",
"(",
")",
"{",
"console",
".",
"log",
"(",
"chalk",
".",
"cyan",
"(",
"`",
"${",
"chalk",
".",
"magenta",
"(",
"'src/less/hierplane.less'",
")",
"}",
"`",
")",
")",
";",
"cp",
".",
"execSync",
"(",
"`",
"${",
"which",
".",
... | Compiles less to css.
@return {undefined} | [
"Compiles",
"less",
"to",
"css",
"."
] | a907bdd7740a0b2fe517afb06b8419ac9aa1dcd0 | https://github.com/allenai/hierplane/blob/a907bdd7740a0b2fe517afb06b8419ac9aa1dcd0/bin/build.js#L106-L110 | train |
allenai/hierplane | bin/build.js | bundleJavascript | function bundleJavascript() {
const bundleEntryPath = path.resolve(__dirname, '..', 'dist', 'static', 'hierplane.js');
const bundlePath = path.resolve(__dirname, '..', 'dist', 'static', 'hierplane.bundle.js');
// Put together our "bundler", which uses browserify
const browserifyOpts = {
entries: [ bundleEn... | javascript | function bundleJavascript() {
const bundleEntryPath = path.resolve(__dirname, '..', 'dist', 'static', 'hierplane.js');
const bundlePath = path.resolve(__dirname, '..', 'dist', 'static', 'hierplane.bundle.js');
// Put together our "bundler", which uses browserify
const browserifyOpts = {
entries: [ bundleEn... | [
"function",
"bundleJavascript",
"(",
")",
"{",
"const",
"bundleEntryPath",
"=",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"'..'",
",",
"'dist'",
",",
"'static'",
",",
"'hierplane.js'",
")",
";",
"const",
"bundlePath",
"=",
"path",
".",
"resolve",
"(",
... | Compresses the static javascript bundle into a single file with all required dependencies so
that people can use it in their browser.
@return {undefined} | [
"Compresses",
"the",
"static",
"javascript",
"bundle",
"into",
"a",
"single",
"file",
"with",
"all",
"required",
"dependencies",
"so",
"that",
"people",
"can",
"use",
"it",
"in",
"their",
"browser",
"."
] | a907bdd7740a0b2fe517afb06b8419ac9aa1dcd0 | https://github.com/allenai/hierplane/blob/a907bdd7740a0b2fe517afb06b8419ac9aa1dcd0/bin/build.js#L118-L156 | train |
JodusNodus/node-syncthing | lib/event-caller.js | iterator | function iterator(since) {
if (stop) {
return;
}
var attr = [];
attr.push({ key: 'since', val: since });
attr.push({ key: 'events', val: events });
req({ method: 'events', endpoint: false, attr: attr }).then(function (eventArr) {
//Check for event count on first request iteration
... | javascript | function iterator(since) {
if (stop) {
return;
}
var attr = [];
attr.push({ key: 'since', val: since });
attr.push({ key: 'events', val: events });
req({ method: 'events', endpoint: false, attr: attr }).then(function (eventArr) {
//Check for event count on first request iteration
... | [
"function",
"iterator",
"(",
"since",
")",
"{",
"if",
"(",
"stop",
")",
"{",
"return",
";",
"}",
"var",
"attr",
"=",
"[",
"]",
";",
"attr",
".",
"push",
"(",
"{",
"key",
":",
"'since'",
",",
"val",
":",
"since",
"}",
")",
";",
"attr",
".",
"p... | Event request loop | [
"Event",
"request",
"loop"
] | 6e19d2cb4c8fb99b583ee468b8a4643b9a506f09 | https://github.com/JodusNodus/node-syncthing/blob/6e19d2cb4c8fb99b583ee468b8a4643b9a506f09/lib/event-caller.js#L36-L76 | train |
JodusNodus/node-syncthing | lib/request.js | handleReq | function handleReq(config) {
var authCheck = csrfTokenCheck();
return function (options, callback) {
if (callback) {
authCheck({ config: config, options: options, callback: callback });
} else {
return new Promise(function (resolve, reject) {
authCheck({
config: config,
... | javascript | function handleReq(config) {
var authCheck = csrfTokenCheck();
return function (options, callback) {
if (callback) {
authCheck({ config: config, options: options, callback: callback });
} else {
return new Promise(function (resolve, reject) {
authCheck({
config: config,
... | [
"function",
"handleReq",
"(",
"config",
")",
"{",
"var",
"authCheck",
"=",
"csrfTokenCheck",
"(",
")",
";",
"return",
"function",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"callback",
")",
"{",
"authCheck",
"(",
"{",
"config",
":",
"config",
... | Wrap in a promise if expected | [
"Wrap",
"in",
"a",
"promise",
"if",
"expected"
] | 6e19d2cb4c8fb99b583ee468b8a4643b9a506f09 | https://github.com/JodusNodus/node-syncthing/blob/6e19d2cb4c8fb99b583ee468b8a4643b9a506f09/lib/request.js#L86-L104 | train |
observing/haproxy | lib/parser.js | Parser | function Parser(config) {
if (!(this instanceof Parser)) return new Parser(config);
this.config = config;
this.config.on('read', function read(type) {
this[type]();
}.bind(this));
} | javascript | function Parser(config) {
if (!(this instanceof Parser)) return new Parser(config);
this.config = config;
this.config.on('read', function read(type) {
this[type]();
}.bind(this));
} | [
"function",
"Parser",
"(",
"config",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Parser",
")",
")",
"return",
"new",
"Parser",
"(",
"config",
")",
";",
"this",
".",
"config",
"=",
"config",
";",
"this",
".",
"config",
".",
"on",
"(",
"'re... | Automatic parser interface for configuration changes.
@constructor
@param {Configuration} config The parent configuration instance
@api private | [
"Automatic",
"parser",
"interface",
"for",
"configuration",
"changes",
"."
] | 93d7bf9ad54c700c384c6e95e43ad5cbf12f7e18 | https://github.com/observing/haproxy/blob/93d7bf9ad54c700c384c6e95e43ad5cbf12f7e18/lib/parser.js#L10-L18 | train |
observing/haproxy | lib/orchestrator.js | Orchestrator | function Orchestrator(options) {
if (!(this instanceof Orchestrator)) return new Orchestrator(options);
options = options || {};
this.which = options.which || require('which').sync('haproxy');
this.pid = options.pid || '';
this.pidFile = options.pidFile || '';
this.config = options.config;
this.discover... | javascript | function Orchestrator(options) {
if (!(this instanceof Orchestrator)) return new Orchestrator(options);
options = options || {};
this.which = options.which || require('which').sync('haproxy');
this.pid = options.pid || '';
this.pidFile = options.pidFile || '';
this.config = options.config;
this.discover... | [
"function",
"Orchestrator",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Orchestrator",
")",
")",
"return",
"new",
"Orchestrator",
"(",
"options",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"which",
... | Orchestrator is a haproxy interface that allows you to run and interact with
the `haproxy` binary.
Options:
- pid: The pid file
- pidFile: The location of the pid file
- config: The location of the configuration file
- [optional] discover: Tries to find your HAProxy instance if you don't know the pid
- [optional] whi... | [
"Orchestrator",
"is",
"a",
"haproxy",
"interface",
"that",
"allows",
"you",
"to",
"run",
"and",
"interact",
"with",
"the",
"haproxy",
"binary",
"."
] | 93d7bf9ad54c700c384c6e95e43ad5cbf12f7e18 | https://github.com/observing/haproxy/blob/93d7bf9ad54c700c384c6e95e43ad5cbf12f7e18/lib/orchestrator.js#L26-L42 | train |
observing/haproxy | lib/configuration.js | property | function property(fn, arg) {
var base = [ section, name ];
return {
writable: false,
enumerable: false,
value: function () {
if (arg) base.push(arg);
return fn.apply(self, base.concat(
Array.prototype.slice.apply(arguments)
));
}
... | javascript | function property(fn, arg) {
var base = [ section, name ];
return {
writable: false,
enumerable: false,
value: function () {
if (arg) base.push(arg);
return fn.apply(self, base.concat(
Array.prototype.slice.apply(arguments)
));
}
... | [
"function",
"property",
"(",
"fn",
",",
"arg",
")",
"{",
"var",
"base",
"=",
"[",
"section",
",",
"name",
"]",
";",
"return",
"{",
"writable",
":",
"false",
",",
"enumerable",
":",
"false",
",",
"value",
":",
"function",
"(",
")",
"{",
"if",
"(",
... | Generate property descriptor.
@param {Function} fn Method to call.
@param {Mixed} arg Additional default arguments, other than section and name.
@return {Object} Property description. | [
"Generate",
"property",
"descriptor",
"."
] | 93d7bf9ad54c700c384c6e95e43ad5cbf12f7e18 | https://github.com/observing/haproxy/blob/93d7bf9ad54c700c384c6e95e43ad5cbf12f7e18/lib/configuration.js#L345-L359 | train |
observing/haproxy | index.js | HAProxy | function HAProxy(socket, options) {
if (!(this instanceof HAProxy)) return new HAProxy(socket, options);
options = options || {};
//
// Allow variable arguments, with socket path or just custom options.
//
if ('object' === typeof socket) {
options = socket;
socket = options.socket || null;
}
... | javascript | function HAProxy(socket, options) {
if (!(this instanceof HAProxy)) return new HAProxy(socket, options);
options = options || {};
//
// Allow variable arguments, with socket path or just custom options.
//
if ('object' === typeof socket) {
options = socket;
socket = options.socket || null;
}
... | [
"function",
"HAProxy",
"(",
"socket",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"HAProxy",
")",
")",
"return",
"new",
"HAProxy",
"(",
"socket",
",",
"options",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"//",... | Control your HAProxy servers using the unix domain socket. This module is
based upon the 1.5 branch socket.
Options:
- pid: The process id
- pidFile: The location of the pid file
- config: The location of the configuration file
- discover: Tries to find your HAProxy instance if you don't know the pid
- socket: The lo... | [
"Control",
"your",
"HAProxy",
"servers",
"using",
"the",
"unix",
"domain",
"socket",
".",
"This",
"module",
"is",
"based",
"upon",
"the",
"1",
".",
"5",
"branch",
"socket",
"."
] | 93d7bf9ad54c700c384c6e95e43ad5cbf12f7e18 | https://github.com/observing/haproxy/blob/93d7bf9ad54c700c384c6e95e43ad5cbf12f7e18/index.js#L42-L69 | train |
tjenkinson/hls-live-thumbnails | src/simple-thumbnail-generator.js | SimpleThumbnailGenerator | function SimpleThumbnailGenerator(options, generatorOptions) {
options = options || {};
generatorOptions = generatorOptions || {};
if (!options.manifestFileName) {
throw new Error("manifestFileName required.");
}
if (typeof(options.logger) === "undefined") {
this._logger = Logger.get('SimpleThumbnailGenerato... | javascript | function SimpleThumbnailGenerator(options, generatorOptions) {
options = options || {};
generatorOptions = generatorOptions || {};
if (!options.manifestFileName) {
throw new Error("manifestFileName required.");
}
if (typeof(options.logger) === "undefined") {
this._logger = Logger.get('SimpleThumbnailGenerato... | [
"function",
"SimpleThumbnailGenerator",
"(",
"options",
",",
"generatorOptions",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"generatorOptions",
"=",
"generatorOptions",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"options",
".",
"manifestFileName",
")"... | Starts generating the thumbnails using the configuration in `generatorOptions`.
Removes thumbnails when they their segments are removed from the playlist after `expireTime` seconds.
@constructor
@param {String} options.manifestFileName The name for the manifest file.
@param {Object} options The time in seconds to keep ... | [
"Starts",
"generating",
"the",
"thumbnails",
"using",
"the",
"configuration",
"in",
"generatorOptions",
".",
"Removes",
"thumbnails",
"when",
"they",
"their",
"segments",
"are",
"removed",
"from",
"the",
"playlist",
"after",
"expireTime",
"seconds",
"."
] | 59679f8aaaf8dc738de210762519511a6d327fdc | https://github.com/tjenkinson/hls-live-thumbnails/blob/59679f8aaaf8dc738de210762519511a6d327fdc/src/simple-thumbnail-generator.js#L18-L59 | train |
sebpiq/WAAClock | demos/tempoChange.js | function(newTempo) {
clock.timeStretch(context.currentTime, [freqEvent1, freqEvent2], currentTempo / newTempo)
currentTempo = newTempo
} | javascript | function(newTempo) {
clock.timeStretch(context.currentTime, [freqEvent1, freqEvent2], currentTempo / newTempo)
currentTempo = newTempo
} | [
"function",
"(",
"newTempo",
")",
"{",
"clock",
".",
"timeStretch",
"(",
"context",
".",
"currentTime",
",",
"[",
"freqEvent1",
",",
"freqEvent2",
"]",
",",
"currentTempo",
"/",
"newTempo",
")",
"currentTempo",
"=",
"newTempo",
"}"
] | To change the tempo, we use the function `Clock.timeStretch`. | [
"To",
"change",
"the",
"tempo",
"we",
"use",
"the",
"function",
"Clock",
".",
"timeStretch",
"."
] | 078f7e8e9118b17afa8c4b288e5212ba2d54462b | https://github.com/sebpiq/WAAClock/blob/078f7e8e9118b17afa8c4b288e5212ba2d54462b/demos/tempoChange.js#L8-L11 | train | |
sebpiq/WAAClock | demos/beatSequence.js | function(track, beatInd) {
var event = clock.callbackAtTime(function(event) {
var bufferNode = soundBank[track].createNode()
bufferNode.start(event.deadline)
}, nextBeatTime(beatInd))
event.repeat(barDur)
event.tolerance({late: 0.01})
beats[track][beatInd] = event
} | javascript | function(track, beatInd) {
var event = clock.callbackAtTime(function(event) {
var bufferNode = soundBank[track].createNode()
bufferNode.start(event.deadline)
}, nextBeatTime(beatInd))
event.repeat(barDur)
event.tolerance({late: 0.01})
beats[track][beatInd] = event
} | [
"function",
"(",
"track",
",",
"beatInd",
")",
"{",
"var",
"event",
"=",
"clock",
".",
"callbackAtTime",
"(",
"function",
"(",
"event",
")",
"{",
"var",
"bufferNode",
"=",
"soundBank",
"[",
"track",
"]",
".",
"createNode",
"(",
")",
"bufferNode",
".",
... | This function activates the beat `beatInd` of `track`. | [
"This",
"function",
"activates",
"the",
"beat",
"beatInd",
"of",
"track",
"."
] | 078f7e8e9118b17afa8c4b288e5212ba2d54462b | https://github.com/sebpiq/WAAClock/blob/078f7e8e9118b17afa8c4b288e5212ba2d54462b/demos/beatSequence.js#L23-L31 | train | |
sebpiq/WAAClock | demos/beatSequence.js | function(track) {
var request = new XMLHttpRequest()
request.open('GET', 'sounds/' + track + '.wav', true)
request.responseType = 'arraybuffer'
request.onload = function() {
context.decodeAudioData(request.response, function(buffer) {
var createNode = function() {
var node = context.createBuff... | javascript | function(track) {
var request = new XMLHttpRequest()
request.open('GET', 'sounds/' + track + '.wav', true)
request.responseType = 'arraybuffer'
request.onload = function() {
context.decodeAudioData(request.response, function(buffer) {
var createNode = function() {
var node = context.createBuff... | [
"function",
"(",
"track",
")",
"{",
"var",
"request",
"=",
"new",
"XMLHttpRequest",
"(",
")",
"request",
".",
"open",
"(",
"'GET'",
",",
"'sounds/'",
"+",
"track",
"+",
"'.wav'",
",",
"true",
")",
"request",
".",
"responseType",
"=",
"'arraybuffer'",
"re... | This helper loads sound buffers | [
"This",
"helper",
"loads",
"sound",
"buffers"
] | 078f7e8e9118b17afa8c4b288e5212ba2d54462b | https://github.com/sebpiq/WAAClock/blob/078f7e8e9118b17afa8c4b288e5212ba2d54462b/demos/beatSequence.js#L50-L66 | train | |
aMarCruz/rollup-plugin-pug | dist/rollup-plugin-pug.js | moveImports | function moveImports(code, imports) {
return code.replace(RE_IMPORTS, function (_, indent, imprt) {
imprt = imprt.trim();
if (imprt.slice(-1) !== ';') {
imprt += ';';
}
imports.push(imprt);
return indent; // keep only the indentation
});
} | javascript | function moveImports(code, imports) {
return code.replace(RE_IMPORTS, function (_, indent, imprt) {
imprt = imprt.trim();
if (imprt.slice(-1) !== ';') {
imprt += ';';
}
imports.push(imprt);
return indent; // keep only the indentation
});
} | [
"function",
"moveImports",
"(",
"code",
",",
"imports",
")",
"{",
"return",
"code",
".",
"replace",
"(",
"RE_IMPORTS",
",",
"function",
"(",
"_",
",",
"indent",
",",
"imprt",
")",
"{",
"imprt",
"=",
"imprt",
".",
"trim",
"(",
")",
";",
"if",
"(",
"... | Adds an import directive to the collected imports.
@param code Procesing code
@param imports Collected imports | [
"Adds",
"an",
"import",
"directive",
"to",
"the",
"collected",
"imports",
"."
] | c32a9b9daeca8ceb46aabd510acf90834984b127 | https://github.com/aMarCruz/rollup-plugin-pug/blob/c32a9b9daeca8ceb46aabd510acf90834984b127/dist/rollup-plugin-pug.js#L68-L77 | train |
aMarCruz/rollup-plugin-pug | dist/rollup-plugin-pug.js | clonePugOpts | function clonePugOpts(opts, filename) {
return PUGPROPS.reduce((o, p) => {
if (p in opts) {
o[p] = clone(opts[p]);
}
return o;
}, { filename });
} | javascript | function clonePugOpts(opts, filename) {
return PUGPROPS.reduce((o, p) => {
if (p in opts) {
o[p] = clone(opts[p]);
}
return o;
}, { filename });
} | [
"function",
"clonePugOpts",
"(",
"opts",
",",
"filename",
")",
"{",
"return",
"PUGPROPS",
".",
"reduce",
"(",
"(",
"o",
",",
"p",
")",
"=>",
"{",
"if",
"(",
"p",
"in",
"opts",
")",
"{",
"o",
"[",
"p",
"]",
"=",
"clone",
"(",
"opts",
"[",
"p",
... | Retuns a deep copy of the properties filtered by an allowed keywords list | [
"Retuns",
"a",
"deep",
"copy",
"of",
"the",
"properties",
"filtered",
"by",
"an",
"allowed",
"keywords",
"list"
] | c32a9b9daeca8ceb46aabd510acf90834984b127 | https://github.com/aMarCruz/rollup-plugin-pug/blob/c32a9b9daeca8ceb46aabd510acf90834984b127/dist/rollup-plugin-pug.js#L114-L121 | train |
amcharts/amcharts3-react | examples/script/example.js | generateData | function generateData() {
var firstDate = new Date();
var dataProvider = [];
for (var i = 0; i < 100; ++i) {
var date = new Date(firstDate.getTime());
date.setDate(i);
dataProvider.push({
date: date,
value: Math.floor(Math.random() * 100)
});
}
return dataProvider;
} | javascript | function generateData() {
var firstDate = new Date();
var dataProvider = [];
for (var i = 0; i < 100; ++i) {
var date = new Date(firstDate.getTime());
date.setDate(i);
dataProvider.push({
date: date,
value: Math.floor(Math.random() * 100)
});
}
return dataProvider;
} | [
"function",
"generateData",
"(",
")",
"{",
"var",
"firstDate",
"=",
"new",
"Date",
"(",
")",
";",
"var",
"dataProvider",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"100",
";",
"++",
"i",
")",
"{",
"var",
"date",
"=",
... | Generate random data | [
"Generate",
"random",
"data"
] | 0930606e49b739f4f97efee462d70cfb80c73d83 | https://github.com/amcharts/amcharts3-react/blob/0930606e49b739f4f97efee462d70cfb80c73d83/examples/script/example.js#L2-L19 | train |
jillix/svg.connectable.js | example/js/svg.js | function(array) {
this.destination = this.parse(array)
// normalize length of arrays
if (this.value.length != this.destination.length) {
var lastValue = this.value[this.value.length - 1]
, lastDestination = this.destination[this.destination.length - 1]
while(this.value.length > t... | javascript | function(array) {
this.destination = this.parse(array)
// normalize length of arrays
if (this.value.length != this.destination.length) {
var lastValue = this.value[this.value.length - 1]
, lastDestination = this.destination[this.destination.length - 1]
while(this.value.length > t... | [
"function",
"(",
"array",
")",
"{",
"this",
".",
"destination",
"=",
"this",
".",
"parse",
"(",
"array",
")",
"// normalize length of arrays",
"if",
"(",
"this",
".",
"value",
".",
"length",
"!=",
"this",
".",
"destination",
".",
"length",
")",
"{",
"var... | Make array morphable | [
"Make",
"array",
"morphable"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L428-L443 | 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.