id int32 0 58k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
23,000 | 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 |
23,001 | 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 |
23,002 | 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' && obj[key] != null) {
if (Array.isArray(obj[key])) {
result[key] = walk(obj[key], fnc, []);
} else {
result[key] = walk(obj[key], fnc, {});
}
result[key] = fnc(key, result[key], result);
} else {
// Fire the function
result[key] = fnc(key, obj[key], obj);
}
}
if (is_root) {
result = fnc('', result);
}
return result;
} | 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' && obj[key] != null) {
if (Array.isArray(obj[key])) {
result[key] = walk(obj[key], fnc, []);
} else {
result[key] = walk(obj[key], fnc, {});
}
result[key] = fnc(key, result[key], result);
} else {
// Fire the function
result[key] = fnc(key, obj[key], obj);
}
}
if (is_root) {
result = fnc('', result);
}
return result;
} | [
"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'",
"&&",
"obj",
"[",
"key",
"]",
"!=",
"null",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
"[",
"key",
"]",
")",
")",
"{",
"result",
"[",
"key",
"]",
"=",
"walk",
"(",
"obj",
"[",
"key",
"]",
",",
"fnc",
",",
"[",
"]",
")",
";",
"}",
"else",
"{",
"result",
"[",
"key",
"]",
"=",
"walk",
"(",
"obj",
"[",
"key",
"]",
",",
"fnc",
",",
"{",
"}",
")",
";",
"}",
"result",
"[",
"key",
"]",
"=",
"fnc",
"(",
"key",
",",
"result",
"[",
"key",
"]",
",",
"result",
")",
";",
"}",
"else",
"{",
"// Fire the function",
"result",
"[",
"key",
"]",
"=",
"fnc",
"(",
"key",
",",
"obj",
"[",
"key",
"]",
",",
"obj",
")",
";",
"}",
"}",
"if",
"(",
"is_root",
")",
"{",
"result",
"=",
"fnc",
"(",
"''",
",",
"result",
")",
";",
"}",
"return",
"result",
";",
"}"
] | 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 |
23,003 | 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') {
object = JSON.parse(object);
}
if (!object || typeof object != 'object') {
return object;
}
result = walk(object, reviver);
if (result == null) {
return result;
}
// To remember which objects have already been revived
seen = new WeakMap();
// Maybe paths need another round of undrying
undry_paths.extra_pass = [];
// Iterate over all the values that require some kind of function to be revived
undry_paths.forEach(function eachEntry(entry, path) {
var path_array = entry.drypath,
path_string = path_array.join('.');
// Regenerate this replacement wrapper first
regenerate(result, null, entry, seen, retrieve, undry_paths, old, path_array.slice(0));
if (entry.unDryConstructor) {
entry.undried = entry.unDryConstructor.unDry(entry.value, false);
} else if (entry.unDryFunction) {
entry.undried = entry.unDryFunction(entry, null, entry.value);
} else {
entry.undried = entry.value;
}
// Remember the old wrapper entry, some other references
// may still point to it's children
old[path_string] = entry;
if (entry.drypath && entry.drypath.length) {
setPath(result, entry.drypath, entry.undried);
}
});
for (var i = 0; i < undry_paths.extra_pass.length; i++) {
entry = undry_paths.extra_pass[i];
holder = entry[0];
temp = entry[1];
path = entry[2];
for (key in holder) {
if (holder[key] == temp) {
holder[key] = temp.undried;
break;
}
}
path.pop();
// Annoying workaround for some circular references
if (path.length && path[path.length - 1] == 'value') {
path.pop();
}
if (path.length) {
// Get the other holder
holder = retrieveFromPath(result, path);
// If the holder object was not found in the result,
// it was probably a child of ANOTHER holder that has already been undried & replaces
// Just get the value from the object containing old references
if (!holder) {
holder = getFromOld(old, path);
}
for (key in holder) {
if (holder[key] == temp) {
holder[key] = temp.undried;
break;
}
}
}
}
// Only now we can resolve paths
result = regenerate(result, result, result, seen, retrieve, undry_paths, old, []);
if (result.undried != null && result.dry) {
return result.undried;
}
return result;
} | 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') {
object = JSON.parse(object);
}
if (!object || typeof object != 'object') {
return object;
}
result = walk(object, reviver);
if (result == null) {
return result;
}
// To remember which objects have already been revived
seen = new WeakMap();
// Maybe paths need another round of undrying
undry_paths.extra_pass = [];
// Iterate over all the values that require some kind of function to be revived
undry_paths.forEach(function eachEntry(entry, path) {
var path_array = entry.drypath,
path_string = path_array.join('.');
// Regenerate this replacement wrapper first
regenerate(result, null, entry, seen, retrieve, undry_paths, old, path_array.slice(0));
if (entry.unDryConstructor) {
entry.undried = entry.unDryConstructor.unDry(entry.value, false);
} else if (entry.unDryFunction) {
entry.undried = entry.unDryFunction(entry, null, entry.value);
} else {
entry.undried = entry.value;
}
// Remember the old wrapper entry, some other references
// may still point to it's children
old[path_string] = entry;
if (entry.drypath && entry.drypath.length) {
setPath(result, entry.drypath, entry.undried);
}
});
for (var i = 0; i < undry_paths.extra_pass.length; i++) {
entry = undry_paths.extra_pass[i];
holder = entry[0];
temp = entry[1];
path = entry[2];
for (key in holder) {
if (holder[key] == temp) {
holder[key] = temp.undried;
break;
}
}
path.pop();
// Annoying workaround for some circular references
if (path.length && path[path.length - 1] == 'value') {
path.pop();
}
if (path.length) {
// Get the other holder
holder = retrieveFromPath(result, path);
// If the holder object was not found in the result,
// it was probably a child of ANOTHER holder that has already been undried & replaces
// Just get the value from the object containing old references
if (!holder) {
holder = getFromOld(old, path);
}
for (key in holder) {
if (holder[key] == temp) {
holder[key] = temp.undried;
break;
}
}
}
}
// Only now we can resolve paths
result = regenerate(result, result, result, seen, retrieve, undry_paths, old, []);
if (result.undried != null && result.dry) {
return result.undried;
}
return result;
} | [
"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'",
")",
"{",
"object",
"=",
"JSON",
".",
"parse",
"(",
"object",
")",
";",
"}",
"if",
"(",
"!",
"object",
"||",
"typeof",
"object",
"!=",
"'object'",
")",
"{",
"return",
"object",
";",
"}",
"result",
"=",
"walk",
"(",
"object",
",",
"reviver",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"return",
"result",
";",
"}",
"// To remember which objects have already been revived",
"seen",
"=",
"new",
"WeakMap",
"(",
")",
";",
"// Maybe paths need another round of undrying",
"undry_paths",
".",
"extra_pass",
"=",
"[",
"]",
";",
"// Iterate over all the values that require some kind of function to be revived",
"undry_paths",
".",
"forEach",
"(",
"function",
"eachEntry",
"(",
"entry",
",",
"path",
")",
"{",
"var",
"path_array",
"=",
"entry",
".",
"drypath",
",",
"path_string",
"=",
"path_array",
".",
"join",
"(",
"'.'",
")",
";",
"// Regenerate this replacement wrapper first",
"regenerate",
"(",
"result",
",",
"null",
",",
"entry",
",",
"seen",
",",
"retrieve",
",",
"undry_paths",
",",
"old",
",",
"path_array",
".",
"slice",
"(",
"0",
")",
")",
";",
"if",
"(",
"entry",
".",
"unDryConstructor",
")",
"{",
"entry",
".",
"undried",
"=",
"entry",
".",
"unDryConstructor",
".",
"unDry",
"(",
"entry",
".",
"value",
",",
"false",
")",
";",
"}",
"else",
"if",
"(",
"entry",
".",
"unDryFunction",
")",
"{",
"entry",
".",
"undried",
"=",
"entry",
".",
"unDryFunction",
"(",
"entry",
",",
"null",
",",
"entry",
".",
"value",
")",
";",
"}",
"else",
"{",
"entry",
".",
"undried",
"=",
"entry",
".",
"value",
";",
"}",
"// Remember the old wrapper entry, some other references",
"// may still point to it's children",
"old",
"[",
"path_string",
"]",
"=",
"entry",
";",
"if",
"(",
"entry",
".",
"drypath",
"&&",
"entry",
".",
"drypath",
".",
"length",
")",
"{",
"setPath",
"(",
"result",
",",
"entry",
".",
"drypath",
",",
"entry",
".",
"undried",
")",
";",
"}",
"}",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"undry_paths",
".",
"extra_pass",
".",
"length",
";",
"i",
"++",
")",
"{",
"entry",
"=",
"undry_paths",
".",
"extra_pass",
"[",
"i",
"]",
";",
"holder",
"=",
"entry",
"[",
"0",
"]",
";",
"temp",
"=",
"entry",
"[",
"1",
"]",
";",
"path",
"=",
"entry",
"[",
"2",
"]",
";",
"for",
"(",
"key",
"in",
"holder",
")",
"{",
"if",
"(",
"holder",
"[",
"key",
"]",
"==",
"temp",
")",
"{",
"holder",
"[",
"key",
"]",
"=",
"temp",
".",
"undried",
";",
"break",
";",
"}",
"}",
"path",
".",
"pop",
"(",
")",
";",
"// Annoying workaround for some circular references",
"if",
"(",
"path",
".",
"length",
"&&",
"path",
"[",
"path",
".",
"length",
"-",
"1",
"]",
"==",
"'value'",
")",
"{",
"path",
".",
"pop",
"(",
")",
";",
"}",
"if",
"(",
"path",
".",
"length",
")",
"{",
"// Get the other holder",
"holder",
"=",
"retrieveFromPath",
"(",
"result",
",",
"path",
")",
";",
"// If the holder object was not found in the result,",
"// it was probably a child of ANOTHER holder that has already been undried & replaces",
"// Just get the value from the object containing old references",
"if",
"(",
"!",
"holder",
")",
"{",
"holder",
"=",
"getFromOld",
"(",
"old",
",",
"path",
")",
";",
"}",
"for",
"(",
"key",
"in",
"holder",
")",
"{",
"if",
"(",
"holder",
"[",
"key",
"]",
"==",
"temp",
")",
"{",
"holder",
"[",
"key",
"]",
"=",
"temp",
".",
"undried",
";",
"break",
";",
"}",
"}",
"}",
"}",
"// Only now we can resolve paths",
"result",
"=",
"regenerate",
"(",
"result",
",",
"result",
",",
"result",
",",
"seen",
",",
"retrieve",
",",
"undry_paths",
",",
"old",
",",
"[",
"]",
")",
";",
"if",
"(",
"result",
".",
"undried",
"!=",
"null",
"&&",
"result",
".",
"dry",
")",
"{",
"return",
"result",
".",
"undried",
";",
"}",
"return",
"result",
";",
"}"
] | 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 |
23,004 | 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 | |
23,005 | 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",
")",
"===",
"simpleTypes",
"[",
"type",
"]",
")",
";",
"}"
] | 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 | |
23,006 | 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;
case simpleTypes.object:
return (Object.keys(item).length === 0);
case simpleTypes.array:
return (item.length === 0);
default:
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;
case simpleTypes.object:
return (Object.keys(item).length === 0);
case simpleTypes.array:
return (item.length === 0);
default:
return false;
};
} | [
"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",
";",
"case",
"simpleTypes",
".",
"object",
":",
"return",
"(",
"Object",
".",
"keys",
"(",
"item",
")",
".",
"length",
"===",
"0",
")",
";",
"case",
"simpleTypes",
".",
"array",
":",
"return",
"(",
"item",
".",
"length",
"===",
"0",
")",
";",
"default",
":",
"return",
"false",
";",
"}",
";",
"}"
] | Check an object for empiness | [
"Check",
"an",
"object",
"for",
"empiness"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L117-L134 | |
23,007 | 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)) {
(function (prop) {
Object.defineProperty(props, prop, {
get: function () {
for (var i = 0; i < inputs.length; ++i) {
if (!checkType(prop, inputs[i], hard)) {
return false;
}
}
return true;
}
});
}(t));
}
}
};
generateProps(simpleTypes, false);
generateProps(harderTypes, true);
// Check whether the specified inputs even exist
Object.defineProperty(props, "there", {
get: function () {
for (var i = 0; i < inputs.length; ++i) {
if (inputs[i] === undefined || inputs[i] === null) {
return false;
}
}
return true;
}
});
// Check whether a passed in input is considered empty or not
Object.defineProperty(props, "empty", {
get: function () {
for (var i = 0; i < inputs.length; ++i) {
if (!checkEmpty(getType(inputs[i]), inputs[i])) {
return false;
}
}
return true;
}
});
return props;
} | 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 (prop) {
Object.defineProperty(props, prop, {
get: function () {
for (var i = 0; i < inputs.length; ++i) {
if (!checkType(prop, inputs[i], hard)) {
return false;
}
}
return true;
}
});
}(t));
}
}
};
generateProps(simpleTypes, false);
generateProps(harderTypes, true);
// Check whether the specified inputs even exist
Object.defineProperty(props, "there", {
get: function () {
for (var i = 0; i < inputs.length; ++i) {
if (inputs[i] === undefined || inputs[i] === null) {
return false;
}
}
return true;
}
});
// Check whether a passed in input is considered empty or not
Object.defineProperty(props, "empty", {
get: function () {
for (var i = 0; i < inputs.length; ++i) {
if (!checkEmpty(getType(inputs[i]), inputs[i])) {
return false;
}
}
return true;
}
});
return props;
} | [
"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",
"(",
"prop",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"props",
",",
"prop",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"inputs",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"!",
"checkType",
"(",
"prop",
",",
"inputs",
"[",
"i",
"]",
",",
"hard",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"}",
")",
";",
"}",
"(",
"t",
")",
")",
";",
"}",
"}",
"}",
";",
"generateProps",
"(",
"simpleTypes",
",",
"false",
")",
";",
"generateProps",
"(",
"harderTypes",
",",
"true",
")",
";",
"// Check whether the specified inputs even exist",
"Object",
".",
"defineProperty",
"(",
"props",
",",
"\"there\"",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"inputs",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"inputs",
"[",
"i",
"]",
"===",
"undefined",
"||",
"inputs",
"[",
"i",
"]",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"}",
")",
";",
"// Check whether a passed in input is considered empty or not",
"Object",
".",
"defineProperty",
"(",
"props",
",",
"\"empty\"",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"inputs",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"!",
"checkEmpty",
"(",
"getType",
"(",
"inputs",
"[",
"i",
"]",
")",
",",
"inputs",
"[",
"i",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"}",
")",
";",
"return",
"props",
";",
"}"
] | 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 | |
23,008 | 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; ++i) {
if (!checkType(prop, inputs[i], hard)) {
return false;
}
}
return true;
}
});
}(t));
}
}
} | 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; ++i) {
if (!checkType(prop, inputs[i], hard)) {
return false;
}
}
return true;
}
});
}(t));
}
}
} | [
"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",
";",
"++",
"i",
")",
"{",
"if",
"(",
"!",
"checkType",
"(",
"prop",
",",
"inputs",
"[",
"i",
"]",
",",
"hard",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"}",
")",
";",
"}",
"(",
"t",
")",
")",
";",
"}",
"}",
"}"
] | 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 | |
23,009 | 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 (acceptableForObj1.indexOf(obj1Type) === -1 || acceptableForObj2.indexOf(obj2Type) === -1) {
exceptionMsg = "msngr.merge() - Only objects, arrays or a single function followed by objects can be merged!";
}
if ([obj1Type, obj2Type].indexOf(internal.types.array) !== -1 && (obj1Type !== internal.types.array || obj2Type !== internal.types.array)) {
exceptionMsg = "msngr.merge() - Arrays cannot be merged with objects or functions!";
}
if (overwrite === true) {
return obj2;
}
if (exceptionMsg) {
throw new Error(exceptionMsg);
}
var result = obj1;
// If we're in the weird spot of getting only arrays then concat and return
// Seriously though, Mr or Mrs or Ms dev, just use Array.prototype.concat()!
if (obj1Type === internal.types.array && obj2Type === internal.types.array) {
return obj1.concat(obj2);
}
for (var key in obj2) {
if (obj2.hasOwnProperty(key)) {
var is = external.is(obj2[key]);
if (is.object) {
result[key] = result[key] || { };
result[key] = twoMerge(result[key], obj2[key]);
} else if (is.array) {
result[key] = result[key] || [];
result[key] = result[key].concat(obj2[key]);
} else {
result[key] = obj2[key];
}
}
}
return result;
} | 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 (acceptableForObj1.indexOf(obj1Type) === -1 || acceptableForObj2.indexOf(obj2Type) === -1) {
exceptionMsg = "msngr.merge() - Only objects, arrays or a single function followed by objects can be merged!";
}
if ([obj1Type, obj2Type].indexOf(internal.types.array) !== -1 && (obj1Type !== internal.types.array || obj2Type !== internal.types.array)) {
exceptionMsg = "msngr.merge() - Arrays cannot be merged with objects or functions!";
}
if (overwrite === true) {
return obj2;
}
if (exceptionMsg) {
throw new Error(exceptionMsg);
}
var result = obj1;
// If we're in the weird spot of getting only arrays then concat and return
// Seriously though, Mr or Mrs or Ms dev, just use Array.prototype.concat()!
if (obj1Type === internal.types.array && obj2Type === internal.types.array) {
return obj1.concat(obj2);
}
for (var key in obj2) {
if (obj2.hasOwnProperty(key)) {
var is = external.is(obj2[key]);
if (is.object) {
result[key] = result[key] || { };
result[key] = twoMerge(result[key], obj2[key]);
} else if (is.array) {
result[key] = result[key] || [];
result[key] = result[key].concat(obj2[key]);
} else {
result[key] = obj2[key];
}
}
}
return result;
} | [
"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",
"(",
"acceptableForObj1",
".",
"indexOf",
"(",
"obj1Type",
")",
"===",
"-",
"1",
"||",
"acceptableForObj2",
".",
"indexOf",
"(",
"obj2Type",
")",
"===",
"-",
"1",
")",
"{",
"exceptionMsg",
"=",
"\"msngr.merge() - Only objects, arrays or a single function followed by objects can be merged!\"",
";",
"}",
"if",
"(",
"[",
"obj1Type",
",",
"obj2Type",
"]",
".",
"indexOf",
"(",
"internal",
".",
"types",
".",
"array",
")",
"!==",
"-",
"1",
"&&",
"(",
"obj1Type",
"!==",
"internal",
".",
"types",
".",
"array",
"||",
"obj2Type",
"!==",
"internal",
".",
"types",
".",
"array",
")",
")",
"{",
"exceptionMsg",
"=",
"\"msngr.merge() - Arrays cannot be merged with objects or functions!\"",
";",
"}",
"if",
"(",
"overwrite",
"===",
"true",
")",
"{",
"return",
"obj2",
";",
"}",
"if",
"(",
"exceptionMsg",
")",
"{",
"throw",
"new",
"Error",
"(",
"exceptionMsg",
")",
";",
"}",
"var",
"result",
"=",
"obj1",
";",
"// If we're in the weird spot of getting only arrays then concat and return",
"// Seriously though, Mr or Mrs or Ms dev, just use Array.prototype.concat()!",
"if",
"(",
"obj1Type",
"===",
"internal",
".",
"types",
".",
"array",
"&&",
"obj2Type",
"===",
"internal",
".",
"types",
".",
"array",
")",
"{",
"return",
"obj1",
".",
"concat",
"(",
"obj2",
")",
";",
"}",
"for",
"(",
"var",
"key",
"in",
"obj2",
")",
"{",
"if",
"(",
"obj2",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"var",
"is",
"=",
"external",
".",
"is",
"(",
"obj2",
"[",
"key",
"]",
")",
";",
"if",
"(",
"is",
".",
"object",
")",
"{",
"result",
"[",
"key",
"]",
"=",
"result",
"[",
"key",
"]",
"||",
"{",
"}",
";",
"result",
"[",
"key",
"]",
"=",
"twoMerge",
"(",
"result",
"[",
"key",
"]",
",",
"obj2",
"[",
"key",
"]",
")",
";",
"}",
"else",
"if",
"(",
"is",
".",
"array",
")",
"{",
"result",
"[",
"key",
"]",
"=",
"result",
"[",
"key",
"]",
"||",
"[",
"]",
";",
"result",
"[",
"key",
"]",
"=",
"result",
"[",
"key",
"]",
".",
"concat",
"(",
"obj2",
"[",
"key",
"]",
")",
";",
"}",
"else",
"{",
"result",
"[",
"key",
"]",
"=",
"obj2",
"[",
"key",
"]",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | 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 | |
23,010 | 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",
"=",
"arr",
"[",
"endIndex",
"]",
";",
"arr",
"[",
"endIndex",
"]",
"=",
"arr",
"[",
"inx",
"]",
";",
"arr",
"[",
"inx",
"]",
"=",
"temp",
";",
"}",
"arr",
".",
"pop",
"(",
")",
";",
"}"
] | 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 | |
23,011 | 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 (middlewares[keys[i]] !== undefined) {
results.push({
method: middlewares[keys[i]],
params: [payload, message]
});
}
}
return results;
} | 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 (middlewares[keys[i]] !== undefined) {
results.push({
method: middlewares[keys[i]],
params: [payload, message]
});
}
}
return results;
} | [
"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",
"(",
"middlewares",
"[",
"keys",
"[",
"i",
"]",
"]",
"!==",
"undefined",
")",
"{",
"results",
".",
"push",
"(",
"{",
"method",
":",
"middlewares",
"[",
"keys",
"[",
"i",
"]",
"]",
",",
"params",
":",
"[",
"payload",
",",
"message",
"]",
"}",
")",
";",
"}",
"}",
"return",
"results",
";",
"}"
] | gets a listing of middlewares | [
"gets",
"a",
"listing",
"of",
"middlewares"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L858-L877 | |
23,012 | 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",
"(",
"function",
"(",
"result",
")",
"{",
"return",
"callback",
"(",
"internal",
".",
"merge",
".",
"apply",
"(",
"this",
",",
"[",
"payload",
"]",
".",
"concat",
"(",
"result",
")",
")",
")",
";",
"}",
")",
";",
"}"
] | 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 | |
23,013 | 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).object) ? external.copy(msgOrIds) : external.copy(messageIndex.query(ids[i]));
var obj = handlers[ids[i]];
methods.push({
method: obj.handler,
params: [payload, msg]
});
if (obj.once === true) {
toDrop.push({
msg: msg,
handler: obj.handler
});
}
}
var execs = internal.executer(methods);
for (var i = 0; i < toDrop.length; ++i) {
external(toDrop[i].msg).drop(toDrop[i].handler);
}
execs.parallel(callback);
}
} | 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).object) ? external.copy(msgOrIds) : external.copy(messageIndex.query(ids[i]));
var obj = handlers[ids[i]];
methods.push({
method: obj.handler,
params: [payload, msg]
});
if (obj.once === true) {
toDrop.push({
msg: msg,
handler: obj.handler
});
}
}
var execs = internal.executer(methods);
for (var i = 0; i < toDrop.length; ++i) {
external(toDrop[i].msg).drop(toDrop[i].handler);
}
execs.parallel(callback);
}
} | [
"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",
")",
".",
"object",
")",
"?",
"external",
".",
"copy",
"(",
"msgOrIds",
")",
":",
"external",
".",
"copy",
"(",
"messageIndex",
".",
"query",
"(",
"ids",
"[",
"i",
"]",
")",
")",
";",
"var",
"obj",
"=",
"handlers",
"[",
"ids",
"[",
"i",
"]",
"]",
";",
"methods",
".",
"push",
"(",
"{",
"method",
":",
"obj",
".",
"handler",
",",
"params",
":",
"[",
"payload",
",",
"msg",
"]",
"}",
")",
";",
"if",
"(",
"obj",
".",
"once",
"===",
"true",
")",
"{",
"toDrop",
".",
"push",
"(",
"{",
"msg",
":",
"msg",
",",
"handler",
":",
"obj",
".",
"handler",
"}",
")",
";",
"}",
"}",
"var",
"execs",
"=",
"internal",
".",
"executer",
"(",
"methods",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"toDrop",
".",
"length",
";",
"++",
"i",
")",
"{",
"external",
"(",
"toDrop",
"[",
"i",
"]",
".",
"msg",
")",
".",
"drop",
"(",
"toDrop",
"[",
"i",
"]",
".",
"handler",
")",
";",
"}",
"execs",
".",
"parallel",
"(",
"callback",
")",
";",
"}",
"}"
] | An explicit emit | [
"An",
"explicit",
"emit"
] | c173dd2b86527b34bc300aabc3b45cfb7474b0f3 | https://github.com/KrisSiegel/msngr.js/blob/c173dd2b86527b34bc300aabc3b45cfb7474b0f3/msngr.js#L897-L927 | |
23,014 | 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 (var i = 0; i < data.length; i++) {
idata.data[i] = data[i]
}
context.putImageData(idata, 0, 0)
return canvas
} | 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 (var i = 0; i < data.length; i++) {
idata.data[i] = data[i]
}
context.putImageData(idata, 0, 0)
return canvas
} | [
"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",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"++",
")",
"{",
"idata",
".",
"data",
"[",
"i",
"]",
"=",
"data",
"[",
"i",
"]",
"}",
"context",
".",
"putImageData",
"(",
"idata",
",",
"0",
",",
"0",
")",
"return",
"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 |
23,015 | 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.requireTypeByName;
constructor.requireTypeFromBuffer = NewType.requireTypeFromBuffer;
constructor.logger = NewType.logger;
} | 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.requireTypeByName;
constructor.requireTypeFromBuffer = NewType.requireTypeFromBuffer;
constructor.logger = NewType.logger;
} | [
"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",
".",
"requireTypeByName",
";",
"constructor",
".",
"requireTypeFromBuffer",
"=",
"NewType",
".",
"requireTypeFromBuffer",
";",
"constructor",
".",
"logger",
"=",
"NewType",
".",
"logger",
";",
"}"
] | 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 |
23,016 | 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) {\n' +
'\t\tvar msg = \'The \\\'channel\\\' option is missing, it\\\'s mandatory\';\n' +
'\t\tself.logger.error(msg);\n' +
'\t\tif(callback) {\n' +
'\t\t\tcallback(new TypeError(msg));\n' +
'\t\t}\n' +
'\t\treturn;\n' +
'\t}\n';
body +=
'\tvar reqPayload = new self.Type(options);\n' +
'\tchannel.callMethod(reqPayload, callback);\n';
if (logger.isDebugEnabled()) {
logger.debug('Body for %s type function:', methodName);
logger.debug('\n' + body);
}
// Create the new Type function
var typeFunction = new Function('options', body);
typeFunction._name = methodName;
typeFunction.requireTypeFromBuffer = ConstructorBuilder.requireTypeFromBuffer;
// Create the function payload class re-calling TypeBuilder constructor.
typeFunction.Type = new ConstructorBuilder(module, tlSchema, true).getType();
typeFunction.logger = getLogger(module + '.' + methodName);
return typeFunction;
} | 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) {\n' +
'\t\tvar msg = \'The \\\'channel\\\' option is missing, it\\\'s mandatory\';\n' +
'\t\tself.logger.error(msg);\n' +
'\t\tif(callback) {\n' +
'\t\t\tcallback(new TypeError(msg));\n' +
'\t\t}\n' +
'\t\treturn;\n' +
'\t}\n';
body +=
'\tvar reqPayload = new self.Type(options);\n' +
'\tchannel.callMethod(reqPayload, callback);\n';
if (logger.isDebugEnabled()) {
logger.debug('Body for %s type function:', methodName);
logger.debug('\n' + body);
}
// Create the new Type function
var typeFunction = new Function('options', body);
typeFunction._name = methodName;
typeFunction.requireTypeFromBuffer = ConstructorBuilder.requireTypeFromBuffer;
// Create the function payload class re-calling TypeBuilder constructor.
typeFunction.Type = new ConstructorBuilder(module, tlSchema, true).getType();
typeFunction.logger = getLogger(module + '.' + methodName);
return typeFunction;
} | [
"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) {\\n'",
"+",
"'\\t\\tvar msg = \\'The \\\\\\'channel\\\\\\' option is missing, it\\\\\\'s mandatory\\';\\n'",
"+",
"'\\t\\tself.logger.error(msg);\\n'",
"+",
"'\\t\\tif(callback) {\\n'",
"+",
"'\\t\\t\\tcallback(new TypeError(msg));\\n'",
"+",
"'\\t\\t}\\n'",
"+",
"'\\t\\treturn;\\n'",
"+",
"'\\t}\\n'",
";",
"body",
"+=",
"'\\tvar reqPayload = new self.Type(options);\\n'",
"+",
"'\\tchannel.callMethod(reqPayload, callback);\\n'",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"'Body for %s type function:'",
",",
"methodName",
")",
";",
"logger",
".",
"debug",
"(",
"'\\n'",
"+",
"body",
")",
";",
"}",
"// Create the new Type function",
"var",
"typeFunction",
"=",
"new",
"Function",
"(",
"'options'",
",",
"body",
")",
";",
"typeFunction",
".",
"_name",
"=",
"methodName",
";",
"typeFunction",
".",
"requireTypeFromBuffer",
"=",
"ConstructorBuilder",
".",
"requireTypeFromBuffer",
";",
"// Create the function payload class re-calling TypeBuilder constructor.",
"typeFunction",
".",
"Type",
"=",
"new",
"ConstructorBuilder",
"(",
"module",
",",
"tlSchema",
",",
"true",
")",
".",
"getType",
"(",
")",
";",
"typeFunction",
".",
"logger",
"=",
"getLogger",
"(",
"module",
"+",
"'.'",
"+",
"methodName",
")",
";",
"return",
"typeFunction",
";",
"}"
] | 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 |
23,017 | 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",
")",
";",
"}",
"if",
"(",
"type",
".",
"id",
")",
"{",
"typeById",
"[",
"type",
".",
"id",
"]",
"=",
"type",
";",
"}",
"return",
"type",
";",
"}"
] | 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 |
23,018 | 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.isDebugEnabled()) {
registryLogger.debug('Require Type \'%s\' by id [%s]', type.typeName, typeId);
}
return type;
} | 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.isDebugEnabled()) {
registryLogger.debug('Require Type \'%s\' by id [%s]', type.typeName, typeId);
}
return type;
} | [
"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",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"registryLogger",
".",
"debug",
"(",
"'Require Type \\'%s\\' by id [%s]'",
",",
"type",
".",
"typeName",
",",
"typeId",
")",
";",
"}",
"return",
"type",
";",
"}"
] | 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 |
23,019 | 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",
")",
";",
"}",
"typeByName",
"[",
"type",
".",
"typeName",
"]",
"=",
"type",
";",
"return",
"type",
";",
"}"
] | 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 |
23,020 | 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 Type \'%s\' by name [%s]', type.id, typeName);
}
return type;
} | 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 Type \'%s\' by name [%s]', type.id, typeName);
}
return type;
} | [
"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 Type \\'%s\\' by name [%s]'",
",",
"type",
".",
"id",
",",
"typeName",
")",
";",
"}",
"return",
"type",
";",
"}"
] | 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 |
23,021 | 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 pair = value2String(prop, this[prop], exclude[prop], noColor);
if (pair.value !== undefined) {
str = str.slice(-1) === ' ' ? str : str + ', ';
str += (noColor ? pair.prop : pair.prop.bold.cyan) + ': ' + pair.value;
}
}
}
str += ' }';
return str;
} | 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 pair = value2String(prop, this[prop], exclude[prop], noColor);
if (pair.value !== undefined) {
str = str.slice(-1) === ' ' ? str : str + ', ';
str += (noColor ? pair.prop : pair.prop.bold.cyan) + ': ' + pair.value;
}
}
}
str += ' }';
return str;
} | [
"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",
"pair",
"=",
"value2String",
"(",
"prop",
",",
"this",
"[",
"prop",
"]",
",",
"exclude",
"[",
"prop",
"]",
",",
"noColor",
")",
";",
"if",
"(",
"pair",
".",
"value",
"!==",
"undefined",
")",
"{",
"str",
"=",
"str",
".",
"slice",
"(",
"-",
"1",
")",
"===",
"' '",
"?",
"str",
":",
"str",
"+",
"', '",
";",
"str",
"+=",
"(",
"noColor",
"?",
"pair",
".",
"prop",
":",
"pair",
".",
"prop",
".",
"bold",
".",
"cyan",
")",
"+",
"': '",
"+",
"pair",
".",
"value",
";",
"}",
"}",
"}",
"str",
"+=",
"' }'",
";",
"return",
"str",
";",
"}"
] | 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 |
23,022 | 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 Buffer(input.slice(i - 2, i), 'hex'));
j++;
}
var buffer = Buffer.concat(buffers);
var paddingLength = byteLength - buffer.length;
if (paddingLength > 0) {
var padding = new Buffer(paddingLength);
padding.fill(0);
buffer = Buffer.concat([buffer, padding]);
}
return buffer;
}
else {
return bigInt2Buffer(new BigInteger(stringValue), byteLength);
}
} | 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 Buffer(input.slice(i - 2, i), 'hex'));
j++;
}
var buffer = Buffer.concat(buffers);
var paddingLength = byteLength - buffer.length;
if (paddingLength > 0) {
var padding = new Buffer(paddingLength);
padding.fill(0);
buffer = Buffer.concat([buffer, padding]);
}
return buffer;
}
else {
return bigInt2Buffer(new BigInteger(stringValue), byteLength);
}
} | [
"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",
"Buffer",
"(",
"input",
".",
"slice",
"(",
"i",
"-",
"2",
",",
"i",
")",
",",
"'hex'",
")",
")",
";",
"j",
"++",
";",
"}",
"var",
"buffer",
"=",
"Buffer",
".",
"concat",
"(",
"buffers",
")",
";",
"var",
"paddingLength",
"=",
"byteLength",
"-",
"buffer",
".",
"length",
";",
"if",
"(",
"paddingLength",
">",
"0",
")",
"{",
"var",
"padding",
"=",
"new",
"Buffer",
"(",
"paddingLength",
")",
";",
"padding",
".",
"fill",
"(",
"0",
")",
";",
"buffer",
"=",
"Buffer",
".",
"concat",
"(",
"[",
"buffer",
",",
"padding",
"]",
")",
";",
"}",
"return",
"buffer",
";",
"}",
"else",
"{",
"return",
"bigInt2Buffer",
"(",
"new",
"BigInteger",
"(",
"stringValue",
")",
",",
"byteLength",
")",
";",
"}",
"}"
] | 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 |
23,023 | 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",
"+=",
"buffer",
".",
"slice",
"(",
"i",
"-",
"1",
",",
"i",
")",
".",
"toString",
"(",
"'hex'",
")",
";",
"}",
"return",
"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 |
23,024 | 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.
*/
/**
* @type {HttpContext}
*/
var ctx = context;
Object.defineProperty(this,'context', {
get: function() {
return ctx;
},
set: function(value) {
ctx = value;
},
configurable:false,
enumerable:false
});
} | 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.
*/
/**
* @type {HttpContext}
*/
var ctx = context;
Object.defineProperty(this,'context', {
get: function() {
return ctx;
},
set: function(value) {
ctx = value;
},
configurable:false,
enumerable:false
});
} | [
"function",
"HttpViewEngine",
"(",
"context",
")",
"{",
"if",
"(",
"this",
".",
"constructor",
"===",
"HttpViewEngine",
".",
"prototype",
".",
"constructor",
")",
"{",
"throw",
"new",
"AbstractClassError",
"(",
")",
";",
"}",
"/**\n * @name HttpViewEngine#context\n * @type HttpContext\n * @description Gets or sets an instance of HttpContext that represents the current HTTP context.\n */",
"/**\n * @type {HttpContext}\n */",
"var",
"ctx",
"=",
"context",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'context'",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"return",
"ctx",
";",
"}",
",",
"set",
":",
"function",
"(",
"value",
")",
"{",
"ctx",
"=",
"value",
";",
"}",
",",
"configurable",
":",
"false",
",",
"enumerable",
":",
"false",
"}",
")",
";",
"}"
] | 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 |
23,025 | 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 |
23,026 | 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 controller e.g. /index.html, /about.html
if (segments.length === 2)
return 'root';
else
//e.g /pages/about where segments are ['','pages','about']
//and the controller of course is always the second segment.
return segments[1];
}
catch (err) {
throw err;
}
} | 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 controller e.g. /index.html, /about.html
if (segments.length === 2)
return 'root';
else
//e.g /pages/about where segments are ['','pages','about']
//and the controller of course is always the second segment.
return segments[1];
}
catch (err) {
throw err;
}
} | [
"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 controller e.g. /index.html, /about.html",
"if",
"(",
"segments",
".",
"length",
"===",
"2",
")",
"return",
"'root'",
";",
"else",
"//e.g /pages/about where segments are ['','pages','about']",
"//and the controller of course is always the second segment.",
"return",
"segments",
"[",
"1",
"]",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"throw",
"err",
";",
"}",
"}"
] | 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 |
23,027 | 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;
this.DOM_PROCESSING_INSTRUCTION_NODE = 7;
this.DOM_COMMENT_NODE = 8;
this.DOM_DOCUMENT_NODE = 9;
// noinspection JSUnusedGlobalSymbols
this.DOM_DOCUMENT_TYPE_NODE = 10;
this.DOM_DOCUMENT_FRAGMENT_NODE = 11;
// noinspection JSUnusedGlobalSymbols
this.DOM_NOTATION_NODE = 12;
this.REGEXP_UNICODE = function () {
var tests = [' ', '\u0120', -1, // Konquerer 3.4.0 fails here.
'!', '\u0120', -1,
'\u0120', '\u0120', 0,
'\u0121', '\u0120', -1,
'\u0121', '\u0120|\u0121', 0,
'\u0122', '\u0120|\u0121', -1,
'\u0120', '[\u0120]', 0, // Safari 2.0.3 fails here.
'\u0121', '[\u0120]', -1,
'\u0121', '[\u0120\u0121]', 0, // Safari 2.0.3 fails here.
'\u0122', '[\u0120\u0121]', -1,
'\u0121', '[\u0120-\u0121]', 0, // Safari 2.0.3 fails here.
'\u0122', '[\u0120-\u0121]', -1];
for (var i = 0; i < tests.length; i += 3) {
if (tests[i].search(new RegExp(tests[i + 1])) !== tests[i + 2]) {
return false;
}
}
return true;
}();
this.XML_S = '[ \t\r\n]+';
this.XML_EQ = '(' + this.XML_S + ')?=(' + this.XML_S + ')?';
this.XML_CHAR_REF = '&#[0-9]+;|&#x[0-9a-fA-F]+;';
// XML 1.0 tokens.
this.XML10_VERSION_INFO = this.XML_S + 'version' + this.XML_EQ + '("1\\.0"|' + "'1\\.0')";
this.XML10_BASE_CHAR = (this.REGEXP_UNICODE) ?
'\u0041-\u005a\u0061-\u007a\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff' +
'\u0100-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3' +
'\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386' +
'\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc' +
'\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c' +
'\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb' +
'\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea' +
'\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be' +
'\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d' +
'\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2' +
'\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a' +
'\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36' +
'\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d' +
'\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9' +
'\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30' +
'\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a' +
'\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4' +
'\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10' +
'\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c' +
'\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1' +
'\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61' +
'\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84' +
'\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5' +
'\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4' +
'\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103' +
'\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c' +
'\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169' +
'\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af' +
'\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b' +
'\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d' +
'\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc' +
'\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec' +
'\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182' +
'\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\uac00-\ud7a3' :
'A-Za-z';
this.XML10_IDEOGRAPHIC = (this.REGEXP_UNICODE) ?
'\u4e00-\u9fa5\u3007\u3021-\u3029' :
'';
this.XML10_COMBINING_CHAR = (this.REGEXP_UNICODE) ?
'\u0300-\u0345\u0360-\u0361\u0483-\u0486\u0591-\u05a1\u05a3-\u05b9' +
'\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u064b-\u0652\u0670\u06d6-\u06dc' +
'\u06dd-\u06df\u06e0-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0901-\u0903\u093c' +
'\u093e-\u094c\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be' +
'\u09bf\u09c0-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a02' +
'\u0a3c\u0a3e\u0a3f\u0a40-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71' +
'\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0b01-\u0b03' +
'\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82-\u0b83' +
'\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44' +
'\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbe-\u0cc4' +
'\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43' +
'\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1' +
'\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39' +
'\u0f3e\u0f3f\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad' +
'\u0fb1-\u0fb7\u0fb9\u20d0-\u20dc\u20e1\u302a-\u302f\u3099\u309a' :
'';
this.XML10_DIGIT = (this.REGEXP_UNICODE) ?
'\u0030-\u0039\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef' +
'\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be7-\u0bef\u0c66-\u0c6f' +
'\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29' :
'0-9';
this.XML10_EXTENDER = (this.REGEXP_UNICODE) ?
'\u00b7\u02d0\u02d1\u0387\u0640\u0e46\u0ec6\u3005\u3031-\u3035' +
'\u309d-\u309e\u30fc-\u30fe' :
'';
this.XML10_LETTER = this.XML10_BASE_CHAR + this.XML10_IDEOGRAPHIC;
this.XML10_NAME_CHAR = this.XML10_LETTER + this.XML10_DIGIT + '\\._:' +
this.XML10_COMBINING_CHAR + this.XML10_EXTENDER + '-';
this.XML10_NAME = '[' + this.XML10_LETTER + '_:][' + this.XML10_NAME_CHAR + ']*';
this.XML10_ENTITY_REF = '&' + this.XML10_NAME + ';';
this.XML10_REFERENCE = this.XML10_ENTITY_REF + '|' + this.XML_CHAR_REF;
this.XML10_ATT_VALUE = '"(([^<&"]|' + this.XML10_REFERENCE + ')*)"|' +
"'(([^<&']|" + this.XML10_REFERENCE + ")*)'";
this.XML10_ATTRIBUTE =
'(' + this.XML10_NAME + ')' + this.XML_EQ + '(' + this.XML10_ATT_VALUE + ')';
// XML 1.1 tokens.
this.XML11_VERSION_INFO = this.XML_S + 'version' + this.XML_EQ + '("1\\.1"|' + "'1\\.1')";
this.XML11_NAME_START_CHAR = (this.REGEXP_UNICODE) ?
':A-Z_a-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02ff\u0370-\u037d' +
'\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff' +
'\uf900-\ufdcf\ufdf0-\ufffd' :
':A-Z_a-z';
this.XML11_NAME_CHAR = this.XML11_NAME_START_CHAR +
((this.REGEXP_UNICODE) ? '\\.0-9\u00b7\u0300-\u036f\u203f-\u2040-' : '\\.0-9-');
this.XML11_NAME = '[' + this.XML11_NAME_START_CHAR + '][' + this.XML11_NAME_CHAR + ']*';
this.XML11_ENTITY_REF = '&' + this.XML11_NAME + ';';
this.XML11_REFERENCE = this.XML11_ENTITY_REF + '|' + this.XML_CHAR_REF;
this.XML11_ATT_VALUE = '"(([^<&"]|' + this.XML11_REFERENCE + ')*)"|' +
"'(([^<&']|" + this.XML11_REFERENCE + ")*)'";
this.XML11_ATTRIBUTE =
'(' + this.XML11_NAME + ')' + this.XML_EQ + '(' + this.XML11_ATT_VALUE + ')';
// XML namespace tokens.
// Used in XML parser and XPath parser.
this.XML_NC_NAME_CHAR = this.XML10_LETTER + this.XML10_DIGIT + '\\._' +
this.XML10_COMBINING_CHAR + this.XML10_EXTENDER + '-';
this.XML_NC_NAME = '[' + this.XML10_LETTER + '_][' + this.XML_NC_NAME_CHAR + ']*';
this.XML10_TAGNAME_REGEXP = new RegExp('^(' + this.XML10_NAME + ')');
this.XML10_ATTRIBUTE_REGEXP = new RegExp(this.XML10_ATTRIBUTE, 'g');
this.XML11_TAGNAME_REGEXP = new RegExp('^(' + this.XML11_NAME + ')');
this.XML11_ATTRIBUTE_REGEXP = new RegExp(this.XML11_ATTRIBUTE, 'g');
} | 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;
this.DOM_PROCESSING_INSTRUCTION_NODE = 7;
this.DOM_COMMENT_NODE = 8;
this.DOM_DOCUMENT_NODE = 9;
// noinspection JSUnusedGlobalSymbols
this.DOM_DOCUMENT_TYPE_NODE = 10;
this.DOM_DOCUMENT_FRAGMENT_NODE = 11;
// noinspection JSUnusedGlobalSymbols
this.DOM_NOTATION_NODE = 12;
this.REGEXP_UNICODE = function () {
var tests = [' ', '\u0120', -1, // Konquerer 3.4.0 fails here.
'!', '\u0120', -1,
'\u0120', '\u0120', 0,
'\u0121', '\u0120', -1,
'\u0121', '\u0120|\u0121', 0,
'\u0122', '\u0120|\u0121', -1,
'\u0120', '[\u0120]', 0, // Safari 2.0.3 fails here.
'\u0121', '[\u0120]', -1,
'\u0121', '[\u0120\u0121]', 0, // Safari 2.0.3 fails here.
'\u0122', '[\u0120\u0121]', -1,
'\u0121', '[\u0120-\u0121]', 0, // Safari 2.0.3 fails here.
'\u0122', '[\u0120-\u0121]', -1];
for (var i = 0; i < tests.length; i += 3) {
if (tests[i].search(new RegExp(tests[i + 1])) !== tests[i + 2]) {
return false;
}
}
return true;
}();
this.XML_S = '[ \t\r\n]+';
this.XML_EQ = '(' + this.XML_S + ')?=(' + this.XML_S + ')?';
this.XML_CHAR_REF = '&#[0-9]+;|&#x[0-9a-fA-F]+;';
// XML 1.0 tokens.
this.XML10_VERSION_INFO = this.XML_S + 'version' + this.XML_EQ + '("1\\.0"|' + "'1\\.0')";
this.XML10_BASE_CHAR = (this.REGEXP_UNICODE) ?
'\u0041-\u005a\u0061-\u007a\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff' +
'\u0100-\u0131\u0134-\u013e\u0141-\u0148\u014a-\u017e\u0180-\u01c3' +
'\u01cd-\u01f0\u01f4-\u01f5\u01fa-\u0217\u0250-\u02a8\u02bb-\u02c1\u0386' +
'\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d6\u03da\u03dc' +
'\u03de\u03e0\u03e2-\u03f3\u0401-\u040c\u040e-\u044f\u0451-\u045c' +
'\u045e-\u0481\u0490-\u04c4\u04c7-\u04c8\u04cb-\u04cc\u04d0-\u04eb' +
'\u04ee-\u04f5\u04f8-\u04f9\u0531-\u0556\u0559\u0561-\u0586\u05d0-\u05ea' +
'\u05f0-\u05f2\u0621-\u063a\u0641-\u064a\u0671-\u06b7\u06ba-\u06be' +
'\u06c0-\u06ce\u06d0-\u06d3\u06d5\u06e5-\u06e6\u0905-\u0939\u093d' +
'\u0958-\u0961\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2' +
'\u09b6-\u09b9\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a' +
'\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36' +
'\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d' +
'\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9' +
'\u0abd\u0ae0\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30' +
'\u0b32-\u0b33\u0b36-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a' +
'\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4' +
'\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10' +
'\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c' +
'\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0-\u0ce1' +
'\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61' +
'\u0e01-\u0e2e\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0e82\u0e84' +
'\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5' +
'\u0ea7\u0eaa-\u0eab\u0ead-\u0eae\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4' +
'\u0f40-\u0f47\u0f49-\u0f69\u10a0-\u10c5\u10d0-\u10f6\u1100\u1102-\u1103' +
'\u1105-\u1107\u1109\u110b-\u110c\u110e-\u1112\u113c\u113e\u1140\u114c' +
'\u114e\u1150\u1154-\u1155\u1159\u115f-\u1161\u1163\u1165\u1167\u1169' +
'\u116d-\u116e\u1172-\u1173\u1175\u119e\u11a8\u11ab\u11ae-\u11af' +
'\u11b7-\u11b8\u11ba\u11bc-\u11c2\u11eb\u11f0\u11f9\u1e00-\u1e9b' +
'\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d' +
'\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc' +
'\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec' +
'\u1ff2-\u1ff4\u1ff6-\u1ffc\u2126\u212a-\u212b\u212e\u2180-\u2182' +
'\u3041-\u3094\u30a1-\u30fa\u3105-\u312c\uac00-\ud7a3' :
'A-Za-z';
this.XML10_IDEOGRAPHIC = (this.REGEXP_UNICODE) ?
'\u4e00-\u9fa5\u3007\u3021-\u3029' :
'';
this.XML10_COMBINING_CHAR = (this.REGEXP_UNICODE) ?
'\u0300-\u0345\u0360-\u0361\u0483-\u0486\u0591-\u05a1\u05a3-\u05b9' +
'\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4\u064b-\u0652\u0670\u06d6-\u06dc' +
'\u06dd-\u06df\u06e0-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0901-\u0903\u093c' +
'\u093e-\u094c\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be' +
'\u09bf\u09c0-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a02' +
'\u0a3c\u0a3e\u0a3f\u0a40-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71' +
'\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0b01-\u0b03' +
'\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82-\u0b83' +
'\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44' +
'\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbe-\u0cc4' +
'\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43' +
'\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1' +
'\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39' +
'\u0f3e\u0f3f\u0f71-\u0f84\u0f86-\u0f8b\u0f90-\u0f95\u0f97\u0f99-\u0fad' +
'\u0fb1-\u0fb7\u0fb9\u20d0-\u20dc\u20e1\u302a-\u302f\u3099\u309a' :
'';
this.XML10_DIGIT = (this.REGEXP_UNICODE) ?
'\u0030-\u0039\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef' +
'\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be7-\u0bef\u0c66-\u0c6f' +
'\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29' :
'0-9';
this.XML10_EXTENDER = (this.REGEXP_UNICODE) ?
'\u00b7\u02d0\u02d1\u0387\u0640\u0e46\u0ec6\u3005\u3031-\u3035' +
'\u309d-\u309e\u30fc-\u30fe' :
'';
this.XML10_LETTER = this.XML10_BASE_CHAR + this.XML10_IDEOGRAPHIC;
this.XML10_NAME_CHAR = this.XML10_LETTER + this.XML10_DIGIT + '\\._:' +
this.XML10_COMBINING_CHAR + this.XML10_EXTENDER + '-';
this.XML10_NAME = '[' + this.XML10_LETTER + '_:][' + this.XML10_NAME_CHAR + ']*';
this.XML10_ENTITY_REF = '&' + this.XML10_NAME + ';';
this.XML10_REFERENCE = this.XML10_ENTITY_REF + '|' + this.XML_CHAR_REF;
this.XML10_ATT_VALUE = '"(([^<&"]|' + this.XML10_REFERENCE + ')*)"|' +
"'(([^<&']|" + this.XML10_REFERENCE + ")*)'";
this.XML10_ATTRIBUTE =
'(' + this.XML10_NAME + ')' + this.XML_EQ + '(' + this.XML10_ATT_VALUE + ')';
// XML 1.1 tokens.
this.XML11_VERSION_INFO = this.XML_S + 'version' + this.XML_EQ + '("1\\.1"|' + "'1\\.1')";
this.XML11_NAME_START_CHAR = (this.REGEXP_UNICODE) ?
':A-Z_a-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02ff\u0370-\u037d' +
'\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff' +
'\uf900-\ufdcf\ufdf0-\ufffd' :
':A-Z_a-z';
this.XML11_NAME_CHAR = this.XML11_NAME_START_CHAR +
((this.REGEXP_UNICODE) ? '\\.0-9\u00b7\u0300-\u036f\u203f-\u2040-' : '\\.0-9-');
this.XML11_NAME = '[' + this.XML11_NAME_START_CHAR + '][' + this.XML11_NAME_CHAR + ']*';
this.XML11_ENTITY_REF = '&' + this.XML11_NAME + ';';
this.XML11_REFERENCE = this.XML11_ENTITY_REF + '|' + this.XML_CHAR_REF;
this.XML11_ATT_VALUE = '"(([^<&"]|' + this.XML11_REFERENCE + ')*)"|' +
"'(([^<&']|" + this.XML11_REFERENCE + ")*)'";
this.XML11_ATTRIBUTE =
'(' + this.XML11_NAME + ')' + this.XML_EQ + '(' + this.XML11_ATT_VALUE + ')';
// XML namespace tokens.
// Used in XML parser and XPath parser.
this.XML_NC_NAME_CHAR = this.XML10_LETTER + this.XML10_DIGIT + '\\._' +
this.XML10_COMBINING_CHAR + this.XML10_EXTENDER + '-';
this.XML_NC_NAME = '[' + this.XML10_LETTER + '_][' + this.XML_NC_NAME_CHAR + ']*';
this.XML10_TAGNAME_REGEXP = new RegExp('^(' + this.XML10_NAME + ')');
this.XML10_ATTRIBUTE_REGEXP = new RegExp(this.XML10_ATTRIBUTE, 'g');
this.XML11_TAGNAME_REGEXP = new RegExp('^(' + this.XML11_NAME + ')');
this.XML11_ATTRIBUTE_REGEXP = new RegExp(this.XML11_ATTRIBUTE, 'g');
} | [
"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",
";",
"this",
".",
"DOM_PROCESSING_INSTRUCTION_NODE",
"=",
"7",
";",
"this",
".",
"DOM_COMMENT_NODE",
"=",
"8",
";",
"this",
".",
"DOM_DOCUMENT_NODE",
"=",
"9",
";",
"// noinspection JSUnusedGlobalSymbols",
"this",
".",
"DOM_DOCUMENT_TYPE_NODE",
"=",
"10",
";",
"this",
".",
"DOM_DOCUMENT_FRAGMENT_NODE",
"=",
"11",
";",
"// noinspection JSUnusedGlobalSymbols",
"this",
".",
"DOM_NOTATION_NODE",
"=",
"12",
";",
"this",
".",
"REGEXP_UNICODE",
"=",
"function",
"(",
")",
"{",
"var",
"tests",
"=",
"[",
"' '",
",",
"'\\u0120'",
",",
"-",
"1",
",",
"// Konquerer 3.4.0 fails here.",
"'!'",
",",
"'\\u0120'",
",",
"-",
"1",
",",
"'\\u0120'",
",",
"'\\u0120'",
",",
"0",
",",
"'\\u0121'",
",",
"'\\u0120'",
",",
"-",
"1",
",",
"'\\u0121'",
",",
"'\\u0120|\\u0121'",
",",
"0",
",",
"'\\u0122'",
",",
"'\\u0120|\\u0121'",
",",
"-",
"1",
",",
"'\\u0120'",
",",
"'[\\u0120]'",
",",
"0",
",",
"// Safari 2.0.3 fails here.",
"'\\u0121'",
",",
"'[\\u0120]'",
",",
"-",
"1",
",",
"'\\u0121'",
",",
"'[\\u0120\\u0121]'",
",",
"0",
",",
"// Safari 2.0.3 fails here.",
"'\\u0122'",
",",
"'[\\u0120\\u0121]'",
",",
"-",
"1",
",",
"'\\u0121'",
",",
"'[\\u0120-\\u0121]'",
",",
"0",
",",
"// Safari 2.0.3 fails here.",
"'\\u0122'",
",",
"'[\\u0120-\\u0121]'",
",",
"-",
"1",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"tests",
".",
"length",
";",
"i",
"+=",
"3",
")",
"{",
"if",
"(",
"tests",
"[",
"i",
"]",
".",
"search",
"(",
"new",
"RegExp",
"(",
"tests",
"[",
"i",
"+",
"1",
"]",
")",
")",
"!==",
"tests",
"[",
"i",
"+",
"2",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"(",
")",
";",
"this",
".",
"XML_S",
"=",
"'[ \\t\\r\\n]+'",
";",
"this",
".",
"XML_EQ",
"=",
"'('",
"+",
"this",
".",
"XML_S",
"+",
"')?=('",
"+",
"this",
".",
"XML_S",
"+",
"')?'",
";",
"this",
".",
"XML_CHAR_REF",
"=",
"'&#[0-9]+;|&#x[0-9a-fA-F]+;'",
";",
"// XML 1.0 tokens.",
"this",
".",
"XML10_VERSION_INFO",
"=",
"this",
".",
"XML_S",
"+",
"'version'",
"+",
"this",
".",
"XML_EQ",
"+",
"'(\"1\\\\.0\"|'",
"+",
"\"'1\\\\.0')\"",
";",
"this",
".",
"XML10_BASE_CHAR",
"=",
"(",
"this",
".",
"REGEXP_UNICODE",
")",
"?",
"'\\u0041-\\u005a\\u0061-\\u007a\\u00c0-\\u00d6\\u00d8-\\u00f6\\u00f8-\\u00ff'",
"+",
"'\\u0100-\\u0131\\u0134-\\u013e\\u0141-\\u0148\\u014a-\\u017e\\u0180-\\u01c3'",
"+",
"'\\u01cd-\\u01f0\\u01f4-\\u01f5\\u01fa-\\u0217\\u0250-\\u02a8\\u02bb-\\u02c1\\u0386'",
"+",
"'\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03ce\\u03d0-\\u03d6\\u03da\\u03dc'",
"+",
"'\\u03de\\u03e0\\u03e2-\\u03f3\\u0401-\\u040c\\u040e-\\u044f\\u0451-\\u045c'",
"+",
"'\\u045e-\\u0481\\u0490-\\u04c4\\u04c7-\\u04c8\\u04cb-\\u04cc\\u04d0-\\u04eb'",
"+",
"'\\u04ee-\\u04f5\\u04f8-\\u04f9\\u0531-\\u0556\\u0559\\u0561-\\u0586\\u05d0-\\u05ea'",
"+",
"'\\u05f0-\\u05f2\\u0621-\\u063a\\u0641-\\u064a\\u0671-\\u06b7\\u06ba-\\u06be'",
"+",
"'\\u06c0-\\u06ce\\u06d0-\\u06d3\\u06d5\\u06e5-\\u06e6\\u0905-\\u0939\\u093d'",
"+",
"'\\u0958-\\u0961\\u0985-\\u098c\\u098f-\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2'",
"+",
"'\\u09b6-\\u09b9\\u09dc-\\u09dd\\u09df-\\u09e1\\u09f0-\\u09f1\\u0a05-\\u0a0a'",
"+",
"'\\u0a0f-\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32-\\u0a33\\u0a35-\\u0a36'",
"+",
"'\\u0a38-\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8b\\u0a8d'",
"+",
"'\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2-\\u0ab3\\u0ab5-\\u0ab9'",
"+",
"'\\u0abd\\u0ae0\\u0b05-\\u0b0c\\u0b0f-\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30'",
"+",
"'\\u0b32-\\u0b33\\u0b36-\\u0b39\\u0b3d\\u0b5c-\\u0b5d\\u0b5f-\\u0b61\\u0b85-\\u0b8a'",
"+",
"'\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99-\\u0b9a\\u0b9c\\u0b9e-\\u0b9f\\u0ba3-\\u0ba4'",
"+",
"'\\u0ba8-\\u0baa\\u0bae-\\u0bb5\\u0bb7-\\u0bb9\\u0c05-\\u0c0c\\u0c0e-\\u0c10'",
"+",
"'\\u0c12-\\u0c28\\u0c2a-\\u0c33\\u0c35-\\u0c39\\u0c60-\\u0c61\\u0c85-\\u0c8c'",
"+",
"'\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cde\\u0ce0-\\u0ce1'",
"+",
"'\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d28\\u0d2a-\\u0d39\\u0d60-\\u0d61'",
"+",
"'\\u0e01-\\u0e2e\\u0e30\\u0e32-\\u0e33\\u0e40-\\u0e45\\u0e81-\\u0e82\\u0e84'",
"+",
"'\\u0e87-\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5'",
"+",
"'\\u0ea7\\u0eaa-\\u0eab\\u0ead-\\u0eae\\u0eb0\\u0eb2-\\u0eb3\\u0ebd\\u0ec0-\\u0ec4'",
"+",
"'\\u0f40-\\u0f47\\u0f49-\\u0f69\\u10a0-\\u10c5\\u10d0-\\u10f6\\u1100\\u1102-\\u1103'",
"+",
"'\\u1105-\\u1107\\u1109\\u110b-\\u110c\\u110e-\\u1112\\u113c\\u113e\\u1140\\u114c'",
"+",
"'\\u114e\\u1150\\u1154-\\u1155\\u1159\\u115f-\\u1161\\u1163\\u1165\\u1167\\u1169'",
"+",
"'\\u116d-\\u116e\\u1172-\\u1173\\u1175\\u119e\\u11a8\\u11ab\\u11ae-\\u11af'",
"+",
"'\\u11b7-\\u11b8\\u11ba\\u11bc-\\u11c2\\u11eb\\u11f0\\u11f9\\u1e00-\\u1e9b'",
"+",
"'\\u1ea0-\\u1ef9\\u1f00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d'",
"+",
"'\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc'",
"+",
"'\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec'",
"+",
"'\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2126\\u212a-\\u212b\\u212e\\u2180-\\u2182'",
"+",
"'\\u3041-\\u3094\\u30a1-\\u30fa\\u3105-\\u312c\\uac00-\\ud7a3'",
":",
"'A-Za-z'",
";",
"this",
".",
"XML10_IDEOGRAPHIC",
"=",
"(",
"this",
".",
"REGEXP_UNICODE",
")",
"?",
"'\\u4e00-\\u9fa5\\u3007\\u3021-\\u3029'",
":",
"''",
";",
"this",
".",
"XML10_COMBINING_CHAR",
"=",
"(",
"this",
".",
"REGEXP_UNICODE",
")",
"?",
"'\\u0300-\\u0345\\u0360-\\u0361\\u0483-\\u0486\\u0591-\\u05a1\\u05a3-\\u05b9'",
"+",
"'\\u05bb-\\u05bd\\u05bf\\u05c1-\\u05c2\\u05c4\\u064b-\\u0652\\u0670\\u06d6-\\u06dc'",
"+",
"'\\u06dd-\\u06df\\u06e0-\\u06e4\\u06e7-\\u06e8\\u06ea-\\u06ed\\u0901-\\u0903\\u093c'",
"+",
"'\\u093e-\\u094c\\u094d\\u0951-\\u0954\\u0962-\\u0963\\u0981-\\u0983\\u09bc\\u09be'",
"+",
"'\\u09bf\\u09c0-\\u09c4\\u09c7-\\u09c8\\u09cb-\\u09cd\\u09d7\\u09e2-\\u09e3\\u0a02'",
"+",
"'\\u0a3c\\u0a3e\\u0a3f\\u0a40-\\u0a42\\u0a47-\\u0a48\\u0a4b-\\u0a4d\\u0a70-\\u0a71'",
"+",
"'\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0b01-\\u0b03'",
"+",
"'\\u0b3c\\u0b3e-\\u0b43\\u0b47-\\u0b48\\u0b4b-\\u0b4d\\u0b56-\\u0b57\\u0b82-\\u0b83'",
"+",
"'\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0c01-\\u0c03\\u0c3e-\\u0c44'",
"+",
"'\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55-\\u0c56\\u0c82-\\u0c83\\u0cbe-\\u0cc4'",
"+",
"'\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5-\\u0cd6\\u0d02-\\u0d03\\u0d3e-\\u0d43'",
"+",
"'\\u0d46-\\u0d48\\u0d4a-\\u0d4d\\u0d57\\u0e31\\u0e34-\\u0e3a\\u0e47-\\u0e4e\\u0eb1'",
"+",
"'\\u0eb4-\\u0eb9\\u0ebb-\\u0ebc\\u0ec8-\\u0ecd\\u0f18-\\u0f19\\u0f35\\u0f37\\u0f39'",
"+",
"'\\u0f3e\\u0f3f\\u0f71-\\u0f84\\u0f86-\\u0f8b\\u0f90-\\u0f95\\u0f97\\u0f99-\\u0fad'",
"+",
"'\\u0fb1-\\u0fb7\\u0fb9\\u20d0-\\u20dc\\u20e1\\u302a-\\u302f\\u3099\\u309a'",
":",
"''",
";",
"this",
".",
"XML10_DIGIT",
"=",
"(",
"this",
".",
"REGEXP_UNICODE",
")",
"?",
"'\\u0030-\\u0039\\u0660-\\u0669\\u06f0-\\u06f9\\u0966-\\u096f\\u09e6-\\u09ef'",
"+",
"'\\u0a66-\\u0a6f\\u0ae6-\\u0aef\\u0b66-\\u0b6f\\u0be7-\\u0bef\\u0c66-\\u0c6f'",
"+",
"'\\u0ce6-\\u0cef\\u0d66-\\u0d6f\\u0e50-\\u0e59\\u0ed0-\\u0ed9\\u0f20-\\u0f29'",
":",
"'0-9'",
";",
"this",
".",
"XML10_EXTENDER",
"=",
"(",
"this",
".",
"REGEXP_UNICODE",
")",
"?",
"'\\u00b7\\u02d0\\u02d1\\u0387\\u0640\\u0e46\\u0ec6\\u3005\\u3031-\\u3035'",
"+",
"'\\u309d-\\u309e\\u30fc-\\u30fe'",
":",
"''",
";",
"this",
".",
"XML10_LETTER",
"=",
"this",
".",
"XML10_BASE_CHAR",
"+",
"this",
".",
"XML10_IDEOGRAPHIC",
";",
"this",
".",
"XML10_NAME_CHAR",
"=",
"this",
".",
"XML10_LETTER",
"+",
"this",
".",
"XML10_DIGIT",
"+",
"'\\\\._:'",
"+",
"this",
".",
"XML10_COMBINING_CHAR",
"+",
"this",
".",
"XML10_EXTENDER",
"+",
"'-'",
";",
"this",
".",
"XML10_NAME",
"=",
"'['",
"+",
"this",
".",
"XML10_LETTER",
"+",
"'_:]['",
"+",
"this",
".",
"XML10_NAME_CHAR",
"+",
"']*'",
";",
"this",
".",
"XML10_ENTITY_REF",
"=",
"'&'",
"+",
"this",
".",
"XML10_NAME",
"+",
"';'",
";",
"this",
".",
"XML10_REFERENCE",
"=",
"this",
".",
"XML10_ENTITY_REF",
"+",
"'|'",
"+",
"this",
".",
"XML_CHAR_REF",
";",
"this",
".",
"XML10_ATT_VALUE",
"=",
"'\"(([^<&\"]|'",
"+",
"this",
".",
"XML10_REFERENCE",
"+",
"')*)\"|'",
"+",
"\"'(([^<&']|\"",
"+",
"this",
".",
"XML10_REFERENCE",
"+",
"\")*)'\"",
";",
"this",
".",
"XML10_ATTRIBUTE",
"=",
"'('",
"+",
"this",
".",
"XML10_NAME",
"+",
"')'",
"+",
"this",
".",
"XML_EQ",
"+",
"'('",
"+",
"this",
".",
"XML10_ATT_VALUE",
"+",
"')'",
";",
"// XML 1.1 tokens.",
"this",
".",
"XML11_VERSION_INFO",
"=",
"this",
".",
"XML_S",
"+",
"'version'",
"+",
"this",
".",
"XML_EQ",
"+",
"'(\"1\\\\.1\"|'",
"+",
"\"'1\\\\.1')\"",
";",
"this",
".",
"XML11_NAME_START_CHAR",
"=",
"(",
"this",
".",
"REGEXP_UNICODE",
")",
"?",
"':A-Z_a-z\\u00c0-\\u00d6\\u00d8-\\u00f6\\u00f8-\\u02ff\\u0370-\\u037d'",
"+",
"'\\u037f-\\u1fff\\u200c-\\u200d\\u2070-\\u218f\\u2c00-\\u2fef\\u3001-\\ud7ff'",
"+",
"'\\uf900-\\ufdcf\\ufdf0-\\ufffd'",
":",
"':A-Z_a-z'",
";",
"this",
".",
"XML11_NAME_CHAR",
"=",
"this",
".",
"XML11_NAME_START_CHAR",
"+",
"(",
"(",
"this",
".",
"REGEXP_UNICODE",
")",
"?",
"'\\\\.0-9\\u00b7\\u0300-\\u036f\\u203f-\\u2040-'",
":",
"'\\\\.0-9-'",
")",
";",
"this",
".",
"XML11_NAME",
"=",
"'['",
"+",
"this",
".",
"XML11_NAME_START_CHAR",
"+",
"']['",
"+",
"this",
".",
"XML11_NAME_CHAR",
"+",
"']*'",
";",
"this",
".",
"XML11_ENTITY_REF",
"=",
"'&'",
"+",
"this",
".",
"XML11_NAME",
"+",
"';'",
";",
"this",
".",
"XML11_REFERENCE",
"=",
"this",
".",
"XML11_ENTITY_REF",
"+",
"'|'",
"+",
"this",
".",
"XML_CHAR_REF",
";",
"this",
".",
"XML11_ATT_VALUE",
"=",
"'\"(([^<&\"]|'",
"+",
"this",
".",
"XML11_REFERENCE",
"+",
"')*)\"|'",
"+",
"\"'(([^<&']|\"",
"+",
"this",
".",
"XML11_REFERENCE",
"+",
"\")*)'\"",
";",
"this",
".",
"XML11_ATTRIBUTE",
"=",
"'('",
"+",
"this",
".",
"XML11_NAME",
"+",
"')'",
"+",
"this",
".",
"XML_EQ",
"+",
"'('",
"+",
"this",
".",
"XML11_ATT_VALUE",
"+",
"')'",
";",
"// XML namespace tokens.",
"// Used in XML parser and XPath parser.",
"this",
".",
"XML_NC_NAME_CHAR",
"=",
"this",
".",
"XML10_LETTER",
"+",
"this",
".",
"XML10_DIGIT",
"+",
"'\\\\._'",
"+",
"this",
".",
"XML10_COMBINING_CHAR",
"+",
"this",
".",
"XML10_EXTENDER",
"+",
"'-'",
";",
"this",
".",
"XML_NC_NAME",
"=",
"'['",
"+",
"this",
".",
"XML10_LETTER",
"+",
"'_]['",
"+",
"this",
".",
"XML_NC_NAME_CHAR",
"+",
"']*'",
";",
"this",
".",
"XML10_TAGNAME_REGEXP",
"=",
"new",
"RegExp",
"(",
"'^('",
"+",
"this",
".",
"XML10_NAME",
"+",
"')'",
")",
";",
"this",
".",
"XML10_ATTRIBUTE_REGEXP",
"=",
"new",
"RegExp",
"(",
"this",
".",
"XML10_ATTRIBUTE",
",",
"'g'",
")",
";",
"this",
".",
"XML11_TAGNAME_REGEXP",
"=",
"new",
"RegExp",
"(",
"'^('",
"+",
"this",
".",
"XML11_NAME",
"+",
"')'",
")",
";",
"this",
".",
"XML11_ATTRIBUTE_REGEXP",
"=",
"new",
"RegExp",
"(",
"this",
".",
"XML11_ATTRIBUTE",
",",
"'g'",
")",
";",
"}"
] | 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 |
23,028 | 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'",
";",
"this",
".",
"contentEncoding",
"=",
"'utf8'",
";",
"}"
] | 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 |
23,029 | 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 page if the view will be fully rendered
* @type {String}
*/
this.layout = null;
/**
* Gets or sets the view data
* @type {String}
*/
this.data = null;
/**
* Represents the current HTTP context
* @type {HttpContext}
*/
this.context = context;
/**
* @name HttpViewContext#writer
* @type HtmlWriter
* @description Gets an instance of HtmlWriter helper class
*/
var writer;
Object.defineProperty(this, 'writer', {
get:function() {
if (writer)
return writer;
writer = new HtmlWriter();
writer.indent = false;
return writer;
}, configurable:false, enumerable:false
});
var self = this;
Object.defineProperty(this, 'model', {
get:function() {
if (self.context.params)
if (self.context.params.controller)
return self.context.model(self.context.params.controller);
return null;
}, configurable:false, enumerable:false
});
//class extension initiators
if (typeof this.init === 'function') {
//call init() method
this.init();
}
} | 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 page if the view will be fully rendered
* @type {String}
*/
this.layout = null;
/**
* Gets or sets the view data
* @type {String}
*/
this.data = null;
/**
* Represents the current HTTP context
* @type {HttpContext}
*/
this.context = context;
/**
* @name HttpViewContext#writer
* @type HtmlWriter
* @description Gets an instance of HtmlWriter helper class
*/
var writer;
Object.defineProperty(this, 'writer', {
get:function() {
if (writer)
return writer;
writer = new HtmlWriter();
writer.indent = false;
return writer;
}, configurable:false, enumerable:false
});
var self = this;
Object.defineProperty(this, 'model', {
get:function() {
if (self.context.params)
if (self.context.params.controller)
return self.context.model(self.context.params.controller);
return null;
}, configurable:false, enumerable:false
});
//class extension initiators
if (typeof this.init === 'function') {
//call init() method
this.init();
}
} | [
"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 */",
"this",
".",
"title",
"=",
"''",
";",
"/**\n * Gets or sets the view layout page if the view will be fully rendered\n * @type {String}\n */",
"this",
".",
"layout",
"=",
"null",
";",
"/**\n * Gets or sets the view data\n * @type {String}\n */",
"this",
".",
"data",
"=",
"null",
";",
"/**\n * Represents the current HTTP context\n * @type {HttpContext}\n */",
"this",
".",
"context",
"=",
"context",
";",
"/**\n * @name HttpViewContext#writer\n * @type HtmlWriter\n * @description Gets an instance of HtmlWriter helper class\n */",
"var",
"writer",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'writer'",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"if",
"(",
"writer",
")",
"return",
"writer",
";",
"writer",
"=",
"new",
"HtmlWriter",
"(",
")",
";",
"writer",
".",
"indent",
"=",
"false",
";",
"return",
"writer",
";",
"}",
",",
"configurable",
":",
"false",
",",
"enumerable",
":",
"false",
"}",
")",
";",
"var",
"self",
"=",
"this",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'model'",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"if",
"(",
"self",
".",
"context",
".",
"params",
")",
"if",
"(",
"self",
".",
"context",
".",
"params",
".",
"controller",
")",
"return",
"self",
".",
"context",
".",
"model",
"(",
"self",
".",
"context",
".",
"params",
".",
"controller",
")",
";",
"return",
"null",
";",
"}",
",",
"configurable",
":",
"false",
",",
"enumerable",
":",
"false",
"}",
")",
";",
"//class extension initiators",
"if",
"(",
"typeof",
"this",
".",
"init",
"===",
"'function'",
")",
"{",
"//call init() method",
"this",
".",
"init",
"(",
")",
";",
"}",
"}"
] | 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 |
23,030 | 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 |
23,031 | 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]);
}
return res;
} | 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]);
}
return res;
} | [
"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",
"]",
")",
";",
"}",
"return",
"res",
";",
"}"
] | 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 |
23,032 | 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",
"-",
"1",
")",
"==",
"'\\x03'",
")",
"text",
"=",
"text",
".",
"substr",
"(",
"0",
",",
"text",
".",
"length",
"-",
"1",
")",
";",
"return",
"text",
";",
"}"
] | 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 |
23,033 | 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.previousPostConversion(result);
return result;
} | 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.previousPostConversion(result);
return result;
} | [
"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",
".",
"previousPostConversion",
"(",
"result",
")",
";",
"return",
"result",
";",
"}"
] | 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 |
23,034 | 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",
",",
"model",
")",
";",
"this",
".",
"statusCode",
"=",
"401",
";",
"}"
] | 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 |
23,035 | 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",
",",
"model",
")",
";",
"}"
] | 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 |
23,036 | 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];
if (p)
return this[p];
}
} | 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];
if (p)
return this[p];
}
} | [
"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",
"]",
";",
"if",
"(",
"p",
")",
"return",
"this",
"[",
"p",
"]",
";",
"}",
"}"
] | 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 |
23,037 | 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 {Array}\n */",
"this",
".",
"args",
"=",
"[",
"]",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"args",
")",
")",
"this",
".",
"args",
"=",
"args",
";",
"}"
] | 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 |
23,038 | 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]*)$";
},
boolean:function() {
return "^true|false$"
},
decimal:function() {
return "^[+-]?[0-9]*\\.?[0-9]*$";
},
float:function() {
return "^[+-]?[0-9]*\\.?[0-9]*$";
},
guid:function() {
return "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$";
},
plural: function() {
return "^[a-zA-Z]+$";
},
string: function() {
return "^'(.*)'$"
},
date:function() {
return "^(datetime)?'\\d{4}-([0]\\d|1[0-2])-([0-2]\\d|3[01])(?:[T ](\\d+):(\\d+)(?::(\\d+)(?:\\.(\\d+))?)?)?(?:Z(-?\\d*))?([+-](\\d+):(\\d+))?'$";
},
};
this.parsers = {
int:function(v) {
return parseInt(v);
},
boolean:function(v) {
return (/^true$/ig.test(v));
},
decimal:function(v) {
return parseFloat(v);
},
float:function(v) {
return parseFloat(v);
},
plural:function(v) {
return pluralize.singular(v);
},
string:function(v) {
return v.replace(/^'/,'').replace(/'$/,'');
},
date:function(v) {
return new Date(Date.parse(v.replace(/^(datetime)?'/,'').replace(/'$/,'')));
}
}
} | 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]*)$";
},
boolean:function() {
return "^true|false$"
},
decimal:function() {
return "^[+-]?[0-9]*\\.?[0-9]*$";
},
float:function() {
return "^[+-]?[0-9]*\\.?[0-9]*$";
},
guid:function() {
return "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$";
},
plural: function() {
return "^[a-zA-Z]+$";
},
string: function() {
return "^'(.*)'$"
},
date:function() {
return "^(datetime)?'\\d{4}-([0]\\d|1[0-2])-([0-2]\\d|3[01])(?:[T ](\\d+):(\\d+)(?::(\\d+)(?:\\.(\\d+))?)?)?(?:Z(-?\\d*))?([+-](\\d+):(\\d+))?'$";
},
};
this.parsers = {
int:function(v) {
return parseInt(v);
},
boolean:function(v) {
return (/^true$/ig.test(v));
},
decimal:function(v) {
return parseFloat(v);
},
float:function(v) {
return parseFloat(v);
},
plural:function(v) {
return pluralize.singular(v);
},
string:function(v) {
return v.replace(/^'/,'').replace(/'$/,'');
},
date:function(v) {
return new Date(Date.parse(v.replace(/^(datetime)?'/,'').replace(/'$/,'')));
}
}
} | [
"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]*)$\"",
";",
"}",
",",
"boolean",
":",
"function",
"(",
")",
"{",
"return",
"\"^true|false$\"",
"}",
",",
"decimal",
":",
"function",
"(",
")",
"{",
"return",
"\"^[+-]?[0-9]*\\\\.?[0-9]*$\"",
";",
"}",
",",
"float",
":",
"function",
"(",
")",
"{",
"return",
"\"^[+-]?[0-9]*\\\\.?[0-9]*$\"",
";",
"}",
",",
"guid",
":",
"function",
"(",
")",
"{",
"return",
"\"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$\"",
";",
"}",
",",
"plural",
":",
"function",
"(",
")",
"{",
"return",
"\"^[a-zA-Z]+$\"",
";",
"}",
",",
"string",
":",
"function",
"(",
")",
"{",
"return",
"\"^'(.*)'$\"",
"}",
",",
"date",
":",
"function",
"(",
")",
"{",
"return",
"\"^(datetime)?'\\\\d{4}-([0]\\\\d|1[0-2])-([0-2]\\\\d|3[01])(?:[T ](\\\\d+):(\\\\d+)(?::(\\\\d+)(?:\\\\.(\\\\d+))?)?)?(?:Z(-?\\\\d*))?([+-](\\\\d+):(\\\\d+))?'$\"",
";",
"}",
",",
"}",
";",
"this",
".",
"parsers",
"=",
"{",
"int",
":",
"function",
"(",
"v",
")",
"{",
"return",
"parseInt",
"(",
"v",
")",
";",
"}",
",",
"boolean",
":",
"function",
"(",
"v",
")",
"{",
"return",
"(",
"/",
"^true$",
"/",
"ig",
".",
"test",
"(",
"v",
")",
")",
";",
"}",
",",
"decimal",
":",
"function",
"(",
"v",
")",
"{",
"return",
"parseFloat",
"(",
"v",
")",
";",
"}",
",",
"float",
":",
"function",
"(",
"v",
")",
"{",
"return",
"parseFloat",
"(",
"v",
")",
";",
"}",
",",
"plural",
":",
"function",
"(",
"v",
")",
"{",
"return",
"pluralize",
".",
"singular",
"(",
"v",
")",
";",
"}",
",",
"string",
":",
"function",
"(",
"v",
")",
"{",
"return",
"v",
".",
"replace",
"(",
"/",
"^'",
"/",
",",
"''",
")",
".",
"replace",
"(",
"/",
"'$",
"/",
",",
"''",
")",
";",
"}",
",",
"date",
":",
"function",
"(",
"v",
")",
"{",
"return",
"new",
"Date",
"(",
"Date",
".",
"parse",
"(",
"v",
".",
"replace",
"(",
"/",
"^(datetime)?'",
"/",
",",
"''",
")",
".",
"replace",
"(",
"/",
"'$",
"/",
",",
"''",
")",
")",
")",
";",
"}",
"}",
"}"
] | 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 |
23,039 | 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 j = 0; j < sort.length; ++j) {
var s = sort[j];
var value = s.expr.evaluate(context);
var evalue;
if (s.type === 'text') {
evalue = value.stringValue();
} else if (s.type === 'number') {
evalue = value.numberValue();
}
sortitem.key.push({value: evalue, order: s.order});
}
// Make the sort stable by adding a lowest priority sort by
// id. This is very convenient and furthermore required by the
// spec ([XSLT] - Section 10 Sorting).
sortitem.key.push({value: i, order: 'ascending'});
sortlist.push(sortitem);
}
sortlist.sort(xpathSortByKey);
var nodes = [];
for (i = 0; i < sortlist.length; ++i) {
nodes.push(sortlist[i].node);
}
input.nodelist = nodes;
input.setNode(0);
} | 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 j = 0; j < sort.length; ++j) {
var s = sort[j];
var value = s.expr.evaluate(context);
var evalue;
if (s.type === 'text') {
evalue = value.stringValue();
} else if (s.type === 'number') {
evalue = value.numberValue();
}
sortitem.key.push({value: evalue, order: s.order});
}
// Make the sort stable by adding a lowest priority sort by
// id. This is very convenient and furthermore required by the
// spec ([XSLT] - Section 10 Sorting).
sortitem.key.push({value: i, order: 'ascending'});
sortlist.push(sortitem);
}
sortlist.sort(xpathSortByKey);
var nodes = [];
for (i = 0; i < sortlist.length; ++i) {
nodes.push(sortlist[i].node);
}
input.nodelist = nodes;
input.setNode(0);
} | [
"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",
"j",
"=",
"0",
";",
"j",
"<",
"sort",
".",
"length",
";",
"++",
"j",
")",
"{",
"var",
"s",
"=",
"sort",
"[",
"j",
"]",
";",
"var",
"value",
"=",
"s",
".",
"expr",
".",
"evaluate",
"(",
"context",
")",
";",
"var",
"evalue",
";",
"if",
"(",
"s",
".",
"type",
"===",
"'text'",
")",
"{",
"evalue",
"=",
"value",
".",
"stringValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"s",
".",
"type",
"===",
"'number'",
")",
"{",
"evalue",
"=",
"value",
".",
"numberValue",
"(",
")",
";",
"}",
"sortitem",
".",
"key",
".",
"push",
"(",
"{",
"value",
":",
"evalue",
",",
"order",
":",
"s",
".",
"order",
"}",
")",
";",
"}",
"// Make the sort stable by adding a lowest priority sort by",
"// id. This is very convenient and furthermore required by the",
"// spec ([XSLT] - Section 10 Sorting).",
"sortitem",
".",
"key",
".",
"push",
"(",
"{",
"value",
":",
"i",
",",
"order",
":",
"'ascending'",
"}",
")",
";",
"sortlist",
".",
"push",
"(",
"sortitem",
")",
";",
"}",
"sortlist",
".",
"sort",
"(",
"xpathSortByKey",
")",
";",
"var",
"nodes",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"sortlist",
".",
"length",
";",
"++",
"i",
")",
"{",
"nodes",
".",
"push",
"(",
"sortlist",
"[",
"i",
"]",
".",
"node",
")",
";",
"}",
"input",
".",
"nodelist",
"=",
"nodes",
";",
"input",
".",
"setNode",
"(",
"0",
")",
";",
"}"
] | 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 |
23,040 | 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",
"(",
"select",
",",
"ns",
")",
";",
"}",
"//parse statement",
"var",
"expr",
"=",
"xpathParse",
"(",
"str",
")",
";",
"//and return value",
"return",
"expr",
".",
"evaluate",
"(",
"context",
")",
";",
"}"
] | 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 |
23,041 | 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.constraints = [];
/**
* Gets an array that contains a collection of indexes which are going to be added or updated
* @type {Array}
*/
this.indexes = [];
/**
* Gets an array that contains the definition of fields that are going to be deleted
* @type {Array}
*/
this.remove = [];
/**
* Gets an array that contains the definition of fields that are going to be changed
* @type {Array}
*/
this.change = [];
/**
* Gets or sets a string that contains the internal version of this migration. This property cannot be null.
* @type {string}
*/
this.version = '0.0';
/**
* Gets or sets a string that represents a short description of this migration
* @type {string}
*/
this.description = null;
/**
* Gets or sets a string that represents the adapter that is going to be migrated through this operation.
* This property cannot be null.
*/
this.appliesTo = null;
/**
* Gets or sets a string that represents the model that is going to be migrated through this operation.
* This property may be null.
*/
this.model = null;
} | 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.constraints = [];
/**
* Gets an array that contains a collection of indexes which are going to be added or updated
* @type {Array}
*/
this.indexes = [];
/**
* Gets an array that contains the definition of fields that are going to be deleted
* @type {Array}
*/
this.remove = [];
/**
* Gets an array that contains the definition of fields that are going to be changed
* @type {Array}
*/
this.change = [];
/**
* Gets or sets a string that contains the internal version of this migration. This property cannot be null.
* @type {string}
*/
this.version = '0.0';
/**
* Gets or sets a string that represents a short description of this migration
* @type {string}
*/
this.description = null;
/**
* Gets or sets a string that represents the adapter that is going to be migrated through this operation.
* This property cannot be null.
*/
this.appliesTo = null;
/**
* Gets or sets a string that represents the model that is going to be migrated through this operation.
* This property may be null.
*/
this.model = null;
} | [
"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 are going to be added\n * @type {Array}\n */",
"this",
".",
"constraints",
"=",
"[",
"]",
";",
"/**\n * Gets an array that contains a collection of indexes which are going to be added or updated\n * @type {Array}\n */",
"this",
".",
"indexes",
"=",
"[",
"]",
";",
"/**\n * Gets an array that contains the definition of fields that are going to be deleted\n * @type {Array}\n */",
"this",
".",
"remove",
"=",
"[",
"]",
";",
"/**\n * Gets an array that contains the definition of fields that are going to be changed\n * @type {Array}\n */",
"this",
".",
"change",
"=",
"[",
"]",
";",
"/**\n * Gets or sets a string that contains the internal version of this migration. This property cannot be null.\n * @type {string}\n */",
"this",
".",
"version",
"=",
"'0.0'",
";",
"/**\n * Gets or sets a string that represents a short description of this migration\n * @type {string}\n */",
"this",
".",
"description",
"=",
"null",
";",
"/**\n * Gets or sets a string that represents the adapter that is going to be migrated through this operation.\n * This property cannot be null.\n */",
"this",
".",
"appliesTo",
"=",
"null",
";",
"/**\n * Gets or sets a string that represents the model that is going to be migrated through this operation.\n * This property may be null.\n */",
"this",
".",
"model",
"=",
"null",
";",
"}"
] | 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 |
23,042 | 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",
"[",
"i",
"]",
"===",
"value",
"||",
"(",
"opt_notype",
"&&",
"array",
"[",
"i",
"]",
"===",
"value",
")",
")",
"{",
"array",
".",
"splice",
"(",
"i",
"--",
",",
"1",
")",
";",
"shift",
"++",
";",
"}",
"}",
"return",
"shift",
";",
"}"
] | 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 |
23,043 | 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'));
if (absoluteExpiration>=0) {
expiration = absoluteExpiration;
}
this[rawCacheProperty] = new NodeCache( {
stdTTL:expiration
});
} | 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'));
if (absoluteExpiration>=0) {
expiration = absoluteExpiration;
}
this[rawCacheProperty] = new NodeCache( {
stdTTL:expiration
});
} | [
"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'",
")",
")",
";",
"if",
"(",
"absoluteExpiration",
">=",
"0",
")",
"{",
"expiration",
"=",
"absoluteExpiration",
";",
"}",
"this",
"[",
"rawCacheProperty",
"]",
"=",
"new",
"NodeCache",
"(",
"{",
"stdTTL",
":",
"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 |
23,044 | 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",
"(",
"key",
")",
",",
"1",
")",
";",
"delete",
"_config",
"[",
"key",
"]",
";",
"}",
"}"
] | Removes a value from localStorage | [
"Removes",
"a",
"value",
"from",
"localStorage"
] | 30d7fdde3606744c3e8941d0b929ad6b68e5c26d | https://github.com/ozantunca/locally/blob/30d7fdde3606744c3e8941d0b929ad6b68e5c26d/dist/locally.js#L223-L230 |
23,045 | 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}
* A method to run if value is not NaN.
*/
function _ifValid(value, method) {
if (!isNaN(value)) {
method();
} else {
throw new TypeError('The VendNumber method must receive a valid String or Number. ' + value);
}
}
// Ensure there's an initial value to start operations on.
var returnValue = parseFloat(values[0]);
// Then remove the element at index 0.
values.splice(0, 1);
// Convert to VendNumber
_ifValid(returnValue, function () {
return returnValue = new VendNumber(returnValue);
});
values.forEach(function (value) {
value = parseFloat(value);
_ifValid(value, function () {
// Convert to VendNumber
value = new VendNumber(value);
// e.g. 5.plus(2) where 5 and 2 are VendNumber's
returnValue = returnValue[operation](value);
});
});
var operationAnswer = undefined;
// Set the final result of the calculation as a standard Number.
_ifValid(returnValue, function () {
return operationAnswer = Number(returnValue.toString());
});
if (operationAnswer) {
return operationAnswer;
}
// End value was not valid so value errors will be displayed but we return 0 to continue.
return 0;
} | 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}
* A method to run if value is not NaN.
*/
function _ifValid(value, method) {
if (!isNaN(value)) {
method();
} else {
throw new TypeError('The VendNumber method must receive a valid String or Number. ' + value);
}
}
// Ensure there's an initial value to start operations on.
var returnValue = parseFloat(values[0]);
// Then remove the element at index 0.
values.splice(0, 1);
// Convert to VendNumber
_ifValid(returnValue, function () {
return returnValue = new VendNumber(returnValue);
});
values.forEach(function (value) {
value = parseFloat(value);
_ifValid(value, function () {
// Convert to VendNumber
value = new VendNumber(value);
// e.g. 5.plus(2) where 5 and 2 are VendNumber's
returnValue = returnValue[operation](value);
});
});
var operationAnswer = undefined;
// Set the final result of the calculation as a standard Number.
_ifValid(returnValue, function () {
return operationAnswer = Number(returnValue.toString());
});
if (operationAnswer) {
return operationAnswer;
}
// End value was not valid so value errors will be displayed but we return 0 to continue.
return 0;
} | [
"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 method on.\n *\n * @param method {Function}\n * A method to run if value is not NaN.\n */",
"function",
"_ifValid",
"(",
"value",
",",
"method",
")",
"{",
"if",
"(",
"!",
"isNaN",
"(",
"value",
")",
")",
"{",
"method",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"TypeError",
"(",
"'The VendNumber method must receive a valid String or Number. '",
"+",
"value",
")",
";",
"}",
"}",
"// Ensure there's an initial value to start operations on.",
"var",
"returnValue",
"=",
"parseFloat",
"(",
"values",
"[",
"0",
"]",
")",
";",
"// Then remove the element at index 0.",
"values",
".",
"splice",
"(",
"0",
",",
"1",
")",
";",
"// Convert to VendNumber",
"_ifValid",
"(",
"returnValue",
",",
"function",
"(",
")",
"{",
"return",
"returnValue",
"=",
"new",
"VendNumber",
"(",
"returnValue",
")",
";",
"}",
")",
";",
"values",
".",
"forEach",
"(",
"function",
"(",
"value",
")",
"{",
"value",
"=",
"parseFloat",
"(",
"value",
")",
";",
"_ifValid",
"(",
"value",
",",
"function",
"(",
")",
"{",
"// Convert to VendNumber",
"value",
"=",
"new",
"VendNumber",
"(",
"value",
")",
";",
"// e.g. 5.plus(2) where 5 and 2 are VendNumber's",
"returnValue",
"=",
"returnValue",
"[",
"operation",
"]",
"(",
"value",
")",
";",
"}",
")",
";",
"}",
")",
";",
"var",
"operationAnswer",
"=",
"undefined",
";",
"// Set the final result of the calculation as a standard Number.",
"_ifValid",
"(",
"returnValue",
",",
"function",
"(",
")",
"{",
"return",
"operationAnswer",
"=",
"Number",
"(",
"returnValue",
".",
"toString",
"(",
")",
")",
";",
"}",
")",
";",
"if",
"(",
"operationAnswer",
")",
"{",
"return",
"operationAnswer",
";",
"}",
"// End value was not valid so value errors will be displayed but we return 0 to continue.",
"return",
"0",
";",
"}"
] | 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 |
23,046 | 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",
"(",
"'+'",
")",
"[",
"0",
"]",
";",
"parsed",
".",
"subaddress",
"=",
"user",
".",
"split",
"(",
"'+'",
")",
"[",
"1",
"]",
";",
"}",
"return",
"parsed",
";",
"}"
] | 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 |
23,047 | 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.lng - widthBuffer),
new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));
} | 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.lng - widthBuffer),
new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));
} | [
"function",
"(",
"bufferRatio",
")",
"{",
"// (Number) -> LatLngBounds\r",
"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",
".",
"lng",
"-",
"widthBuffer",
")",
",",
"new",
"L",
".",
"LatLng",
"(",
"ne",
".",
"lat",
"+",
"heightBuffer",
",",
"ne",
".",
"lng",
"+",
"widthBuffer",
")",
")",
";",
"}"
] | 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 | |
23,048 | 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",
"&&",
"iso3166",
".",
"is2",
"(",
"iso2",
")",
")",
"{",
"return",
"iso3166",
".",
"to3",
"(",
"iso2",
")",
";",
"}",
"return",
"null",
";",
"}"
] | 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 |
23,049 | 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
return wofData.properties[property];
}
return false;
} | 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
return wofData.properties[property];
}
return false;
} | [
"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",
"return",
"wofData",
".",
"properties",
"[",
"property",
"]",
";",
"}",
"return",
"false",
";",
"}"
] | 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 |
23,050 | 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 to wof:name if all else fails
return getLocalizedName(wofData, 'wof:lang_x_spoken') ||
getLocalizedName(wofData, 'wof:lang_x_official') ||
getLocalizedName(wofData, 'wof:lang') ||
getPropertyValue(wofData, 'wof:label') ||
getPropertyValue(wofData, 'wof:name');
} | 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 to wof:name if all else fails
return getLocalizedName(wofData, 'wof:lang_x_spoken') ||
getLocalizedName(wofData, 'wof:lang_x_official') ||
getLocalizedName(wofData, 'wof:lang') ||
getPropertyValue(wofData, 'wof:label') ||
getPropertyValue(wofData, 'wof:name');
} | [
"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 to wof:name if all else fails",
"return",
"getLocalizedName",
"(",
"wofData",
",",
"'wof:lang_x_spoken'",
")",
"||",
"getLocalizedName",
"(",
"wofData",
",",
"'wof:lang_x_official'",
")",
"||",
"getLocalizedName",
"(",
"wofData",
",",
"'wof:lang'",
")",
"||",
"getPropertyValue",
"(",
"wofData",
",",
"'wof:label'",
")",
"||",
"getPropertyValue",
"(",
"wofData",
",",
"'wof:name'",
")",
";",
"}"
] | 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 |
23,051 | 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`,
wofData.properties['wof:lang_x_official'], languages);
}
// for now always just grab the first language in the array
return `name:${languages[0]}_x_preferred`;
} | 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`,
wofData.properties['wof:lang_x_official'], languages);
}
// for now always just grab the first language in the array
return `name:${languages[0]}_x_preferred`;
} | [
"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",
"(",
"`",
"${",
"langProperty",
"}",
"`",
",",
"wofData",
".",
"properties",
"[",
"'wof:lang_x_official'",
"]",
",",
"languages",
")",
";",
"}",
"// for now always just grab the first language in the array",
"return",
"`",
"${",
"languages",
"[",
"0",
"]",
"}",
"`",
";",
"}"
] | 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 {string} langProperty
@returns {string} | [
"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 |
23,052 | 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",
"'lookupById'",
":",
"return",
"handleLookupById",
"(",
"msg",
")",
";",
"default",
":",
"logger",
".",
"error",
"(",
"'Unknown message:'",
",",
"msg",
")",
";",
"}",
"}"
] | 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 |
23,053 | 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",
")",
"?",
"{",
"}",
":",
"poly",
".",
"properties",
";",
"}"
] | Search `adminLookup` for `latLon`. | [
"Search",
"adminLookup",
"for",
"latLon",
"."
] | 2be8c4f4553e695e595a68e4e7e3b486fb402e51 | https://github.com/pelias/wof-pip-service/blob/2be8c4f4553e695e595a68e4e7e3b486fb402e51/src/worker.js#L78-L82 |
23,054 | 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",
"===",
"-",
"1",
")",
"return",
";",
"const",
"firstPart",
"=",
"steemitLink",
".",
"slice",
"(",
"usernamePos",
"+",
"2",
")",
";",
"// adding 2 to remove \"/@\"",
"return",
"firstPart",
".",
"slice",
"(",
"0",
",",
"firstPart",
".",
"search",
"(",
"'/'",
")",
")",
";",
"}",
"}"
] | 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 |
23,055 | 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('/') + 1).replace('/', '').replace('#', '');
}
} | 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('/') + 1).replace('/', '').replace('#', '');
}
} | [
"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",
"(",
"'/'",
")",
"+",
"1",
")",
".",
"replace",
"(",
"'/'",
",",
"''",
")",
".",
"replace",
"(",
"'#'",
",",
"''",
")",
";",
"}",
"}"
] | 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 |
23,056 | 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",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"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 |
23,057 | 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",
".",
"api",
"||",
"'gifs'",
",",
"endpoint",
":",
"'search'",
",",
"query",
":",
"typeof",
"options",
"===",
"'string'",
"?",
"{",
"q",
":",
"options",
"}",
":",
"options",
"}",
",",
"callback",
")",
";",
"}"
] | 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 results to those rated (y,g, pg, pg-13 or r).
options.fmt {String} - (optional) return results in html or json format (useful for viewing responses as GIFs to debug/test)
@param callback | [
"Search",
"all",
"Giphy",
"gifs",
"by",
"word",
"or",
"phrase"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L72-L84 | |
23,058 | 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.join();
}
return this._request({
api: 'gifs',
query: {
ids: id
}
}, callback);
} | 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.join();
}
return this._request({
api: 'gifs',
query: {
ids: id
}
}, callback);
} | [
"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",
".",
"join",
"(",
")",
";",
"}",
"return",
"this",
".",
"_request",
"(",
"{",
"api",
":",
"'gifs'",
",",
"query",
":",
"{",
"ids",
":",
"id",
"}",
"}",
",",
"callback",
")",
";",
"}"
] | 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 | |
23,059 | 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",
":",
"options",
".",
"api",
"||",
"'gifs'",
",",
"endpoint",
":",
"'translate'",
",",
"query",
":",
"typeof",
"options",
"===",
"'string'",
"?",
"{",
"s",
":",
"options",
"}",
":",
"options",
"}",
",",
"callback",
")",
";",
"}"
] | 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 viewing responses as GIFs to debug/test) | [
"Search",
"for",
"Giphy",
"gifs",
"by",
"phrase",
"with",
"Gify",
"vocabulary"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L121-L133 | |
23,060 | 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;
} else if (typeof options === 'function') {
callback = options;
}
return this._request(reqOptions, callback);
} | 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;
} else if (typeof options === 'function') {
callback = options;
}
return this._request(reqOptions, callback);
} | [
"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",
";",
"}",
"else",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"}",
"return",
"this",
".",
"_request",
"(",
"reqOptions",
",",
"callback",
")",
";",
"}"
] | 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 to debug/test) | [
"Fetch",
"random",
"gif",
"filtered",
"by",
"tag"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L143-L160 | |
23,061 | 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).length !== 0) {
reqOptions.query = options;
} else if (typeof options === 'function') {
callback = options;
}
return this._request(reqOptions, callback);
} | 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).length !== 0) {
reqOptions.query = options;
} else if (typeof options === 'function') {
callback = options;
}
return this._request(reqOptions, callback);
} | [
"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",
")",
".",
"length",
"!==",
"0",
")",
"{",
"reqOptions",
".",
"query",
"=",
"options",
";",
"}",
"else",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"}",
"return",
"this",
".",
"_request",
"(",
"reqOptions",
",",
"callback",
")",
";",
"}"
] | 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 (useful for viewing responses as GIFs to debug/test) | [
"Fetch",
"trending",
"gifs"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L170-L190 | |
23,062 | 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.query !== 'undefined' && typeof options.query === 'object') {
if (Object.keys(options.query).length === 0) {
if (callback) {
return callback(new Error('Options object should not be empty'));
}
return Promise.reject(new Error('Options object should not be empty'));
}
options.query.api_key = this.apiKey;
query = queryStringify(options.query);
} else {
query = queryStringify({
api_key: self.apiKey
});
}
var httpOptions = {
httpService: this.httpService,
request: {
host: API_HOSTNAME,
path: API_BASE_PATH + options.api + endpoint + query
},
timeout: this.timeout,
fmt: options.query && options.query.fmt,
https: this.https
};
var makeRequest = function (resolve, reject) {
httpService.get(httpOptions, resolve, reject);
};
if (callback) {
var resolve = function (res) {
callback(null, res);
};
var reject = function (err) {
callback(err);
};
makeRequest(resolve, reject);
} else {
if (!promisesExist) {
throw new Error('Callback must be provided unless Promises are available');
}
return new Promise(function (resolve, reject) {
makeRequest(resolve, reject);
});
}
} | 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.query !== 'undefined' && typeof options.query === 'object') {
if (Object.keys(options.query).length === 0) {
if (callback) {
return callback(new Error('Options object should not be empty'));
}
return Promise.reject(new Error('Options object should not be empty'));
}
options.query.api_key = this.apiKey;
query = queryStringify(options.query);
} else {
query = queryStringify({
api_key: self.apiKey
});
}
var httpOptions = {
httpService: this.httpService,
request: {
host: API_HOSTNAME,
path: API_BASE_PATH + options.api + endpoint + query
},
timeout: this.timeout,
fmt: options.query && options.query.fmt,
https: this.https
};
var makeRequest = function (resolve, reject) {
httpService.get(httpOptions, resolve, reject);
};
if (callback) {
var resolve = function (res) {
callback(null, res);
};
var reject = function (err) {
callback(err);
};
makeRequest(resolve, reject);
} else {
if (!promisesExist) {
throw new Error('Callback must be provided unless Promises are available');
}
return new Promise(function (resolve, reject) {
makeRequest(resolve, reject);
});
}
} | [
"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",
".",
"query",
"!==",
"'undefined'",
"&&",
"typeof",
"options",
".",
"query",
"===",
"'object'",
")",
"{",
"if",
"(",
"Object",
".",
"keys",
"(",
"options",
".",
"query",
")",
".",
"length",
"===",
"0",
")",
"{",
"if",
"(",
"callback",
")",
"{",
"return",
"callback",
"(",
"new",
"Error",
"(",
"'Options object should not be empty'",
")",
")",
";",
"}",
"return",
"Promise",
".",
"reject",
"(",
"new",
"Error",
"(",
"'Options object should not be empty'",
")",
")",
";",
"}",
"options",
".",
"query",
".",
"api_key",
"=",
"this",
".",
"apiKey",
";",
"query",
"=",
"queryStringify",
"(",
"options",
".",
"query",
")",
";",
"}",
"else",
"{",
"query",
"=",
"queryStringify",
"(",
"{",
"api_key",
":",
"self",
".",
"apiKey",
"}",
")",
";",
"}",
"var",
"httpOptions",
"=",
"{",
"httpService",
":",
"this",
".",
"httpService",
",",
"request",
":",
"{",
"host",
":",
"API_HOSTNAME",
",",
"path",
":",
"API_BASE_PATH",
"+",
"options",
".",
"api",
"+",
"endpoint",
"+",
"query",
"}",
",",
"timeout",
":",
"this",
".",
"timeout",
",",
"fmt",
":",
"options",
".",
"query",
"&&",
"options",
".",
"query",
".",
"fmt",
",",
"https",
":",
"this",
".",
"https",
"}",
";",
"var",
"makeRequest",
"=",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"httpService",
".",
"get",
"(",
"httpOptions",
",",
"resolve",
",",
"reject",
")",
";",
"}",
";",
"if",
"(",
"callback",
")",
"{",
"var",
"resolve",
"=",
"function",
"(",
"res",
")",
"{",
"callback",
"(",
"null",
",",
"res",
")",
";",
"}",
";",
"var",
"reject",
"=",
"function",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
";",
"makeRequest",
"(",
"resolve",
",",
"reject",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"promisesExist",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Callback must be provided unless Promises are available'",
")",
";",
"}",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"makeRequest",
"(",
"resolve",
",",
"reject",
")",
";",
"}",
")",
";",
"}",
"}"
] | 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 used by Giphy. | [
"Prepares",
"the",
"HTTP",
"request",
"and",
"query",
"string",
"for",
"the",
"Giphy",
"API"
] | 670b0e4bd0397d8168192d28808699bec92475de | https://github.com/austinkelleher/giphy-api/blob/670b0e4bd0397d8168192d28808699bec92475de/index.js#L201-L261 | |
23,063 | 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);
omxProcess.on('error', () => {
emitError('Problem running omxplayer, is it installed?.');
});
return omxProcess;
} | 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);
omxProcess.on('error', () => {
emitError('Problem running omxplayer, is it installed?.');
});
return omxProcess;
} | [
"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",
")",
";",
"omxProcess",
".",
"on",
"(",
"'error'",
",",
"(",
")",
"=>",
"{",
"emitError",
"(",
"'Problem running omxplayer, is it installed?.'",
")",
";",
"}",
")",
";",
"return",
"omxProcess",
";",
"}"
] | Spawns the omxplayer process. | [
"Spawns",
"the",
"omxplayer",
"process",
"."
] | 0ee6f30f23008e80b0dfe892bb84166c2e8a6922 | https://github.com/Ap0c/node-omxplayer/blob/0ee6f30f23008e80b0dfe892bb84166c2e8a6922/index.js#L84-L100 |
23,064 | 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) {
device.open ();
this.device = device;
}
}
this.inverse = false;
this.animationsEnabled = true;
var self = this;
this.getSerial(function (err, result) {
if (typeof(err) === 'undefined')
{
self.requiresSoftwareColorPatch = self.getVersionMajor() == 1 &&
self.getVersionMinor() >= 1 && self.getVersionMinor() <= 3;
}
});
} | 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) {
device.open ();
this.device = device;
}
}
this.inverse = false;
this.animationsEnabled = true;
var self = this;
this.getSerial(function (err, result) {
if (typeof(err) === 'undefined')
{
self.requiresSoftwareColorPatch = self.getVersionMajor() == 1 &&
self.getVersionMinor() >= 1 && self.getVersionMinor() <= 3;
}
});
} | [
"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",
")",
"{",
"device",
".",
"open",
"(",
")",
";",
"this",
".",
"device",
"=",
"device",
";",
"}",
"}",
"this",
".",
"inverse",
"=",
"false",
";",
"this",
".",
"animationsEnabled",
"=",
"true",
";",
"var",
"self",
"=",
"this",
";",
"this",
".",
"getSerial",
"(",
"function",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"typeof",
"(",
"err",
")",
"===",
"'undefined'",
")",
"{",
"self",
".",
"requiresSoftwareColorPatch",
"=",
"self",
".",
"getVersionMajor",
"(",
")",
"==",
"1",
"&&",
"self",
".",
"getVersionMinor",
"(",
")",
">=",
"1",
"&&",
"self",
".",
"getVersionMinor",
"(",
")",
"<=",
"3",
";",
"}",
"}",
")",
";",
"}"
] | 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} [product] Product name of the device. Used only in Windows. | [
"Initialize",
"new",
"BlinkStick",
"device"
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L190-L218 |
23,065 | 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;
}
return { 'reportId': reportId, 'maxLeds': maxLeds };
} | 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;
}
return { 'reportId': reportId, 'maxLeds': maxLeds };
} | [
"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",
";",
"}",
"return",
"{",
"'reportId'",
":",
"reportId",
",",
"'maxLeds'",
":",
"maxLeds",
"}",
";",
"}"
] | 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 |
23,066 | 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++) {
if (i === 0) break;
result += String.fromCharCode(buffer[i]);
}
callback(err, result);
});
} | 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++) {
if (i === 0) break;
result += String.fromCharCode(buffer[i]);
}
callback(err, result);
});
} | [
"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",
"++",
")",
"{",
"if",
"(",
"i",
"===",
"0",
")",
"break",
";",
"result",
"+=",
"String",
".",
"fromCharCode",
"(",
"buffer",
"[",
"i",
"]",
")",
";",
"}",
"callback",
"(",
"err",
",",
"result",
")",
";",
"}",
")",
";",
"}"
] | 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 |
23,067 | 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 |
23,068 | 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",
")",
";",
"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",
")",
";",
"}"
] | 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 value. | [
"Sets",
"an",
"infoblock",
"on",
"a",
"device",
"."
] | 6878a511831aa268f892c4b6f2ec6a661ac36ca7 | https://github.com/arvydas/blinkstick-node/blob/6878a511831aa268f892c4b6f2ec6a661ac36ca7/blinkstick.js#L823-L833 |
23,069 | 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 &&
device.productId === PRODUCT_ID &&
filter(device))
{
result.push(new BlinkStick(device.path, device.serialNumber, device.manufacturer, device.product));
}
}
} else {
devices = usb.getDeviceList();
for (i in devices) {
device = devices[i];
if (device.deviceDescriptor.idVendor === VENDOR_ID &&
device.deviceDescriptor.idProduct === PRODUCT_ID &&
filter(device))
result.push(new BlinkStick(device));
}
}
return result;
} | 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 &&
device.productId === PRODUCT_ID &&
filter(device))
{
result.push(new BlinkStick(device.path, device.serialNumber, device.manufacturer, device.product));
}
}
} else {
devices = usb.getDeviceList();
for (i in devices) {
device = devices[i];
if (device.deviceDescriptor.idVendor === VENDOR_ID &&
device.deviceDescriptor.idProduct === PRODUCT_ID &&
filter(device))
result.push(new BlinkStick(device));
}
}
return result;
} | [
"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",
"&&",
"device",
".",
"productId",
"===",
"PRODUCT_ID",
"&&",
"filter",
"(",
"device",
")",
")",
"{",
"result",
".",
"push",
"(",
"new",
"BlinkStick",
"(",
"device",
".",
"path",
",",
"device",
".",
"serialNumber",
",",
"device",
".",
"manufacturer",
",",
"device",
".",
"product",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"devices",
"=",
"usb",
".",
"getDeviceList",
"(",
")",
";",
"for",
"(",
"i",
"in",
"devices",
")",
"{",
"device",
"=",
"devices",
"[",
"i",
"]",
";",
"if",
"(",
"device",
".",
"deviceDescriptor",
".",
"idVendor",
"===",
"VENDOR_ID",
"&&",
"device",
".",
"deviceDescriptor",
".",
"idProduct",
"===",
"PRODUCT_ID",
"&&",
"filter",
"(",
"device",
")",
")",
"result",
".",
"push",
"(",
"new",
"BlinkStick",
"(",
"device",
")",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | 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 |
23,070 | 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",
"=",
"usb",
".",
"findByIds",
"(",
"VENDOR_ID",
",",
"PRODUCT_ID",
")",
";",
"if",
"(",
"device",
")",
"return",
"new",
"BlinkStick",
"(",
"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 | |
23,071 | 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) {
result.push(serial);
i += 1;
finder();
});
}
};
finder();
} | 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) {
result.push(serial);
i += 1;
finder();
});
}
};
finder();
} | [
"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",
")",
"{",
"result",
".",
"push",
"(",
"serial",
")",
";",
"i",
"+=",
"1",
";",
"finder",
"(",
")",
";",
"}",
")",
";",
"}",
"}",
";",
"finder",
"(",
")",
";",
"}"
] | 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 | |
23,072 | 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) {
if (serialNumber == serial) {
if (callback) callback(devices[i]);
} else {
i += 1;
finder();
}
});
}
};
finder();
} | 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) {
if (serialNumber == serial) {
if (callback) callback(devices[i]);
} else {
i += 1;
finder();
}
});
}
};
finder();
} | [
"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",
")",
"{",
"if",
"(",
"serialNumber",
"==",
"serial",
")",
"{",
"if",
"(",
"callback",
")",
"callback",
"(",
"devices",
"[",
"i",
"]",
")",
";",
"}",
"else",
"{",
"i",
"+=",
"1",
";",
"finder",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
";",
"finder",
"(",
")",
";",
"}"
] | 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 | |
23,073 | 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",
"(",
"getAllChildSpans",
"(",
"n",
")",
")",
")",
".",
"reduce",
"(",
"(",
"all",
",",
"arr",
")",
"=>",
"all",
".",
"concat",
"(",
"arr",
")",
")",
":",
"[",
"]",
")",
";",
"}"
] | 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 |
23,074 | 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.execSync(`${babelPath} ${jsPath} ${outFile} --ignore test.js`, execArgs);
console.log(chalk.green('babel compilation complete'));
} | 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.execSync(`${babelPath} ${jsPath} ${outFile} --ignore test.js`, execArgs);
console.log(chalk.green('babel compilation complete'));
} | [
"function",
"compileJavascript",
"(",
"filePath",
")",
"{",
"const",
"jsPath",
"=",
"filePath",
"||",
"'src'",
";",
"const",
"babelPath",
"=",
"which",
".",
"sync",
"(",
"'babel'",
")",
";",
"const",
"outFile",
"=",
"jsPath",
".",
"endsWith",
"(",
"'.js'",
")",
"?",
"`",
"${",
"jsPath",
".",
"replace",
"(",
"'src/'",
",",
"'dist/'",
")",
"}",
"`",
":",
"`",
"`",
";",
"console",
".",
"log",
"(",
"chalk",
".",
"cyan",
"(",
"`",
"${",
"chalk",
".",
"magenta",
"(",
"jsPath",
")",
"}",
"`",
")",
")",
";",
"cp",
".",
"execSync",
"(",
"`",
"${",
"babelPath",
"}",
"${",
"jsPath",
"}",
"${",
"outFile",
"}",
"`",
",",
"execArgs",
")",
";",
"console",
".",
"log",
"(",
"chalk",
".",
"green",
"(",
"'babel compilation complete'",
")",
")",
";",
"}"
] | 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 |
23,075 | 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.min.css')}`));
} | 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.min.css')}`));
} | [
"function",
"compileLess",
"(",
")",
"{",
"console",
".",
"log",
"(",
"chalk",
".",
"cyan",
"(",
"`",
"${",
"chalk",
".",
"magenta",
"(",
"'src/less/hierplane.less'",
")",
"}",
"`",
")",
")",
";",
"cp",
".",
"execSync",
"(",
"`",
"${",
"which",
".",
"sync",
"(",
"'lessc'",
")",
"}",
"`",
")",
";",
"console",
".",
"log",
"(",
"chalk",
".",
"green",
"(",
"`",
"${",
"chalk",
".",
"magenta",
"(",
"'dist/static/hierplane.min.css'",
")",
"}",
"`",
")",
")",
";",
"}"
] | Compiles less to css.
@return {undefined} | [
"Compiles",
"less",
"to",
"css",
"."
] | a907bdd7740a0b2fe517afb06b8419ac9aa1dcd0 | https://github.com/allenai/hierplane/blob/a907bdd7740a0b2fe517afb06b8419ac9aa1dcd0/bin/build.js#L106-L110 |
23,076 | 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: [ bundleEntryPath ],
standalone: 'hierplane'
};
// If we're watching or changes, enable watchify
if (isWatchTarget) {
// These are required for watchify
browserifyOpts.packageCache = {};
browserifyOpts.cache = {};
// Enable the plugin
browserifyOpts.plugin = [ watchify ];
};
// Construct the bundler
const bundler = browserify(browserifyOpts);
// Make an inline function which writes out the bundle, so that we can invoke it whenever
// an update is detected if the watch target is being executed.
const writeBundle = () => {
console.log(chalk.cyan(`bundling ${chalk.magenta(path.relative(execArgs.cwd, bundleEntryPath))}`));
bundler.bundle().pipe(fs.createWriteStream(bundlePath))
console.log(chalk.green(`wrote ${chalk.magenta(path.relative(execArgs.cwd, bundlePath))}`));
};
// Write out the bundle once
writeBundle();
// If we're supposed to watch for changes, write out the bundle whenever they occur
if (isWatchTarget) {
bundler.on('update', writeBundle);
}
} | 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: [ bundleEntryPath ],
standalone: 'hierplane'
};
// If we're watching or changes, enable watchify
if (isWatchTarget) {
// These are required for watchify
browserifyOpts.packageCache = {};
browserifyOpts.cache = {};
// Enable the plugin
browserifyOpts.plugin = [ watchify ];
};
// Construct the bundler
const bundler = browserify(browserifyOpts);
// Make an inline function which writes out the bundle, so that we can invoke it whenever
// an update is detected if the watch target is being executed.
const writeBundle = () => {
console.log(chalk.cyan(`bundling ${chalk.magenta(path.relative(execArgs.cwd, bundleEntryPath))}`));
bundler.bundle().pipe(fs.createWriteStream(bundlePath))
console.log(chalk.green(`wrote ${chalk.magenta(path.relative(execArgs.cwd, bundlePath))}`));
};
// Write out the bundle once
writeBundle();
// If we're supposed to watch for changes, write out the bundle whenever they occur
if (isWatchTarget) {
bundler.on('update', writeBundle);
}
} | [
"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",
":",
"[",
"bundleEntryPath",
"]",
",",
"standalone",
":",
"'hierplane'",
"}",
";",
"// If we're watching or changes, enable watchify",
"if",
"(",
"isWatchTarget",
")",
"{",
"// These are required for watchify",
"browserifyOpts",
".",
"packageCache",
"=",
"{",
"}",
";",
"browserifyOpts",
".",
"cache",
"=",
"{",
"}",
";",
"// Enable the plugin",
"browserifyOpts",
".",
"plugin",
"=",
"[",
"watchify",
"]",
";",
"}",
";",
"// Construct the bundler",
"const",
"bundler",
"=",
"browserify",
"(",
"browserifyOpts",
")",
";",
"// Make an inline function which writes out the bundle, so that we can invoke it whenever",
"// an update is detected if the watch target is being executed.",
"const",
"writeBundle",
"=",
"(",
")",
"=>",
"{",
"console",
".",
"log",
"(",
"chalk",
".",
"cyan",
"(",
"`",
"${",
"chalk",
".",
"magenta",
"(",
"path",
".",
"relative",
"(",
"execArgs",
".",
"cwd",
",",
"bundleEntryPath",
")",
")",
"}",
"`",
")",
")",
";",
"bundler",
".",
"bundle",
"(",
")",
".",
"pipe",
"(",
"fs",
".",
"createWriteStream",
"(",
"bundlePath",
")",
")",
"console",
".",
"log",
"(",
"chalk",
".",
"green",
"(",
"`",
"${",
"chalk",
".",
"magenta",
"(",
"path",
".",
"relative",
"(",
"execArgs",
".",
"cwd",
",",
"bundlePath",
")",
")",
"}",
"`",
")",
")",
";",
"}",
";",
"// Write out the bundle once",
"writeBundle",
"(",
")",
";",
"// If we're supposed to watch for changes, write out the bundle whenever they occur",
"if",
"(",
"isWatchTarget",
")",
"{",
"bundler",
".",
"on",
"(",
"'update'",
",",
"writeBundle",
")",
";",
"}",
"}"
] | 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 |
23,077 | 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
if (since != 0) {
eventArr.forEach(function (e) {
_this.emit(lowerCaseFirst(e.type), e.data);
});
}
//Update event count
if (eventArr.length > 0) {
since = eventArr[eventArr.length - 1].id;
}
//Reset tries
tries = 0;
setTimeout(function () {
return iterator(since);
}, 100);
}).catch(function (err) {
_this.emit('error', err);
//Try to regain connection & reset event counter
if (tries < retries) {
tries++;
setTimeout(function () {
return iterator(0);
}, 500);
}
});
} | 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
if (since != 0) {
eventArr.forEach(function (e) {
_this.emit(lowerCaseFirst(e.type), e.data);
});
}
//Update event count
if (eventArr.length > 0) {
since = eventArr[eventArr.length - 1].id;
}
//Reset tries
tries = 0;
setTimeout(function () {
return iterator(since);
}, 100);
}).catch(function (err) {
_this.emit('error', err);
//Try to regain connection & reset event counter
if (tries < retries) {
tries++;
setTimeout(function () {
return iterator(0);
}, 500);
}
});
} | [
"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",
"if",
"(",
"since",
"!=",
"0",
")",
"{",
"eventArr",
".",
"forEach",
"(",
"function",
"(",
"e",
")",
"{",
"_this",
".",
"emit",
"(",
"lowerCaseFirst",
"(",
"e",
".",
"type",
")",
",",
"e",
".",
"data",
")",
";",
"}",
")",
";",
"}",
"//Update event count",
"if",
"(",
"eventArr",
".",
"length",
">",
"0",
")",
"{",
"since",
"=",
"eventArr",
"[",
"eventArr",
".",
"length",
"-",
"1",
"]",
".",
"id",
";",
"}",
"//Reset tries",
"tries",
"=",
"0",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"return",
"iterator",
"(",
"since",
")",
";",
"}",
",",
"100",
")",
";",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"_this",
".",
"emit",
"(",
"'error'",
",",
"err",
")",
";",
"//Try to regain connection & reset event counter",
"if",
"(",
"tries",
"<",
"retries",
")",
"{",
"tries",
"++",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"return",
"iterator",
"(",
"0",
")",
";",
"}",
",",
"500",
")",
";",
"}",
"}",
")",
";",
"}"
] | Event request loop | [
"Event",
"request",
"loop"
] | 6e19d2cb4c8fb99b583ee468b8a4643b9a506f09 | https://github.com/JodusNodus/node-syncthing/blob/6e19d2cb4c8fb99b583ee468b8a4643b9a506f09/lib/event-caller.js#L36-L76 |
23,078 | 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,
options: options,
callback: function callback(err, res) {
return err ? reject(err) : resolve(res);
}
});
});
}
};
} | 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,
options: options,
callback: function callback(err, res) {
return err ? reject(err) : resolve(res);
}
});
});
}
};
} | [
"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",
",",
"options",
":",
"options",
",",
"callback",
":",
"function",
"callback",
"(",
"err",
",",
"res",
")",
"{",
"return",
"err",
"?",
"reject",
"(",
"err",
")",
":",
"resolve",
"(",
"res",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}",
"}",
";",
"}"
] | 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 |
23,079 | 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",
"(",
"'read'",
",",
"function",
"read",
"(",
"type",
")",
"{",
"this",
"[",
"type",
"]",
"(",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | 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 |
23,080 | 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 = options.discover || false;
this.prefix = options.prefix || '';
//
// Discover a running process.
//
if (this.discover && !this.pid) this.read();
} | 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 = options.discover || false;
this.prefix = options.prefix || '';
//
// Discover a running process.
//
if (this.discover && !this.pid) this.read();
} | [
"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",
"=",
"options",
".",
"discover",
"||",
"false",
";",
"this",
".",
"prefix",
"=",
"options",
".",
"prefix",
"||",
"''",
";",
"//",
"// Discover a running process.",
"//",
"if",
"(",
"this",
".",
"discover",
"&&",
"!",
"this",
".",
"pid",
")",
"this",
".",
"read",
"(",
")",
";",
"}"
] | 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] which: The location of the haproxy
@constructor
@param {Object} options Orchestrator configuration.
@api public | [
"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 |
23,081 | 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",
"(",
"arg",
")",
"base",
".",
"push",
"(",
"arg",
")",
";",
"return",
"fn",
".",
"apply",
"(",
"self",
",",
"base",
".",
"concat",
"(",
"Array",
".",
"prototype",
".",
"slice",
".",
"apply",
"(",
"arguments",
")",
")",
")",
";",
"}",
"}",
";",
"}"
] | 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 |
23,082 | 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;
}
this.socket = socket || '/tmp/haproxy.sock'; // Path to socket
this.cfg = options.config || '/etc/haproxy/haproxy.cfg'; // Config location
//
// Create a new `haproxy` orchestrator which interacts with the binary.
//
this.orchestrator = new Orchestrator({
discover: options.discover,
pidFile: options.pidFile,
prefix: options.prefix,
which: options.which,
pid: options.pid,
config: this.cfg
});
} | 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;
}
this.socket = socket || '/tmp/haproxy.sock'; // Path to socket
this.cfg = options.config || '/etc/haproxy/haproxy.cfg'; // Config location
//
// Create a new `haproxy` orchestrator which interacts with the binary.
//
this.orchestrator = new Orchestrator({
discover: options.discover,
pidFile: options.pidFile,
prefix: options.prefix,
which: options.which,
pid: options.pid,
config: this.cfg
});
} | [
"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",
";",
"}",
"this",
".",
"socket",
"=",
"socket",
"||",
"'/tmp/haproxy.sock'",
";",
"// Path to socket",
"this",
".",
"cfg",
"=",
"options",
".",
"config",
"||",
"'/etc/haproxy/haproxy.cfg'",
";",
"// Config location",
"//",
"// Create a new `haproxy` orchestrator which interacts with the binary.",
"//",
"this",
".",
"orchestrator",
"=",
"new",
"Orchestrator",
"(",
"{",
"discover",
":",
"options",
".",
"discover",
",",
"pidFile",
":",
"options",
".",
"pidFile",
",",
"prefix",
":",
"options",
".",
"prefix",
",",
"which",
":",
"options",
".",
"which",
",",
"pid",
":",
"options",
".",
"pid",
",",
"config",
":",
"this",
".",
"cfg",
"}",
")",
";",
"}"
] | 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 location of the unix socket
- [optional] which: The location of the haproxy
@see http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#9.2
@constructor
@param {String} socket Path to the unix domain socket
@param {Object} options Configuration
@api public | [
"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 |
23,083 | 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('SimpleThumbnailGenerator');
}
else {
if (options.logger === null) {
this._logger = nullLogger;
}
else {
this._logger = options.logger;
}
}
this._generatorOptions = generatorOptions;
this._manifestFileName = options.manifestFileName;
this._expireTime = options.expireTime || 0;
this._segmentRemovalTimes = {
// the sn of the first fragment in the array
offset: null,
// the times when the corresponding fragments were removed
times: []
};
// {sn, thumbnails, removalTime}
// thumbnails is array of {time, name}
this._segments = [];
this._playlistRemoved = false;
this._playlistEnded = false;
this._generator = new ThumbnailGenerator(Object.assign({}, generatorOptions, {
// if the user doesn't provide a temp directory get a general one
tempDir: generatorOptions.tempDir || utils.getTempDir()
}));
this._gcTimerId = setInterval(this._gc.bind(this), 30000);
this._emitter = ee({});
this._registerGeneratorListeners();
this._updateManifest();
} | 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('SimpleThumbnailGenerator');
}
else {
if (options.logger === null) {
this._logger = nullLogger;
}
else {
this._logger = options.logger;
}
}
this._generatorOptions = generatorOptions;
this._manifestFileName = options.manifestFileName;
this._expireTime = options.expireTime || 0;
this._segmentRemovalTimes = {
// the sn of the first fragment in the array
offset: null,
// the times when the corresponding fragments were removed
times: []
};
// {sn, thumbnails, removalTime}
// thumbnails is array of {time, name}
this._segments = [];
this._playlistRemoved = false;
this._playlistEnded = false;
this._generator = new ThumbnailGenerator(Object.assign({}, generatorOptions, {
// if the user doesn't provide a temp directory get a general one
tempDir: generatorOptions.tempDir || utils.getTempDir()
}));
this._gcTimerId = setInterval(this._gc.bind(this), 30000);
this._emitter = ee({});
this._registerGeneratorListeners();
this._updateManifest();
} | [
"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",
"(",
"'SimpleThumbnailGenerator'",
")",
";",
"}",
"else",
"{",
"if",
"(",
"options",
".",
"logger",
"===",
"null",
")",
"{",
"this",
".",
"_logger",
"=",
"nullLogger",
";",
"}",
"else",
"{",
"this",
".",
"_logger",
"=",
"options",
".",
"logger",
";",
"}",
"}",
"this",
".",
"_generatorOptions",
"=",
"generatorOptions",
";",
"this",
".",
"_manifestFileName",
"=",
"options",
".",
"manifestFileName",
";",
"this",
".",
"_expireTime",
"=",
"options",
".",
"expireTime",
"||",
"0",
";",
"this",
".",
"_segmentRemovalTimes",
"=",
"{",
"// the sn of the first fragment in the array",
"offset",
":",
"null",
",",
"// the times when the corresponding fragments were removed",
"times",
":",
"[",
"]",
"}",
";",
"// {sn, thumbnails, removalTime}",
"// thumbnails is array of {time, name}",
"this",
".",
"_segments",
"=",
"[",
"]",
";",
"this",
".",
"_playlistRemoved",
"=",
"false",
";",
"this",
".",
"_playlistEnded",
"=",
"false",
";",
"this",
".",
"_generator",
"=",
"new",
"ThumbnailGenerator",
"(",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"generatorOptions",
",",
"{",
"// if the user doesn't provide a temp directory get a general one",
"tempDir",
":",
"generatorOptions",
".",
"tempDir",
"||",
"utils",
".",
"getTempDir",
"(",
")",
"}",
")",
")",
";",
"this",
".",
"_gcTimerId",
"=",
"setInterval",
"(",
"this",
".",
"_gc",
".",
"bind",
"(",
"this",
")",
",",
"30000",
")",
";",
"this",
".",
"_emitter",
"=",
"ee",
"(",
"{",
"}",
")",
";",
"this",
".",
"_registerGeneratorListeners",
"(",
")",
";",
"this",
".",
"_updateManifest",
"(",
")",
";",
"}"
] | 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 thumbnails for before deleting them, once their segments have left the playlist. Defaults to 0.
@param {Number} [options.expireTime] The time in seconds to keep thumbnails for before deleting them, once their segments have left the playlist. Defaults to 0.
@param {Number} [options.logger] An object with `debug`, `info`, `warn` and `error` functions, or null, to disable logging.
@param {Object} [generatorOptions] Configuraton for `ThumbnailGenerator`. | [
"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 |
23,084 | 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 | |
23,085 | 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",
".",
"start",
"(",
"event",
".",
"deadline",
")",
"}",
",",
"nextBeatTime",
"(",
"beatInd",
")",
")",
"event",
".",
"repeat",
"(",
"barDur",
")",
"event",
".",
"tolerance",
"(",
"{",
"late",
":",
"0.01",
"}",
")",
"beats",
"[",
"track",
"]",
"[",
"beatInd",
"]",
"=",
"event",
"}"
] | 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 | |
23,086 | 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.createBufferSource()
node.buffer = buffer
node.connect(context.destination)
return node
}
soundBank[track] = { createNode: createNode }
})
}
request.send()
} | 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.createBufferSource()
node.buffer = buffer
node.connect(context.destination)
return node
}
soundBank[track] = { createNode: createNode }
})
}
request.send()
} | [
"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",
".",
"createBufferSource",
"(",
")",
"node",
".",
"buffer",
"=",
"buffer",
"node",
".",
"connect",
"(",
"context",
".",
"destination",
")",
"return",
"node",
"}",
"soundBank",
"[",
"track",
"]",
"=",
"{",
"createNode",
":",
"createNode",
"}",
"}",
")",
"}",
"request",
".",
"send",
"(",
")",
"}"
] | This helper loads sound buffers | [
"This",
"helper",
"loads",
"sound",
"buffers"
] | 078f7e8e9118b17afa8c4b288e5212ba2d54462b | https://github.com/sebpiq/WAAClock/blob/078f7e8e9118b17afa8c4b288e5212ba2d54462b/demos/beatSequence.js#L50-L66 | |
23,087 | 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",
"(",
"imprt",
".",
"slice",
"(",
"-",
"1",
")",
"!==",
"';'",
")",
"{",
"imprt",
"+=",
"';'",
";",
"}",
"imports",
".",
"push",
"(",
"imprt",
")",
";",
"return",
"indent",
";",
"// keep only the indentation\r",
"}",
")",
";",
"}"
] | 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 |
23,088 | 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",
"]",
")",
";",
"}",
"return",
"o",
";",
"}",
",",
"{",
"filename",
"}",
")",
";",
"}"
] | 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 |
23,089 | 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",
"=",
"new",
"Date",
"(",
"firstDate",
".",
"getTime",
"(",
")",
")",
";",
"date",
".",
"setDate",
"(",
"i",
")",
";",
"dataProvider",
".",
"push",
"(",
"{",
"date",
":",
"date",
",",
"value",
":",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"100",
")",
"}",
")",
";",
"}",
"return",
"dataProvider",
";",
"}"
] | Generate random data | [
"Generate",
"random",
"data"
] | 0930606e49b739f4f97efee462d70cfb80c73d83 | https://github.com/amcharts/amcharts3-react/blob/0930606e49b739f4f97efee462d70cfb80c73d83/examples/script/example.js#L2-L19 |
23,090 | 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 > this.destination.length)
this.destination.push(lastDestination)
while(this.value.length < this.destination.length)
this.value.push(lastValue)
}
return this
} | 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 > this.destination.length)
this.destination.push(lastDestination)
while(this.value.length < this.destination.length)
this.value.push(lastValue)
}
return this
} | [
"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",
">",
"this",
".",
"destination",
".",
"length",
")",
"this",
".",
"destination",
".",
"push",
"(",
"lastDestination",
")",
"while",
"(",
"this",
".",
"value",
".",
"length",
"<",
"this",
".",
"destination",
".",
"length",
")",
"this",
".",
"value",
".",
"push",
"(",
"lastValue",
")",
"}",
"return",
"this",
"}"
] | Make array morphable | [
"Make",
"array",
"morphable"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L428-L443 | |
23,091 | jillix/svg.connectable.js | example/js/svg.js | function() {
// convert to a poly point string
for (var i = 0, il = this.value.length, array = []; i < il; i++)
array.push(this.value[i].join(','))
return array.join(' ')
} | javascript | function() {
// convert to a poly point string
for (var i = 0, il = this.value.length, array = []; i < il; i++)
array.push(this.value[i].join(','))
return array.join(' ')
} | [
"function",
"(",
")",
"{",
"// convert to a poly point string",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"this",
".",
"value",
".",
"length",
",",
"array",
"=",
"[",
"]",
";",
"i",
"<",
"il",
";",
"i",
"++",
")",
"array",
".",
"push",
"(",
"this",
".",
"value",
"[",
"i",
"]",
".",
"join",
"(",
"','",
")",
")",
"return",
"array",
".",
"join",
"(",
"' '",
")",
"}"
] | Convert array to string | [
"Convert",
"array",
"to",
"string"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L504-L510 | |
23,092 | jillix/svg.connectable.js | example/js/svg.js | function(o, ease, delay){
if(typeof o == 'object'){
ease = o.ease
delay = o.delay
o = o.duration
}
var situation = new SVG.Situation({
duration: o || 1000,
delay: delay || 0,
ease: SVG.easing[ease || '-'] || ease
})
this.queue(situation)
return this
} | javascript | function(o, ease, delay){
if(typeof o == 'object'){
ease = o.ease
delay = o.delay
o = o.duration
}
var situation = new SVG.Situation({
duration: o || 1000,
delay: delay || 0,
ease: SVG.easing[ease || '-'] || ease
})
this.queue(situation)
return this
} | [
"function",
"(",
"o",
",",
"ease",
",",
"delay",
")",
"{",
"if",
"(",
"typeof",
"o",
"==",
"'object'",
")",
"{",
"ease",
"=",
"o",
".",
"ease",
"delay",
"=",
"o",
".",
"delay",
"o",
"=",
"o",
".",
"duration",
"}",
"var",
"situation",
"=",
"new",
"SVG",
".",
"Situation",
"(",
"{",
"duration",
":",
"o",
"||",
"1000",
",",
"delay",
":",
"delay",
"||",
"0",
",",
"ease",
":",
"SVG",
".",
"easing",
"[",
"ease",
"||",
"'-'",
"]",
"||",
"ease",
"}",
")",
"this",
".",
"queue",
"(",
"situation",
")",
"return",
"this",
"}"
] | sets or returns the target of this animation
@param o object || number In case of Object it holds all parameters. In case of number its the duration of the animation
@param ease function || string Function which should be used for easing or easing keyword
@param delay Number indicating the delay before the animation starts
@return target || this | [
"sets",
"or",
"returns",
"the",
"target",
"of",
"this",
"animation"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L1281-L1298 | |
23,093 | jillix/svg.connectable.js | example/js/svg.js | function(o, ease, delay) {
return (this.fx || (this.fx = new SVG.FX(this))).animate(o, ease, delay)
} | javascript | function(o, ease, delay) {
return (this.fx || (this.fx = new SVG.FX(this))).animate(o, ease, delay)
} | [
"function",
"(",
"o",
",",
"ease",
",",
"delay",
")",
"{",
"return",
"(",
"this",
".",
"fx",
"||",
"(",
"this",
".",
"fx",
"=",
"new",
"SVG",
".",
"FX",
"(",
"this",
")",
")",
")",
".",
"animate",
"(",
"o",
",",
"ease",
",",
"delay",
")",
"}"
] | Get fx module or create a new one, then animate with given duration and ease | [
"Get",
"fx",
"module",
"or",
"create",
"a",
"new",
"one",
"then",
"animate",
"with",
"given",
"duration",
"and",
"ease"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L1827-L1829 | |
23,094 | jillix/svg.connectable.js | example/js/svg.js | function(a, v, relative) {
// apply attributes individually
if (typeof a == 'object') {
for (var key in a)
this.attr(key, a[key])
} else {
// the MorphObj takes care about the right function used
this.add(a, new SVG.MorphObj(null, v), 'attrs')
}
return this
} | javascript | function(a, v, relative) {
// apply attributes individually
if (typeof a == 'object') {
for (var key in a)
this.attr(key, a[key])
} else {
// the MorphObj takes care about the right function used
this.add(a, new SVG.MorphObj(null, v), 'attrs')
}
return this
} | [
"function",
"(",
"a",
",",
"v",
",",
"relative",
")",
"{",
"// apply attributes individually",
"if",
"(",
"typeof",
"a",
"==",
"'object'",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"a",
")",
"this",
".",
"attr",
"(",
"key",
",",
"a",
"[",
"key",
"]",
")",
"}",
"else",
"{",
"// the MorphObj takes care about the right function used",
"this",
".",
"add",
"(",
"a",
",",
"new",
"SVG",
".",
"MorphObj",
"(",
"null",
",",
"v",
")",
",",
"'attrs'",
")",
"}",
"return",
"this",
"}"
] | Add animatable attributes | [
"Add",
"animatable",
"attributes"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L1891-L1903 | |
23,095 | jillix/svg.connectable.js | example/js/svg.js | function(box) {
var b = new c()
// merge boxes
b.x = Math.min(this.x, box.x)
b.y = Math.min(this.y, box.y)
b.width = Math.max(this.x + this.width, box.x + box.width) - b.x
b.height = Math.max(this.y + this.height, box.y + box.height) - b.y
return fullBox(b)
} | javascript | function(box) {
var b = new c()
// merge boxes
b.x = Math.min(this.x, box.x)
b.y = Math.min(this.y, box.y)
b.width = Math.max(this.x + this.width, box.x + box.width) - b.x
b.height = Math.max(this.y + this.height, box.y + box.height) - b.y
return fullBox(b)
} | [
"function",
"(",
"box",
")",
"{",
"var",
"b",
"=",
"new",
"c",
"(",
")",
"// merge boxes",
"b",
".",
"x",
"=",
"Math",
".",
"min",
"(",
"this",
".",
"x",
",",
"box",
".",
"x",
")",
"b",
".",
"y",
"=",
"Math",
".",
"min",
"(",
"this",
".",
"y",
",",
"box",
".",
"y",
")",
"b",
".",
"width",
"=",
"Math",
".",
"max",
"(",
"this",
".",
"x",
"+",
"this",
".",
"width",
",",
"box",
".",
"x",
"+",
"box",
".",
"width",
")",
"-",
"b",
".",
"x",
"b",
".",
"height",
"=",
"Math",
".",
"max",
"(",
"this",
".",
"y",
"+",
"this",
".",
"height",
",",
"box",
".",
"y",
"+",
"box",
".",
"height",
")",
"-",
"b",
".",
"y",
"return",
"fullBox",
"(",
"b",
")",
"}"
] | Merge rect box with another, return a new instance | [
"Merge",
"rect",
"box",
"with",
"another",
"return",
"a",
"new",
"instance"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L2171-L2181 | |
23,096 | jillix/svg.connectable.js | example/js/svg.js | function() {
// find delta transform points
var px = deltaTransformPoint(this, 0, 1)
, py = deltaTransformPoint(this, 1, 0)
, skewX = 180 / Math.PI * Math.atan2(px.y, px.x) - 90
return {
// translation
x: this.e
, y: this.f
, transformedX:(this.e * Math.cos(skewX * Math.PI / 180) + this.f * Math.sin(skewX * Math.PI / 180)) / Math.sqrt(this.a * this.a + this.b * this.b)
, transformedY:(this.f * Math.cos(skewX * Math.PI / 180) + this.e * Math.sin(-skewX * Math.PI / 180)) / Math.sqrt(this.c * this.c + this.d * this.d)
// skew
, skewX: -skewX
, skewY: 180 / Math.PI * Math.atan2(py.y, py.x)
// scale
, scaleX: Math.sqrt(this.a * this.a + this.b * this.b)
, scaleY: Math.sqrt(this.c * this.c + this.d * this.d)
// rotation
, rotation: skewX
, a: this.a
, b: this.b
, c: this.c
, d: this.d
, e: this.e
, f: this.f
, matrix: new SVG.Matrix(this)
}
} | javascript | function() {
// find delta transform points
var px = deltaTransformPoint(this, 0, 1)
, py = deltaTransformPoint(this, 1, 0)
, skewX = 180 / Math.PI * Math.atan2(px.y, px.x) - 90
return {
// translation
x: this.e
, y: this.f
, transformedX:(this.e * Math.cos(skewX * Math.PI / 180) + this.f * Math.sin(skewX * Math.PI / 180)) / Math.sqrt(this.a * this.a + this.b * this.b)
, transformedY:(this.f * Math.cos(skewX * Math.PI / 180) + this.e * Math.sin(-skewX * Math.PI / 180)) / Math.sqrt(this.c * this.c + this.d * this.d)
// skew
, skewX: -skewX
, skewY: 180 / Math.PI * Math.atan2(py.y, py.x)
// scale
, scaleX: Math.sqrt(this.a * this.a + this.b * this.b)
, scaleY: Math.sqrt(this.c * this.c + this.d * this.d)
// rotation
, rotation: skewX
, a: this.a
, b: this.b
, c: this.c
, d: this.d
, e: this.e
, f: this.f
, matrix: new SVG.Matrix(this)
}
} | [
"function",
"(",
")",
"{",
"// find delta transform points",
"var",
"px",
"=",
"deltaTransformPoint",
"(",
"this",
",",
"0",
",",
"1",
")",
",",
"py",
"=",
"deltaTransformPoint",
"(",
"this",
",",
"1",
",",
"0",
")",
",",
"skewX",
"=",
"180",
"/",
"Math",
".",
"PI",
"*",
"Math",
".",
"atan2",
"(",
"px",
".",
"y",
",",
"px",
".",
"x",
")",
"-",
"90",
"return",
"{",
"// translation",
"x",
":",
"this",
".",
"e",
",",
"y",
":",
"this",
".",
"f",
",",
"transformedX",
":",
"(",
"this",
".",
"e",
"*",
"Math",
".",
"cos",
"(",
"skewX",
"*",
"Math",
".",
"PI",
"/",
"180",
")",
"+",
"this",
".",
"f",
"*",
"Math",
".",
"sin",
"(",
"skewX",
"*",
"Math",
".",
"PI",
"/",
"180",
")",
")",
"/",
"Math",
".",
"sqrt",
"(",
"this",
".",
"a",
"*",
"this",
".",
"a",
"+",
"this",
".",
"b",
"*",
"this",
".",
"b",
")",
",",
"transformedY",
":",
"(",
"this",
".",
"f",
"*",
"Math",
".",
"cos",
"(",
"skewX",
"*",
"Math",
".",
"PI",
"/",
"180",
")",
"+",
"this",
".",
"e",
"*",
"Math",
".",
"sin",
"(",
"-",
"skewX",
"*",
"Math",
".",
"PI",
"/",
"180",
")",
")",
"/",
"Math",
".",
"sqrt",
"(",
"this",
".",
"c",
"*",
"this",
".",
"c",
"+",
"this",
".",
"d",
"*",
"this",
".",
"d",
")",
"// skew",
",",
"skewX",
":",
"-",
"skewX",
",",
"skewY",
":",
"180",
"/",
"Math",
".",
"PI",
"*",
"Math",
".",
"atan2",
"(",
"py",
".",
"y",
",",
"py",
".",
"x",
")",
"// scale",
",",
"scaleX",
":",
"Math",
".",
"sqrt",
"(",
"this",
".",
"a",
"*",
"this",
".",
"a",
"+",
"this",
".",
"b",
"*",
"this",
".",
"b",
")",
",",
"scaleY",
":",
"Math",
".",
"sqrt",
"(",
"this",
".",
"c",
"*",
"this",
".",
"c",
"+",
"this",
".",
"d",
"*",
"this",
".",
"d",
")",
"// rotation",
",",
"rotation",
":",
"skewX",
",",
"a",
":",
"this",
".",
"a",
",",
"b",
":",
"this",
".",
"b",
",",
"c",
":",
"this",
".",
"c",
",",
"d",
":",
"this",
".",
"d",
",",
"e",
":",
"this",
".",
"e",
",",
"f",
":",
"this",
".",
"f",
",",
"matrix",
":",
"new",
"SVG",
".",
"Matrix",
"(",
"this",
")",
"}",
"}"
] | Extract individual transformations | [
"Extract",
"individual",
"transformations"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L2211-L2239 | |
23,097 | jillix/svg.connectable.js | example/js/svg.js | function(a, v, n) {
// act as full getter
if (a == null) {
// get an object of attributes
a = {}
v = this.node.attributes
for (n = v.length - 1; n >= 0; n--)
a[v[n].nodeName] = SVG.regex.isNumber.test(v[n].nodeValue) ? parseFloat(v[n].nodeValue) : v[n].nodeValue
return a
} else if (typeof a == 'object') {
// apply every attribute individually if an object is passed
for (v in a) this.attr(v, a[v])
} else if (v === null) {
// remove value
this.node.removeAttribute(a)
} else if (v == null) {
// act as a getter if the first and only argument is not an object
v = this.node.getAttribute(a)
return v == null ?
SVG.defaults.attrs[a] :
SVG.regex.isNumber.test(v) ?
parseFloat(v) : v
} else {
// BUG FIX: some browsers will render a stroke if a color is given even though stroke width is 0
if (a == 'stroke-width')
this.attr('stroke', parseFloat(v) > 0 ? this._stroke : null)
else if (a == 'stroke')
this._stroke = v
// convert image fill and stroke to patterns
if (a == 'fill' || a == 'stroke') {
if (SVG.regex.isImage.test(v))
v = this.doc().defs().image(v, 0, 0)
if (v instanceof SVG.Image)
v = this.doc().defs().pattern(0, 0, function() {
this.add(v)
})
}
// ensure correct numeric values (also accepts NaN and Infinity)
if (typeof v === 'number')
v = new SVG.Number(v)
// ensure full hex color
else if (SVG.Color.isColor(v))
v = new SVG.Color(v)
// parse array values
else if (Array.isArray(v))
v = new SVG.Array(v)
// store parametric transformation values locally
else if (v instanceof SVG.Matrix && v.param)
this.param = v.param
// if the passed attribute is leading...
if (a == 'leading') {
// ... call the leading method instead
if (this.leading)
this.leading(v)
} else {
// set given attribute on node
typeof n === 'string' ?
this.node.setAttributeNS(n, a, v.toString()) :
this.node.setAttribute(a, v.toString())
}
// rebuild if required
if (this.rebuild && (a == 'font-size' || a == 'x'))
this.rebuild(a, v)
}
return this
} | javascript | function(a, v, n) {
// act as full getter
if (a == null) {
// get an object of attributes
a = {}
v = this.node.attributes
for (n = v.length - 1; n >= 0; n--)
a[v[n].nodeName] = SVG.regex.isNumber.test(v[n].nodeValue) ? parseFloat(v[n].nodeValue) : v[n].nodeValue
return a
} else if (typeof a == 'object') {
// apply every attribute individually if an object is passed
for (v in a) this.attr(v, a[v])
} else if (v === null) {
// remove value
this.node.removeAttribute(a)
} else if (v == null) {
// act as a getter if the first and only argument is not an object
v = this.node.getAttribute(a)
return v == null ?
SVG.defaults.attrs[a] :
SVG.regex.isNumber.test(v) ?
parseFloat(v) : v
} else {
// BUG FIX: some browsers will render a stroke if a color is given even though stroke width is 0
if (a == 'stroke-width')
this.attr('stroke', parseFloat(v) > 0 ? this._stroke : null)
else if (a == 'stroke')
this._stroke = v
// convert image fill and stroke to patterns
if (a == 'fill' || a == 'stroke') {
if (SVG.regex.isImage.test(v))
v = this.doc().defs().image(v, 0, 0)
if (v instanceof SVG.Image)
v = this.doc().defs().pattern(0, 0, function() {
this.add(v)
})
}
// ensure correct numeric values (also accepts NaN and Infinity)
if (typeof v === 'number')
v = new SVG.Number(v)
// ensure full hex color
else if (SVG.Color.isColor(v))
v = new SVG.Color(v)
// parse array values
else if (Array.isArray(v))
v = new SVG.Array(v)
// store parametric transformation values locally
else if (v instanceof SVG.Matrix && v.param)
this.param = v.param
// if the passed attribute is leading...
if (a == 'leading') {
// ... call the leading method instead
if (this.leading)
this.leading(v)
} else {
// set given attribute on node
typeof n === 'string' ?
this.node.setAttributeNS(n, a, v.toString()) :
this.node.setAttribute(a, v.toString())
}
// rebuild if required
if (this.rebuild && (a == 'font-size' || a == 'x'))
this.rebuild(a, v)
}
return this
} | [
"function",
"(",
"a",
",",
"v",
",",
"n",
")",
"{",
"// act as full getter",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"// get an object of attributes",
"a",
"=",
"{",
"}",
"v",
"=",
"this",
".",
"node",
".",
"attributes",
"for",
"(",
"n",
"=",
"v",
".",
"length",
"-",
"1",
";",
"n",
">=",
"0",
";",
"n",
"--",
")",
"a",
"[",
"v",
"[",
"n",
"]",
".",
"nodeName",
"]",
"=",
"SVG",
".",
"regex",
".",
"isNumber",
".",
"test",
"(",
"v",
"[",
"n",
"]",
".",
"nodeValue",
")",
"?",
"parseFloat",
"(",
"v",
"[",
"n",
"]",
".",
"nodeValue",
")",
":",
"v",
"[",
"n",
"]",
".",
"nodeValue",
"return",
"a",
"}",
"else",
"if",
"(",
"typeof",
"a",
"==",
"'object'",
")",
"{",
"// apply every attribute individually if an object is passed",
"for",
"(",
"v",
"in",
"a",
")",
"this",
".",
"attr",
"(",
"v",
",",
"a",
"[",
"v",
"]",
")",
"}",
"else",
"if",
"(",
"v",
"===",
"null",
")",
"{",
"// remove value",
"this",
".",
"node",
".",
"removeAttribute",
"(",
"a",
")",
"}",
"else",
"if",
"(",
"v",
"==",
"null",
")",
"{",
"// act as a getter if the first and only argument is not an object",
"v",
"=",
"this",
".",
"node",
".",
"getAttribute",
"(",
"a",
")",
"return",
"v",
"==",
"null",
"?",
"SVG",
".",
"defaults",
".",
"attrs",
"[",
"a",
"]",
":",
"SVG",
".",
"regex",
".",
"isNumber",
".",
"test",
"(",
"v",
")",
"?",
"parseFloat",
"(",
"v",
")",
":",
"v",
"}",
"else",
"{",
"// BUG FIX: some browsers will render a stroke if a color is given even though stroke width is 0",
"if",
"(",
"a",
"==",
"'stroke-width'",
")",
"this",
".",
"attr",
"(",
"'stroke'",
",",
"parseFloat",
"(",
"v",
")",
">",
"0",
"?",
"this",
".",
"_stroke",
":",
"null",
")",
"else",
"if",
"(",
"a",
"==",
"'stroke'",
")",
"this",
".",
"_stroke",
"=",
"v",
"// convert image fill and stroke to patterns",
"if",
"(",
"a",
"==",
"'fill'",
"||",
"a",
"==",
"'stroke'",
")",
"{",
"if",
"(",
"SVG",
".",
"regex",
".",
"isImage",
".",
"test",
"(",
"v",
")",
")",
"v",
"=",
"this",
".",
"doc",
"(",
")",
".",
"defs",
"(",
")",
".",
"image",
"(",
"v",
",",
"0",
",",
"0",
")",
"if",
"(",
"v",
"instanceof",
"SVG",
".",
"Image",
")",
"v",
"=",
"this",
".",
"doc",
"(",
")",
".",
"defs",
"(",
")",
".",
"pattern",
"(",
"0",
",",
"0",
",",
"function",
"(",
")",
"{",
"this",
".",
"add",
"(",
"v",
")",
"}",
")",
"}",
"// ensure correct numeric values (also accepts NaN and Infinity)",
"if",
"(",
"typeof",
"v",
"===",
"'number'",
")",
"v",
"=",
"new",
"SVG",
".",
"Number",
"(",
"v",
")",
"// ensure full hex color",
"else",
"if",
"(",
"SVG",
".",
"Color",
".",
"isColor",
"(",
"v",
")",
")",
"v",
"=",
"new",
"SVG",
".",
"Color",
"(",
"v",
")",
"// parse array values",
"else",
"if",
"(",
"Array",
".",
"isArray",
"(",
"v",
")",
")",
"v",
"=",
"new",
"SVG",
".",
"Array",
"(",
"v",
")",
"// store parametric transformation values locally",
"else",
"if",
"(",
"v",
"instanceof",
"SVG",
".",
"Matrix",
"&&",
"v",
".",
"param",
")",
"this",
".",
"param",
"=",
"v",
".",
"param",
"// if the passed attribute is leading...",
"if",
"(",
"a",
"==",
"'leading'",
")",
"{",
"// ... call the leading method instead",
"if",
"(",
"this",
".",
"leading",
")",
"this",
".",
"leading",
"(",
"v",
")",
"}",
"else",
"{",
"// set given attribute on node",
"typeof",
"n",
"===",
"'string'",
"?",
"this",
".",
"node",
".",
"setAttributeNS",
"(",
"n",
",",
"a",
",",
"v",
".",
"toString",
"(",
")",
")",
":",
"this",
".",
"node",
".",
"setAttribute",
"(",
"a",
",",
"v",
".",
"toString",
"(",
")",
")",
"}",
"// rebuild if required",
"if",
"(",
"this",
".",
"rebuild",
"&&",
"(",
"a",
"==",
"'font-size'",
"||",
"a",
"==",
"'x'",
")",
")",
"this",
".",
"rebuild",
"(",
"a",
",",
"v",
")",
"}",
"return",
"this",
"}"
] | Set svg element attribute | [
"Set",
"svg",
"element",
"attribute"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L2452-L2531 | |
23,098 | jillix/svg.connectable.js | example/js/svg.js | function() {
var matrix = (this.attr('transform') || '')
// split transformations
.split(/\)\s*/).slice(0,-1).map(function(str){
// generate key => value pairs
var kv = str.trim().split('(')
return [kv[0], kv[1].split(SVG.regex.matrixElements).map(function(str){ return parseFloat(str) })]
})
// calculate every transformation into one matrix
.reduce(function(matrix, transform){
if(transform[0] == 'matrix') return matrix.multiply(arrayToMatrix(transform[1]))
return matrix[transform[0]].apply(matrix, transform[1])
}, new SVG.Matrix())
return matrix
} | javascript | function() {
var matrix = (this.attr('transform') || '')
// split transformations
.split(/\)\s*/).slice(0,-1).map(function(str){
// generate key => value pairs
var kv = str.trim().split('(')
return [kv[0], kv[1].split(SVG.regex.matrixElements).map(function(str){ return parseFloat(str) })]
})
// calculate every transformation into one matrix
.reduce(function(matrix, transform){
if(transform[0] == 'matrix') return matrix.multiply(arrayToMatrix(transform[1]))
return matrix[transform[0]].apply(matrix, transform[1])
}, new SVG.Matrix())
return matrix
} | [
"function",
"(",
")",
"{",
"var",
"matrix",
"=",
"(",
"this",
".",
"attr",
"(",
"'transform'",
")",
"||",
"''",
")",
"// split transformations",
".",
"split",
"(",
"/",
"\\)\\s*",
"/",
")",
".",
"slice",
"(",
"0",
",",
"-",
"1",
")",
".",
"map",
"(",
"function",
"(",
"str",
")",
"{",
"// generate key => value pairs",
"var",
"kv",
"=",
"str",
".",
"trim",
"(",
")",
".",
"split",
"(",
"'('",
")",
"return",
"[",
"kv",
"[",
"0",
"]",
",",
"kv",
"[",
"1",
"]",
".",
"split",
"(",
"SVG",
".",
"regex",
".",
"matrixElements",
")",
".",
"map",
"(",
"function",
"(",
"str",
")",
"{",
"return",
"parseFloat",
"(",
"str",
")",
"}",
")",
"]",
"}",
")",
"// calculate every transformation into one matrix",
".",
"reduce",
"(",
"function",
"(",
"matrix",
",",
"transform",
")",
"{",
"if",
"(",
"transform",
"[",
"0",
"]",
"==",
"'matrix'",
")",
"return",
"matrix",
".",
"multiply",
"(",
"arrayToMatrix",
"(",
"transform",
"[",
"1",
"]",
")",
")",
"return",
"matrix",
"[",
"transform",
"[",
"0",
"]",
"]",
".",
"apply",
"(",
"matrix",
",",
"transform",
"[",
"1",
"]",
")",
"}",
",",
"new",
"SVG",
".",
"Matrix",
"(",
")",
")",
"return",
"matrix",
"}"
] | merge the whole transformation chain into one matrix and returns it | [
"merge",
"the",
"whole",
"transformation",
"chain",
"into",
"one",
"matrix",
"and",
"returns",
"it"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L2713-L2731 | |
23,099 | jillix/svg.connectable.js | example/js/svg.js | function(parent) {
if(this == parent) return this
var ctm = this.screenCTM()
var temp = parent.rect(1,1)
var pCtm = temp.screenCTM().inverse()
temp.remove()
this.addTo(parent).untransform().transform(pCtm.multiply(ctm))
return this
} | javascript | function(parent) {
if(this == parent) return this
var ctm = this.screenCTM()
var temp = parent.rect(1,1)
var pCtm = temp.screenCTM().inverse()
temp.remove()
this.addTo(parent).untransform().transform(pCtm.multiply(ctm))
return this
} | [
"function",
"(",
"parent",
")",
"{",
"if",
"(",
"this",
"==",
"parent",
")",
"return",
"this",
"var",
"ctm",
"=",
"this",
".",
"screenCTM",
"(",
")",
"var",
"temp",
"=",
"parent",
".",
"rect",
"(",
"1",
",",
"1",
")",
"var",
"pCtm",
"=",
"temp",
".",
"screenCTM",
"(",
")",
".",
"inverse",
"(",
")",
"temp",
".",
"remove",
"(",
")",
"this",
".",
"addTo",
"(",
"parent",
")",
".",
"untransform",
"(",
")",
".",
"transform",
"(",
"pCtm",
".",
"multiply",
"(",
"ctm",
")",
")",
"return",
"this",
"}"
] | add an element to another parent without changing the visual representation on the screen | [
"add",
"an",
"element",
"to",
"another",
"parent",
"without",
"changing",
"the",
"visual",
"representation",
"on",
"the",
"screen"
] | 279b5a44112b99e777462650514ec1332ea5d202 | https://github.com/jillix/svg.connectable.js/blob/279b5a44112b99e777462650514ec1332ea5d202/example/js/svg.js#L2733-L2743 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.