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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,500 | mapbox/eslint-plugin-react-filenames | lib/util/Components.js | function(node) {
if (utils.isExplicitComponent(node)) {
return true;
}
if (!node.superClass) {
return false;
}
return new RegExp('^(' + pragma + '\\.)?(Pure)?Component$').test(sourceCode.getText(node.superClass));
} | javascript | function(node) {
if (utils.isExplicitComponent(node)) {
return true;
}
if (!node.superClass) {
return false;
}
return new RegExp('^(' + pragma + '\\.)?(Pure)?Component$').test(sourceCode.getText(node.superClass));
} | [
"function",
"(",
"node",
")",
"{",
"if",
"(",
"utils",
".",
"isExplicitComponent",
"(",
"node",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"node",
".",
"superClass",
")",
"{",
"return",
"false",
";",
"}",
"return",
"new",
"RegExp",
"(",
"'^('",
"+",
"pragma",
"+",
"'\\\\.)?(Pure)?Component$'",
")",
".",
"test",
"(",
"sourceCode",
".",
"getText",
"(",
"node",
".",
"superClass",
")",
")",
";",
"}"
] | Check if the node is a React ES6 component
@param {ASTNode} node The AST node being checked.
@returns {Boolean} True if the node is a React ES6 component, false if not | [
"Check",
"if",
"the",
"node",
"is",
"a",
"React",
"ES6",
"component"
] | d25030b865124f2f0555ba17b8f73a99c2111af0 | https://github.com/mapbox/eslint-plugin-react-filenames/blob/d25030b865124f2f0555ba17b8f73a99c2111af0/lib/util/Components.js#L166-L175 | |
20,501 | mapbox/eslint-plugin-react-filenames | lib/util/Components.js | function(node) {
var comment = sourceCode.getJSDocComment(node);
if (comment === null) {
return false;
}
var commentAst = doctrine.parse(comment.value, {
unwrap: true,
tags: ['extends', 'augments']
});
var relevantTags = commentAst.tags.filter(function(tag) {
return tag.name === 'React.Component' || tag.name === 'React.PureComponent';
});
return relevantTags.length > 0;
} | javascript | function(node) {
var comment = sourceCode.getJSDocComment(node);
if (comment === null) {
return false;
}
var commentAst = doctrine.parse(comment.value, {
unwrap: true,
tags: ['extends', 'augments']
});
var relevantTags = commentAst.tags.filter(function(tag) {
return tag.name === 'React.Component' || tag.name === 'React.PureComponent';
});
return relevantTags.length > 0;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"comment",
"=",
"sourceCode",
".",
"getJSDocComment",
"(",
"node",
")",
";",
"if",
"(",
"comment",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"var",
"commentAst",
"=",
"doctrine",
".",
"parse",
"(",
"comment",
".",
"value",
",",
"{",
"unwrap",
":",
"true",
",",
"tags",
":",
"[",
"'extends'",
",",
"'augments'",
"]",
"}",
")",
";",
"var",
"relevantTags",
"=",
"commentAst",
".",
"tags",
".",
"filter",
"(",
"function",
"(",
"tag",
")",
"{",
"return",
"tag",
".",
"name",
"===",
"'React.Component'",
"||",
"tag",
".",
"name",
"===",
"'React.PureComponent'",
";",
"}",
")",
";",
"return",
"relevantTags",
".",
"length",
">",
"0",
";",
"}"
] | Check if the node is explicitly declared as a descendant of a React Component
@param {ASTNode} node The AST node being checked (can be a ReturnStatement or an ArrowFunctionExpression).
@returns {Boolean} True if the node is explicitly declared as a descendant of a React Component, false if not | [
"Check",
"if",
"the",
"node",
"is",
"explicitly",
"declared",
"as",
"a",
"descendant",
"of",
"a",
"React",
"Component"
] | d25030b865124f2f0555ba17b8f73a99c2111af0 | https://github.com/mapbox/eslint-plugin-react-filenames/blob/d25030b865124f2f0555ba17b8f73a99c2111af0/lib/util/Components.js#L183-L200 | |
20,502 | mapbox/eslint-plugin-react-filenames | lib/util/Components.js | function (node) {
if (node.superClass) {
return new RegExp('^(' + pragma + '\\.)?PureComponent$').test(sourceCode.getText(node.superClass));
}
return false;
} | javascript | function (node) {
if (node.superClass) {
return new RegExp('^(' + pragma + '\\.)?PureComponent$').test(sourceCode.getText(node.superClass));
}
return false;
} | [
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"superClass",
")",
"{",
"return",
"new",
"RegExp",
"(",
"'^('",
"+",
"pragma",
"+",
"'\\\\.)?PureComponent$'",
")",
".",
"test",
"(",
"sourceCode",
".",
"getText",
"(",
"node",
".",
"superClass",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Checks to see if our component extends React.PureComponent
@param {ASTNode} node The AST node being checked.
@returns {Boolean} True if node extends React.PureComponent, false if not | [
"Checks",
"to",
"see",
"if",
"our",
"component",
"extends",
"React",
".",
"PureComponent"
] | d25030b865124f2f0555ba17b8f73a99c2111af0 | https://github.com/mapbox/eslint-plugin-react-filenames/blob/d25030b865124f2f0555ba17b8f73a99c2111af0/lib/util/Components.js#L208-L213 | |
20,503 | mapbox/eslint-plugin-react-filenames | lib/util/Components.js | function(node) {
if (!node.value || !node.value.body || !node.value.body.body) {
return false;
}
var i = node.value.body.body.length - 1;
for (; i >= 0; i--) {
if (node.value.body.body[i].type === 'ReturnStatement') {
return node.value.body.body[i];
}
}
return false;
} | javascript | function(node) {
if (!node.value || !node.value.body || !node.value.body.body) {
return false;
}
var i = node.value.body.body.length - 1;
for (; i >= 0; i--) {
if (node.value.body.body[i].type === 'ReturnStatement') {
return node.value.body.body[i];
}
}
return false;
} | [
"function",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
".",
"value",
"||",
"!",
"node",
".",
"value",
".",
"body",
"||",
"!",
"node",
".",
"value",
".",
"body",
".",
"body",
")",
"{",
"return",
"false",
";",
"}",
"var",
"i",
"=",
"node",
".",
"value",
".",
"body",
".",
"body",
".",
"length",
"-",
"1",
";",
"for",
"(",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"node",
".",
"value",
".",
"body",
".",
"body",
"[",
"i",
"]",
".",
"type",
"===",
"'ReturnStatement'",
")",
"{",
"return",
"node",
".",
"value",
".",
"body",
".",
"body",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Find a return statment in the current node
@param {ASTNode} ASTnode The AST node being checked | [
"Find",
"a",
"return",
"statment",
"in",
"the",
"current",
"node"
] | d25030b865124f2f0555ba17b8f73a99c2111af0 | https://github.com/mapbox/eslint-plugin-react-filenames/blob/d25030b865124f2f0555ba17b8f73a99c2111af0/lib/util/Components.js#L277-L288 | |
20,504 | mapbox/eslint-plugin-react-filenames | lib/util/getTokenBeforeClosingBracket.js | getTokenBeforeClosingBracket | function getTokenBeforeClosingBracket(node) {
var attributes = node.attributes;
if (attributes.length === 0) {
return node.name;
}
return attributes[attributes.length - 1];
} | javascript | function getTokenBeforeClosingBracket(node) {
var attributes = node.attributes;
if (attributes.length === 0) {
return node.name;
}
return attributes[attributes.length - 1];
} | [
"function",
"getTokenBeforeClosingBracket",
"(",
"node",
")",
"{",
"var",
"attributes",
"=",
"node",
".",
"attributes",
";",
"if",
"(",
"attributes",
".",
"length",
"===",
"0",
")",
"{",
"return",
"node",
".",
"name",
";",
"}",
"return",
"attributes",
"[",
"attributes",
".",
"length",
"-",
"1",
"]",
";",
"}"
] | Find the token before the closing bracket.
@param {ASTNode} node - The JSX element node.
@returns {Token} The token before the closing bracket. | [
"Find",
"the",
"token",
"before",
"the",
"closing",
"bracket",
"."
] | d25030b865124f2f0555ba17b8f73a99c2111af0 | https://github.com/mapbox/eslint-plugin-react-filenames/blob/d25030b865124f2f0555ba17b8f73a99c2111af0/lib/util/getTokenBeforeClosingBracket.js#L8-L14 |
20,505 | espruino/EspruinoTools | libs/targz.js | function (chunks, start, end) {
var soff=0, eoff=0, i=0, j=0;
for (i=0; i<chunks.length; i++) {
if (soff + chunks[i].length > start)
break;
soff += chunks[i].length;
}
var strs = [];
eoff = soff;
for (j=i; j<chunks.length; j++) {
strs.push(chunks[j]);
if (eoff + chunks[j].length > end)
break;
eoff += chunks[j].length;
}
var s = strs.join('');
return s.substring(start-soff, start-soff+(end-start));
} | javascript | function (chunks, start, end) {
var soff=0, eoff=0, i=0, j=0;
for (i=0; i<chunks.length; i++) {
if (soff + chunks[i].length > start)
break;
soff += chunks[i].length;
}
var strs = [];
eoff = soff;
for (j=i; j<chunks.length; j++) {
strs.push(chunks[j]);
if (eoff + chunks[j].length > end)
break;
eoff += chunks[j].length;
}
var s = strs.join('');
return s.substring(start-soff, start-soff+(end-start));
} | [
"function",
"(",
"chunks",
",",
"start",
",",
"end",
")",
"{",
"var",
"soff",
"=",
"0",
",",
"eoff",
"=",
"0",
",",
"i",
"=",
"0",
",",
"j",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"chunks",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"soff",
"+",
"chunks",
"[",
"i",
"]",
".",
"length",
">",
"start",
")",
"break",
";",
"soff",
"+=",
"chunks",
"[",
"i",
"]",
".",
"length",
";",
"}",
"var",
"strs",
"=",
"[",
"]",
";",
"eoff",
"=",
"soff",
";",
"for",
"(",
"j",
"=",
"i",
";",
"j",
"<",
"chunks",
".",
"length",
";",
"j",
"++",
")",
"{",
"strs",
".",
"push",
"(",
"chunks",
"[",
"j",
"]",
")",
";",
"if",
"(",
"eoff",
"+",
"chunks",
"[",
"j",
"]",
".",
"length",
">",
"end",
")",
"break",
";",
"eoff",
"+=",
"chunks",
"[",
"j",
"]",
".",
"length",
";",
"}",
"var",
"s",
"=",
"strs",
".",
"join",
"(",
"''",
")",
";",
"return",
"s",
".",
"substring",
"(",
"start",
"-",
"soff",
",",
"start",
"-",
"soff",
"+",
"(",
"end",
"-",
"start",
")",
")",
";",
"}"
] | extract substring from an array of strings | [
"extract",
"substring",
"from",
"an",
"array",
"of",
"strings"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/libs/targz.js#L113-L130 | |
20,506 | espruino/EspruinoTools | plugins/minify.js | minifyCodeEsprima | function minifyCodeEsprima(code,callback,description) {
if ((typeof esprima == "undefined") ||
(typeof esmangle == "undefined") ||
(typeof escodegen == "undefined")) {
console.warn("esprima/esmangle/escodegen not defined - not minifying")
return callback(code);
}
var code, syntax, option, str, before, after;
var options = {};
options["mangle"] = Espruino.Config.MINIFICATION_Mangle;
options["remove-unreachable-branch"] = Espruino.Config.MINIFICATION_Unreachable;
options["remove-unused-vars"] = Espruino.Config.MINIFICATION_Unused;
options["fold-constant"] = Espruino.Config.MINIFICATION_Literal;
options["eliminate-dead-code"] = Espruino.Config.MINIFICATION_DeadCode;
option = {format: {indent: {style: ''},quotes: 'auto',compact: true}};
str = '';
try {
before = code.length;
syntax = esprima.parse(code, { raw: true, loc: true });
syntax = obfuscate(syntax,options);
code = escodegen.generate(syntax, option);
after = code.length;
if (before > after) {
Espruino.Core.Notifications.info('No errors'+description+'. Minified ' + before + ' bytes to ' + after + ' bytes.');
} else {
Espruino.Core.Notifications.info('Can not minify further'+description+', code is already optimized.');
}
callback(code);
} catch (e) {
Espruino.Core.Notifications.error(e.toString()+description);
console.error(e.stack);
callback(code);
} finally { }
} | javascript | function minifyCodeEsprima(code,callback,description) {
if ((typeof esprima == "undefined") ||
(typeof esmangle == "undefined") ||
(typeof escodegen == "undefined")) {
console.warn("esprima/esmangle/escodegen not defined - not minifying")
return callback(code);
}
var code, syntax, option, str, before, after;
var options = {};
options["mangle"] = Espruino.Config.MINIFICATION_Mangle;
options["remove-unreachable-branch"] = Espruino.Config.MINIFICATION_Unreachable;
options["remove-unused-vars"] = Espruino.Config.MINIFICATION_Unused;
options["fold-constant"] = Espruino.Config.MINIFICATION_Literal;
options["eliminate-dead-code"] = Espruino.Config.MINIFICATION_DeadCode;
option = {format: {indent: {style: ''},quotes: 'auto',compact: true}};
str = '';
try {
before = code.length;
syntax = esprima.parse(code, { raw: true, loc: true });
syntax = obfuscate(syntax,options);
code = escodegen.generate(syntax, option);
after = code.length;
if (before > after) {
Espruino.Core.Notifications.info('No errors'+description+'. Minified ' + before + ' bytes to ' + after + ' bytes.');
} else {
Espruino.Core.Notifications.info('Can not minify further'+description+', code is already optimized.');
}
callback(code);
} catch (e) {
Espruino.Core.Notifications.error(e.toString()+description);
console.error(e.stack);
callback(code);
} finally { }
} | [
"function",
"minifyCodeEsprima",
"(",
"code",
",",
"callback",
",",
"description",
")",
"{",
"if",
"(",
"(",
"typeof",
"esprima",
"==",
"\"undefined\"",
")",
"||",
"(",
"typeof",
"esmangle",
"==",
"\"undefined\"",
")",
"||",
"(",
"typeof",
"escodegen",
"==",
"\"undefined\"",
")",
")",
"{",
"console",
".",
"warn",
"(",
"\"esprima/esmangle/escodegen not defined - not minifying\"",
")",
"return",
"callback",
"(",
"code",
")",
";",
"}",
"var",
"code",
",",
"syntax",
",",
"option",
",",
"str",
",",
"before",
",",
"after",
";",
"var",
"options",
"=",
"{",
"}",
";",
"options",
"[",
"\"mangle\"",
"]",
"=",
"Espruino",
".",
"Config",
".",
"MINIFICATION_Mangle",
";",
"options",
"[",
"\"remove-unreachable-branch\"",
"]",
"=",
"Espruino",
".",
"Config",
".",
"MINIFICATION_Unreachable",
";",
"options",
"[",
"\"remove-unused-vars\"",
"]",
"=",
"Espruino",
".",
"Config",
".",
"MINIFICATION_Unused",
";",
"options",
"[",
"\"fold-constant\"",
"]",
"=",
"Espruino",
".",
"Config",
".",
"MINIFICATION_Literal",
";",
"options",
"[",
"\"eliminate-dead-code\"",
"]",
"=",
"Espruino",
".",
"Config",
".",
"MINIFICATION_DeadCode",
";",
"option",
"=",
"{",
"format",
":",
"{",
"indent",
":",
"{",
"style",
":",
"''",
"}",
",",
"quotes",
":",
"'auto'",
",",
"compact",
":",
"true",
"}",
"}",
";",
"str",
"=",
"''",
";",
"try",
"{",
"before",
"=",
"code",
".",
"length",
";",
"syntax",
"=",
"esprima",
".",
"parse",
"(",
"code",
",",
"{",
"raw",
":",
"true",
",",
"loc",
":",
"true",
"}",
")",
";",
"syntax",
"=",
"obfuscate",
"(",
"syntax",
",",
"options",
")",
";",
"code",
"=",
"escodegen",
".",
"generate",
"(",
"syntax",
",",
"option",
")",
";",
"after",
"=",
"code",
".",
"length",
";",
"if",
"(",
"before",
">",
"after",
")",
"{",
"Espruino",
".",
"Core",
".",
"Notifications",
".",
"info",
"(",
"'No errors'",
"+",
"description",
"+",
"'. Minified '",
"+",
"before",
"+",
"' bytes to '",
"+",
"after",
"+",
"' bytes.'",
")",
";",
"}",
"else",
"{",
"Espruino",
".",
"Core",
".",
"Notifications",
".",
"info",
"(",
"'Can not minify further'",
"+",
"description",
"+",
"', code is already optimized.'",
")",
";",
"}",
"callback",
"(",
"code",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"Espruino",
".",
"Core",
".",
"Notifications",
".",
"error",
"(",
"e",
".",
"toString",
"(",
")",
"+",
"description",
")",
";",
"console",
".",
"error",
"(",
"e",
".",
"stack",
")",
";",
"callback",
"(",
"code",
")",
";",
"}",
"finally",
"{",
"}",
"}"
] | Use the 'offline' Esprima compile | [
"Use",
"the",
"offline",
"Esprima",
"compile"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/plugins/minify.js#L118-L152 |
20,507 | espruino/EspruinoTools | plugins/minify.js | minifyCodeGoogle | function minifyCodeGoogle(code, callback, minificationLevel, description){
for (var i in minifyCache) {
var item = minifyCache[i];
if (item.code==code && item.level==minificationLevel) {
console.log("Found code in minification cache - using that"+description);
// move to front of cache
minifyCache.splice(i,1); // remove old
minifyCache.push(item); // add at front
// callback
callback(item.minified);
return;
}
}
closureCompilerGoogle(code, minificationLevel, 'compiled_code', function(minified) {
if (minified.trim()!="") {
Espruino.Core.Notifications.info('No errors'+description+'. Minifying ' + code.length + ' bytes to ' + minified.length + ' bytes');
if (minifyCache.length>100)
minifyCache = minifyCache.slice(-100);
minifyCache.push({ level : minificationLevel, code : code, minified : minified });
callback(minified);
} else {
Espruino.Core.Notifications.warning("Errors while minifying"+description+" - sending unminified code.");
callback(code);
// get errors...
closureCompilerGoogle(code, minificationLevel, 'errors',function(errors) {
errors.split("\n").forEach(function (err) {
if (err.trim()!="")
Espruino.Core.Notifications.error(err.trim()+description);
});
});
}
});
} | javascript | function minifyCodeGoogle(code, callback, minificationLevel, description){
for (var i in minifyCache) {
var item = minifyCache[i];
if (item.code==code && item.level==minificationLevel) {
console.log("Found code in minification cache - using that"+description);
// move to front of cache
minifyCache.splice(i,1); // remove old
minifyCache.push(item); // add at front
// callback
callback(item.minified);
return;
}
}
closureCompilerGoogle(code, minificationLevel, 'compiled_code', function(minified) {
if (minified.trim()!="") {
Espruino.Core.Notifications.info('No errors'+description+'. Minifying ' + code.length + ' bytes to ' + minified.length + ' bytes');
if (minifyCache.length>100)
minifyCache = minifyCache.slice(-100);
minifyCache.push({ level : minificationLevel, code : code, minified : minified });
callback(minified);
} else {
Espruino.Core.Notifications.warning("Errors while minifying"+description+" - sending unminified code.");
callback(code);
// get errors...
closureCompilerGoogle(code, minificationLevel, 'errors',function(errors) {
errors.split("\n").forEach(function (err) {
if (err.trim()!="")
Espruino.Core.Notifications.error(err.trim()+description);
});
});
}
});
} | [
"function",
"minifyCodeGoogle",
"(",
"code",
",",
"callback",
",",
"minificationLevel",
",",
"description",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"minifyCache",
")",
"{",
"var",
"item",
"=",
"minifyCache",
"[",
"i",
"]",
";",
"if",
"(",
"item",
".",
"code",
"==",
"code",
"&&",
"item",
".",
"level",
"==",
"minificationLevel",
")",
"{",
"console",
".",
"log",
"(",
"\"Found code in minification cache - using that\"",
"+",
"description",
")",
";",
"// move to front of cache",
"minifyCache",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"// remove old",
"minifyCache",
".",
"push",
"(",
"item",
")",
";",
"// add at front",
"// callback",
"callback",
"(",
"item",
".",
"minified",
")",
";",
"return",
";",
"}",
"}",
"closureCompilerGoogle",
"(",
"code",
",",
"minificationLevel",
",",
"'compiled_code'",
",",
"function",
"(",
"minified",
")",
"{",
"if",
"(",
"minified",
".",
"trim",
"(",
")",
"!=",
"\"\"",
")",
"{",
"Espruino",
".",
"Core",
".",
"Notifications",
".",
"info",
"(",
"'No errors'",
"+",
"description",
"+",
"'. Minifying '",
"+",
"code",
".",
"length",
"+",
"' bytes to '",
"+",
"minified",
".",
"length",
"+",
"' bytes'",
")",
";",
"if",
"(",
"minifyCache",
".",
"length",
">",
"100",
")",
"minifyCache",
"=",
"minifyCache",
".",
"slice",
"(",
"-",
"100",
")",
";",
"minifyCache",
".",
"push",
"(",
"{",
"level",
":",
"minificationLevel",
",",
"code",
":",
"code",
",",
"minified",
":",
"minified",
"}",
")",
";",
"callback",
"(",
"minified",
")",
";",
"}",
"else",
"{",
"Espruino",
".",
"Core",
".",
"Notifications",
".",
"warning",
"(",
"\"Errors while minifying\"",
"+",
"description",
"+",
"\" - sending unminified code.\"",
")",
";",
"callback",
"(",
"code",
")",
";",
"// get errors...",
"closureCompilerGoogle",
"(",
"code",
",",
"minificationLevel",
",",
"'errors'",
",",
"function",
"(",
"errors",
")",
"{",
"errors",
".",
"split",
"(",
"\"\\n\"",
")",
".",
"forEach",
"(",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
"trim",
"(",
")",
"!=",
"\"\"",
")",
"Espruino",
".",
"Core",
".",
"Notifications",
".",
"error",
"(",
"err",
".",
"trim",
"(",
")",
"+",
"description",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"}"
] | Use the 'online' Closure compiler | [
"Use",
"the",
"online",
"Closure",
"compiler"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/plugins/minify.js#L209-L241 |
20,508 | espruino/EspruinoTools | espruino.js | initModule | function initModule(modName, mod) {
console.log("Initialising "+modName);
if (mod.init !== undefined)
mod.init();
} | javascript | function initModule(modName, mod) {
console.log("Initialising "+modName);
if (mod.init !== undefined)
mod.init();
} | [
"function",
"initModule",
"(",
"modName",
",",
"mod",
")",
"{",
"console",
".",
"log",
"(",
"\"Initialising \"",
"+",
"modName",
")",
";",
"if",
"(",
"mod",
".",
"init",
"!==",
"undefined",
")",
"mod",
".",
"init",
"(",
")",
";",
"}"
] | Initialise all modules | [
"Initialise",
"all",
"modules"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/espruino.js#L45-L49 |
20,509 | espruino/EspruinoTools | espruino.js | callProcessor | function callProcessor(eventType, data, callback) {
var p = processors[eventType];
// no processors
if (p===undefined || p.length==0) {
if (callback!==undefined) callback(data);
return;
}
// now go through all processors
var n = 0;
var cbCalled = false;
var cb = function(inData) {
if (cbCalled) throw new Error("Internal error in "+eventType+" processor. Callback is called TWICE.");
cbCalled = true;
if (n < p.length) {
cbCalled = false;
p[n++](inData, cb);
} else {
if (callback!==undefined) callback(inData);
}
};
cb(data);
} | javascript | function callProcessor(eventType, data, callback) {
var p = processors[eventType];
// no processors
if (p===undefined || p.length==0) {
if (callback!==undefined) callback(data);
return;
}
// now go through all processors
var n = 0;
var cbCalled = false;
var cb = function(inData) {
if (cbCalled) throw new Error("Internal error in "+eventType+" processor. Callback is called TWICE.");
cbCalled = true;
if (n < p.length) {
cbCalled = false;
p[n++](inData, cb);
} else {
if (callback!==undefined) callback(inData);
}
};
cb(data);
} | [
"function",
"callProcessor",
"(",
"eventType",
",",
"data",
",",
"callback",
")",
"{",
"var",
"p",
"=",
"processors",
"[",
"eventType",
"]",
";",
"// no processors",
"if",
"(",
"p",
"===",
"undefined",
"||",
"p",
".",
"length",
"==",
"0",
")",
"{",
"if",
"(",
"callback",
"!==",
"undefined",
")",
"callback",
"(",
"data",
")",
";",
"return",
";",
"}",
"// now go through all processors",
"var",
"n",
"=",
"0",
";",
"var",
"cbCalled",
"=",
"false",
";",
"var",
"cb",
"=",
"function",
"(",
"inData",
")",
"{",
"if",
"(",
"cbCalled",
")",
"throw",
"new",
"Error",
"(",
"\"Internal error in \"",
"+",
"eventType",
"+",
"\" processor. Callback is called TWICE.\"",
")",
";",
"cbCalled",
"=",
"true",
";",
"if",
"(",
"n",
"<",
"p",
".",
"length",
")",
"{",
"cbCalled",
"=",
"false",
";",
"p",
"[",
"n",
"++",
"]",
"(",
"inData",
",",
"cb",
")",
";",
"}",
"else",
"{",
"if",
"(",
"callback",
"!==",
"undefined",
")",
"callback",
"(",
"inData",
")",
";",
"}",
"}",
";",
"cb",
"(",
"data",
")",
";",
"}"
] | Call a processor function | [
"Call",
"a",
"processor",
"function"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/espruino.js#L80-L101 |
20,510 | espruino/EspruinoTools | core/config.js | getSections | function getSections() {
var sections = [];
// add sections we know about
for (var name in builtinSections)
sections.push(builtinSections[name]);
// add other sections
for (var i in Espruino.Core.Config.data) {
var c = Espruino.Core.Config.data[i];
var found = false;
for (var s in sections)
if (sections[s].name == c.section)
found = true;
if (!found) {
console.warn("Section named "+c.section+" was not added with Config.addSection");
sections[c.section] = {
name : c.section,
sortOrder : 0
};
}
}
// Now sort by sortOrder
sections.sort(function (a,b) { return a.sortOrder - b.sortOrder; });
return sections;
} | javascript | function getSections() {
var sections = [];
// add sections we know about
for (var name in builtinSections)
sections.push(builtinSections[name]);
// add other sections
for (var i in Espruino.Core.Config.data) {
var c = Espruino.Core.Config.data[i];
var found = false;
for (var s in sections)
if (sections[s].name == c.section)
found = true;
if (!found) {
console.warn("Section named "+c.section+" was not added with Config.addSection");
sections[c.section] = {
name : c.section,
sortOrder : 0
};
}
}
// Now sort by sortOrder
sections.sort(function (a,b) { return a.sortOrder - b.sortOrder; });
return sections;
} | [
"function",
"getSections",
"(",
")",
"{",
"var",
"sections",
"=",
"[",
"]",
";",
"// add sections we know about",
"for",
"(",
"var",
"name",
"in",
"builtinSections",
")",
"sections",
".",
"push",
"(",
"builtinSections",
"[",
"name",
"]",
")",
";",
"// add other sections",
"for",
"(",
"var",
"i",
"in",
"Espruino",
".",
"Core",
".",
"Config",
".",
"data",
")",
"{",
"var",
"c",
"=",
"Espruino",
".",
"Core",
".",
"Config",
".",
"data",
"[",
"i",
"]",
";",
"var",
"found",
"=",
"false",
";",
"for",
"(",
"var",
"s",
"in",
"sections",
")",
"if",
"(",
"sections",
"[",
"s",
"]",
".",
"name",
"==",
"c",
".",
"section",
")",
"found",
"=",
"true",
";",
"if",
"(",
"!",
"found",
")",
"{",
"console",
".",
"warn",
"(",
"\"Section named \"",
"+",
"c",
".",
"section",
"+",
"\" was not added with Config.addSection\"",
")",
";",
"sections",
"[",
"c",
".",
"section",
"]",
"=",
"{",
"name",
":",
"c",
".",
"section",
",",
"sortOrder",
":",
"0",
"}",
";",
"}",
"}",
"// Now sort by sortOrder",
"sections",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
".",
"sortOrder",
"-",
"b",
".",
"sortOrder",
";",
"}",
")",
";",
"return",
"sections",
";",
"}"
] | Get an object containing information on all 'sections' used in all the configs | [
"Get",
"an",
"object",
"containing",
"information",
"on",
"all",
"sections",
"used",
"in",
"all",
"the",
"configs"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/config.js#L122-L148 |
20,511 | espruino/EspruinoTools | core/utils.js | countBrackets | function countBrackets(str) {
var lex = getLexer(str);
var brackets = 0;
var tok = lex.next();
while (tok!==undefined) {
if (tok.str=="(" || tok.str=="{" || tok.str=="[") brackets++;
if (tok.str==")" || tok.str=="}" || tok.str=="]") brackets--;
tok = lex.next();
}
return brackets;
} | javascript | function countBrackets(str) {
var lex = getLexer(str);
var brackets = 0;
var tok = lex.next();
while (tok!==undefined) {
if (tok.str=="(" || tok.str=="{" || tok.str=="[") brackets++;
if (tok.str==")" || tok.str=="}" || tok.str=="]") brackets--;
tok = lex.next();
}
return brackets;
} | [
"function",
"countBrackets",
"(",
"str",
")",
"{",
"var",
"lex",
"=",
"getLexer",
"(",
"str",
")",
";",
"var",
"brackets",
"=",
"0",
";",
"var",
"tok",
"=",
"lex",
".",
"next",
"(",
")",
";",
"while",
"(",
"tok",
"!==",
"undefined",
")",
"{",
"if",
"(",
"tok",
".",
"str",
"==",
"\"(\"",
"||",
"tok",
".",
"str",
"==",
"\"{\"",
"||",
"tok",
".",
"str",
"==",
"\"[\"",
")",
"brackets",
"++",
";",
"if",
"(",
"tok",
".",
"str",
"==",
"\")\"",
"||",
"tok",
".",
"str",
"==",
"\"}\"",
"||",
"tok",
".",
"str",
"==",
"\"]\"",
")",
"brackets",
"--",
";",
"tok",
"=",
"lex",
".",
"next",
"(",
")",
";",
"}",
"return",
"brackets",
";",
"}"
] | Count brackets in a string - will be 0 if all are closed | [
"Count",
"brackets",
"in",
"a",
"string",
"-",
"will",
"be",
"0",
"if",
"all",
"are",
"closed"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/utils.js#L171-L181 |
20,512 | espruino/EspruinoTools | core/utils.js | getEspruinoPrompt | function getEspruinoPrompt(callback) {
if (Espruino.Core.Terminal!==undefined &&
Espruino.Core.Terminal.getTerminalLine()==">") {
console.log("Found a prompt... great!");
return callback();
}
var receivedData = "";
var prevReader = Espruino.Core.Serial.startListening(function (readData) {
var bufView = new Uint8Array(readData);
for(var i = 0; i < bufView.length; i++) {
receivedData += String.fromCharCode(bufView[i]);
}
if (receivedData[receivedData.length-1] == ">") {
if (receivedData.substr(-6)=="debug>") {
console.log("Got debug> - sending Ctrl-C to break out and we'll be good");
Espruino.Core.Serial.write('\x03');
} else {
if (receivedData == "\r\n=undefined\r\n>")
receivedData=""; // this was just what we expected - so ignore it
console.log("Received a prompt after sending newline... good!");
clearTimeout(timeout);
nextStep();
}
}
});
// timeout in case something goes wrong...
var hadToBreak = false;
var timeout = setTimeout(function() {
console.log("Got "+JSON.stringify(receivedData));
// if we haven't had the prompt displayed for us, Ctrl-C to break out of what we had
console.log("No Prompt found, got "+JSON.stringify(receivedData[receivedData.length-1])+" - issuing Ctrl-C to try and break out");
Espruino.Core.Serial.write('\x03');
hadToBreak = true;
timeout = setTimeout(function() {
console.log("Still no prompt - issuing another Ctrl-C");
Espruino.Core.Serial.write('\x03');
nextStep();
},500);
},500);
// when we're done...
var nextStep = function() {
// send data to console anyway...
if(prevReader) prevReader(receivedData);
receivedData = "";
// start the previous reader listening again
Espruino.Core.Serial.startListening(prevReader);
// call our callback
if (callback) callback(hadToBreak);
};
// send a newline, and we hope we'll see '=undefined\r\n>'
Espruino.Core.Serial.write('\n');
} | javascript | function getEspruinoPrompt(callback) {
if (Espruino.Core.Terminal!==undefined &&
Espruino.Core.Terminal.getTerminalLine()==">") {
console.log("Found a prompt... great!");
return callback();
}
var receivedData = "";
var prevReader = Espruino.Core.Serial.startListening(function (readData) {
var bufView = new Uint8Array(readData);
for(var i = 0; i < bufView.length; i++) {
receivedData += String.fromCharCode(bufView[i]);
}
if (receivedData[receivedData.length-1] == ">") {
if (receivedData.substr(-6)=="debug>") {
console.log("Got debug> - sending Ctrl-C to break out and we'll be good");
Espruino.Core.Serial.write('\x03');
} else {
if (receivedData == "\r\n=undefined\r\n>")
receivedData=""; // this was just what we expected - so ignore it
console.log("Received a prompt after sending newline... good!");
clearTimeout(timeout);
nextStep();
}
}
});
// timeout in case something goes wrong...
var hadToBreak = false;
var timeout = setTimeout(function() {
console.log("Got "+JSON.stringify(receivedData));
// if we haven't had the prompt displayed for us, Ctrl-C to break out of what we had
console.log("No Prompt found, got "+JSON.stringify(receivedData[receivedData.length-1])+" - issuing Ctrl-C to try and break out");
Espruino.Core.Serial.write('\x03');
hadToBreak = true;
timeout = setTimeout(function() {
console.log("Still no prompt - issuing another Ctrl-C");
Espruino.Core.Serial.write('\x03');
nextStep();
},500);
},500);
// when we're done...
var nextStep = function() {
// send data to console anyway...
if(prevReader) prevReader(receivedData);
receivedData = "";
// start the previous reader listening again
Espruino.Core.Serial.startListening(prevReader);
// call our callback
if (callback) callback(hadToBreak);
};
// send a newline, and we hope we'll see '=undefined\r\n>'
Espruino.Core.Serial.write('\n');
} | [
"function",
"getEspruinoPrompt",
"(",
"callback",
")",
"{",
"if",
"(",
"Espruino",
".",
"Core",
".",
"Terminal",
"!==",
"undefined",
"&&",
"Espruino",
".",
"Core",
".",
"Terminal",
".",
"getTerminalLine",
"(",
")",
"==",
"\">\"",
")",
"{",
"console",
".",
"log",
"(",
"\"Found a prompt... great!\"",
")",
";",
"return",
"callback",
"(",
")",
";",
"}",
"var",
"receivedData",
"=",
"\"\"",
";",
"var",
"prevReader",
"=",
"Espruino",
".",
"Core",
".",
"Serial",
".",
"startListening",
"(",
"function",
"(",
"readData",
")",
"{",
"var",
"bufView",
"=",
"new",
"Uint8Array",
"(",
"readData",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"bufView",
".",
"length",
";",
"i",
"++",
")",
"{",
"receivedData",
"+=",
"String",
".",
"fromCharCode",
"(",
"bufView",
"[",
"i",
"]",
")",
";",
"}",
"if",
"(",
"receivedData",
"[",
"receivedData",
".",
"length",
"-",
"1",
"]",
"==",
"\">\"",
")",
"{",
"if",
"(",
"receivedData",
".",
"substr",
"(",
"-",
"6",
")",
"==",
"\"debug>\"",
")",
"{",
"console",
".",
"log",
"(",
"\"Got debug> - sending Ctrl-C to break out and we'll be good\"",
")",
";",
"Espruino",
".",
"Core",
".",
"Serial",
".",
"write",
"(",
"'\\x03'",
")",
";",
"}",
"else",
"{",
"if",
"(",
"receivedData",
"==",
"\"\\r\\n=undefined\\r\\n>\"",
")",
"receivedData",
"=",
"\"\"",
";",
"// this was just what we expected - so ignore it",
"console",
".",
"log",
"(",
"\"Received a prompt after sending newline... good!\"",
")",
";",
"clearTimeout",
"(",
"timeout",
")",
";",
"nextStep",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"// timeout in case something goes wrong...",
"var",
"hadToBreak",
"=",
"false",
";",
"var",
"timeout",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"\"Got \"",
"+",
"JSON",
".",
"stringify",
"(",
"receivedData",
")",
")",
";",
"// if we haven't had the prompt displayed for us, Ctrl-C to break out of what we had",
"console",
".",
"log",
"(",
"\"No Prompt found, got \"",
"+",
"JSON",
".",
"stringify",
"(",
"receivedData",
"[",
"receivedData",
".",
"length",
"-",
"1",
"]",
")",
"+",
"\" - issuing Ctrl-C to try and break out\"",
")",
";",
"Espruino",
".",
"Core",
".",
"Serial",
".",
"write",
"(",
"'\\x03'",
")",
";",
"hadToBreak",
"=",
"true",
";",
"timeout",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"\"Still no prompt - issuing another Ctrl-C\"",
")",
";",
"Espruino",
".",
"Core",
".",
"Serial",
".",
"write",
"(",
"'\\x03'",
")",
";",
"nextStep",
"(",
")",
";",
"}",
",",
"500",
")",
";",
"}",
",",
"500",
")",
";",
"// when we're done...",
"var",
"nextStep",
"=",
"function",
"(",
")",
"{",
"// send data to console anyway...",
"if",
"(",
"prevReader",
")",
"prevReader",
"(",
"receivedData",
")",
";",
"receivedData",
"=",
"\"\"",
";",
"// start the previous reader listening again",
"Espruino",
".",
"Core",
".",
"Serial",
".",
"startListening",
"(",
"prevReader",
")",
";",
"// call our callback",
"if",
"(",
"callback",
")",
"callback",
"(",
"hadToBreak",
")",
";",
"}",
";",
"// send a newline, and we hope we'll see '=undefined\\r\\n>'",
"Espruino",
".",
"Core",
".",
"Serial",
".",
"write",
"(",
"'\\n'",
")",
";",
"}"
] | Try and get a prompt from Espruino - if we don't see one, issue Ctrl-C
and hope it comes back. Calls callback with first argument true if it
had to Ctrl-C out | [
"Try",
"and",
"get",
"a",
"prompt",
"from",
"Espruino",
"-",
"if",
"we",
"don",
"t",
"see",
"one",
"issue",
"Ctrl",
"-",
"C",
"and",
"hope",
"it",
"comes",
"back",
".",
"Calls",
"callback",
"with",
"first",
"argument",
"true",
"if",
"it",
"had",
"to",
"Ctrl",
"-",
"C",
"out"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/utils.js#L186-L239 |
20,513 | espruino/EspruinoTools | core/utils.js | executeExpression | function executeExpression(expressionToExecute, callback) {
var receivedData = "";
var hadDataSinceTimeout = false;
function getProcessInfo(expressionToExecute, callback) {
var prevReader = Espruino.Core.Serial.startListening(function (readData) {
var bufView = new Uint8Array(readData);
for(var i = 0; i < bufView.length; i++) {
receivedData += String.fromCharCode(bufView[i]);
}
// check if we got what we wanted
var startProcess = receivedData.indexOf("< <<");
var endProcess = receivedData.indexOf(">> >", startProcess);
if(startProcess >= 0 && endProcess > 0){
// All good - get the data!
var result = receivedData.substring(startProcess + 4,endProcess);
console.log("Got "+JSON.stringify(receivedData));
// strip out the text we found
receivedData = receivedData.substr(0,startProcess) + receivedData.substr(endProcess+4);
// Now stop time timeout
if (timeout) clearInterval(timeout);
timeout = "cancelled";
// Do the next stuff
nextStep(result);
} else if (startProcess >= 0) {
// we got some data - so keep waiting...
hadDataSinceTimeout = true;
}
});
// when we're done...
var nextStep = function(result) {
// start the previous reader listing again
Espruino.Core.Serial.startListening(prevReader);
// forward the original text to the previous reader
if(prevReader) prevReader(receivedData);
// run the callback
callback(result);
};
var timeout = undefined;
// Don't Ctrl-C, as we've already got ourselves a prompt with Espruino.Core.Utils.getEspruinoPrompt
Espruino.Core.Serial.write('\x10print("<","<<",JSON.stringify('+expressionToExecute+'),">>",">")\n',
undefined, function() {
// now it's sent, wait for data
var maxTimeout = 10; // seconds - how long we wait if we're getting data
var minTimeout = 2; // seconds - how long we wait if we're not getting data
var pollInterval = 500; // milliseconds
var timeoutSeconds = 0;
if (timeout != "cancelled")
timeout = setInterval(function onTimeout(){
timeoutSeconds += pollInterval/1000;
// if we're still getting data, keep waiting for up to 10 secs
if (hadDataSinceTimeout && timeoutSeconds<maxTimeout) {
hadDataSinceTimeout = false;
} else if (timeoutSeconds > minTimeout) {
// No data yet...
// OR we keep getting data for > maxTimeout seconds
clearInterval(timeout);
console.warn("No result found for "+JSON.stringify(expressionToExecute)+" - just got "+JSON.stringify(receivedData));
nextStep(undefined);
}
}, pollInterval);
});
}
if(Espruino.Core.Serial.isConnected()){
Espruino.Core.Utils.getEspruinoPrompt(function() {
getProcessInfo(expressionToExecute, callback);
});
} else {
console.error("executeExpression called when not connected!");
callback(undefined);
}
} | javascript | function executeExpression(expressionToExecute, callback) {
var receivedData = "";
var hadDataSinceTimeout = false;
function getProcessInfo(expressionToExecute, callback) {
var prevReader = Espruino.Core.Serial.startListening(function (readData) {
var bufView = new Uint8Array(readData);
for(var i = 0; i < bufView.length; i++) {
receivedData += String.fromCharCode(bufView[i]);
}
// check if we got what we wanted
var startProcess = receivedData.indexOf("< <<");
var endProcess = receivedData.indexOf(">> >", startProcess);
if(startProcess >= 0 && endProcess > 0){
// All good - get the data!
var result = receivedData.substring(startProcess + 4,endProcess);
console.log("Got "+JSON.stringify(receivedData));
// strip out the text we found
receivedData = receivedData.substr(0,startProcess) + receivedData.substr(endProcess+4);
// Now stop time timeout
if (timeout) clearInterval(timeout);
timeout = "cancelled";
// Do the next stuff
nextStep(result);
} else if (startProcess >= 0) {
// we got some data - so keep waiting...
hadDataSinceTimeout = true;
}
});
// when we're done...
var nextStep = function(result) {
// start the previous reader listing again
Espruino.Core.Serial.startListening(prevReader);
// forward the original text to the previous reader
if(prevReader) prevReader(receivedData);
// run the callback
callback(result);
};
var timeout = undefined;
// Don't Ctrl-C, as we've already got ourselves a prompt with Espruino.Core.Utils.getEspruinoPrompt
Espruino.Core.Serial.write('\x10print("<","<<",JSON.stringify('+expressionToExecute+'),">>",">")\n',
undefined, function() {
// now it's sent, wait for data
var maxTimeout = 10; // seconds - how long we wait if we're getting data
var minTimeout = 2; // seconds - how long we wait if we're not getting data
var pollInterval = 500; // milliseconds
var timeoutSeconds = 0;
if (timeout != "cancelled")
timeout = setInterval(function onTimeout(){
timeoutSeconds += pollInterval/1000;
// if we're still getting data, keep waiting for up to 10 secs
if (hadDataSinceTimeout && timeoutSeconds<maxTimeout) {
hadDataSinceTimeout = false;
} else if (timeoutSeconds > minTimeout) {
// No data yet...
// OR we keep getting data for > maxTimeout seconds
clearInterval(timeout);
console.warn("No result found for "+JSON.stringify(expressionToExecute)+" - just got "+JSON.stringify(receivedData));
nextStep(undefined);
}
}, pollInterval);
});
}
if(Espruino.Core.Serial.isConnected()){
Espruino.Core.Utils.getEspruinoPrompt(function() {
getProcessInfo(expressionToExecute, callback);
});
} else {
console.error("executeExpression called when not connected!");
callback(undefined);
}
} | [
"function",
"executeExpression",
"(",
"expressionToExecute",
",",
"callback",
")",
"{",
"var",
"receivedData",
"=",
"\"\"",
";",
"var",
"hadDataSinceTimeout",
"=",
"false",
";",
"function",
"getProcessInfo",
"(",
"expressionToExecute",
",",
"callback",
")",
"{",
"var",
"prevReader",
"=",
"Espruino",
".",
"Core",
".",
"Serial",
".",
"startListening",
"(",
"function",
"(",
"readData",
")",
"{",
"var",
"bufView",
"=",
"new",
"Uint8Array",
"(",
"readData",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"bufView",
".",
"length",
";",
"i",
"++",
")",
"{",
"receivedData",
"+=",
"String",
".",
"fromCharCode",
"(",
"bufView",
"[",
"i",
"]",
")",
";",
"}",
"// check if we got what we wanted",
"var",
"startProcess",
"=",
"receivedData",
".",
"indexOf",
"(",
"\"< <<\"",
")",
";",
"var",
"endProcess",
"=",
"receivedData",
".",
"indexOf",
"(",
"\">> >\"",
",",
"startProcess",
")",
";",
"if",
"(",
"startProcess",
">=",
"0",
"&&",
"endProcess",
">",
"0",
")",
"{",
"// All good - get the data!",
"var",
"result",
"=",
"receivedData",
".",
"substring",
"(",
"startProcess",
"+",
"4",
",",
"endProcess",
")",
";",
"console",
".",
"log",
"(",
"\"Got \"",
"+",
"JSON",
".",
"stringify",
"(",
"receivedData",
")",
")",
";",
"// strip out the text we found",
"receivedData",
"=",
"receivedData",
".",
"substr",
"(",
"0",
",",
"startProcess",
")",
"+",
"receivedData",
".",
"substr",
"(",
"endProcess",
"+",
"4",
")",
";",
"// Now stop time timeout",
"if",
"(",
"timeout",
")",
"clearInterval",
"(",
"timeout",
")",
";",
"timeout",
"=",
"\"cancelled\"",
";",
"// Do the next stuff",
"nextStep",
"(",
"result",
")",
";",
"}",
"else",
"if",
"(",
"startProcess",
">=",
"0",
")",
"{",
"// we got some data - so keep waiting...",
"hadDataSinceTimeout",
"=",
"true",
";",
"}",
"}",
")",
";",
"// when we're done...",
"var",
"nextStep",
"=",
"function",
"(",
"result",
")",
"{",
"// start the previous reader listing again",
"Espruino",
".",
"Core",
".",
"Serial",
".",
"startListening",
"(",
"prevReader",
")",
";",
"// forward the original text to the previous reader",
"if",
"(",
"prevReader",
")",
"prevReader",
"(",
"receivedData",
")",
";",
"// run the callback",
"callback",
"(",
"result",
")",
";",
"}",
";",
"var",
"timeout",
"=",
"undefined",
";",
"// Don't Ctrl-C, as we've already got ourselves a prompt with Espruino.Core.Utils.getEspruinoPrompt",
"Espruino",
".",
"Core",
".",
"Serial",
".",
"write",
"(",
"'\\x10print(\"<\",\"<<\",JSON.stringify('",
"+",
"expressionToExecute",
"+",
"'),\">>\",\">\")\\n'",
",",
"undefined",
",",
"function",
"(",
")",
"{",
"// now it's sent, wait for data",
"var",
"maxTimeout",
"=",
"10",
";",
"// seconds - how long we wait if we're getting data",
"var",
"minTimeout",
"=",
"2",
";",
"// seconds - how long we wait if we're not getting data",
"var",
"pollInterval",
"=",
"500",
";",
"// milliseconds",
"var",
"timeoutSeconds",
"=",
"0",
";",
"if",
"(",
"timeout",
"!=",
"\"cancelled\"",
")",
"timeout",
"=",
"setInterval",
"(",
"function",
"onTimeout",
"(",
")",
"{",
"timeoutSeconds",
"+=",
"pollInterval",
"/",
"1000",
";",
"// if we're still getting data, keep waiting for up to 10 secs",
"if",
"(",
"hadDataSinceTimeout",
"&&",
"timeoutSeconds",
"<",
"maxTimeout",
")",
"{",
"hadDataSinceTimeout",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"timeoutSeconds",
">",
"minTimeout",
")",
"{",
"// No data yet...",
"// OR we keep getting data for > maxTimeout seconds",
"clearInterval",
"(",
"timeout",
")",
";",
"console",
".",
"warn",
"(",
"\"No result found for \"",
"+",
"JSON",
".",
"stringify",
"(",
"expressionToExecute",
")",
"+",
"\" - just got \"",
"+",
"JSON",
".",
"stringify",
"(",
"receivedData",
")",
")",
";",
"nextStep",
"(",
"undefined",
")",
";",
"}",
"}",
",",
"pollInterval",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"Espruino",
".",
"Core",
".",
"Serial",
".",
"isConnected",
"(",
")",
")",
"{",
"Espruino",
".",
"Core",
".",
"Utils",
".",
"getEspruinoPrompt",
"(",
"function",
"(",
")",
"{",
"getProcessInfo",
"(",
"expressionToExecute",
",",
"callback",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"console",
".",
"error",
"(",
"\"executeExpression called when not connected!\"",
")",
";",
"callback",
"(",
"undefined",
")",
";",
"}",
"}"
] | Return the value of executing an expression on the board | [
"Return",
"the",
"value",
"of",
"executing",
"an",
"expression",
"on",
"the",
"board"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/utils.js#L242-L316 |
20,514 | espruino/EspruinoTools | core/utils.js | isRecognisedBluetoothDevice | function isRecognisedBluetoothDevice(name) {
if (!name) return false;
var devs = recognisedBluetoothDevices();
for (var i=0;i<devs.length;i++)
if (name.substr(0, devs[i].length) == devs[i])
return true;
return false;
} | javascript | function isRecognisedBluetoothDevice(name) {
if (!name) return false;
var devs = recognisedBluetoothDevices();
for (var i=0;i<devs.length;i++)
if (name.substr(0, devs[i].length) == devs[i])
return true;
return false;
} | [
"function",
"isRecognisedBluetoothDevice",
"(",
"name",
")",
"{",
"if",
"(",
"!",
"name",
")",
"return",
"false",
";",
"var",
"devs",
"=",
"recognisedBluetoothDevices",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"devs",
".",
"length",
";",
"i",
"++",
")",
"if",
"(",
"name",
".",
"substr",
"(",
"0",
",",
"devs",
"[",
"i",
"]",
".",
"length",
")",
"==",
"devs",
"[",
"i",
"]",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | If we can't find service info, add devices
based only on their name | [
"If",
"we",
"can",
"t",
"find",
"service",
"info",
"add",
"devices",
"based",
"only",
"on",
"their",
"name"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/utils.js#L482-L489 |
20,515 | espruino/EspruinoTools | core/utils.js | stringToArrayBuffer | function stringToArrayBuffer(str) {
var buf=new Uint8Array(str.length);
for (var i=0; i<str.length; i++) {
var ch = str.charCodeAt(i);
if (ch>=256) {
console.warn("stringToArrayBuffer got non-8 bit character - code "+ch);
ch = "?".charCodeAt(0);
}
buf[i] = ch;
}
return buf.buffer;
} | javascript | function stringToArrayBuffer(str) {
var buf=new Uint8Array(str.length);
for (var i=0; i<str.length; i++) {
var ch = str.charCodeAt(i);
if (ch>=256) {
console.warn("stringToArrayBuffer got non-8 bit character - code "+ch);
ch = "?".charCodeAt(0);
}
buf[i] = ch;
}
return buf.buffer;
} | [
"function",
"stringToArrayBuffer",
"(",
"str",
")",
"{",
"var",
"buf",
"=",
"new",
"Uint8Array",
"(",
"str",
".",
"length",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"ch",
"=",
"str",
".",
"charCodeAt",
"(",
"i",
")",
";",
"if",
"(",
"ch",
">=",
"256",
")",
"{",
"console",
".",
"warn",
"(",
"\"stringToArrayBuffer got non-8 bit character - code \"",
"+",
"ch",
")",
";",
"ch",
"=",
"\"?\"",
".",
"charCodeAt",
"(",
"0",
")",
";",
"}",
"buf",
"[",
"i",
"]",
"=",
"ch",
";",
"}",
"return",
"buf",
".",
"buffer",
";",
"}"
] | Converts a string to an ArrayBuffer | [
"Converts",
"a",
"string",
"to",
"an",
"ArrayBuffer"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/utils.js#L515-L526 |
20,516 | espruino/EspruinoTools | core/utils.js | stringToBuffer | function stringToBuffer(str) {
var buf = new Buffer(str.length);
for (var i = 0; i < buf.length; i++) {
buf.writeUInt8(str.charCodeAt(i), i);
}
return buf;
} | javascript | function stringToBuffer(str) {
var buf = new Buffer(str.length);
for (var i = 0; i < buf.length; i++) {
buf.writeUInt8(str.charCodeAt(i), i);
}
return buf;
} | [
"function",
"stringToBuffer",
"(",
"str",
")",
"{",
"var",
"buf",
"=",
"new",
"Buffer",
"(",
"str",
".",
"length",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"buf",
".",
"length",
";",
"i",
"++",
")",
"{",
"buf",
".",
"writeUInt8",
"(",
"str",
".",
"charCodeAt",
"(",
"i",
")",
",",
"i",
")",
";",
"}",
"return",
"buf",
";",
"}"
] | Converts a string to a Buffer | [
"Converts",
"a",
"string",
"to",
"a",
"Buffer"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/utils.js#L529-L535 |
20,517 | espruino/EspruinoTools | core/utils.js | dataViewToArrayBuffer | function dataViewToArrayBuffer(str) {
var bufView = new Uint8Array(dv.byteLength);
for (var i = 0; i < bufView.length; i++) {
bufView[i] = dv.getUint8(i);
}
return bufView.buffer;
} | javascript | function dataViewToArrayBuffer(str) {
var bufView = new Uint8Array(dv.byteLength);
for (var i = 0; i < bufView.length; i++) {
bufView[i] = dv.getUint8(i);
}
return bufView.buffer;
} | [
"function",
"dataViewToArrayBuffer",
"(",
"str",
")",
"{",
"var",
"bufView",
"=",
"new",
"Uint8Array",
"(",
"dv",
".",
"byteLength",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"bufView",
".",
"length",
";",
"i",
"++",
")",
"{",
"bufView",
"[",
"i",
"]",
"=",
"dv",
".",
"getUint8",
"(",
"i",
")",
";",
"}",
"return",
"bufView",
".",
"buffer",
";",
"}"
] | Converts a DataView to an ArrayBuffer | [
"Converts",
"a",
"DataView",
"to",
"an",
"ArrayBuffer"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/utils.js#L538-L544 |
20,518 | espruino/EspruinoTools | core/modules.js | moduleLoaded | function moduleLoaded(resolve, requires, modName, data, loadedModuleData, alreadyMinified){
// Check for any modules used from this module that we don't already have
var newRequires = getModulesRequired(data);
console.log(" - "+modName+" requires "+JSON.stringify(newRequires));
// if we need new modules, set them to load and get their promises
var newPromises = [];
for (var i in newRequires) {
if (requires.indexOf(newRequires[i])<0) {
console.log(" Queueing "+newRequires[i]);
requires.push(newRequires[i]);
newPromises.push(loadModule(requires, newRequires[i], loadedModuleData));
} else {
console.log(" Already loading "+newRequires[i]);
}
}
var loadProcessedModule = function (module) {
// add the module to the beginning of our array
if (Espruino.Config.MODULE_AS_FUNCTION)
loadedModuleData.unshift("Modules.addCached(" + JSON.stringify(module.name) + ",function(){" + module.code + "});");
else
loadedModuleData.unshift("Modules.addCached(" + JSON.stringify(module.name) + "," + JSON.stringify(module.code) + ");");
// if we needed to load something, wait until we have all promises complete before resolving our promise!
Promise.all(newPromises).then(function(){ resolve(); });
}
if (alreadyMinified)
loadProcessedModule({code:data,name:modName});
else
Espruino.callProcessor("transformModuleForEspruino", {code:data,name:modName}, loadProcessedModule);
} | javascript | function moduleLoaded(resolve, requires, modName, data, loadedModuleData, alreadyMinified){
// Check for any modules used from this module that we don't already have
var newRequires = getModulesRequired(data);
console.log(" - "+modName+" requires "+JSON.stringify(newRequires));
// if we need new modules, set them to load and get their promises
var newPromises = [];
for (var i in newRequires) {
if (requires.indexOf(newRequires[i])<0) {
console.log(" Queueing "+newRequires[i]);
requires.push(newRequires[i]);
newPromises.push(loadModule(requires, newRequires[i], loadedModuleData));
} else {
console.log(" Already loading "+newRequires[i]);
}
}
var loadProcessedModule = function (module) {
// add the module to the beginning of our array
if (Espruino.Config.MODULE_AS_FUNCTION)
loadedModuleData.unshift("Modules.addCached(" + JSON.stringify(module.name) + ",function(){" + module.code + "});");
else
loadedModuleData.unshift("Modules.addCached(" + JSON.stringify(module.name) + "," + JSON.stringify(module.code) + ");");
// if we needed to load something, wait until we have all promises complete before resolving our promise!
Promise.all(newPromises).then(function(){ resolve(); });
}
if (alreadyMinified)
loadProcessedModule({code:data,name:modName});
else
Espruino.callProcessor("transformModuleForEspruino", {code:data,name:modName}, loadProcessedModule);
} | [
"function",
"moduleLoaded",
"(",
"resolve",
",",
"requires",
",",
"modName",
",",
"data",
",",
"loadedModuleData",
",",
"alreadyMinified",
")",
"{",
"// Check for any modules used from this module that we don't already have",
"var",
"newRequires",
"=",
"getModulesRequired",
"(",
"data",
")",
";",
"console",
".",
"log",
"(",
"\" - \"",
"+",
"modName",
"+",
"\" requires \"",
"+",
"JSON",
".",
"stringify",
"(",
"newRequires",
")",
")",
";",
"// if we need new modules, set them to load and get their promises",
"var",
"newPromises",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"in",
"newRequires",
")",
"{",
"if",
"(",
"requires",
".",
"indexOf",
"(",
"newRequires",
"[",
"i",
"]",
")",
"<",
"0",
")",
"{",
"console",
".",
"log",
"(",
"\" Queueing \"",
"+",
"newRequires",
"[",
"i",
"]",
")",
";",
"requires",
".",
"push",
"(",
"newRequires",
"[",
"i",
"]",
")",
";",
"newPromises",
".",
"push",
"(",
"loadModule",
"(",
"requires",
",",
"newRequires",
"[",
"i",
"]",
",",
"loadedModuleData",
")",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"\" Already loading \"",
"+",
"newRequires",
"[",
"i",
"]",
")",
";",
"}",
"}",
"var",
"loadProcessedModule",
"=",
"function",
"(",
"module",
")",
"{",
"// add the module to the beginning of our array",
"if",
"(",
"Espruino",
".",
"Config",
".",
"MODULE_AS_FUNCTION",
")",
"loadedModuleData",
".",
"unshift",
"(",
"\"Modules.addCached(\"",
"+",
"JSON",
".",
"stringify",
"(",
"module",
".",
"name",
")",
"+",
"\",function(){\"",
"+",
"module",
".",
"code",
"+",
"\"});\"",
")",
";",
"else",
"loadedModuleData",
".",
"unshift",
"(",
"\"Modules.addCached(\"",
"+",
"JSON",
".",
"stringify",
"(",
"module",
".",
"name",
")",
"+",
"\",\"",
"+",
"JSON",
".",
"stringify",
"(",
"module",
".",
"code",
")",
"+",
"\");\"",
")",
";",
"// if we needed to load something, wait until we have all promises complete before resolving our promise!",
"Promise",
".",
"all",
"(",
"newPromises",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"alreadyMinified",
")",
"loadProcessedModule",
"(",
"{",
"code",
":",
"data",
",",
"name",
":",
"modName",
"}",
")",
";",
"else",
"Espruino",
".",
"callProcessor",
"(",
"\"transformModuleForEspruino\"",
",",
"{",
"code",
":",
"data",
",",
"name",
":",
"modName",
"}",
",",
"loadProcessedModule",
")",
";",
"}"
] | Called from loadModule when a module is loaded. Parse it for other modules it might use
and resolve dfd after all submodules have been loaded | [
"Called",
"from",
"loadModule",
"when",
"a",
"module",
"is",
"loaded",
".",
"Parse",
"it",
"for",
"other",
"modules",
"it",
"might",
"use",
"and",
"resolve",
"dfd",
"after",
"all",
"submodules",
"have",
"been",
"loaded"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/modules.js#L170-L199 |
20,519 | espruino/EspruinoTools | core/modules.js | loadModules | function loadModules(code, callback){
var loadedModuleData = [];
var requires = getModulesRequired(code);
if (requires.length == 0) {
// no modules needed - just return
callback(code);
} else {
Espruino.Core.Status.setStatus("Loading modules");
// Kick off the module loading (each returns a promise)
var promises = requires.map(function (moduleName) {
return loadModule(requires, moduleName, loadedModuleData);
});
// When all promises are complete
Promise.all(promises).then(function(){
callback(loadedModuleData.join("\n") + "\n" + code);
});
}
} | javascript | function loadModules(code, callback){
var loadedModuleData = [];
var requires = getModulesRequired(code);
if (requires.length == 0) {
// no modules needed - just return
callback(code);
} else {
Espruino.Core.Status.setStatus("Loading modules");
// Kick off the module loading (each returns a promise)
var promises = requires.map(function (moduleName) {
return loadModule(requires, moduleName, loadedModuleData);
});
// When all promises are complete
Promise.all(promises).then(function(){
callback(loadedModuleData.join("\n") + "\n" + code);
});
}
} | [
"function",
"loadModules",
"(",
"code",
",",
"callback",
")",
"{",
"var",
"loadedModuleData",
"=",
"[",
"]",
";",
"var",
"requires",
"=",
"getModulesRequired",
"(",
"code",
")",
";",
"if",
"(",
"requires",
".",
"length",
"==",
"0",
")",
"{",
"// no modules needed - just return",
"callback",
"(",
"code",
")",
";",
"}",
"else",
"{",
"Espruino",
".",
"Core",
".",
"Status",
".",
"setStatus",
"(",
"\"Loading modules\"",
")",
";",
"// Kick off the module loading (each returns a promise)",
"var",
"promises",
"=",
"requires",
".",
"map",
"(",
"function",
"(",
"moduleName",
")",
"{",
"return",
"loadModule",
"(",
"requires",
",",
"moduleName",
",",
"loadedModuleData",
")",
";",
"}",
")",
";",
"// When all promises are complete",
"Promise",
".",
"all",
"(",
"promises",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"callback",
"(",
"loadedModuleData",
".",
"join",
"(",
"\"\\n\"",
")",
"+",
"\"\\n\"",
"+",
"code",
")",
";",
"}",
")",
";",
"}",
"}"
] | Finds instances of 'require' and then ensures that
those modules are loaded into the module cache beforehand
(by inserting the relevant 'addCached' commands into 'code' | [
"Finds",
"instances",
"of",
"require",
"and",
"then",
"ensures",
"that",
"those",
"modules",
"are",
"loaded",
"into",
"the",
"module",
"cache",
"beforehand",
"(",
"by",
"inserting",
"the",
"relevant",
"addCached",
"commands",
"into",
"code"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/modules.js#L223-L240 |
20,520 | espruino/EspruinoTools | bin/espruino-cli.js | makeJobFile | function makeJobFile(config) {
var job = {"espruino":{}};
// assign commandline values
for (var key in args) {
switch (key) {
case 'job': // remove job itself, and others set internally from the results
case 'espruinoPrefix':
case 'espruinoPostfix':
break;
default: job[key] = args[key]; // otherwise just output each key: value
}
// write fields of Espruino.Config passed as config
for (var k in config) { if (typeof config[k]!=='function') job.espruino[k] = config[k]; };
}
// name job file same as code file with json ending or default and save.
var jobFile = isNextValidJS(args.file) ? args.file.slice(0,args.file.lastIndexOf('.'))+'.json' : "job.json";
if (!fs.existsSync(jobFile)) {
log("Creating job file "+JSON.stringify(jobFile));
fs.writeFileSync(jobFile,JSON.stringify(job,null,2),{encoding:"utf8"});
} else
log("WARNING: File "+JSON.stringify(jobFile)+" already exists - not overwriting.");
} | javascript | function makeJobFile(config) {
var job = {"espruino":{}};
// assign commandline values
for (var key in args) {
switch (key) {
case 'job': // remove job itself, and others set internally from the results
case 'espruinoPrefix':
case 'espruinoPostfix':
break;
default: job[key] = args[key]; // otherwise just output each key: value
}
// write fields of Espruino.Config passed as config
for (var k in config) { if (typeof config[k]!=='function') job.espruino[k] = config[k]; };
}
// name job file same as code file with json ending or default and save.
var jobFile = isNextValidJS(args.file) ? args.file.slice(0,args.file.lastIndexOf('.'))+'.json' : "job.json";
if (!fs.existsSync(jobFile)) {
log("Creating job file "+JSON.stringify(jobFile));
fs.writeFileSync(jobFile,JSON.stringify(job,null,2),{encoding:"utf8"});
} else
log("WARNING: File "+JSON.stringify(jobFile)+" already exists - not overwriting.");
} | [
"function",
"makeJobFile",
"(",
"config",
")",
"{",
"var",
"job",
"=",
"{",
"\"espruino\"",
":",
"{",
"}",
"}",
";",
"// assign commandline values",
"for",
"(",
"var",
"key",
"in",
"args",
")",
"{",
"switch",
"(",
"key",
")",
"{",
"case",
"'job'",
":",
"// remove job itself, and others set internally from the results",
"case",
"'espruinoPrefix'",
":",
"case",
"'espruinoPostfix'",
":",
"break",
";",
"default",
":",
"job",
"[",
"key",
"]",
"=",
"args",
"[",
"key",
"]",
";",
"// otherwise just output each key: value",
"}",
"// write fields of Espruino.Config passed as config",
"for",
"(",
"var",
"k",
"in",
"config",
")",
"{",
"if",
"(",
"typeof",
"config",
"[",
"k",
"]",
"!==",
"'function'",
")",
"job",
".",
"espruino",
"[",
"k",
"]",
"=",
"config",
"[",
"k",
"]",
";",
"}",
";",
"}",
"// name job file same as code file with json ending or default and save.",
"var",
"jobFile",
"=",
"isNextValidJS",
"(",
"args",
".",
"file",
")",
"?",
"args",
".",
"file",
".",
"slice",
"(",
"0",
",",
"args",
".",
"file",
".",
"lastIndexOf",
"(",
"'.'",
")",
")",
"+",
"'.json'",
":",
"\"job.json\"",
";",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"jobFile",
")",
")",
"{",
"log",
"(",
"\"Creating job file \"",
"+",
"JSON",
".",
"stringify",
"(",
"jobFile",
")",
")",
";",
"fs",
".",
"writeFileSync",
"(",
"jobFile",
",",
"JSON",
".",
"stringify",
"(",
"job",
",",
"null",
",",
"2",
")",
",",
"{",
"encoding",
":",
"\"utf8\"",
"}",
")",
";",
"}",
"else",
"log",
"(",
"\"WARNING: File \"",
"+",
"JSON",
".",
"stringify",
"(",
"jobFile",
")",
"+",
"\" already exists - not overwriting.\"",
")",
";",
"}"
] | create a job file from commandline settings | [
"create",
"a",
"job",
"file",
"from",
"commandline",
"settings"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/bin/espruino-cli.js#L366-L388 |
20,521 | espruino/EspruinoTools | core/env.js | getBoardList | function getBoardList(callback) {
var jsonDir = Espruino.Config.BOARD_JSON_URL;
// ensure jsonDir ends with slash
if (jsonDir.indexOf('/', jsonDir.length - 1) === -1) {
jsonDir += '/';
}
Espruino.Core.Utils.getJSONURL(jsonDir + "boards.json", function(boards){
// now load all the individual JSON files
var promises = [];
for (var boardId in boards) {
promises.push((function() {
var id = boardId;
return new Promise(function(resolve, reject) {
Espruino.Core.Utils.getJSONURL(jsonDir + boards[boardId].json, function (data) {
boards[id]["json"] = data;
resolve();
});
});
})());
}
// When all are loaded, load the callback
Promise.all(promises).then(function() {
callback(boards);
});
});
} | javascript | function getBoardList(callback) {
var jsonDir = Espruino.Config.BOARD_JSON_URL;
// ensure jsonDir ends with slash
if (jsonDir.indexOf('/', jsonDir.length - 1) === -1) {
jsonDir += '/';
}
Espruino.Core.Utils.getJSONURL(jsonDir + "boards.json", function(boards){
// now load all the individual JSON files
var promises = [];
for (var boardId in boards) {
promises.push((function() {
var id = boardId;
return new Promise(function(resolve, reject) {
Espruino.Core.Utils.getJSONURL(jsonDir + boards[boardId].json, function (data) {
boards[id]["json"] = data;
resolve();
});
});
})());
}
// When all are loaded, load the callback
Promise.all(promises).then(function() {
callback(boards);
});
});
} | [
"function",
"getBoardList",
"(",
"callback",
")",
"{",
"var",
"jsonDir",
"=",
"Espruino",
".",
"Config",
".",
"BOARD_JSON_URL",
";",
"// ensure jsonDir ends with slash",
"if",
"(",
"jsonDir",
".",
"indexOf",
"(",
"'/'",
",",
"jsonDir",
".",
"length",
"-",
"1",
")",
"===",
"-",
"1",
")",
"{",
"jsonDir",
"+=",
"'/'",
";",
"}",
"Espruino",
".",
"Core",
".",
"Utils",
".",
"getJSONURL",
"(",
"jsonDir",
"+",
"\"boards.json\"",
",",
"function",
"(",
"boards",
")",
"{",
"// now load all the individual JSON files",
"var",
"promises",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"boardId",
"in",
"boards",
")",
"{",
"promises",
".",
"push",
"(",
"(",
"function",
"(",
")",
"{",
"var",
"id",
"=",
"boardId",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"Espruino",
".",
"Core",
".",
"Utils",
".",
"getJSONURL",
"(",
"jsonDir",
"+",
"boards",
"[",
"boardId",
"]",
".",
"json",
",",
"function",
"(",
"data",
")",
"{",
"boards",
"[",
"id",
"]",
"[",
"\"json\"",
"]",
"=",
"data",
";",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
")",
"(",
")",
")",
";",
"}",
"// When all are loaded, load the callback",
"Promise",
".",
"all",
"(",
"promises",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"callback",
"(",
"boards",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Get a list of boards that we know about | [
"Get",
"a",
"list",
"of",
"boards",
"that",
"we",
"know",
"about"
] | e31e564ebf302c53c8a73aa7f58f5f42a33fe26e | https://github.com/espruino/EspruinoTools/blob/e31e564ebf302c53c8a73aa7f58f5f42a33fe26e/core/env.js#L99-L127 |
20,522 | moleculerjs/moleculer-cli | src/alias-template/index.js | handler | function handler(opts) {
Object.assign(values, opts);
const configPath = path.join(os.homedir(), ".moleculer-templates.json");
return (
Promise.resolve()
//check for existing template alias config file
.then(() => {
return new Promise((resolve, reject) => {
fs.exists(configPath, exists => {
if (exists) {
fs.readFile(configPath, (err, config) => {
if (err) {
reject();
}
values.aliasedTemplates = JSON.parse(config);
resolve();
});
} else {
resolve();
}
});
});
})
// check if template name already exists
.then(() => {
const { templateName, aliasedTemplates } = values;
if (aliasedTemplates[templateName]) {
// if exists ask for overwrite
return inquirer.prompt([{
type: "confirm",
name: "continue",
message: chalk.yellow.bold(`The alias '${templateName}' already exists with value '${aliasedTemplates[templateName]}'! Overwrite?`),
default: false
}]).then(answers => {
if (!answers.continue)
process.exit(0);
});
}
})
// write template name and repo url
.then(() => {
const { templateName, templateUrl, aliasedTemplates } = values;
const newAliases = JSON.stringify(Object.assign(aliasedTemplates, { [templateName]: templateUrl }));
fs.writeFileSync(configPath, newAliases);
})
.catch(err => fail(err))
);
} | javascript | function handler(opts) {
Object.assign(values, opts);
const configPath = path.join(os.homedir(), ".moleculer-templates.json");
return (
Promise.resolve()
//check for existing template alias config file
.then(() => {
return new Promise((resolve, reject) => {
fs.exists(configPath, exists => {
if (exists) {
fs.readFile(configPath, (err, config) => {
if (err) {
reject();
}
values.aliasedTemplates = JSON.parse(config);
resolve();
});
} else {
resolve();
}
});
});
})
// check if template name already exists
.then(() => {
const { templateName, aliasedTemplates } = values;
if (aliasedTemplates[templateName]) {
// if exists ask for overwrite
return inquirer.prompt([{
type: "confirm",
name: "continue",
message: chalk.yellow.bold(`The alias '${templateName}' already exists with value '${aliasedTemplates[templateName]}'! Overwrite?`),
default: false
}]).then(answers => {
if (!answers.continue)
process.exit(0);
});
}
})
// write template name and repo url
.then(() => {
const { templateName, templateUrl, aliasedTemplates } = values;
const newAliases = JSON.stringify(Object.assign(aliasedTemplates, { [templateName]: templateUrl }));
fs.writeFileSync(configPath, newAliases);
})
.catch(err => fail(err))
);
} | [
"function",
"handler",
"(",
"opts",
")",
"{",
"Object",
".",
"assign",
"(",
"values",
",",
"opts",
")",
";",
"const",
"configPath",
"=",
"path",
".",
"join",
"(",
"os",
".",
"homedir",
"(",
")",
",",
"\".moleculer-templates.json\"",
")",
";",
"return",
"(",
"Promise",
".",
"resolve",
"(",
")",
"//check for existing template alias config file",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fs",
".",
"exists",
"(",
"configPath",
",",
"exists",
"=>",
"{",
"if",
"(",
"exists",
")",
"{",
"fs",
".",
"readFile",
"(",
"configPath",
",",
"(",
"err",
",",
"config",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"reject",
"(",
")",
";",
"}",
"values",
".",
"aliasedTemplates",
"=",
"JSON",
".",
"parse",
"(",
"config",
")",
";",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"resolve",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}",
")",
"// check if template name already exists",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"const",
"{",
"templateName",
",",
"aliasedTemplates",
"}",
"=",
"values",
";",
"if",
"(",
"aliasedTemplates",
"[",
"templateName",
"]",
")",
"{",
"// if exists ask for overwrite",
"return",
"inquirer",
".",
"prompt",
"(",
"[",
"{",
"type",
":",
"\"confirm\"",
",",
"name",
":",
"\"continue\"",
",",
"message",
":",
"chalk",
".",
"yellow",
".",
"bold",
"(",
"`",
"${",
"templateName",
"}",
"${",
"aliasedTemplates",
"[",
"templateName",
"]",
"}",
"`",
")",
",",
"default",
":",
"false",
"}",
"]",
")",
".",
"then",
"(",
"answers",
"=>",
"{",
"if",
"(",
"!",
"answers",
".",
"continue",
")",
"process",
".",
"exit",
"(",
"0",
")",
";",
"}",
")",
";",
"}",
"}",
")",
"// write template name and repo url",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"const",
"{",
"templateName",
",",
"templateUrl",
",",
"aliasedTemplates",
"}",
"=",
"values",
";",
"const",
"newAliases",
"=",
"JSON",
".",
"stringify",
"(",
"Object",
".",
"assign",
"(",
"aliasedTemplates",
",",
"{",
"[",
"templateName",
"]",
":",
"templateUrl",
"}",
")",
")",
";",
"fs",
".",
"writeFileSync",
"(",
"configPath",
",",
"newAliases",
")",
";",
"}",
")",
".",
"catch",
"(",
"err",
"=>",
"fail",
"(",
"err",
")",
")",
")",
";",
"}"
] | Handler for yards command
@param {any} opts | [
"Handler",
"for",
"yards",
"command"
] | 0a607efbc929e3e2bb2b50ebee413e7a5ecd6d30 | https://github.com/moleculerjs/moleculer-cli/blob/0a607efbc929e3e2bb2b50ebee413e7a5ecd6d30/src/alias-template/index.js#L27-L75 |
20,523 | moleculerjs/moleculer-cli | src/init/index.js | renderTemplate | function renderTemplate(skipInterpolation) {
skipInterpolation = typeof skipInterpolation === "string" ? [skipInterpolation] : skipInterpolation;
const handlebarsMatcher = /{{([^{}]+)}}/;
return function (files, metalsmith, done) {
const keys = Object.keys(files);
const metadata = metalsmith.metadata();
async.each(keys, (file, next) => {
// skipping files with skipInterpolation option
if (skipInterpolation && multimatch([file], skipInterpolation, { dot: true }).length) {
return next();
}
async.series([
// interpolate the file contents
function (callback) {
const str = files[file].contents.toString();
if (!handlebarsMatcher.test(str)) {
return callback();
}
render(str, metadata, function (err, res) {
if (err) return callback(err);
files[file].contents = Buffer.from(res);
callback();
});
},
// interpolate the file name
function (callback) {
if (!handlebarsMatcher.test(file)) {
return callback();
}
render(file, metadata, function (err, res) {
if (err) return callback(err);
// safety check to prevent file deletion in case filename doesn't change
if (file === res) return callback();
// safety check to prevent overwriting another file
if (files[res]) return callback(`Cannot rename file ${file} to ${res}. A file with that name already exists.`);
// add entry for interpolated file name
files[res] = files[file];
// delete entry for template file name
delete files[file];
callback();
});
}
], function (err) {
if (err) return done(err);
next();
});
}, done);
};
} | javascript | function renderTemplate(skipInterpolation) {
skipInterpolation = typeof skipInterpolation === "string" ? [skipInterpolation] : skipInterpolation;
const handlebarsMatcher = /{{([^{}]+)}}/;
return function (files, metalsmith, done) {
const keys = Object.keys(files);
const metadata = metalsmith.metadata();
async.each(keys, (file, next) => {
// skipping files with skipInterpolation option
if (skipInterpolation && multimatch([file], skipInterpolation, { dot: true }).length) {
return next();
}
async.series([
// interpolate the file contents
function (callback) {
const str = files[file].contents.toString();
if (!handlebarsMatcher.test(str)) {
return callback();
}
render(str, metadata, function (err, res) {
if (err) return callback(err);
files[file].contents = Buffer.from(res);
callback();
});
},
// interpolate the file name
function (callback) {
if (!handlebarsMatcher.test(file)) {
return callback();
}
render(file, metadata, function (err, res) {
if (err) return callback(err);
// safety check to prevent file deletion in case filename doesn't change
if (file === res) return callback();
// safety check to prevent overwriting another file
if (files[res]) return callback(`Cannot rename file ${file} to ${res}. A file with that name already exists.`);
// add entry for interpolated file name
files[res] = files[file];
// delete entry for template file name
delete files[file];
callback();
});
}
], function (err) {
if (err) return done(err);
next();
});
}, done);
};
} | [
"function",
"renderTemplate",
"(",
"skipInterpolation",
")",
"{",
"skipInterpolation",
"=",
"typeof",
"skipInterpolation",
"===",
"\"string\"",
"?",
"[",
"skipInterpolation",
"]",
":",
"skipInterpolation",
";",
"const",
"handlebarsMatcher",
"=",
"/",
"{{([^{}]+)}}",
"/",
";",
"return",
"function",
"(",
"files",
",",
"metalsmith",
",",
"done",
")",
"{",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"files",
")",
";",
"const",
"metadata",
"=",
"metalsmith",
".",
"metadata",
"(",
")",
";",
"async",
".",
"each",
"(",
"keys",
",",
"(",
"file",
",",
"next",
")",
"=>",
"{",
"// skipping files with skipInterpolation option",
"if",
"(",
"skipInterpolation",
"&&",
"multimatch",
"(",
"[",
"file",
"]",
",",
"skipInterpolation",
",",
"{",
"dot",
":",
"true",
"}",
")",
".",
"length",
")",
"{",
"return",
"next",
"(",
")",
";",
"}",
"async",
".",
"series",
"(",
"[",
"// interpolate the file contents",
"function",
"(",
"callback",
")",
"{",
"const",
"str",
"=",
"files",
"[",
"file",
"]",
".",
"contents",
".",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"handlebarsMatcher",
".",
"test",
"(",
"str",
")",
")",
"{",
"return",
"callback",
"(",
")",
";",
"}",
"render",
"(",
"str",
",",
"metadata",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"files",
"[",
"file",
"]",
".",
"contents",
"=",
"Buffer",
".",
"from",
"(",
"res",
")",
";",
"callback",
"(",
")",
";",
"}",
")",
";",
"}",
",",
"// interpolate the file name",
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"!",
"handlebarsMatcher",
".",
"test",
"(",
"file",
")",
")",
"{",
"return",
"callback",
"(",
")",
";",
"}",
"render",
"(",
"file",
",",
"metadata",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"// safety check to prevent file deletion in case filename doesn't change",
"if",
"(",
"file",
"===",
"res",
")",
"return",
"callback",
"(",
")",
";",
"// safety check to prevent overwriting another file",
"if",
"(",
"files",
"[",
"res",
"]",
")",
"return",
"callback",
"(",
"`",
"${",
"file",
"}",
"${",
"res",
"}",
"`",
")",
";",
"// add entry for interpolated file name",
"files",
"[",
"res",
"]",
"=",
"files",
"[",
"file",
"]",
";",
"// delete entry for template file name",
"delete",
"files",
"[",
"file",
"]",
";",
"callback",
"(",
")",
";",
"}",
")",
";",
"}",
"]",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"done",
"(",
"err",
")",
";",
"next",
"(",
")",
";",
"}",
")",
";",
"}",
",",
"done",
")",
";",
"}",
";",
"}"
] | Render a template file with handlebars | [
"Render",
"a",
"template",
"file",
"with",
"handlebars"
] | 0a607efbc929e3e2bb2b50ebee413e7a5ecd6d30 | https://github.com/moleculerjs/moleculer-cli/blob/0a607efbc929e3e2bb2b50ebee413e7a5ecd6d30/src/init/index.js#L295-L353 |
20,524 | moleculerjs/moleculer-cli | src/init/index.js | function (callback) {
const str = files[file].contents.toString();
if (!handlebarsMatcher.test(str)) {
return callback();
}
render(str, metadata, function (err, res) {
if (err) return callback(err);
files[file].contents = Buffer.from(res);
callback();
});
} | javascript | function (callback) {
const str = files[file].contents.toString();
if (!handlebarsMatcher.test(str)) {
return callback();
}
render(str, metadata, function (err, res) {
if (err) return callback(err);
files[file].contents = Buffer.from(res);
callback();
});
} | [
"function",
"(",
"callback",
")",
"{",
"const",
"str",
"=",
"files",
"[",
"file",
"]",
".",
"contents",
".",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"handlebarsMatcher",
".",
"test",
"(",
"str",
")",
")",
"{",
"return",
"callback",
"(",
")",
";",
"}",
"render",
"(",
"str",
",",
"metadata",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"files",
"[",
"file",
"]",
".",
"contents",
"=",
"Buffer",
".",
"from",
"(",
"res",
")",
";",
"callback",
"(",
")",
";",
"}",
")",
";",
"}"
] | interpolate the file contents | [
"interpolate",
"the",
"file",
"contents"
] | 0a607efbc929e3e2bb2b50ebee413e7a5ecd6d30 | https://github.com/moleculerjs/moleculer-cli/blob/0a607efbc929e3e2bb2b50ebee413e7a5ecd6d30/src/init/index.js#L313-L324 | |
20,525 | moleculerjs/moleculer-cli | src/init/index.js | function (callback) {
if (!handlebarsMatcher.test(file)) {
return callback();
}
render(file, metadata, function (err, res) {
if (err) return callback(err);
// safety check to prevent file deletion in case filename doesn't change
if (file === res) return callback();
// safety check to prevent overwriting another file
if (files[res]) return callback(`Cannot rename file ${file} to ${res}. A file with that name already exists.`);
// add entry for interpolated file name
files[res] = files[file];
// delete entry for template file name
delete files[file];
callback();
});
} | javascript | function (callback) {
if (!handlebarsMatcher.test(file)) {
return callback();
}
render(file, metadata, function (err, res) {
if (err) return callback(err);
// safety check to prevent file deletion in case filename doesn't change
if (file === res) return callback();
// safety check to prevent overwriting another file
if (files[res]) return callback(`Cannot rename file ${file} to ${res}. A file with that name already exists.`);
// add entry for interpolated file name
files[res] = files[file];
// delete entry for template file name
delete files[file];
callback();
});
} | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"!",
"handlebarsMatcher",
".",
"test",
"(",
"file",
")",
")",
"{",
"return",
"callback",
"(",
")",
";",
"}",
"render",
"(",
"file",
",",
"metadata",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"// safety check to prevent file deletion in case filename doesn't change",
"if",
"(",
"file",
"===",
"res",
")",
"return",
"callback",
"(",
")",
";",
"// safety check to prevent overwriting another file",
"if",
"(",
"files",
"[",
"res",
"]",
")",
"return",
"callback",
"(",
"`",
"${",
"file",
"}",
"${",
"res",
"}",
"`",
")",
";",
"// add entry for interpolated file name",
"files",
"[",
"res",
"]",
"=",
"files",
"[",
"file",
"]",
";",
"// delete entry for template file name",
"delete",
"files",
"[",
"file",
"]",
";",
"callback",
"(",
")",
";",
"}",
")",
";",
"}"
] | interpolate the file name | [
"interpolate",
"the",
"file",
"name"
] | 0a607efbc929e3e2bb2b50ebee413e7a5ecd6d30 | https://github.com/moleculerjs/moleculer-cli/blob/0a607efbc929e3e2bb2b50ebee413e7a5ecd6d30/src/init/index.js#L327-L345 | |
20,526 | bitshares/bitsharesjs-ws | lib/src/ChainConfig.js | function(chain_id) {
let i, len, network, network_name, ref;
ref = Object.keys(_this.networks);
for (i = 0, len = ref.length; i < len; i++) {
network_name = ref[i];
network = _this.networks[network_name];
if (network.chain_id === chain_id) {
_this.network_name = network_name;
if (network.address_prefix) {
_this.address_prefix = network.address_prefix;
ecc_config.address_prefix = network.address_prefix;
}
// console.log("INFO Configured for", network_name, ":", network.core_asset, "\n");
return {
network_name: network_name,
network: network
}
}
}
if (!_this.network_name) {
console.log("Unknown chain id (this may be a testnet)", chain_id);
}
} | javascript | function(chain_id) {
let i, len, network, network_name, ref;
ref = Object.keys(_this.networks);
for (i = 0, len = ref.length; i < len; i++) {
network_name = ref[i];
network = _this.networks[network_name];
if (network.chain_id === chain_id) {
_this.network_name = network_name;
if (network.address_prefix) {
_this.address_prefix = network.address_prefix;
ecc_config.address_prefix = network.address_prefix;
}
// console.log("INFO Configured for", network_name, ":", network.core_asset, "\n");
return {
network_name: network_name,
network: network
}
}
}
if (!_this.network_name) {
console.log("Unknown chain id (this may be a testnet)", chain_id);
}
} | [
"function",
"(",
"chain_id",
")",
"{",
"let",
"i",
",",
"len",
",",
"network",
",",
"network_name",
",",
"ref",
";",
"ref",
"=",
"Object",
".",
"keys",
"(",
"_this",
".",
"networks",
")",
";",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"ref",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"network_name",
"=",
"ref",
"[",
"i",
"]",
";",
"network",
"=",
"_this",
".",
"networks",
"[",
"network_name",
"]",
";",
"if",
"(",
"network",
".",
"chain_id",
"===",
"chain_id",
")",
"{",
"_this",
".",
"network_name",
"=",
"network_name",
";",
"if",
"(",
"network",
".",
"address_prefix",
")",
"{",
"_this",
".",
"address_prefix",
"=",
"network",
".",
"address_prefix",
";",
"ecc_config",
".",
"address_prefix",
"=",
"network",
".",
"address_prefix",
";",
"}",
"// console.log(\"INFO Configured for\", network_name, \":\", network.core_asset, \"\\n\");",
"return",
"{",
"network_name",
":",
"network_name",
",",
"network",
":",
"network",
"}",
"}",
"}",
"if",
"(",
"!",
"_this",
".",
"network_name",
")",
"{",
"console",
".",
"log",
"(",
"\"Unknown chain id (this may be a testnet)\"",
",",
"chain_id",
")",
";",
"}",
"}"
] | Set a few properties for known chain IDs. | [
"Set",
"a",
"few",
"properties",
"for",
"known",
"chain",
"IDs",
"."
] | 074b043f04725950e6ecd9e48f3d280d28822138 | https://github.com/bitshares/bitsharesjs-ws/blob/074b043f04725950e6ecd9e48f3d280d28822138/lib/src/ChainConfig.js#L37-L69 | |
20,527 | rapid7/le_js | src/le.js | function(msg) {
var event = _getEvent.apply(this, arguments);
var data = {event: event};
// Add agent info if required
if (_pageInfo !== 'never') {
if (!_sentPageInfo || _pageInfo === 'per-entry') {
_sentPageInfo = true;
if (typeof event.screen === "undefined" &&
typeof event.browser === "undefined")
_rawLog(_agentInfo()).level('PAGE').send();
}
}
if (_traceCode) {
data.trace = _traceCode;
}
return {level: function(l) {
// Don't log PAGE events to console
// PAGE events are generated for the agentInfo function
if (_print && typeof console !== "undefined" && l !== 'PAGE') {
var serialized = null;
if (typeof XDomainRequest !== "undefined") {
// We're using IE8/9
serialized = data.trace + ' ' + data.event;
}
try {
console[l.toLowerCase()].call(console, (serialized || data));
} catch (ex) {
// IE compat fix
console.log((serialized || data));
}
}
data.level = l;
return {send: function() {
var cache = [];
var serialized = JSON.stringify(data, function(key, value) {
if (typeof value === "undefined") {
return "undefined";
} else if (typeof value === "object" && value !== null) {
if (_indexOf(cache, value) !== -1) {
// We've seen this object before;
// return a placeholder instead to prevent
// cycles
return "<?>";
}
cache.push(value);
}
return value;
});
if (_active) {
_backlog.push(serialized);
} else {
_apiCall(_token, serialized);
}
}};
}};
} | javascript | function(msg) {
var event = _getEvent.apply(this, arguments);
var data = {event: event};
// Add agent info if required
if (_pageInfo !== 'never') {
if (!_sentPageInfo || _pageInfo === 'per-entry') {
_sentPageInfo = true;
if (typeof event.screen === "undefined" &&
typeof event.browser === "undefined")
_rawLog(_agentInfo()).level('PAGE').send();
}
}
if (_traceCode) {
data.trace = _traceCode;
}
return {level: function(l) {
// Don't log PAGE events to console
// PAGE events are generated for the agentInfo function
if (_print && typeof console !== "undefined" && l !== 'PAGE') {
var serialized = null;
if (typeof XDomainRequest !== "undefined") {
// We're using IE8/9
serialized = data.trace + ' ' + data.event;
}
try {
console[l.toLowerCase()].call(console, (serialized || data));
} catch (ex) {
// IE compat fix
console.log((serialized || data));
}
}
data.level = l;
return {send: function() {
var cache = [];
var serialized = JSON.stringify(data, function(key, value) {
if (typeof value === "undefined") {
return "undefined";
} else if (typeof value === "object" && value !== null) {
if (_indexOf(cache, value) !== -1) {
// We've seen this object before;
// return a placeholder instead to prevent
// cycles
return "<?>";
}
cache.push(value);
}
return value;
});
if (_active) {
_backlog.push(serialized);
} else {
_apiCall(_token, serialized);
}
}};
}};
} | [
"function",
"(",
"msg",
")",
"{",
"var",
"event",
"=",
"_getEvent",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"data",
"=",
"{",
"event",
":",
"event",
"}",
";",
"// Add agent info if required",
"if",
"(",
"_pageInfo",
"!==",
"'never'",
")",
"{",
"if",
"(",
"!",
"_sentPageInfo",
"||",
"_pageInfo",
"===",
"'per-entry'",
")",
"{",
"_sentPageInfo",
"=",
"true",
";",
"if",
"(",
"typeof",
"event",
".",
"screen",
"===",
"\"undefined\"",
"&&",
"typeof",
"event",
".",
"browser",
"===",
"\"undefined\"",
")",
"_rawLog",
"(",
"_agentInfo",
"(",
")",
")",
".",
"level",
"(",
"'PAGE'",
")",
".",
"send",
"(",
")",
";",
"}",
"}",
"if",
"(",
"_traceCode",
")",
"{",
"data",
".",
"trace",
"=",
"_traceCode",
";",
"}",
"return",
"{",
"level",
":",
"function",
"(",
"l",
")",
"{",
"// Don't log PAGE events to console",
"// PAGE events are generated for the agentInfo function",
"if",
"(",
"_print",
"&&",
"typeof",
"console",
"!==",
"\"undefined\"",
"&&",
"l",
"!==",
"'PAGE'",
")",
"{",
"var",
"serialized",
"=",
"null",
";",
"if",
"(",
"typeof",
"XDomainRequest",
"!==",
"\"undefined\"",
")",
"{",
"// We're using IE8/9",
"serialized",
"=",
"data",
".",
"trace",
"+",
"' '",
"+",
"data",
".",
"event",
";",
"}",
"try",
"{",
"console",
"[",
"l",
".",
"toLowerCase",
"(",
")",
"]",
".",
"call",
"(",
"console",
",",
"(",
"serialized",
"||",
"data",
")",
")",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"// IE compat fix",
"console",
".",
"log",
"(",
"(",
"serialized",
"||",
"data",
")",
")",
";",
"}",
"}",
"data",
".",
"level",
"=",
"l",
";",
"return",
"{",
"send",
":",
"function",
"(",
")",
"{",
"var",
"cache",
"=",
"[",
"]",
";",
"var",
"serialized",
"=",
"JSON",
".",
"stringify",
"(",
"data",
",",
"function",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"\"undefined\"",
")",
"{",
"return",
"\"undefined\"",
";",
"}",
"else",
"if",
"(",
"typeof",
"value",
"===",
"\"object\"",
"&&",
"value",
"!==",
"null",
")",
"{",
"if",
"(",
"_indexOf",
"(",
"cache",
",",
"value",
")",
"!==",
"-",
"1",
")",
"{",
"// We've seen this object before;",
"// return a placeholder instead to prevent",
"// cycles",
"return",
"\"<?>\"",
";",
"}",
"cache",
".",
"push",
"(",
"value",
")",
";",
"}",
"return",
"value",
";",
"}",
")",
";",
"if",
"(",
"_active",
")",
"{",
"_backlog",
".",
"push",
"(",
"serialized",
")",
";",
"}",
"else",
"{",
"_apiCall",
"(",
"_token",
",",
"serialized",
")",
";",
"}",
"}",
"}",
";",
"}",
"}",
";",
"}"
] | Single arg stops the compiler arity warning | [
"Single",
"arg",
"stops",
"the",
"compiler",
"arity",
"warning"
] | f5f07b4a20e9d376734bb08e5b9a9def3a50687d | https://github.com/rapid7/le_js/blob/f5f07b4a20e9d376734bb08e5b9a9def3a50687d/src/le.js#L158-L220 | |
20,528 | rapid7/le_js | src/le.js | Logger | function Logger(options) {
var logger;
// Default values
var dict = {
ssl: true,
catchall: false,
trace: true,
page_info: 'never',
print: false,
endpoint: null,
token: null
};
if (typeof options === "object")
for (var k in options)
dict[k] = options[k];
else
throw new Error("Invalid parameters for createLogStream()");
if (dict.token === null) {
throw new Error("Token not present.");
} else {
logger = new LogStream(dict);
}
var _log = function(msg) {
if (logger) {
return logger.log.apply(this, arguments);
} else
throw new Error("You must call LE.init(...) first.");
};
// The public interface
return {
log: function() {
_log.apply(this, arguments).level('LOG').send();
},
warn: function() {
_log.apply(this, arguments).level('WARN').send();
},
error: function() {
_log.apply(this, arguments).level('ERROR').send();
},
info: function() {
_log.apply(this, arguments).level('INFO').send();
}
};
} | javascript | function Logger(options) {
var logger;
// Default values
var dict = {
ssl: true,
catchall: false,
trace: true,
page_info: 'never',
print: false,
endpoint: null,
token: null
};
if (typeof options === "object")
for (var k in options)
dict[k] = options[k];
else
throw new Error("Invalid parameters for createLogStream()");
if (dict.token === null) {
throw new Error("Token not present.");
} else {
logger = new LogStream(dict);
}
var _log = function(msg) {
if (logger) {
return logger.log.apply(this, arguments);
} else
throw new Error("You must call LE.init(...) first.");
};
// The public interface
return {
log: function() {
_log.apply(this, arguments).level('LOG').send();
},
warn: function() {
_log.apply(this, arguments).level('WARN').send();
},
error: function() {
_log.apply(this, arguments).level('ERROR').send();
},
info: function() {
_log.apply(this, arguments).level('INFO').send();
}
};
} | [
"function",
"Logger",
"(",
"options",
")",
"{",
"var",
"logger",
";",
"// Default values",
"var",
"dict",
"=",
"{",
"ssl",
":",
"true",
",",
"catchall",
":",
"false",
",",
"trace",
":",
"true",
",",
"page_info",
":",
"'never'",
",",
"print",
":",
"false",
",",
"endpoint",
":",
"null",
",",
"token",
":",
"null",
"}",
";",
"if",
"(",
"typeof",
"options",
"===",
"\"object\"",
")",
"for",
"(",
"var",
"k",
"in",
"options",
")",
"dict",
"[",
"k",
"]",
"=",
"options",
"[",
"k",
"]",
";",
"else",
"throw",
"new",
"Error",
"(",
"\"Invalid parameters for createLogStream()\"",
")",
";",
"if",
"(",
"dict",
".",
"token",
"===",
"null",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Token not present.\"",
")",
";",
"}",
"else",
"{",
"logger",
"=",
"new",
"LogStream",
"(",
"dict",
")",
";",
"}",
"var",
"_log",
"=",
"function",
"(",
"msg",
")",
"{",
"if",
"(",
"logger",
")",
"{",
"return",
"logger",
".",
"log",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"else",
"throw",
"new",
"Error",
"(",
"\"You must call LE.init(...) first.\"",
")",
";",
"}",
";",
"// The public interface",
"return",
"{",
"log",
":",
"function",
"(",
")",
"{",
"_log",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
".",
"level",
"(",
"'LOG'",
")",
".",
"send",
"(",
")",
";",
"}",
",",
"warn",
":",
"function",
"(",
")",
"{",
"_log",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
".",
"level",
"(",
"'WARN'",
")",
".",
"send",
"(",
")",
";",
"}",
",",
"error",
":",
"function",
"(",
")",
"{",
"_log",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
".",
"level",
"(",
"'ERROR'",
")",
".",
"send",
"(",
")",
";",
"}",
",",
"info",
":",
"function",
"(",
")",
"{",
"_log",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
".",
"level",
"(",
"'INFO'",
")",
".",
"send",
"(",
")",
";",
"}",
"}",
";",
"}"
] | A single log object
@constructor
@param {Object} options | [
"A",
"single",
"log",
"object"
] | f5f07b4a20e9d376734bb08e5b9a9def3a50687d | https://github.com/rapid7/le_js/blob/f5f07b4a20e9d376734bb08e5b9a9def3a50687d/src/le.js#L289-L337 |
20,529 | dschnelldavis/angular2-json-schema-form | build.js | _copyPackageJson | function _copyPackageJson(from, to) {
return new Promise((resolve, reject) => {
const origin = path.join(from, 'package.json');
const destination = path.join(to, 'package.json');
let data = JSON.parse(fs.readFileSync(origin, 'utf-8'));
delete data.engines;
delete data.scripts;
delete data.devDependencies;
fs.writeFileSync(destination, JSON.stringify(data, null, 2));
resolve();
});
} | javascript | function _copyPackageJson(from, to) {
return new Promise((resolve, reject) => {
const origin = path.join(from, 'package.json');
const destination = path.join(to, 'package.json');
let data = JSON.parse(fs.readFileSync(origin, 'utf-8'));
delete data.engines;
delete data.scripts;
delete data.devDependencies;
fs.writeFileSync(destination, JSON.stringify(data, null, 2));
resolve();
});
} | [
"function",
"_copyPackageJson",
"(",
"from",
",",
"to",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"origin",
"=",
"path",
".",
"join",
"(",
"from",
",",
"'package.json'",
")",
";",
"const",
"destination",
"=",
"path",
".",
"join",
"(",
"to",
",",
"'package.json'",
")",
";",
"let",
"data",
"=",
"JSON",
".",
"parse",
"(",
"fs",
".",
"readFileSync",
"(",
"origin",
",",
"'utf-8'",
")",
")",
";",
"delete",
"data",
".",
"engines",
";",
"delete",
"data",
".",
"scripts",
";",
"delete",
"data",
".",
"devDependencies",
";",
"fs",
".",
"writeFileSync",
"(",
"destination",
",",
"JSON",
".",
"stringify",
"(",
"data",
",",
"null",
",",
"2",
")",
")",
";",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}"
] | Copy and update package.json file. | [
"Copy",
"and",
"update",
"package",
".",
"json",
"file",
"."
] | 1a5bfee8744666d8504369ec9e6dfeb1c27f8ce1 | https://github.com/dschnelldavis/angular2-json-schema-form/blob/1a5bfee8744666d8504369ec9e6dfeb1c27f8ce1/build.js#L190-L201 |
20,530 | actionably/dashbot | examples/google-example-api-ai.js | getRandomNumber | function getRandomNumber(min, max) {
return Math.round(Math.random() * (max - min) + min);
} | javascript | function getRandomNumber(min, max) {
return Math.round(Math.random() * (max - min) + min);
} | [
"function",
"getRandomNumber",
"(",
"min",
",",
"max",
")",
"{",
"return",
"Math",
".",
"round",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"(",
"max",
"-",
"min",
")",
"+",
"min",
")",
";",
"}"
] | Generate the random number | [
"Generate",
"the",
"random",
"number"
] | 1e26498a806f28697975a5df257e156a952e7677 | https://github.com/actionably/dashbot/blob/1e26498a806f28697975a5df257e156a952e7677/examples/google-example-api-ai.js#L35-L37 |
20,531 | nodeshift/nodeshift | lib/resource-enrichers/labels-enricher.js | addLabelsToResource | async function addLabelsToResource (config, resourceList) {
return resourceList.map((resource) => {
const baseLabel = {
project: config.projectName,
version: config.projectVersion,
provider: 'nodeshift'
};
resource.metadata.labels = _.merge({}, baseLabel, resource.metadata.labels);
if (resource.kind === 'Deployment' || resource.kind === 'DeploymentConfig') {
resource.metadata.labels.app = config.projectName;
resource.spec.template.metadata.labels = _.merge({}, baseLabel, resource.spec.template.metadata.labels);
resource.spec.template.metadata.labels.app = config.projectName;
}
return resource;
});
} | javascript | async function addLabelsToResource (config, resourceList) {
return resourceList.map((resource) => {
const baseLabel = {
project: config.projectName,
version: config.projectVersion,
provider: 'nodeshift'
};
resource.metadata.labels = _.merge({}, baseLabel, resource.metadata.labels);
if (resource.kind === 'Deployment' || resource.kind === 'DeploymentConfig') {
resource.metadata.labels.app = config.projectName;
resource.spec.template.metadata.labels = _.merge({}, baseLabel, resource.spec.template.metadata.labels);
resource.spec.template.metadata.labels.app = config.projectName;
}
return resource;
});
} | [
"async",
"function",
"addLabelsToResource",
"(",
"config",
",",
"resourceList",
")",
"{",
"return",
"resourceList",
".",
"map",
"(",
"(",
"resource",
")",
"=>",
"{",
"const",
"baseLabel",
"=",
"{",
"project",
":",
"config",
".",
"projectName",
",",
"version",
":",
"config",
".",
"projectVersion",
",",
"provider",
":",
"'nodeshift'",
"}",
";",
"resource",
".",
"metadata",
".",
"labels",
"=",
"_",
".",
"merge",
"(",
"{",
"}",
",",
"baseLabel",
",",
"resource",
".",
"metadata",
".",
"labels",
")",
";",
"if",
"(",
"resource",
".",
"kind",
"===",
"'Deployment'",
"||",
"resource",
".",
"kind",
"===",
"'DeploymentConfig'",
")",
"{",
"resource",
".",
"metadata",
".",
"labels",
".",
"app",
"=",
"config",
".",
"projectName",
";",
"resource",
".",
"spec",
".",
"template",
".",
"metadata",
".",
"labels",
"=",
"_",
".",
"merge",
"(",
"{",
"}",
",",
"baseLabel",
",",
"resource",
".",
"spec",
".",
"template",
".",
"metadata",
".",
"labels",
")",
";",
"resource",
".",
"spec",
".",
"template",
".",
"metadata",
".",
"labels",
".",
"app",
"=",
"config",
".",
"projectName",
";",
"}",
"return",
"resource",
";",
"}",
")",
";",
"}"
] | Add labels to the metadata of a resource | [
"Add",
"labels",
"to",
"the",
"metadata",
"of",
"a",
"resource"
] | 22f8ae1e4f90b1325faf95939eb71226f8aa61f0 | https://github.com/nodeshift/nodeshift/blob/22f8ae1e4f90b1325faf95939eb71226f8aa61f0/lib/resource-enrichers/labels-enricher.js#L24-L43 |
20,532 | nodeshift/nodeshift | lib/load-enrichers.js | loadEnrichers | function loadEnrichers () {
// find all the js files in the resource-enrichers directory
const enrichers = fs.readdirSync(`${__dirname}/resource-enrichers`).reduce((loaded, file) => {
const filesSplit = file.split('.');
if (filesSplit[1] === 'js') {
const mod = require(`./resource-enrichers/${file}`);
loaded[mod.name] = mod.enrich;
return loaded;
}
return loaded;
}, {});
return enrichers;
} | javascript | function loadEnrichers () {
// find all the js files in the resource-enrichers directory
const enrichers = fs.readdirSync(`${__dirname}/resource-enrichers`).reduce((loaded, file) => {
const filesSplit = file.split('.');
if (filesSplit[1] === 'js') {
const mod = require(`./resource-enrichers/${file}`);
loaded[mod.name] = mod.enrich;
return loaded;
}
return loaded;
}, {});
return enrichers;
} | [
"function",
"loadEnrichers",
"(",
")",
"{",
"// find all the js files in the resource-enrichers directory",
"const",
"enrichers",
"=",
"fs",
".",
"readdirSync",
"(",
"`",
"${",
"__dirname",
"}",
"`",
")",
".",
"reduce",
"(",
"(",
"loaded",
",",
"file",
")",
"=>",
"{",
"const",
"filesSplit",
"=",
"file",
".",
"split",
"(",
"'.'",
")",
";",
"if",
"(",
"filesSplit",
"[",
"1",
"]",
"===",
"'js'",
")",
"{",
"const",
"mod",
"=",
"require",
"(",
"`",
"${",
"file",
"}",
"`",
")",
";",
"loaded",
"[",
"mod",
".",
"name",
"]",
"=",
"mod",
".",
"enrich",
";",
"return",
"loaded",
";",
"}",
"return",
"loaded",
";",
"}",
",",
"{",
"}",
")",
";",
"return",
"enrichers",
";",
"}"
] | Returns an object with the enrichers The key property will be the name prop from the enricher The value will be the enrich function from the enricher | [
"Returns",
"an",
"object",
"with",
"the",
"enrichers",
"The",
"key",
"property",
"will",
"be",
"the",
"name",
"prop",
"from",
"the",
"enricher",
"The",
"value",
"will",
"be",
"the",
"enrich",
"function",
"from",
"the",
"enricher"
] | 22f8ae1e4f90b1325faf95939eb71226f8aa61f0 | https://github.com/nodeshift/nodeshift/blob/22f8ae1e4f90b1325faf95939eb71226f8aa61f0/lib/load-enrichers.js#L26-L41 |
20,533 | nodeshift/nodeshift | lib/resource-enrichers/service-enricher.js | defaultService | function defaultService (config) {
const serviceConfig = _.merge({}, baseServiceConfig);
// Apply MetaData
serviceConfig.metadata = objectMetadata({
name: config.projectName,
namespace: config.namespace.name
});
serviceConfig.spec.selector = {
project: config.projectName,
provider: 'nodeshift'
};
serviceConfig.spec.ports = [
{
protocol: 'TCP',
port: config.port,
targetPort: config.port,
name: 'http'
}
];
serviceConfig.spec.type = 'ClusterIP';
return serviceConfig;
} | javascript | function defaultService (config) {
const serviceConfig = _.merge({}, baseServiceConfig);
// Apply MetaData
serviceConfig.metadata = objectMetadata({
name: config.projectName,
namespace: config.namespace.name
});
serviceConfig.spec.selector = {
project: config.projectName,
provider: 'nodeshift'
};
serviceConfig.spec.ports = [
{
protocol: 'TCP',
port: config.port,
targetPort: config.port,
name: 'http'
}
];
serviceConfig.spec.type = 'ClusterIP';
return serviceConfig;
} | [
"function",
"defaultService",
"(",
"config",
")",
"{",
"const",
"serviceConfig",
"=",
"_",
".",
"merge",
"(",
"{",
"}",
",",
"baseServiceConfig",
")",
";",
"// Apply MetaData",
"serviceConfig",
".",
"metadata",
"=",
"objectMetadata",
"(",
"{",
"name",
":",
"config",
".",
"projectName",
",",
"namespace",
":",
"config",
".",
"namespace",
".",
"name",
"}",
")",
";",
"serviceConfig",
".",
"spec",
".",
"selector",
"=",
"{",
"project",
":",
"config",
".",
"projectName",
",",
"provider",
":",
"'nodeshift'",
"}",
";",
"serviceConfig",
".",
"spec",
".",
"ports",
"=",
"[",
"{",
"protocol",
":",
"'TCP'",
",",
"port",
":",
"config",
".",
"port",
",",
"targetPort",
":",
"config",
".",
"port",
",",
"name",
":",
"'http'",
"}",
"]",
";",
"serviceConfig",
".",
"spec",
".",
"type",
"=",
"'ClusterIP'",
";",
"return",
"serviceConfig",
";",
"}"
] | Returns a default service config. need to figure out a better way to do those port mappings | [
"Returns",
"a",
"default",
"service",
"config",
".",
"need",
"to",
"figure",
"out",
"a",
"better",
"way",
"to",
"do",
"those",
"port",
"mappings"
] | 22f8ae1e4f90b1325faf95939eb71226f8aa61f0 | https://github.com/nodeshift/nodeshift/blob/22f8ae1e4f90b1325faf95939eb71226f8aa61f0/lib/resource-enrichers/service-enricher.js#L33-L59 |
20,534 | godong9/solr-node | lib/client.js | Client | function Client(options) {
this.options = {
host: options.host || '127.0.0.1',
port: options.port || '8983',
core: options.core || '',
rootPath: options.rootPath || 'solr',
protocol: options.protocol || 'http'
};
// Optional Authentication
if (options.user && options.password) {
this.options.user = options.user;
this.options.password = options.password;
}
// Path Constants List
this.SEARCH_PATH = 'select';
this.TERMS_PATH = 'terms';
this.SPELL_PATH = 'spell';
this.MLT_PATH = 'mlt';
this.UPDATE_PATH = 'update';
this.UPDATE_EXTRACT_PATH = 'update/extract';
this.PING_PATH = 'admin/ping';
this.SUGGEST_PATH = 'suggest';
} | javascript | function Client(options) {
this.options = {
host: options.host || '127.0.0.1',
port: options.port || '8983',
core: options.core || '',
rootPath: options.rootPath || 'solr',
protocol: options.protocol || 'http'
};
// Optional Authentication
if (options.user && options.password) {
this.options.user = options.user;
this.options.password = options.password;
}
// Path Constants List
this.SEARCH_PATH = 'select';
this.TERMS_PATH = 'terms';
this.SPELL_PATH = 'spell';
this.MLT_PATH = 'mlt';
this.UPDATE_PATH = 'update';
this.UPDATE_EXTRACT_PATH = 'update/extract';
this.PING_PATH = 'admin/ping';
this.SUGGEST_PATH = 'suggest';
} | [
"function",
"Client",
"(",
"options",
")",
"{",
"this",
".",
"options",
"=",
"{",
"host",
":",
"options",
".",
"host",
"||",
"'127.0.0.1'",
",",
"port",
":",
"options",
".",
"port",
"||",
"'8983'",
",",
"core",
":",
"options",
".",
"core",
"||",
"''",
",",
"rootPath",
":",
"options",
".",
"rootPath",
"||",
"'solr'",
",",
"protocol",
":",
"options",
".",
"protocol",
"||",
"'http'",
"}",
";",
"// Optional Authentication",
"if",
"(",
"options",
".",
"user",
"&&",
"options",
".",
"password",
")",
"{",
"this",
".",
"options",
".",
"user",
"=",
"options",
".",
"user",
";",
"this",
".",
"options",
".",
"password",
"=",
"options",
".",
"password",
";",
"}",
"// Path Constants List",
"this",
".",
"SEARCH_PATH",
"=",
"'select'",
";",
"this",
".",
"TERMS_PATH",
"=",
"'terms'",
";",
"this",
".",
"SPELL_PATH",
"=",
"'spell'",
";",
"this",
".",
"MLT_PATH",
"=",
"'mlt'",
";",
"this",
".",
"UPDATE_PATH",
"=",
"'update'",
";",
"this",
".",
"UPDATE_EXTRACT_PATH",
"=",
"'update/extract'",
";",
"this",
".",
"PING_PATH",
"=",
"'admin/ping'",
";",
"this",
".",
"SUGGEST_PATH",
"=",
"'suggest'",
";",
"}"
] | Solr Node Client
@constructor
@param {Object} options
@param {String} [options.host] - host address of Solr server
@param {Number|String} [options.port] - port number of Solr server
@param {String} [options.core] - client core name
@param {String} [options.user] - client user name
@param {String} [options.password] - client password name
@param {String} [options.rootPath] - solr root path
@param {String} [options.protocol] - request protocol ('http'|'https') | [
"Solr",
"Node",
"Client"
] | 4db8c34e1bd4d4cf13f5fa7c4d1298a52efa62b1 | https://github.com/godong9/solr-node/blob/4db8c34e1bd4d4cf13f5fa7c4d1298a52efa62b1/lib/client.js#L28-L51 |
20,535 | infusion/Quaternion.js | quaternion.js | function() {
// Q* := Q / |Q|
// unrolled Q.scale(1 / Q.norm())
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var norm = Math.sqrt(w * w + x * x + y * y + z * z);
if (norm < Quaternion['EPSILON']) {
return Quaternion['ZERO'];
}
norm = 1 / norm;
return new Quaternion(w * norm, x * norm, y * norm, z * norm);
} | javascript | function() {
// Q* := Q / |Q|
// unrolled Q.scale(1 / Q.norm())
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var norm = Math.sqrt(w * w + x * x + y * y + z * z);
if (norm < Quaternion['EPSILON']) {
return Quaternion['ZERO'];
}
norm = 1 / norm;
return new Quaternion(w * norm, x * norm, y * norm, z * norm);
} | [
"function",
"(",
")",
"{",
"// Q* := Q / |Q|",
"// unrolled Q.scale(1 / Q.norm())",
"var",
"w",
"=",
"this",
"[",
"'w'",
"]",
";",
"var",
"x",
"=",
"this",
"[",
"'x'",
"]",
";",
"var",
"y",
"=",
"this",
"[",
"'y'",
"]",
";",
"var",
"z",
"=",
"this",
"[",
"'z'",
"]",
";",
"var",
"norm",
"=",
"Math",
".",
"sqrt",
"(",
"w",
"*",
"w",
"+",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
"+",
"z",
"*",
"z",
")",
";",
"if",
"(",
"norm",
"<",
"Quaternion",
"[",
"'EPSILON'",
"]",
")",
"{",
"return",
"Quaternion",
"[",
"'ZERO'",
"]",
";",
"}",
"norm",
"=",
"1",
"/",
"norm",
";",
"return",
"new",
"Quaternion",
"(",
"w",
"*",
"norm",
",",
"x",
"*",
"norm",
",",
"y",
"*",
"norm",
",",
"z",
"*",
"norm",
")",
";",
"}"
] | Normalizes the quaternion to have |Q| = 1 as long as the norm is not zero
Alternative names are the signum, unit or versor
@returns {Quaternion} | [
"Normalizes",
"the",
"quaternion",
"to",
"have",
"|Q|",
"=",
"1",
"as",
"long",
"as",
"the",
"norm",
"is",
"not",
"zero",
"Alternative",
"names",
"are",
"the",
"signum",
"unit",
"or",
"versor"
] | 3c6ef625b2d1ea5274b62eae8dacd564ec917ea4 | https://github.com/infusion/Quaternion.js/blob/3c6ef625b2d1ea5274b62eae8dacd564ec917ea4/quaternion.js#L342-L362 | |
20,536 | infusion/Quaternion.js | quaternion.js | function(w, x, y, z) {
parse(P, w, x, y, z);
// Q1 * Q2 = [w1 * w2 - dot(v1, v2), w1 * v2 + w2 * v1 + cross(v1, v2)]
// Not commutative because cross(v1, v2) != cross(v2, v1)!
var w1 = this['w'];
var x1 = this['x'];
var y1 = this['y'];
var z1 = this['z'];
var w2 = P['w'];
var x2 = P['x'];
var y2 = P['y'];
var z2 = P['z'];
return new Quaternion(
w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2,
w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2,
w1 * y2 + y1 * w2 + z1 * x2 - x1 * z2,
w1 * z2 + z1 * w2 + x1 * y2 - y1 * x2);
} | javascript | function(w, x, y, z) {
parse(P, w, x, y, z);
// Q1 * Q2 = [w1 * w2 - dot(v1, v2), w1 * v2 + w2 * v1 + cross(v1, v2)]
// Not commutative because cross(v1, v2) != cross(v2, v1)!
var w1 = this['w'];
var x1 = this['x'];
var y1 = this['y'];
var z1 = this['z'];
var w2 = P['w'];
var x2 = P['x'];
var y2 = P['y'];
var z2 = P['z'];
return new Quaternion(
w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2,
w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2,
w1 * y2 + y1 * w2 + z1 * x2 - x1 * z2,
w1 * z2 + z1 * w2 + x1 * y2 - y1 * x2);
} | [
"function",
"(",
"w",
",",
"x",
",",
"y",
",",
"z",
")",
"{",
"parse",
"(",
"P",
",",
"w",
",",
"x",
",",
"y",
",",
"z",
")",
";",
"// Q1 * Q2 = [w1 * w2 - dot(v1, v2), w1 * v2 + w2 * v1 + cross(v1, v2)]",
"// Not commutative because cross(v1, v2) != cross(v2, v1)!",
"var",
"w1",
"=",
"this",
"[",
"'w'",
"]",
";",
"var",
"x1",
"=",
"this",
"[",
"'x'",
"]",
";",
"var",
"y1",
"=",
"this",
"[",
"'y'",
"]",
";",
"var",
"z1",
"=",
"this",
"[",
"'z'",
"]",
";",
"var",
"w2",
"=",
"P",
"[",
"'w'",
"]",
";",
"var",
"x2",
"=",
"P",
"[",
"'x'",
"]",
";",
"var",
"y2",
"=",
"P",
"[",
"'y'",
"]",
";",
"var",
"z2",
"=",
"P",
"[",
"'z'",
"]",
";",
"return",
"new",
"Quaternion",
"(",
"w1",
"*",
"w2",
"-",
"x1",
"*",
"x2",
"-",
"y1",
"*",
"y2",
"-",
"z1",
"*",
"z2",
",",
"w1",
"*",
"x2",
"+",
"x1",
"*",
"w2",
"+",
"y1",
"*",
"z2",
"-",
"z1",
"*",
"y2",
",",
"w1",
"*",
"y2",
"+",
"y1",
"*",
"w2",
"+",
"z1",
"*",
"x2",
"-",
"x1",
"*",
"z2",
",",
"w1",
"*",
"z2",
"+",
"z1",
"*",
"w2",
"+",
"x1",
"*",
"y2",
"-",
"y1",
"*",
"x2",
")",
";",
"}"
] | Calculates the Hamilton product of two quaternions
Leaving out the imaginary part results in just scaling the quat
@param {number|Object|string} w real
@param {number=} x imag
@param {number=} y imag
@param {number=} z imag
@returns {Quaternion} | [
"Calculates",
"the",
"Hamilton",
"product",
"of",
"two",
"quaternions",
"Leaving",
"out",
"the",
"imaginary",
"part",
"results",
"in",
"just",
"scaling",
"the",
"quat"
] | 3c6ef625b2d1ea5274b62eae8dacd564ec917ea4 | https://github.com/infusion/Quaternion.js/blob/3c6ef625b2d1ea5274b62eae8dacd564ec917ea4/quaternion.js#L373-L396 | |
20,537 | infusion/Quaternion.js | quaternion.js | function(w, x, y, z) {
parse(P, w, x, y, z);
// dot(Q1, Q2) := w1 * w2 + dot(v1, v2)
return this['w'] * P['w'] + this['x'] * P['x'] + this['y'] * P['y'] + this['z'] * P['z'];
} | javascript | function(w, x, y, z) {
parse(P, w, x, y, z);
// dot(Q1, Q2) := w1 * w2 + dot(v1, v2)
return this['w'] * P['w'] + this['x'] * P['x'] + this['y'] * P['y'] + this['z'] * P['z'];
} | [
"function",
"(",
"w",
",",
"x",
",",
"y",
",",
"z",
")",
"{",
"parse",
"(",
"P",
",",
"w",
",",
"x",
",",
"y",
",",
"z",
")",
";",
"// dot(Q1, Q2) := w1 * w2 + dot(v1, v2)",
"return",
"this",
"[",
"'w'",
"]",
"*",
"P",
"[",
"'w'",
"]",
"+",
"this",
"[",
"'x'",
"]",
"*",
"P",
"[",
"'x'",
"]",
"+",
"this",
"[",
"'y'",
"]",
"*",
"P",
"[",
"'y'",
"]",
"+",
"this",
"[",
"'z'",
"]",
"*",
"P",
"[",
"'z'",
"]",
";",
"}"
] | Calculates the dot product of two quaternions
@param {number|Object|string} w real
@param {number=} x imag
@param {number=} y imag
@param {number=} z imag
@returns {number} | [
"Calculates",
"the",
"dot",
"product",
"of",
"two",
"quaternions"
] | 3c6ef625b2d1ea5274b62eae8dacd564ec917ea4 | https://github.com/infusion/Quaternion.js/blob/3c6ef625b2d1ea5274b62eae8dacd564ec917ea4/quaternion.js#L420-L427 | |
20,538 | infusion/Quaternion.js | quaternion.js | function() {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var vNorm = Math.sqrt(x * x + y * y + z * z);
var wExp = Math.exp(w);
var scale = wExp / vNorm * Math.sin(vNorm);
if (vNorm === 0) {
//return new Quaternion(wExp * Math.cos(vNorm), 0, 0, 0);
return new Quaternion(wExp, 0, 0, 0);
}
return new Quaternion(
wExp * Math.cos(vNorm),
x * scale,
y * scale,
z * scale);
} | javascript | function() {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var vNorm = Math.sqrt(x * x + y * y + z * z);
var wExp = Math.exp(w);
var scale = wExp / vNorm * Math.sin(vNorm);
if (vNorm === 0) {
//return new Quaternion(wExp * Math.cos(vNorm), 0, 0, 0);
return new Quaternion(wExp, 0, 0, 0);
}
return new Quaternion(
wExp * Math.cos(vNorm),
x * scale,
y * scale,
z * scale);
} | [
"function",
"(",
")",
"{",
"var",
"w",
"=",
"this",
"[",
"'w'",
"]",
";",
"var",
"x",
"=",
"this",
"[",
"'x'",
"]",
";",
"var",
"y",
"=",
"this",
"[",
"'y'",
"]",
";",
"var",
"z",
"=",
"this",
"[",
"'z'",
"]",
";",
"var",
"vNorm",
"=",
"Math",
".",
"sqrt",
"(",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
"+",
"z",
"*",
"z",
")",
";",
"var",
"wExp",
"=",
"Math",
".",
"exp",
"(",
"w",
")",
";",
"var",
"scale",
"=",
"wExp",
"/",
"vNorm",
"*",
"Math",
".",
"sin",
"(",
"vNorm",
")",
";",
"if",
"(",
"vNorm",
"===",
"0",
")",
"{",
"//return new Quaternion(wExp * Math.cos(vNorm), 0, 0, 0);",
"return",
"new",
"Quaternion",
"(",
"wExp",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"}",
"return",
"new",
"Quaternion",
"(",
"wExp",
"*",
"Math",
".",
"cos",
"(",
"vNorm",
")",
",",
"x",
"*",
"scale",
",",
"y",
"*",
"scale",
",",
"z",
"*",
"scale",
")",
";",
"}"
] | Calculates the natural exponentiation of the quaternion
@returns {Quaternion} | [
"Calculates",
"the",
"natural",
"exponentiation",
"of",
"the",
"quaternion"
] | 3c6ef625b2d1ea5274b62eae8dacd564ec917ea4 | https://github.com/infusion/Quaternion.js/blob/3c6ef625b2d1ea5274b62eae8dacd564ec917ea4/quaternion.js#L525-L546 | |
20,539 | infusion/Quaternion.js | quaternion.js | function() {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
if (y === 0 && z === 0) {
return new Quaternion(
logHypot(w, x),
Math.atan2(x, w), 0, 0);
}
var qNorm2 = x * x + y * y + z * z + w * w;
var vNorm = Math.sqrt(x * x + y * y + z * z);
var scale = Math.atan2(vNorm, w) / vNorm;
return new Quaternion(
Math.log(qNorm2) * 0.5,
x * scale,
y * scale,
z * scale);
} | javascript | function() {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
if (y === 0 && z === 0) {
return new Quaternion(
logHypot(w, x),
Math.atan2(x, w), 0, 0);
}
var qNorm2 = x * x + y * y + z * z + w * w;
var vNorm = Math.sqrt(x * x + y * y + z * z);
var scale = Math.atan2(vNorm, w) / vNorm;
return new Quaternion(
Math.log(qNorm2) * 0.5,
x * scale,
y * scale,
z * scale);
} | [
"function",
"(",
")",
"{",
"var",
"w",
"=",
"this",
"[",
"'w'",
"]",
";",
"var",
"x",
"=",
"this",
"[",
"'x'",
"]",
";",
"var",
"y",
"=",
"this",
"[",
"'y'",
"]",
";",
"var",
"z",
"=",
"this",
"[",
"'z'",
"]",
";",
"if",
"(",
"y",
"===",
"0",
"&&",
"z",
"===",
"0",
")",
"{",
"return",
"new",
"Quaternion",
"(",
"logHypot",
"(",
"w",
",",
"x",
")",
",",
"Math",
".",
"atan2",
"(",
"x",
",",
"w",
")",
",",
"0",
",",
"0",
")",
";",
"}",
"var",
"qNorm2",
"=",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
"+",
"z",
"*",
"z",
"+",
"w",
"*",
"w",
";",
"var",
"vNorm",
"=",
"Math",
".",
"sqrt",
"(",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
"+",
"z",
"*",
"z",
")",
";",
"var",
"scale",
"=",
"Math",
".",
"atan2",
"(",
"vNorm",
",",
"w",
")",
"/",
"vNorm",
";",
"return",
"new",
"Quaternion",
"(",
"Math",
".",
"log",
"(",
"qNorm2",
")",
"*",
"0.5",
",",
"x",
"*",
"scale",
",",
"y",
"*",
"scale",
",",
"z",
"*",
"scale",
")",
";",
"}"
] | Calculates the natural logarithm of the quaternion
@returns {Quaternion} | [
"Calculates",
"the",
"natural",
"logarithm",
"of",
"the",
"quaternion"
] | 3c6ef625b2d1ea5274b62eae8dacd564ec917ea4 | https://github.com/infusion/Quaternion.js/blob/3c6ef625b2d1ea5274b62eae8dacd564ec917ea4/quaternion.js#L552-L575 | |
20,540 | infusion/Quaternion.js | quaternion.js | function(w, x, y, z) {
parse(P, w, x, y, z);
if (P['y'] === 0 && P['z'] === 0) {
if (P['w'] === 1 && P['x'] === 0) {
return this;
}
if (P['w'] === 0 && P['x'] === 0) {
return Quaternion['ONE'];
}
// Check if we can operate in C
// Borrowed from complex.js
if (this['y'] === 0 && this['z'] === 0) {
var a = this['w'];
var b = this['x'];
if (a === 0 && b === 0) {
return Quaternion['ZERO'];
}
var arg = Math.atan2(b, a);
var loh = logHypot(a, b);
if (P['x'] === 0) {
if (b === 0 && a >= 0) {
return new Quaternion(Math.pow(a, P['w']), 0, 0, 0);
} else if (a === 0) {
switch (P['w'] % 4) {
case 0:
return new Quaternion(Math.pow(b, P['w']), 0, 0, 0);
case 1:
return new Quaternion(0, Math.pow(b, P['w']), 0, 0);
case 2:
return new Quaternion(-Math.pow(b, P['w']), 0, 0, 0);
case 3:
return new Quaternion(0, -Math.pow(b, P['w']), 0, 0);
}
}
}
a = Math.exp(P['w'] * loh - P['x'] * arg);
b = P['x'] * loh + P['w'] * arg;
return new Quaternion(
a * Math.cos(b),
a * Math.sin(b), 0, 0);
}
}
// Normal quaternion behavior
// q^p = e^ln(q^p) = e^(ln(q)*p)
return this.log().mul(P).exp();
} | javascript | function(w, x, y, z) {
parse(P, w, x, y, z);
if (P['y'] === 0 && P['z'] === 0) {
if (P['w'] === 1 && P['x'] === 0) {
return this;
}
if (P['w'] === 0 && P['x'] === 0) {
return Quaternion['ONE'];
}
// Check if we can operate in C
// Borrowed from complex.js
if (this['y'] === 0 && this['z'] === 0) {
var a = this['w'];
var b = this['x'];
if (a === 0 && b === 0) {
return Quaternion['ZERO'];
}
var arg = Math.atan2(b, a);
var loh = logHypot(a, b);
if (P['x'] === 0) {
if (b === 0 && a >= 0) {
return new Quaternion(Math.pow(a, P['w']), 0, 0, 0);
} else if (a === 0) {
switch (P['w'] % 4) {
case 0:
return new Quaternion(Math.pow(b, P['w']), 0, 0, 0);
case 1:
return new Quaternion(0, Math.pow(b, P['w']), 0, 0);
case 2:
return new Quaternion(-Math.pow(b, P['w']), 0, 0, 0);
case 3:
return new Quaternion(0, -Math.pow(b, P['w']), 0, 0);
}
}
}
a = Math.exp(P['w'] * loh - P['x'] * arg);
b = P['x'] * loh + P['w'] * arg;
return new Quaternion(
a * Math.cos(b),
a * Math.sin(b), 0, 0);
}
}
// Normal quaternion behavior
// q^p = e^ln(q^p) = e^(ln(q)*p)
return this.log().mul(P).exp();
} | [
"function",
"(",
"w",
",",
"x",
",",
"y",
",",
"z",
")",
"{",
"parse",
"(",
"P",
",",
"w",
",",
"x",
",",
"y",
",",
"z",
")",
";",
"if",
"(",
"P",
"[",
"'y'",
"]",
"===",
"0",
"&&",
"P",
"[",
"'z'",
"]",
"===",
"0",
")",
"{",
"if",
"(",
"P",
"[",
"'w'",
"]",
"===",
"1",
"&&",
"P",
"[",
"'x'",
"]",
"===",
"0",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"P",
"[",
"'w'",
"]",
"===",
"0",
"&&",
"P",
"[",
"'x'",
"]",
"===",
"0",
")",
"{",
"return",
"Quaternion",
"[",
"'ONE'",
"]",
";",
"}",
"// Check if we can operate in C",
"// Borrowed from complex.js",
"if",
"(",
"this",
"[",
"'y'",
"]",
"===",
"0",
"&&",
"this",
"[",
"'z'",
"]",
"===",
"0",
")",
"{",
"var",
"a",
"=",
"this",
"[",
"'w'",
"]",
";",
"var",
"b",
"=",
"this",
"[",
"'x'",
"]",
";",
"if",
"(",
"a",
"===",
"0",
"&&",
"b",
"===",
"0",
")",
"{",
"return",
"Quaternion",
"[",
"'ZERO'",
"]",
";",
"}",
"var",
"arg",
"=",
"Math",
".",
"atan2",
"(",
"b",
",",
"a",
")",
";",
"var",
"loh",
"=",
"logHypot",
"(",
"a",
",",
"b",
")",
";",
"if",
"(",
"P",
"[",
"'x'",
"]",
"===",
"0",
")",
"{",
"if",
"(",
"b",
"===",
"0",
"&&",
"a",
">=",
"0",
")",
"{",
"return",
"new",
"Quaternion",
"(",
"Math",
".",
"pow",
"(",
"a",
",",
"P",
"[",
"'w'",
"]",
")",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"}",
"else",
"if",
"(",
"a",
"===",
"0",
")",
"{",
"switch",
"(",
"P",
"[",
"'w'",
"]",
"%",
"4",
")",
"{",
"case",
"0",
":",
"return",
"new",
"Quaternion",
"(",
"Math",
".",
"pow",
"(",
"b",
",",
"P",
"[",
"'w'",
"]",
")",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"case",
"1",
":",
"return",
"new",
"Quaternion",
"(",
"0",
",",
"Math",
".",
"pow",
"(",
"b",
",",
"P",
"[",
"'w'",
"]",
")",
",",
"0",
",",
"0",
")",
";",
"case",
"2",
":",
"return",
"new",
"Quaternion",
"(",
"-",
"Math",
".",
"pow",
"(",
"b",
",",
"P",
"[",
"'w'",
"]",
")",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"case",
"3",
":",
"return",
"new",
"Quaternion",
"(",
"0",
",",
"-",
"Math",
".",
"pow",
"(",
"b",
",",
"P",
"[",
"'w'",
"]",
")",
",",
"0",
",",
"0",
")",
";",
"}",
"}",
"}",
"a",
"=",
"Math",
".",
"exp",
"(",
"P",
"[",
"'w'",
"]",
"*",
"loh",
"-",
"P",
"[",
"'x'",
"]",
"*",
"arg",
")",
";",
"b",
"=",
"P",
"[",
"'x'",
"]",
"*",
"loh",
"+",
"P",
"[",
"'w'",
"]",
"*",
"arg",
";",
"return",
"new",
"Quaternion",
"(",
"a",
"*",
"Math",
".",
"cos",
"(",
"b",
")",
",",
"a",
"*",
"Math",
".",
"sin",
"(",
"b",
")",
",",
"0",
",",
"0",
")",
";",
"}",
"}",
"// Normal quaternion behavior",
"// q^p = e^ln(q^p) = e^(ln(q)*p)",
"return",
"this",
".",
"log",
"(",
")",
".",
"mul",
"(",
"P",
")",
".",
"exp",
"(",
")",
";",
"}"
] | Calculates the power of a quaternion raised to a real number or another quaternion
@param {number|Object|string} w real
@param {number=} x imag
@param {number=} y imag
@param {number=} z imag
@returns {Quaternion} | [
"Calculates",
"the",
"power",
"of",
"a",
"quaternion",
"raised",
"to",
"a",
"real",
"number",
"or",
"another",
"quaternion"
] | 3c6ef625b2d1ea5274b62eae8dacd564ec917ea4 | https://github.com/infusion/Quaternion.js/blob/3c6ef625b2d1ea5274b62eae8dacd564ec917ea4/quaternion.js#L585-L645 | |
20,541 | infusion/Quaternion.js | quaternion.js | function(w, x, y, z) {
parse(P, w, x, y, z);
var eps = Quaternion['EPSILON'];
// maybe check for NaN's here?
return Math.abs(P['w'] - this['w']) < eps
&& Math.abs(P['x'] - this['x']) < eps
&& Math.abs(P['y'] - this['y']) < eps
&& Math.abs(P['z'] - this['z']) < eps;
} | javascript | function(w, x, y, z) {
parse(P, w, x, y, z);
var eps = Quaternion['EPSILON'];
// maybe check for NaN's here?
return Math.abs(P['w'] - this['w']) < eps
&& Math.abs(P['x'] - this['x']) < eps
&& Math.abs(P['y'] - this['y']) < eps
&& Math.abs(P['z'] - this['z']) < eps;
} | [
"function",
"(",
"w",
",",
"x",
",",
"y",
",",
"z",
")",
"{",
"parse",
"(",
"P",
",",
"w",
",",
"x",
",",
"y",
",",
"z",
")",
";",
"var",
"eps",
"=",
"Quaternion",
"[",
"'EPSILON'",
"]",
";",
"// maybe check for NaN's here?",
"return",
"Math",
".",
"abs",
"(",
"P",
"[",
"'w'",
"]",
"-",
"this",
"[",
"'w'",
"]",
")",
"<",
"eps",
"&&",
"Math",
".",
"abs",
"(",
"P",
"[",
"'x'",
"]",
"-",
"this",
"[",
"'x'",
"]",
")",
"<",
"eps",
"&&",
"Math",
".",
"abs",
"(",
"P",
"[",
"'y'",
"]",
"-",
"this",
"[",
"'y'",
"]",
")",
"<",
"eps",
"&&",
"Math",
".",
"abs",
"(",
"P",
"[",
"'z'",
"]",
"-",
"this",
"[",
"'z'",
"]",
")",
"<",
"eps",
";",
"}"
] | Checks if two quats are the same
@param {number|Object|string} w real
@param {number=} x imag
@param {number=} y imag
@param {number=} z imag
@returns {boolean} | [
"Checks",
"if",
"two",
"quats",
"are",
"the",
"same"
] | 3c6ef625b2d1ea5274b62eae8dacd564ec917ea4 | https://github.com/infusion/Quaternion.js/blob/3c6ef625b2d1ea5274b62eae8dacd564ec917ea4/quaternion.js#L655-L666 | |
20,542 | infusion/Quaternion.js | quaternion.js | function() {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var ret = '';
if (isNaN(w) || isNaN(x) || isNaN(y) || isNaN(z)) {
return 'NaN';
}
// Alternative design?
// '(%f, [%f %f %f])'
ret = numToStr(w, '', ret);
ret += numToStr(x, 'i', ret);
ret += numToStr(y, 'j', ret);
ret += numToStr(z, 'k', ret);
if ('' === ret)
return '0';
return ret;
} | javascript | function() {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var ret = '';
if (isNaN(w) || isNaN(x) || isNaN(y) || isNaN(z)) {
return 'NaN';
}
// Alternative design?
// '(%f, [%f %f %f])'
ret = numToStr(w, '', ret);
ret += numToStr(x, 'i', ret);
ret += numToStr(y, 'j', ret);
ret += numToStr(z, 'k', ret);
if ('' === ret)
return '0';
return ret;
} | [
"function",
"(",
")",
"{",
"var",
"w",
"=",
"this",
"[",
"'w'",
"]",
";",
"var",
"x",
"=",
"this",
"[",
"'x'",
"]",
";",
"var",
"y",
"=",
"this",
"[",
"'y'",
"]",
";",
"var",
"z",
"=",
"this",
"[",
"'z'",
"]",
";",
"var",
"ret",
"=",
"''",
";",
"if",
"(",
"isNaN",
"(",
"w",
")",
"||",
"isNaN",
"(",
"x",
")",
"||",
"isNaN",
"(",
"y",
")",
"||",
"isNaN",
"(",
"z",
")",
")",
"{",
"return",
"'NaN'",
";",
"}",
"// Alternative design?",
"// '(%f, [%f %f %f])'",
"ret",
"=",
"numToStr",
"(",
"w",
",",
"''",
",",
"ret",
")",
";",
"ret",
"+=",
"numToStr",
"(",
"x",
",",
"'i'",
",",
"ret",
")",
";",
"ret",
"+=",
"numToStr",
"(",
"y",
",",
"'j'",
",",
"ret",
")",
";",
"ret",
"+=",
"numToStr",
"(",
"z",
",",
"'k'",
",",
"ret",
")",
";",
"if",
"(",
"''",
"===",
"ret",
")",
"return",
"'0'",
";",
"return",
"ret",
";",
"}"
] | Gets the Quaternion as a well formatted string
@returns {string} | [
"Gets",
"the",
"Quaternion",
"as",
"a",
"well",
"formatted",
"string"
] | 3c6ef625b2d1ea5274b62eae8dacd564ec917ea4 | https://github.com/infusion/Quaternion.js/blob/3c6ef625b2d1ea5274b62eae8dacd564ec917ea4/quaternion.js#L690-L714 | |
20,543 | infusion/Quaternion.js | quaternion.js | function(d2) {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var n = w * w + x * x + y * y + z * z;
var s = n === 0 ? 0 : 2 / n;
var wx = s * w * x, wy = s * w * y, wz = s * w * z;
var xx = s * x * x, xy = s * x * y, xz = s * x * z;
var yy = s * y * y, yz = s * y * z, zz = s * z * z;
if (d2) {
return [
[1 - (yy + zz), xy - wz, xz + wy],
[xy + wz, 1 - (xx + zz), yz - wx],
[xz - wy, yz + wx, 1 - (xx + yy)]];
}
return [
1 - (yy + zz), xy - wz, xz + wy,
xy + wz, 1 - (xx + zz), yz - wx,
xz - wy, yz + wx, 1 - (xx + yy)];
} | javascript | function(d2) {
var w = this['w'];
var x = this['x'];
var y = this['y'];
var z = this['z'];
var n = w * w + x * x + y * y + z * z;
var s = n === 0 ? 0 : 2 / n;
var wx = s * w * x, wy = s * w * y, wz = s * w * z;
var xx = s * x * x, xy = s * x * y, xz = s * x * z;
var yy = s * y * y, yz = s * y * z, zz = s * z * z;
if (d2) {
return [
[1 - (yy + zz), xy - wz, xz + wy],
[xy + wz, 1 - (xx + zz), yz - wx],
[xz - wy, yz + wx, 1 - (xx + yy)]];
}
return [
1 - (yy + zz), xy - wz, xz + wy,
xy + wz, 1 - (xx + zz), yz - wx,
xz - wy, yz + wx, 1 - (xx + yy)];
} | [
"function",
"(",
"d2",
")",
"{",
"var",
"w",
"=",
"this",
"[",
"'w'",
"]",
";",
"var",
"x",
"=",
"this",
"[",
"'x'",
"]",
";",
"var",
"y",
"=",
"this",
"[",
"'y'",
"]",
";",
"var",
"z",
"=",
"this",
"[",
"'z'",
"]",
";",
"var",
"n",
"=",
"w",
"*",
"w",
"+",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
"+",
"z",
"*",
"z",
";",
"var",
"s",
"=",
"n",
"===",
"0",
"?",
"0",
":",
"2",
"/",
"n",
";",
"var",
"wx",
"=",
"s",
"*",
"w",
"*",
"x",
",",
"wy",
"=",
"s",
"*",
"w",
"*",
"y",
",",
"wz",
"=",
"s",
"*",
"w",
"*",
"z",
";",
"var",
"xx",
"=",
"s",
"*",
"x",
"*",
"x",
",",
"xy",
"=",
"s",
"*",
"x",
"*",
"y",
",",
"xz",
"=",
"s",
"*",
"x",
"*",
"z",
";",
"var",
"yy",
"=",
"s",
"*",
"y",
"*",
"y",
",",
"yz",
"=",
"s",
"*",
"y",
"*",
"z",
",",
"zz",
"=",
"s",
"*",
"z",
"*",
"z",
";",
"if",
"(",
"d2",
")",
"{",
"return",
"[",
"[",
"1",
"-",
"(",
"yy",
"+",
"zz",
")",
",",
"xy",
"-",
"wz",
",",
"xz",
"+",
"wy",
"]",
",",
"[",
"xy",
"+",
"wz",
",",
"1",
"-",
"(",
"xx",
"+",
"zz",
")",
",",
"yz",
"-",
"wx",
"]",
",",
"[",
"xz",
"-",
"wy",
",",
"yz",
"+",
"wx",
",",
"1",
"-",
"(",
"xx",
"+",
"yy",
")",
"]",
"]",
";",
"}",
"return",
"[",
"1",
"-",
"(",
"yy",
"+",
"zz",
")",
",",
"xy",
"-",
"wz",
",",
"xz",
"+",
"wy",
",",
"xy",
"+",
"wz",
",",
"1",
"-",
"(",
"xx",
"+",
"zz",
")",
",",
"yz",
"-",
"wx",
",",
"xz",
"-",
"wy",
",",
"yz",
"+",
"wx",
",",
"1",
"-",
"(",
"xx",
"+",
"yy",
")",
"]",
";",
"}"
] | Calculates the 3x3 rotation matrix for the current quat
@param {boolean=} d2
@see https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion
@returns {Array} | [
"Calculates",
"the",
"3x3",
"rotation",
"matrix",
"for",
"the",
"current",
"quat"
] | 3c6ef625b2d1ea5274b62eae8dacd564ec917ea4 | https://github.com/infusion/Quaternion.js/blob/3c6ef625b2d1ea5274b62eae8dacd564ec917ea4/quaternion.js#L749-L773 | |
20,544 | infusion/Quaternion.js | quaternion.js | function(v) {
// [0, v'] = Q * [0, v] * Q'
// Q
var w1 = this['w'];
var x1 = this['x'];
var y1 = this['y'];
var z1 = this['z'];
// [0, v]
var w2 = 0;
var x2 = v[0];
var y2 = v[1];
var z2 = v[2];
// Q * [0, v]
var w3 = /*w1 * w2*/ -x1 * x2 - y1 * y2 - z1 * z2;
var x3 = w1 * x2 + /*x1 * w2 +*/ y1 * z2 - z1 * y2;
var y3 = w1 * y2 + /*y1 * w2 +*/ z1 * x2 - x1 * z2;
var z3 = w1 * z2 + /*z1 * w2 +*/ x1 * y2 - y1 * x2;
var w4 = w3 * w1 + x3 * x1 + y3 * y1 + z3 * z1;
var x4 = x3 * w1 - w3 * x1 - y3 * z1 + z3 * y1;
var y4 = y3 * w1 - w3 * y1 - z3 * x1 + x3 * z1;
var z4 = z3 * w1 - w3 * z1 - x3 * y1 + y3 * x1;
return [x4, y4, z4];
} | javascript | function(v) {
// [0, v'] = Q * [0, v] * Q'
// Q
var w1 = this['w'];
var x1 = this['x'];
var y1 = this['y'];
var z1 = this['z'];
// [0, v]
var w2 = 0;
var x2 = v[0];
var y2 = v[1];
var z2 = v[2];
// Q * [0, v]
var w3 = /*w1 * w2*/ -x1 * x2 - y1 * y2 - z1 * z2;
var x3 = w1 * x2 + /*x1 * w2 +*/ y1 * z2 - z1 * y2;
var y3 = w1 * y2 + /*y1 * w2 +*/ z1 * x2 - x1 * z2;
var z3 = w1 * z2 + /*z1 * w2 +*/ x1 * y2 - y1 * x2;
var w4 = w3 * w1 + x3 * x1 + y3 * y1 + z3 * z1;
var x4 = x3 * w1 - w3 * x1 - y3 * z1 + z3 * y1;
var y4 = y3 * w1 - w3 * y1 - z3 * x1 + x3 * z1;
var z4 = z3 * w1 - w3 * z1 - x3 * y1 + y3 * x1;
return [x4, y4, z4];
} | [
"function",
"(",
"v",
")",
"{",
"// [0, v'] = Q * [0, v] * Q'",
"// Q",
"var",
"w1",
"=",
"this",
"[",
"'w'",
"]",
";",
"var",
"x1",
"=",
"this",
"[",
"'x'",
"]",
";",
"var",
"y1",
"=",
"this",
"[",
"'y'",
"]",
";",
"var",
"z1",
"=",
"this",
"[",
"'z'",
"]",
";",
"// [0, v]",
"var",
"w2",
"=",
"0",
";",
"var",
"x2",
"=",
"v",
"[",
"0",
"]",
";",
"var",
"y2",
"=",
"v",
"[",
"1",
"]",
";",
"var",
"z2",
"=",
"v",
"[",
"2",
"]",
";",
"// Q * [0, v]",
"var",
"w3",
"=",
"/*w1 * w2*/",
"-",
"x1",
"*",
"x2",
"-",
"y1",
"*",
"y2",
"-",
"z1",
"*",
"z2",
";",
"var",
"x3",
"=",
"w1",
"*",
"x2",
"+",
"/*x1 * w2 +*/",
"y1",
"*",
"z2",
"-",
"z1",
"*",
"y2",
";",
"var",
"y3",
"=",
"w1",
"*",
"y2",
"+",
"/*y1 * w2 +*/",
"z1",
"*",
"x2",
"-",
"x1",
"*",
"z2",
";",
"var",
"z3",
"=",
"w1",
"*",
"z2",
"+",
"/*z1 * w2 +*/",
"x1",
"*",
"y2",
"-",
"y1",
"*",
"x2",
";",
"var",
"w4",
"=",
"w3",
"*",
"w1",
"+",
"x3",
"*",
"x1",
"+",
"y3",
"*",
"y1",
"+",
"z3",
"*",
"z1",
";",
"var",
"x4",
"=",
"x3",
"*",
"w1",
"-",
"w3",
"*",
"x1",
"-",
"y3",
"*",
"z1",
"+",
"z3",
"*",
"y1",
";",
"var",
"y4",
"=",
"y3",
"*",
"w1",
"-",
"w3",
"*",
"y1",
"-",
"z3",
"*",
"x1",
"+",
"x3",
"*",
"z1",
";",
"var",
"z4",
"=",
"z3",
"*",
"w1",
"-",
"w3",
"*",
"z1",
"-",
"x3",
"*",
"y1",
"+",
"y3",
"*",
"x1",
";",
"return",
"[",
"x4",
",",
"y4",
",",
"z4",
"]",
";",
"}"
] | Rotates a vector according to the current quaternion
@param {Array} v The vector to be rotated
@returns {Array} | [
"Rotates",
"a",
"vector",
"according",
"to",
"the",
"current",
"quaternion"
] | 3c6ef625b2d1ea5274b62eae8dacd564ec917ea4 | https://github.com/infusion/Quaternion.js/blob/3c6ef625b2d1ea5274b62eae8dacd564ec917ea4/quaternion.js#L822-L850 | |
20,545 | josdejong/ducktype | ducktype.js | createPrototype | function createPrototype (type, options) {
return new DuckType({
name: options && options.name || null,
test: function test (object) {
return (object instanceof type);
}
});
} | javascript | function createPrototype (type, options) {
return new DuckType({
name: options && options.name || null,
test: function test (object) {
return (object instanceof type);
}
});
} | [
"function",
"createPrototype",
"(",
"type",
",",
"options",
")",
"{",
"return",
"new",
"DuckType",
"(",
"{",
"name",
":",
"options",
"&&",
"options",
".",
"name",
"||",
"null",
",",
"test",
":",
"function",
"test",
"(",
"object",
")",
"{",
"return",
"(",
"object",
"instanceof",
"type",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create a ducktype handling a prototype
@param {Object} type A prototype function
@param {{name: String}} [options]
@returns {*} | [
"Create",
"a",
"ducktype",
"handling",
"a",
"prototype"
] | 7a0f60ef6b02e777669a86301fa642e24e53ccb8 | https://github.com/josdejong/ducktype/blob/7a0f60ef6b02e777669a86301fa642e24e53ccb8/ducktype.js#L310-L317 |
20,546 | josdejong/ducktype | ducktype.js | createCombi | function createCombi (types, options) {
var tests = types.map(function (type) {
return ducktype(type).test;
});
return new DuckType({
name: options && options.name || null,
test: function test (object) {
for (var i = 0, ii = tests.length; i < ii; i++) {
if (tests[i](object)) {
return true;
}
}
return false;
}
});
} | javascript | function createCombi (types, options) {
var tests = types.map(function (type) {
return ducktype(type).test;
});
return new DuckType({
name: options && options.name || null,
test: function test (object) {
for (var i = 0, ii = tests.length; i < ii; i++) {
if (tests[i](object)) {
return true;
}
}
return false;
}
});
} | [
"function",
"createCombi",
"(",
"types",
",",
"options",
")",
"{",
"var",
"tests",
"=",
"types",
".",
"map",
"(",
"function",
"(",
"type",
")",
"{",
"return",
"ducktype",
"(",
"type",
")",
".",
"test",
";",
"}",
")",
";",
"return",
"new",
"DuckType",
"(",
"{",
"name",
":",
"options",
"&&",
"options",
".",
"name",
"||",
"null",
",",
"test",
":",
"function",
"test",
"(",
"object",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ii",
"=",
"tests",
".",
"length",
";",
"i",
"<",
"ii",
";",
"i",
"++",
")",
"{",
"if",
"(",
"tests",
"[",
"i",
"]",
"(",
"object",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"}",
")",
";",
"}"
] | Create a ducktype handling a combination of types
@param {Array} types
@param {{name: String}} [options]
@returns {*} | [
"Create",
"a",
"ducktype",
"handling",
"a",
"combination",
"of",
"types"
] | 7a0f60ef6b02e777669a86301fa642e24e53ccb8 | https://github.com/josdejong/ducktype/blob/7a0f60ef6b02e777669a86301fa642e24e53ccb8/ducktype.js#L325-L341 |
20,547 | josdejong/ducktype | ducktype.js | createFunction | function createFunction (test, options) {
return new DuckType({
name: options && options.name || null,
test: test
});
} | javascript | function createFunction (test, options) {
return new DuckType({
name: options && options.name || null,
test: test
});
} | [
"function",
"createFunction",
"(",
"test",
",",
"options",
")",
"{",
"return",
"new",
"DuckType",
"(",
"{",
"name",
":",
"options",
"&&",
"options",
".",
"name",
"||",
"null",
",",
"test",
":",
"test",
"}",
")",
";",
"}"
] | Create a ducktype from a test function
@param {Function} test A test function, returning true when a provided
object matches, or else returns false.
@param {{name: String}} [options]
@returns {*} | [
"Create",
"a",
"ducktype",
"from",
"a",
"test",
"function"
] | 7a0f60ef6b02e777669a86301fa642e24e53ccb8 | https://github.com/josdejong/ducktype/blob/7a0f60ef6b02e777669a86301fa642e24e53ccb8/ducktype.js#L350-L355 |
20,548 | josdejong/ducktype | ducktype.js | createRegExp | function createRegExp (regexp, options) {
return new DuckType({
name: options && options.name || null,
test: function (object) {
return ((object instanceof String) || typeof(object) === 'string') && regexp.test(object);
}
});
} | javascript | function createRegExp (regexp, options) {
return new DuckType({
name: options && options.name || null,
test: function (object) {
return ((object instanceof String) || typeof(object) === 'string') && regexp.test(object);
}
});
} | [
"function",
"createRegExp",
"(",
"regexp",
",",
"options",
")",
"{",
"return",
"new",
"DuckType",
"(",
"{",
"name",
":",
"options",
"&&",
"options",
".",
"name",
"||",
"null",
",",
"test",
":",
"function",
"(",
"object",
")",
"{",
"return",
"(",
"(",
"object",
"instanceof",
"String",
")",
"||",
"typeof",
"(",
"object",
")",
"===",
"'string'",
")",
"&&",
"regexp",
".",
"test",
"(",
"object",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create a ducktype from a regular expression. The created ducktype
will check whether the provided object is a String,
and matches with the regular expression
@param {RegExp} regexp A regular expression
@param {{name: String}} [options]
@returns {*} | [
"Create",
"a",
"ducktype",
"from",
"a",
"regular",
"expression",
".",
"The",
"created",
"ducktype",
"will",
"check",
"whether",
"the",
"provided",
"object",
"is",
"a",
"String",
"and",
"matches",
"with",
"the",
"regular",
"expression"
] | 7a0f60ef6b02e777669a86301fa642e24e53ccb8 | https://github.com/josdejong/ducktype/blob/7a0f60ef6b02e777669a86301fa642e24e53ccb8/ducktype.js#L365-L372 |
20,549 | josdejong/ducktype | ducktype.js | isUrl | function isUrl(string){
if (typeof string !== 'string') {
return false;
}
var match = string.match(protocolAndDomainRE);
if (!match) {
return false;
}
var everythingAfterProtocol = match[1];
if (!everythingAfterProtocol) {
return false;
}
return localhostDomainRE.test(everythingAfterProtocol) ||
nonLocalhostDomainRE.test(everythingAfterProtocol);
} | javascript | function isUrl(string){
if (typeof string !== 'string') {
return false;
}
var match = string.match(protocolAndDomainRE);
if (!match) {
return false;
}
var everythingAfterProtocol = match[1];
if (!everythingAfterProtocol) {
return false;
}
return localhostDomainRE.test(everythingAfterProtocol) ||
nonLocalhostDomainRE.test(everythingAfterProtocol);
} | [
"function",
"isUrl",
"(",
"string",
")",
"{",
"if",
"(",
"typeof",
"string",
"!==",
"'string'",
")",
"{",
"return",
"false",
";",
"}",
"var",
"match",
"=",
"string",
".",
"match",
"(",
"protocolAndDomainRE",
")",
";",
"if",
"(",
"!",
"match",
")",
"{",
"return",
"false",
";",
"}",
"var",
"everythingAfterProtocol",
"=",
"match",
"[",
"1",
"]",
";",
"if",
"(",
"!",
"everythingAfterProtocol",
")",
"{",
"return",
"false",
";",
"}",
"return",
"localhostDomainRE",
".",
"test",
"(",
"everythingAfterProtocol",
")",
"||",
"nonLocalhostDomainRE",
".",
"test",
"(",
"everythingAfterProtocol",
")",
";",
"}"
] | Loosely validate a URL `string`.
Source: https://github.com/segmentio/is-url
@param {String} string
@return {Boolean} | [
"Loosely",
"validate",
"a",
"URL",
"string",
"."
] | 7a0f60ef6b02e777669a86301fa642e24e53ccb8 | https://github.com/josdejong/ducktype/blob/7a0f60ef6b02e777669a86301fa642e24e53ccb8/ducktype.js#L609-L626 |
20,550 | jshttp/media-typer | index.js | MediaType | function MediaType (type, subtype, suffix) {
this.type = type
this.subtype = subtype
this.suffix = suffix
} | javascript | function MediaType (type, subtype, suffix) {
this.type = type
this.subtype = subtype
this.suffix = suffix
} | [
"function",
"MediaType",
"(",
"type",
",",
"subtype",
",",
"suffix",
")",
"{",
"this",
".",
"type",
"=",
"type",
"this",
".",
"subtype",
"=",
"subtype",
"this",
".",
"suffix",
"=",
"suffix",
"}"
] | Class for MediaType object.
@public | [
"Class",
"for",
"MediaType",
"object",
"."
] | 1332b73ed8584b7b25d556c55b6de9d64fa3ce2c | https://github.com/jshttp/media-typer/blob/1332b73ed8584b7b25d556c55b6de9d64fa3ce2c/index.js#L139-L143 |
20,551 | Kurento/kurento-client-core-js | lib/complexTypes/AudioCodec.js | checkAudioCodec | function checkAudioCodec(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('OPUS|PCMU|RAW'))
throw SyntaxError(key+' param is not one of [OPUS|PCMU|RAW] ('+value+')');
} | javascript | function checkAudioCodec(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('OPUS|PCMU|RAW'))
throw SyntaxError(key+' param is not one of [OPUS|PCMU|RAW] ('+value+')');
} | [
"function",
"checkAudioCodec",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'OPUS|PCMU|RAW'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [OPUS|PCMU|RAW] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Codec used for transmission of audio.
@typedef core/complexTypes.AudioCodec
@type {(OPUS|PCMU|RAW)}
Checker for {@link module:core/complexTypes.AudioCodec}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.AudioCodec} value | [
"Codec",
"used",
"for",
"transmission",
"of",
"audio",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/AudioCodec.js#L39-L46 |
20,552 | Kurento/kurento-client-core-js | lib/complexTypes/RTCStatsIceCandidatePairState.js | checkRTCStatsIceCandidatePairState | function checkRTCStatsIceCandidatePairState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('frozen|waiting|inprogress|failed|succeeded|cancelled'))
throw SyntaxError(key+' param is not one of [frozen|waiting|inprogress|failed|succeeded|cancelled] ('+value+')');
} | javascript | function checkRTCStatsIceCandidatePairState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('frozen|waiting|inprogress|failed|succeeded|cancelled'))
throw SyntaxError(key+' param is not one of [frozen|waiting|inprogress|failed|succeeded|cancelled] ('+value+')');
} | [
"function",
"checkRTCStatsIceCandidatePairState",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'frozen|waiting|inprogress|failed|succeeded|cancelled'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [frozen|waiting|inprogress|failed|succeeded|cancelled] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Represents the state of the checklist for the local and remote candidates in
a pair.
@typedef core/complexTypes.RTCStatsIceCandidatePairState
@type {(frozen|waiting|inprogress|failed|succeeded|cancelled)}
Checker for {@link module:core/complexTypes.RTCStatsIceCandidatePairState}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.RTCStatsIceCandidatePairState} value | [
"Represents",
"the",
"state",
"of",
"the",
"checklist",
"for",
"the",
"local",
"and",
"remote",
"candidates",
"in",
"a",
"pair",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/RTCStatsIceCandidatePairState.js#L40-L47 |
20,553 | Kurento/kurento-client-core-js | lib/complexTypes/GstreamerDotDetails.js | checkGstreamerDotDetails | function checkGstreamerDotDetails(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('SHOW_MEDIA_TYPE|SHOW_CAPS_DETAILS|SHOW_NON_DEFAULT_PARAMS|SHOW_STATES|SHOW_FULL_PARAMS|SHOW_ALL|SHOW_VERBOSE'))
throw SyntaxError(key+' param is not one of [SHOW_MEDIA_TYPE|SHOW_CAPS_DETAILS|SHOW_NON_DEFAULT_PARAMS|SHOW_STATES|SHOW_FULL_PARAMS|SHOW_ALL|SHOW_VERBOSE] ('+value+')');
} | javascript | function checkGstreamerDotDetails(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('SHOW_MEDIA_TYPE|SHOW_CAPS_DETAILS|SHOW_NON_DEFAULT_PARAMS|SHOW_STATES|SHOW_FULL_PARAMS|SHOW_ALL|SHOW_VERBOSE'))
throw SyntaxError(key+' param is not one of [SHOW_MEDIA_TYPE|SHOW_CAPS_DETAILS|SHOW_NON_DEFAULT_PARAMS|SHOW_STATES|SHOW_FULL_PARAMS|SHOW_ALL|SHOW_VERBOSE] ('+value+')');
} | [
"function",
"checkGstreamerDotDetails",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'SHOW_MEDIA_TYPE|SHOW_CAPS_DETAILS|SHOW_NON_DEFAULT_PARAMS|SHOW_STATES|SHOW_FULL_PARAMS|SHOW_ALL|SHOW_VERBOSE'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [SHOW_MEDIA_TYPE|SHOW_CAPS_DETAILS|SHOW_NON_DEFAULT_PARAMS|SHOW_STATES|SHOW_FULL_PARAMS|SHOW_ALL|SHOW_VERBOSE] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Details of gstreamer dot graphs
@typedef core/complexTypes.GstreamerDotDetails
@type {(SHOW_MEDIA_TYPE|SHOW_CAPS_DETAILS|SHOW_NON_DEFAULT_PARAMS|SHOW_STATES|SHOW_FULL_PARAMS|SHOW_ALL|SHOW_VERBOSE)}
Checker for {@link module:core/complexTypes.GstreamerDotDetails}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.GstreamerDotDetails} value | [
"Details",
"of",
"gstreamer",
"dot",
"graphs"
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/GstreamerDotDetails.js#L39-L46 |
20,554 | Kurento/kurento-client-core-js | lib/complexTypes/RTCStatsIceCandidateType.js | checkRTCStatsIceCandidateType | function checkRTCStatsIceCandidateType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('host|serverreflexive|peerreflexive|relayed'))
throw SyntaxError(key+' param is not one of [host|serverreflexive|peerreflexive|relayed] ('+value+')');
} | javascript | function checkRTCStatsIceCandidateType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('host|serverreflexive|peerreflexive|relayed'))
throw SyntaxError(key+' param is not one of [host|serverreflexive|peerreflexive|relayed] ('+value+')');
} | [
"function",
"checkRTCStatsIceCandidateType",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'host|serverreflexive|peerreflexive|relayed'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [host|serverreflexive|peerreflexive|relayed] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Types of candidates
@typedef core/complexTypes.RTCStatsIceCandidateType
@type {(host|serverreflexive|peerreflexive|relayed)}
Checker for {@link module:core/complexTypes.RTCStatsIceCandidateType}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.RTCStatsIceCandidateType} value | [
"Types",
"of",
"candidates"
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/RTCStatsIceCandidateType.js#L39-L46 |
20,555 | Kurento/kurento-client-core-js | lib/complexTypes/ConnectionState.js | checkConnectionState | function checkConnectionState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('DISCONNECTED|CONNECTED'))
throw SyntaxError(key+' param is not one of [DISCONNECTED|CONNECTED] ('+value+')');
} | javascript | function checkConnectionState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('DISCONNECTED|CONNECTED'))
throw SyntaxError(key+' param is not one of [DISCONNECTED|CONNECTED] ('+value+')');
} | [
"function",
"checkConnectionState",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'DISCONNECTED|CONNECTED'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [DISCONNECTED|CONNECTED] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | State of the connection.
@typedef core/complexTypes.ConnectionState
@type {(DISCONNECTED|CONNECTED)}
Checker for {@link module:core/complexTypes.ConnectionState}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.ConnectionState} value | [
"State",
"of",
"the",
"connection",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/ConnectionState.js#L39-L46 |
20,556 | Kurento/kurento-client-core-js | lib/complexTypes/RTCDataChannelState.js | checkRTCDataChannelState | function checkRTCDataChannelState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('connecting|open|closing|closed'))
throw SyntaxError(key+' param is not one of [connecting|open|closing|closed] ('+value+')');
} | javascript | function checkRTCDataChannelState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('connecting|open|closing|closed'))
throw SyntaxError(key+' param is not one of [connecting|open|closing|closed] ('+value+')');
} | [
"function",
"checkRTCDataChannelState",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'connecting|open|closing|closed'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [connecting|open|closing|closed] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Represents the state of the RTCDataChannel
@typedef core/complexTypes.RTCDataChannelState
@type {(connecting|open|closing|closed)}
Checker for {@link module:core/complexTypes.RTCDataChannelState}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.RTCDataChannelState} value | [
"Represents",
"the",
"state",
"of",
"the",
"RTCDataChannel"
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/RTCDataChannelState.js#L39-L46 |
20,557 | Kurento/kurento-client-core-js | lib/complexTypes/MediaState.js | checkMediaState | function checkMediaState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('DISCONNECTED|CONNECTED'))
throw SyntaxError(key+' param is not one of [DISCONNECTED|CONNECTED] ('+value+')');
} | javascript | function checkMediaState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('DISCONNECTED|CONNECTED'))
throw SyntaxError(key+' param is not one of [DISCONNECTED|CONNECTED] ('+value+')');
} | [
"function",
"checkMediaState",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'DISCONNECTED|CONNECTED'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [DISCONNECTED|CONNECTED] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | State of the media.
@typedef core/complexTypes.MediaState
@type {(DISCONNECTED|CONNECTED)}
Checker for {@link module:core/complexTypes.MediaState}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.MediaState} value | [
"State",
"of",
"the",
"media",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/MediaState.js#L39-L46 |
20,558 | Kurento/kurento-client-core-js | lib/complexTypes/MediaFlowState.js | checkMediaFlowState | function checkMediaFlowState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('FLOWING|NOT_FLOWING'))
throw SyntaxError(key+' param is not one of [FLOWING|NOT_FLOWING] ('+value+')');
} | javascript | function checkMediaFlowState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('FLOWING|NOT_FLOWING'))
throw SyntaxError(key+' param is not one of [FLOWING|NOT_FLOWING] ('+value+')');
} | [
"function",
"checkMediaFlowState",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'FLOWING|NOT_FLOWING'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [FLOWING|NOT_FLOWING] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Flowing state of the media.
@typedef core/complexTypes.MediaFlowState
@type {(FLOWING|NOT_FLOWING)}
Checker for {@link module:core/complexTypes.MediaFlowState}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.MediaFlowState} value | [
"Flowing",
"state",
"of",
"the",
"media",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/MediaFlowState.js#L39-L46 |
20,559 | Kurento/kurento-client-core-js | lib/complexTypes/AudioCaps.js | AudioCaps | function AudioCaps(audioCapsDict){
if(!(this instanceof AudioCaps))
return new AudioCaps(audioCapsDict)
audioCapsDict = audioCapsDict || {}
// Check audioCapsDict has the required fields
//
// checkType('AudioCodec', 'audioCapsDict.codec', audioCapsDict.codec, {required: true});
//
// checkType('int', 'audioCapsDict.bitrate', audioCapsDict.bitrate, {required: true});
//
// Init parent class
AudioCaps.super_.call(this, audioCapsDict)
// Set object properties
Object.defineProperties(this, {
codec: {
writable: true,
enumerable: true,
value: audioCapsDict.codec
},
bitrate: {
writable: true,
enumerable: true,
value: audioCapsDict.bitrate
}
})
} | javascript | function AudioCaps(audioCapsDict){
if(!(this instanceof AudioCaps))
return new AudioCaps(audioCapsDict)
audioCapsDict = audioCapsDict || {}
// Check audioCapsDict has the required fields
//
// checkType('AudioCodec', 'audioCapsDict.codec', audioCapsDict.codec, {required: true});
//
// checkType('int', 'audioCapsDict.bitrate', audioCapsDict.bitrate, {required: true});
//
// Init parent class
AudioCaps.super_.call(this, audioCapsDict)
// Set object properties
Object.defineProperties(this, {
codec: {
writable: true,
enumerable: true,
value: audioCapsDict.codec
},
bitrate: {
writable: true,
enumerable: true,
value: audioCapsDict.bitrate
}
})
} | [
"function",
"AudioCaps",
"(",
"audioCapsDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"AudioCaps",
")",
")",
"return",
"new",
"AudioCaps",
"(",
"audioCapsDict",
")",
"audioCapsDict",
"=",
"audioCapsDict",
"||",
"{",
"}",
"// Check audioCapsDict has the required fields",
"// ",
"// checkType('AudioCodec', 'audioCapsDict.codec', audioCapsDict.codec, {required: true});",
"// ",
"// checkType('int', 'audioCapsDict.bitrate', audioCapsDict.bitrate, {required: true});",
"// ",
"// Init parent class",
"AudioCaps",
".",
"super_",
".",
"call",
"(",
"this",
",",
"audioCapsDict",
")",
"// Set object properties",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"codec",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"audioCapsDict",
".",
"codec",
"}",
",",
"bitrate",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"audioCapsDict",
".",
"bitrate",
"}",
"}",
")",
"}"
] | Format for audio media
@constructor module:core/complexTypes.AudioCaps
@property {module:core/complexTypes.AudioCodec} codec
Audio codec
@property {external:Integer} bitrate
Bitrate | [
"Format",
"for",
"audio",
"media"
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/AudioCaps.js#L39-L68 |
20,560 | Kurento/kurento-client-core-js | lib/complexTypes/RTCPeerConnectionStats.js | RTCPeerConnectionStats | function RTCPeerConnectionStats(rTCPeerConnectionStatsDict){
if(!(this instanceof RTCPeerConnectionStats))
return new RTCPeerConnectionStats(rTCPeerConnectionStatsDict)
rTCPeerConnectionStatsDict = rTCPeerConnectionStatsDict || {}
// Check rTCPeerConnectionStatsDict has the required fields
//
// checkType('int64', 'rTCPeerConnectionStatsDict.dataChannelsOpened', rTCPeerConnectionStatsDict.dataChannelsOpened, {required: true});
//
// checkType('int64', 'rTCPeerConnectionStatsDict.dataChannelsClosed', rTCPeerConnectionStatsDict.dataChannelsClosed, {required: true});
//
// Init parent class
RTCPeerConnectionStats.super_.call(this, rTCPeerConnectionStatsDict)
// Set object properties
Object.defineProperties(this, {
dataChannelsOpened: {
writable: true,
enumerable: true,
value: rTCPeerConnectionStatsDict.dataChannelsOpened
},
dataChannelsClosed: {
writable: true,
enumerable: true,
value: rTCPeerConnectionStatsDict.dataChannelsClosed
}
})
} | javascript | function RTCPeerConnectionStats(rTCPeerConnectionStatsDict){
if(!(this instanceof RTCPeerConnectionStats))
return new RTCPeerConnectionStats(rTCPeerConnectionStatsDict)
rTCPeerConnectionStatsDict = rTCPeerConnectionStatsDict || {}
// Check rTCPeerConnectionStatsDict has the required fields
//
// checkType('int64', 'rTCPeerConnectionStatsDict.dataChannelsOpened', rTCPeerConnectionStatsDict.dataChannelsOpened, {required: true});
//
// checkType('int64', 'rTCPeerConnectionStatsDict.dataChannelsClosed', rTCPeerConnectionStatsDict.dataChannelsClosed, {required: true});
//
// Init parent class
RTCPeerConnectionStats.super_.call(this, rTCPeerConnectionStatsDict)
// Set object properties
Object.defineProperties(this, {
dataChannelsOpened: {
writable: true,
enumerable: true,
value: rTCPeerConnectionStatsDict.dataChannelsOpened
},
dataChannelsClosed: {
writable: true,
enumerable: true,
value: rTCPeerConnectionStatsDict.dataChannelsClosed
}
})
} | [
"function",
"RTCPeerConnectionStats",
"(",
"rTCPeerConnectionStatsDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"RTCPeerConnectionStats",
")",
")",
"return",
"new",
"RTCPeerConnectionStats",
"(",
"rTCPeerConnectionStatsDict",
")",
"rTCPeerConnectionStatsDict",
"=",
"rTCPeerConnectionStatsDict",
"||",
"{",
"}",
"// Check rTCPeerConnectionStatsDict has the required fields",
"// ",
"// checkType('int64', 'rTCPeerConnectionStatsDict.dataChannelsOpened', rTCPeerConnectionStatsDict.dataChannelsOpened, {required: true});",
"// ",
"// checkType('int64', 'rTCPeerConnectionStatsDict.dataChannelsClosed', rTCPeerConnectionStatsDict.dataChannelsClosed, {required: true});",
"// ",
"// Init parent class",
"RTCPeerConnectionStats",
".",
"super_",
".",
"call",
"(",
"this",
",",
"rTCPeerConnectionStatsDict",
")",
"// Set object properties",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"dataChannelsOpened",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"rTCPeerConnectionStatsDict",
".",
"dataChannelsOpened",
"}",
",",
"dataChannelsClosed",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"rTCPeerConnectionStatsDict",
".",
"dataChannelsClosed",
"}",
"}",
")",
"}"
] | Statistics related to the peer connection.
@constructor module:core/complexTypes.RTCPeerConnectionStats
@property {external:int64} dataChannelsOpened
Represents the number of unique datachannels opened.
@property {external:int64} dataChannelsClosed
Represents the number of unique datachannels closed.
@extends module:core.RTCStats | [
"Statistics",
"related",
"to",
"the",
"peer",
"connection",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/RTCPeerConnectionStats.js#L41-L70 |
20,561 | Kurento/kurento-client-core-js | lib/complexTypes/VideoCaps.js | VideoCaps | function VideoCaps(videoCapsDict){
if(!(this instanceof VideoCaps))
return new VideoCaps(videoCapsDict)
videoCapsDict = videoCapsDict || {}
// Check videoCapsDict has the required fields
//
// checkType('VideoCodec', 'videoCapsDict.codec', videoCapsDict.codec, {required: true});
//
// checkType('Fraction', 'videoCapsDict.framerate', videoCapsDict.framerate, {required: true});
//
// Init parent class
VideoCaps.super_.call(this, videoCapsDict)
// Set object properties
Object.defineProperties(this, {
codec: {
writable: true,
enumerable: true,
value: videoCapsDict.codec
},
framerate: {
writable: true,
enumerable: true,
value: videoCapsDict.framerate
}
})
} | javascript | function VideoCaps(videoCapsDict){
if(!(this instanceof VideoCaps))
return new VideoCaps(videoCapsDict)
videoCapsDict = videoCapsDict || {}
// Check videoCapsDict has the required fields
//
// checkType('VideoCodec', 'videoCapsDict.codec', videoCapsDict.codec, {required: true});
//
// checkType('Fraction', 'videoCapsDict.framerate', videoCapsDict.framerate, {required: true});
//
// Init parent class
VideoCaps.super_.call(this, videoCapsDict)
// Set object properties
Object.defineProperties(this, {
codec: {
writable: true,
enumerable: true,
value: videoCapsDict.codec
},
framerate: {
writable: true,
enumerable: true,
value: videoCapsDict.framerate
}
})
} | [
"function",
"VideoCaps",
"(",
"videoCapsDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"VideoCaps",
")",
")",
"return",
"new",
"VideoCaps",
"(",
"videoCapsDict",
")",
"videoCapsDict",
"=",
"videoCapsDict",
"||",
"{",
"}",
"// Check videoCapsDict has the required fields",
"// ",
"// checkType('VideoCodec', 'videoCapsDict.codec', videoCapsDict.codec, {required: true});",
"// ",
"// checkType('Fraction', 'videoCapsDict.framerate', videoCapsDict.framerate, {required: true});",
"// ",
"// Init parent class",
"VideoCaps",
".",
"super_",
".",
"call",
"(",
"this",
",",
"videoCapsDict",
")",
"// Set object properties",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"codec",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"videoCapsDict",
".",
"codec",
"}",
",",
"framerate",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"videoCapsDict",
".",
"framerate",
"}",
"}",
")",
"}"
] | Format for video media
@constructor module:core/complexTypes.VideoCaps
@property {module:core/complexTypes.VideoCodec} codec
Video codec
@property {module:core/complexTypes.Fraction} framerate
Framerate | [
"Format",
"for",
"video",
"media"
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/VideoCaps.js#L39-L68 |
20,562 | Kurento/kurento-client-core-js | lib/complexTypes/VideoCodec.js | checkVideoCodec | function checkVideoCodec(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('VP8|H264|RAW'))
throw SyntaxError(key+' param is not one of [VP8|H264|RAW] ('+value+')');
} | javascript | function checkVideoCodec(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('VP8|H264|RAW'))
throw SyntaxError(key+' param is not one of [VP8|H264|RAW] ('+value+')');
} | [
"function",
"checkVideoCodec",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'VP8|H264|RAW'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [VP8|H264|RAW] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Codec used for transmission of video.
@typedef core/complexTypes.VideoCodec
@type {(VP8|H264|RAW)}
Checker for {@link module:core/complexTypes.VideoCodec}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.VideoCodec} value | [
"Codec",
"used",
"for",
"transmission",
"of",
"video",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/VideoCodec.js#L39-L46 |
20,563 | Kurento/kurento-client-core-js | lib/complexTypes/FilterType.js | checkFilterType | function checkFilterType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('AUDIO|AUTODETECT|VIDEO'))
throw SyntaxError(key+' param is not one of [AUDIO|AUTODETECT|VIDEO] ('+value+')');
} | javascript | function checkFilterType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('AUDIO|AUTODETECT|VIDEO'))
throw SyntaxError(key+' param is not one of [AUDIO|AUTODETECT|VIDEO] ('+value+')');
} | [
"function",
"checkFilterType",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'AUDIO|AUTODETECT|VIDEO'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [AUDIO|AUTODETECT|VIDEO] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Type of filter to be created.
Can take the values AUDIO, VIDEO or AUTODETECT.
@typedef core/complexTypes.FilterType
@type {(AUDIO|AUTODETECT|VIDEO)}
Checker for {@link module:core/complexTypes.FilterType}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.FilterType} value | [
"Type",
"of",
"filter",
"to",
"be",
"created",
".",
"Can",
"take",
"the",
"values",
"AUDIO",
"VIDEO",
"or",
"AUTODETECT",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/FilterType.js#L40-L47 |
20,564 | Kurento/kurento-client-core-js | lib/complexTypes/MediaType.js | checkMediaType | function checkMediaType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('AUDIO|DATA|VIDEO'))
throw SyntaxError(key+' param is not one of [AUDIO|DATA|VIDEO] ('+value+')');
} | javascript | function checkMediaType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('AUDIO|DATA|VIDEO'))
throw SyntaxError(key+' param is not one of [AUDIO|DATA|VIDEO] ('+value+')');
} | [
"function",
"checkMediaType",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'AUDIO|DATA|VIDEO'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [AUDIO|DATA|VIDEO] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Type of media stream to be exchanged.
Can take the values AUDIO, DATA or VIDEO.
@typedef core/complexTypes.MediaType
@type {(AUDIO|DATA|VIDEO)}
Checker for {@link module:core/complexTypes.MediaType}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.MediaType} value | [
"Type",
"of",
"media",
"stream",
"to",
"be",
"exchanged",
".",
"Can",
"take",
"the",
"values",
"AUDIO",
"DATA",
"or",
"VIDEO",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/MediaType.js#L40-L47 |
20,565 | Kurento/kurento-client-core-js | lib/complexTypes/EndpointStats.js | EndpointStats | function EndpointStats(endpointStatsDict){
if(!(this instanceof EndpointStats))
return new EndpointStats(endpointStatsDict)
endpointStatsDict = endpointStatsDict || {}
// Check endpointStatsDict has the required fields
//
// checkType('double', 'endpointStatsDict.audioE2ELatency', endpointStatsDict.audioE2ELatency, {required: true});
//
// checkType('double', 'endpointStatsDict.videoE2ELatency', endpointStatsDict.videoE2ELatency, {required: true});
//
// checkType('MediaLatencyStat', 'endpointStatsDict.E2ELatency', endpointStatsDict.E2ELatency, {isArray: true, required: true});
//
// Init parent class
EndpointStats.super_.call(this, endpointStatsDict)
// Set object properties
Object.defineProperties(this, {
audioE2ELatency: {
writable: true,
enumerable: true,
value: endpointStatsDict.audioE2ELatency
},
videoE2ELatency: {
writable: true,
enumerable: true,
value: endpointStatsDict.videoE2ELatency
},
E2ELatency: {
writable: true,
enumerable: true,
value: endpointStatsDict.E2ELatency
}
})
} | javascript | function EndpointStats(endpointStatsDict){
if(!(this instanceof EndpointStats))
return new EndpointStats(endpointStatsDict)
endpointStatsDict = endpointStatsDict || {}
// Check endpointStatsDict has the required fields
//
// checkType('double', 'endpointStatsDict.audioE2ELatency', endpointStatsDict.audioE2ELatency, {required: true});
//
// checkType('double', 'endpointStatsDict.videoE2ELatency', endpointStatsDict.videoE2ELatency, {required: true});
//
// checkType('MediaLatencyStat', 'endpointStatsDict.E2ELatency', endpointStatsDict.E2ELatency, {isArray: true, required: true});
//
// Init parent class
EndpointStats.super_.call(this, endpointStatsDict)
// Set object properties
Object.defineProperties(this, {
audioE2ELatency: {
writable: true,
enumerable: true,
value: endpointStatsDict.audioE2ELatency
},
videoE2ELatency: {
writable: true,
enumerable: true,
value: endpointStatsDict.videoE2ELatency
},
E2ELatency: {
writable: true,
enumerable: true,
value: endpointStatsDict.E2ELatency
}
})
} | [
"function",
"EndpointStats",
"(",
"endpointStatsDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"EndpointStats",
")",
")",
"return",
"new",
"EndpointStats",
"(",
"endpointStatsDict",
")",
"endpointStatsDict",
"=",
"endpointStatsDict",
"||",
"{",
"}",
"// Check endpointStatsDict has the required fields",
"// ",
"// checkType('double', 'endpointStatsDict.audioE2ELatency', endpointStatsDict.audioE2ELatency, {required: true});",
"// ",
"// checkType('double', 'endpointStatsDict.videoE2ELatency', endpointStatsDict.videoE2ELatency, {required: true});",
"// ",
"// checkType('MediaLatencyStat', 'endpointStatsDict.E2ELatency', endpointStatsDict.E2ELatency, {isArray: true, required: true});",
"// ",
"// Init parent class",
"EndpointStats",
".",
"super_",
".",
"call",
"(",
"this",
",",
"endpointStatsDict",
")",
"// Set object properties",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"audioE2ELatency",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"endpointStatsDict",
".",
"audioE2ELatency",
"}",
",",
"videoE2ELatency",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"endpointStatsDict",
".",
"videoE2ELatency",
"}",
",",
"E2ELatency",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"endpointStatsDict",
".",
"E2ELatency",
"}",
"}",
")",
"}"
] | A dictionary that represents the stats gathered in the endpoint element.
@constructor module:core/complexTypes.EndpointStats
@property {external:double} audioE2ELatency
@deprecated
End-to-end audio latency measured in nano seconds
@property {external:double} videoE2ELatency
@deprecated
End-to-end video latency measured in nano seconds
@property {module:core/complexTypes.MediaLatencyStat} E2ELatency
The average end to end latency for each media stream measured in nano
seconds
@extends module:core.ElementStats | [
"A",
"dictionary",
"that",
"represents",
"the",
"stats",
"gathered",
"in",
"the",
"endpoint",
"element",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/EndpointStats.js#L46-L82 |
20,566 | Kurento/kurento-client-core-js | lib/complexTypes/Fraction.js | Fraction | function Fraction(fractionDict){
if(!(this instanceof Fraction))
return new Fraction(fractionDict)
fractionDict = fractionDict || {}
// Check fractionDict has the required fields
//
// checkType('int', 'fractionDict.numerator', fractionDict.numerator, {required: true});
//
// checkType('int', 'fractionDict.denominator', fractionDict.denominator, {required: true});
//
// Init parent class
Fraction.super_.call(this, fractionDict)
// Set object properties
Object.defineProperties(this, {
numerator: {
writable: true,
enumerable: true,
value: fractionDict.numerator
},
denominator: {
writable: true,
enumerable: true,
value: fractionDict.denominator
}
})
} | javascript | function Fraction(fractionDict){
if(!(this instanceof Fraction))
return new Fraction(fractionDict)
fractionDict = fractionDict || {}
// Check fractionDict has the required fields
//
// checkType('int', 'fractionDict.numerator', fractionDict.numerator, {required: true});
//
// checkType('int', 'fractionDict.denominator', fractionDict.denominator, {required: true});
//
// Init parent class
Fraction.super_.call(this, fractionDict)
// Set object properties
Object.defineProperties(this, {
numerator: {
writable: true,
enumerable: true,
value: fractionDict.numerator
},
denominator: {
writable: true,
enumerable: true,
value: fractionDict.denominator
}
})
} | [
"function",
"Fraction",
"(",
"fractionDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Fraction",
")",
")",
"return",
"new",
"Fraction",
"(",
"fractionDict",
")",
"fractionDict",
"=",
"fractionDict",
"||",
"{",
"}",
"// Check fractionDict has the required fields",
"// ",
"// checkType('int', 'fractionDict.numerator', fractionDict.numerator, {required: true});",
"// ",
"// checkType('int', 'fractionDict.denominator', fractionDict.denominator, {required: true});",
"// ",
"// Init parent class",
"Fraction",
".",
"super_",
".",
"call",
"(",
"this",
",",
"fractionDict",
")",
"// Set object properties",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"numerator",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"fractionDict",
".",
"numerator",
"}",
",",
"denominator",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"fractionDict",
".",
"denominator",
"}",
"}",
")",
"}"
] | Type that represents a fraction of an integer numerator over an integer
denominator
@constructor module:core/complexTypes.Fraction
@property {external:Integer} numerator
the numerator of the fraction
@property {external:Integer} denominator
the denominator of the fraction | [
"Type",
"that",
"represents",
"a",
"fraction",
"of",
"an",
"integer",
"numerator",
"over",
"an",
"integer",
"denominator"
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/Fraction.js#L40-L69 |
20,567 | Kurento/kurento-client-core-js | lib/complexTypes/MediaTranscodingState.js | checkMediaTranscodingState | function checkMediaTranscodingState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('TRANSCODING|NOT_TRANSCODING'))
throw SyntaxError(key+' param is not one of [TRANSCODING|NOT_TRANSCODING] ('+value+')');
} | javascript | function checkMediaTranscodingState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('TRANSCODING|NOT_TRANSCODING'))
throw SyntaxError(key+' param is not one of [TRANSCODING|NOT_TRANSCODING] ('+value+')');
} | [
"function",
"checkMediaTranscodingState",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'TRANSCODING|NOT_TRANSCODING'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [TRANSCODING|NOT_TRANSCODING] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Transcoding state for a media.
@typedef core/complexTypes.MediaTranscodingState
@type {(TRANSCODING|NOT_TRANSCODING)}
Checker for {@link module:core/complexTypes.MediaTranscodingState}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.MediaTranscodingState} value | [
"Transcoding",
"state",
"for",
"a",
"media",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/MediaTranscodingState.js#L39-L46 |
20,568 | Kurento/kurento-client-core-js | lib/complexTypes/ServerType.js | checkServerType | function checkServerType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('KMS|KCS'))
throw SyntaxError(key+' param is not one of [KMS|KCS] ('+value+')');
} | javascript | function checkServerType(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('KMS|KCS'))
throw SyntaxError(key+' param is not one of [KMS|KCS] ('+value+')');
} | [
"function",
"checkServerType",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'KMS|KCS'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [KMS|KCS] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | Indicates if the server is a real media server or a proxy
@typedef core/complexTypes.ServerType
@type {(KMS|KCS)}
Checker for {@link module:core/complexTypes.ServerType}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.ServerType} value | [
"Indicates",
"if",
"the",
"server",
"is",
"a",
"real",
"media",
"server",
"or",
"a",
"proxy"
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/ServerType.js#L39-L46 |
20,569 | Kurento/kurento-client-core-js | lib/complexTypes/ElementStats.js | ElementStats | function ElementStats(elementStatsDict){
if(!(this instanceof ElementStats))
return new ElementStats(elementStatsDict)
elementStatsDict = elementStatsDict || {}
// Check elementStatsDict has the required fields
//
// checkType('double', 'elementStatsDict.inputAudioLatency', elementStatsDict.inputAudioLatency, {required: true});
//
// checkType('double', 'elementStatsDict.inputVideoLatency', elementStatsDict.inputVideoLatency, {required: true});
//
// checkType('MediaLatencyStat', 'elementStatsDict.inputLatency', elementStatsDict.inputLatency, {isArray: true, required: true});
//
// Init parent class
ElementStats.super_.call(this, elementStatsDict)
// Set object properties
Object.defineProperties(this, {
inputAudioLatency: {
writable: true,
enumerable: true,
value: elementStatsDict.inputAudioLatency
},
inputVideoLatency: {
writable: true,
enumerable: true,
value: elementStatsDict.inputVideoLatency
},
inputLatency: {
writable: true,
enumerable: true,
value: elementStatsDict.inputLatency
}
})
} | javascript | function ElementStats(elementStatsDict){
if(!(this instanceof ElementStats))
return new ElementStats(elementStatsDict)
elementStatsDict = elementStatsDict || {}
// Check elementStatsDict has the required fields
//
// checkType('double', 'elementStatsDict.inputAudioLatency', elementStatsDict.inputAudioLatency, {required: true});
//
// checkType('double', 'elementStatsDict.inputVideoLatency', elementStatsDict.inputVideoLatency, {required: true});
//
// checkType('MediaLatencyStat', 'elementStatsDict.inputLatency', elementStatsDict.inputLatency, {isArray: true, required: true});
//
// Init parent class
ElementStats.super_.call(this, elementStatsDict)
// Set object properties
Object.defineProperties(this, {
inputAudioLatency: {
writable: true,
enumerable: true,
value: elementStatsDict.inputAudioLatency
},
inputVideoLatency: {
writable: true,
enumerable: true,
value: elementStatsDict.inputVideoLatency
},
inputLatency: {
writable: true,
enumerable: true,
value: elementStatsDict.inputLatency
}
})
} | [
"function",
"ElementStats",
"(",
"elementStatsDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ElementStats",
")",
")",
"return",
"new",
"ElementStats",
"(",
"elementStatsDict",
")",
"elementStatsDict",
"=",
"elementStatsDict",
"||",
"{",
"}",
"// Check elementStatsDict has the required fields",
"// ",
"// checkType('double', 'elementStatsDict.inputAudioLatency', elementStatsDict.inputAudioLatency, {required: true});",
"// ",
"// checkType('double', 'elementStatsDict.inputVideoLatency', elementStatsDict.inputVideoLatency, {required: true});",
"// ",
"// checkType('MediaLatencyStat', 'elementStatsDict.inputLatency', elementStatsDict.inputLatency, {isArray: true, required: true});",
"// ",
"// Init parent class",
"ElementStats",
".",
"super_",
".",
"call",
"(",
"this",
",",
"elementStatsDict",
")",
"// Set object properties",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"inputAudioLatency",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"elementStatsDict",
".",
"inputAudioLatency",
"}",
",",
"inputVideoLatency",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"elementStatsDict",
".",
"inputVideoLatency",
"}",
",",
"inputLatency",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"elementStatsDict",
".",
"inputLatency",
"}",
"}",
")",
"}"
] | A dictionary that represents the stats gathered in the media element.
@constructor module:core/complexTypes.ElementStats
@property {external:double} inputAudioLatency
@deprecated
Audio average measured on the sink pad in nano seconds
@property {external:double} inputVideoLatency
@deprecated
Video average measured on the sink pad in nano seconds
@property {module:core/complexTypes.MediaLatencyStat} inputLatency
The average time that buffers take to get on the input pads of this element
in nano seconds
@extends module:core.Stats | [
"A",
"dictionary",
"that",
"represents",
"the",
"stats",
"gathered",
"in",
"the",
"media",
"element",
"."
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/ElementStats.js#L46-L82 |
20,570 | Kurento/kurento-client-core-js | lib/complexTypes/UriEndpointState.js | checkUriEndpointState | function checkUriEndpointState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('STOP|START|PAUSE'))
throw SyntaxError(key+' param is not one of [STOP|START|PAUSE] ('+value+')');
} | javascript | function checkUriEndpointState(key, value)
{
if(typeof value != 'string')
throw SyntaxError(key+' param should be a String, not '+typeof value);
if(!value.match('STOP|START|PAUSE'))
throw SyntaxError(key+' param is not one of [STOP|START|PAUSE] ('+value+')');
} | [
"function",
"checkUriEndpointState",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!=",
"'string'",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param should be a String, not '",
"+",
"typeof",
"value",
")",
";",
"if",
"(",
"!",
"value",
".",
"match",
"(",
"'STOP|START|PAUSE'",
")",
")",
"throw",
"SyntaxError",
"(",
"key",
"+",
"' param is not one of [STOP|START|PAUSE] ('",
"+",
"value",
"+",
"')'",
")",
";",
"}"
] | State of the endpoint
@typedef core/complexTypes.UriEndpointState
@type {(STOP|START|PAUSE)}
Checker for {@link module:core/complexTypes.UriEndpointState}
@memberof module:core/complexTypes
@param {external:String} key
@param {module:core/complexTypes.UriEndpointState} value | [
"State",
"of",
"the",
"endpoint"
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/UriEndpointState.js#L39-L46 |
20,571 | Kurento/kurento-client-core-js | lib/complexTypes/RembParams.js | RembParams | function RembParams(rembParamsDict){
if(!(this instanceof RembParams))
return new RembParams(rembParamsDict)
rembParamsDict = rembParamsDict || {}
// Check rembParamsDict has the required fields
//
// checkType('int', 'rembParamsDict.packetsRecvIntervalTop', rembParamsDict.packetsRecvIntervalTop);
//
// checkType('float', 'rembParamsDict.exponentialFactor', rembParamsDict.exponentialFactor);
//
// checkType('int', 'rembParamsDict.linealFactorMin', rembParamsDict.linealFactorMin);
//
// checkType('float', 'rembParamsDict.linealFactorGrade', rembParamsDict.linealFactorGrade);
//
// checkType('float', 'rembParamsDict.decrementFactor', rembParamsDict.decrementFactor);
//
// checkType('float', 'rembParamsDict.thresholdFactor', rembParamsDict.thresholdFactor);
//
// checkType('int', 'rembParamsDict.upLosses', rembParamsDict.upLosses);
//
// checkType('int', 'rembParamsDict.rembOnConnect', rembParamsDict.rembOnConnect);
//
// Init parent class
RembParams.super_.call(this, rembParamsDict)
// Set object properties
Object.defineProperties(this, {
packetsRecvIntervalTop: {
writable: true,
enumerable: true,
value: rembParamsDict.packetsRecvIntervalTop
},
exponentialFactor: {
writable: true,
enumerable: true,
value: rembParamsDict.exponentialFactor
},
linealFactorMin: {
writable: true,
enumerable: true,
value: rembParamsDict.linealFactorMin
},
linealFactorGrade: {
writable: true,
enumerable: true,
value: rembParamsDict.linealFactorGrade
},
decrementFactor: {
writable: true,
enumerable: true,
value: rembParamsDict.decrementFactor
},
thresholdFactor: {
writable: true,
enumerable: true,
value: rembParamsDict.thresholdFactor
},
upLosses: {
writable: true,
enumerable: true,
value: rembParamsDict.upLosses
},
rembOnConnect: {
writable: true,
enumerable: true,
value: rembParamsDict.rembOnConnect
}
})
} | javascript | function RembParams(rembParamsDict){
if(!(this instanceof RembParams))
return new RembParams(rembParamsDict)
rembParamsDict = rembParamsDict || {}
// Check rembParamsDict has the required fields
//
// checkType('int', 'rembParamsDict.packetsRecvIntervalTop', rembParamsDict.packetsRecvIntervalTop);
//
// checkType('float', 'rembParamsDict.exponentialFactor', rembParamsDict.exponentialFactor);
//
// checkType('int', 'rembParamsDict.linealFactorMin', rembParamsDict.linealFactorMin);
//
// checkType('float', 'rembParamsDict.linealFactorGrade', rembParamsDict.linealFactorGrade);
//
// checkType('float', 'rembParamsDict.decrementFactor', rembParamsDict.decrementFactor);
//
// checkType('float', 'rembParamsDict.thresholdFactor', rembParamsDict.thresholdFactor);
//
// checkType('int', 'rembParamsDict.upLosses', rembParamsDict.upLosses);
//
// checkType('int', 'rembParamsDict.rembOnConnect', rembParamsDict.rembOnConnect);
//
// Init parent class
RembParams.super_.call(this, rembParamsDict)
// Set object properties
Object.defineProperties(this, {
packetsRecvIntervalTop: {
writable: true,
enumerable: true,
value: rembParamsDict.packetsRecvIntervalTop
},
exponentialFactor: {
writable: true,
enumerable: true,
value: rembParamsDict.exponentialFactor
},
linealFactorMin: {
writable: true,
enumerable: true,
value: rembParamsDict.linealFactorMin
},
linealFactorGrade: {
writable: true,
enumerable: true,
value: rembParamsDict.linealFactorGrade
},
decrementFactor: {
writable: true,
enumerable: true,
value: rembParamsDict.decrementFactor
},
thresholdFactor: {
writable: true,
enumerable: true,
value: rembParamsDict.thresholdFactor
},
upLosses: {
writable: true,
enumerable: true,
value: rembParamsDict.upLosses
},
rembOnConnect: {
writable: true,
enumerable: true,
value: rembParamsDict.rembOnConnect
}
})
} | [
"function",
"RembParams",
"(",
"rembParamsDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"RembParams",
")",
")",
"return",
"new",
"RembParams",
"(",
"rembParamsDict",
")",
"rembParamsDict",
"=",
"rembParamsDict",
"||",
"{",
"}",
"// Check rembParamsDict has the required fields",
"// ",
"// checkType('int', 'rembParamsDict.packetsRecvIntervalTop', rembParamsDict.packetsRecvIntervalTop);",
"// ",
"// checkType('float', 'rembParamsDict.exponentialFactor', rembParamsDict.exponentialFactor);",
"// ",
"// checkType('int', 'rembParamsDict.linealFactorMin', rembParamsDict.linealFactorMin);",
"// ",
"// checkType('float', 'rembParamsDict.linealFactorGrade', rembParamsDict.linealFactorGrade);",
"// ",
"// checkType('float', 'rembParamsDict.decrementFactor', rembParamsDict.decrementFactor);",
"// ",
"// checkType('float', 'rembParamsDict.thresholdFactor', rembParamsDict.thresholdFactor);",
"// ",
"// checkType('int', 'rembParamsDict.upLosses', rembParamsDict.upLosses);",
"// ",
"// checkType('int', 'rembParamsDict.rembOnConnect', rembParamsDict.rembOnConnect);",
"// ",
"// Init parent class",
"RembParams",
".",
"super_",
".",
"call",
"(",
"this",
",",
"rembParamsDict",
")",
"// Set object properties",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"packetsRecvIntervalTop",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"rembParamsDict",
".",
"packetsRecvIntervalTop",
"}",
",",
"exponentialFactor",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"rembParamsDict",
".",
"exponentialFactor",
"}",
",",
"linealFactorMin",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"rembParamsDict",
".",
"linealFactorMin",
"}",
",",
"linealFactorGrade",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"rembParamsDict",
".",
"linealFactorGrade",
"}",
",",
"decrementFactor",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"rembParamsDict",
".",
"decrementFactor",
"}",
",",
"thresholdFactor",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"rembParamsDict",
".",
"thresholdFactor",
"}",
",",
"upLosses",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"rembParamsDict",
".",
"upLosses",
"}",
",",
"rembOnConnect",
":",
"{",
"writable",
":",
"true",
",",
"enumerable",
":",
"true",
",",
"value",
":",
"rembParamsDict",
".",
"rembOnConnect",
"}",
"}",
")",
"}"
] | Defines values for parameters of congestion control
@constructor module:core/complexTypes.RembParams
@property {external:Integer} packetsRecvIntervalTop
Size of the RTP packets history to smooth fraction-lost.
Units: num of packets
@property {external:Number} exponentialFactor
Factor used to increase exponentially the next REMB when it is below the
threshold.
REMB[i+1] = REMB[i] * (1 + exponentialFactor)
@property {external:Integer} linealFactorMin
Set the min of the factor used to increase linearly the next REMB when it is
Units: bps (bits per second).
REMB[i+1] = REMB[i] + MIN (linealFactorMin, linealFactor)
@property {external:Number} linealFactorGrade
Determine the value of the next linearFactor based on the threshold and the
current REMB. Taking into account that the frequency of updating is 500ms,
the default value makes that the last REMB is reached in 60secs.
linealFactor = (REMB - TH) / linealFactorGrade
@property {external:Number} decrementFactor
Determine how much is decreased the current REMB when too losses are
detected.
REMB[i+1] = REMB[i] * decrementFactor
@property {external:Number} thresholdFactor
Determine the next threshold (TH) when too losses are detected.
TH[i+1] = REMB[i] * thresholdFactor
@property {external:Integer} upLosses
Max fraction-lost to no determine too losses. This value is the denominator
of the fraction N/256, so the default value is about 4% of losses (12/256)
@property {external:Integer} rembOnConnect
REMB propagated upstream when video sending is started in a new connected
endpoint.
Unit: bps(bits per second) | [
"Defines",
"values",
"for",
"parameters",
"of",
"congestion",
"control"
] | 20f31e902790e28f14d9a9334b58cdcc848c10f5 | https://github.com/Kurento/kurento-client-core-js/blob/20f31e902790e28f14d9a9334b58cdcc848c10f5/lib/complexTypes/RembParams.js#L65-L136 |
20,572 | gitbook-plugins/gitbook-plugin-search-pro | index.js | function(page) {
if (this.output.name != 'website' || page.search === false) {
return page;
}
var text;
this.log.debug.ln('index page', page.path);
text = page.content;
// Decode HTML
text = Html.decode(text);
// Strip HTML tags
text = text.replace(/(<([^>]+)>)/ig, '');
text = text.replace(/[\n ]+/g, ' ');
var keywords = [];
if (page.search) {
keywords = page.search.keywords || [];
}
// Add to index
var doc = {
url: this.output.toURL(page.path),
title: page.title,
summary: page.description,
keywords: keywords.join(' '),
body: text
};
documentsStore[doc.url] = doc;
return page;
} | javascript | function(page) {
if (this.output.name != 'website' || page.search === false) {
return page;
}
var text;
this.log.debug.ln('index page', page.path);
text = page.content;
// Decode HTML
text = Html.decode(text);
// Strip HTML tags
text = text.replace(/(<([^>]+)>)/ig, '');
text = text.replace(/[\n ]+/g, ' ');
var keywords = [];
if (page.search) {
keywords = page.search.keywords || [];
}
// Add to index
var doc = {
url: this.output.toURL(page.path),
title: page.title,
summary: page.description,
keywords: keywords.join(' '),
body: text
};
documentsStore[doc.url] = doc;
return page;
} | [
"function",
"(",
"page",
")",
"{",
"if",
"(",
"this",
".",
"output",
".",
"name",
"!=",
"'website'",
"||",
"page",
".",
"search",
"===",
"false",
")",
"{",
"return",
"page",
";",
"}",
"var",
"text",
";",
"this",
".",
"log",
".",
"debug",
".",
"ln",
"(",
"'index page'",
",",
"page",
".",
"path",
")",
";",
"text",
"=",
"page",
".",
"content",
";",
"// Decode HTML",
"text",
"=",
"Html",
".",
"decode",
"(",
"text",
")",
";",
"// Strip HTML tags",
"text",
"=",
"text",
".",
"replace",
"(",
"/",
"(<([^>]+)>)",
"/",
"ig",
",",
"''",
")",
";",
"text",
"=",
"text",
".",
"replace",
"(",
"/",
"[\\n ]+",
"/",
"g",
",",
"' '",
")",
";",
"var",
"keywords",
"=",
"[",
"]",
";",
"if",
"(",
"page",
".",
"search",
")",
"{",
"keywords",
"=",
"page",
".",
"search",
".",
"keywords",
"||",
"[",
"]",
";",
"}",
"// Add to index",
"var",
"doc",
"=",
"{",
"url",
":",
"this",
".",
"output",
".",
"toURL",
"(",
"page",
".",
"path",
")",
",",
"title",
":",
"page",
".",
"title",
",",
"summary",
":",
"page",
".",
"description",
",",
"keywords",
":",
"keywords",
".",
"join",
"(",
"' '",
")",
",",
"body",
":",
"text",
"}",
";",
"documentsStore",
"[",
"doc",
".",
"url",
"]",
"=",
"doc",
";",
"return",
"page",
";",
"}"
] | Index each page | [
"Index",
"each",
"page"
] | 9e9e86c1b54c8363d75d309713d3d502a36bcdcf | https://github.com/gitbook-plugins/gitbook-plugin-search-pro/blob/9e9e86c1b54c8363d75d309713d3d502a36bcdcf/index.js#L22-L54 | |
20,573 | gitbook-plugins/gitbook-plugin-search-pro | index.js | function() {
if (this.output.name != 'website') return;
this.log.debug.ln('write search index');
return this.output.writeFile('search_plus_index.json', JSON.stringify(documentsStore));
} | javascript | function() {
if (this.output.name != 'website') return;
this.log.debug.ln('write search index');
return this.output.writeFile('search_plus_index.json', JSON.stringify(documentsStore));
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"output",
".",
"name",
"!=",
"'website'",
")",
"return",
";",
"this",
".",
"log",
".",
"debug",
".",
"ln",
"(",
"'write search index'",
")",
";",
"return",
"this",
".",
"output",
".",
"writeFile",
"(",
"'search_plus_index.json'",
",",
"JSON",
".",
"stringify",
"(",
"documentsStore",
")",
")",
";",
"}"
] | Write index to disk | [
"Write",
"index",
"to",
"disk"
] | 9e9e86c1b54c8363d75d309713d3d502a36bcdcf | https://github.com/gitbook-plugins/gitbook-plugin-search-pro/blob/9e9e86c1b54c8363d75d309713d3d502a36bcdcf/index.js#L57-L62 | |
20,574 | mapbox/to-color | index.js | toColor | function toColor(str, opacity) {
var rgb = [0, 0, 0, opacity || 0.75];
try {
for (var i = 0; i < str.length; i++) {
var v = str.charCodeAt(i);
var idx = v % 3;
rgb[idx] = (rgb[i % 3] + (13 * (v % 13))) % 20;
}
} finally {
return 'rgba(' +
rgb.map(function(c, idx) {
return idx === 3 ? c : (4 + c) * 17;
}).join(',') + ')';
}
} | javascript | function toColor(str, opacity) {
var rgb = [0, 0, 0, opacity || 0.75];
try {
for (var i = 0; i < str.length; i++) {
var v = str.charCodeAt(i);
var idx = v % 3;
rgb[idx] = (rgb[i % 3] + (13 * (v % 13))) % 20;
}
} finally {
return 'rgba(' +
rgb.map(function(c, idx) {
return idx === 3 ? c : (4 + c) * 17;
}).join(',') + ')';
}
} | [
"function",
"toColor",
"(",
"str",
",",
"opacity",
")",
"{",
"var",
"rgb",
"=",
"[",
"0",
",",
"0",
",",
"0",
",",
"opacity",
"||",
"0.75",
"]",
";",
"try",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"v",
"=",
"str",
".",
"charCodeAt",
"(",
"i",
")",
";",
"var",
"idx",
"=",
"v",
"%",
"3",
";",
"rgb",
"[",
"idx",
"]",
"=",
"(",
"rgb",
"[",
"i",
"%",
"3",
"]",
"+",
"(",
"13",
"*",
"(",
"v",
"%",
"13",
")",
")",
")",
"%",
"20",
";",
"}",
"}",
"finally",
"{",
"return",
"'rgba('",
"+",
"rgb",
".",
"map",
"(",
"function",
"(",
"c",
",",
"idx",
")",
"{",
"return",
"idx",
"===",
"3",
"?",
"c",
":",
"(",
"4",
"+",
"c",
")",
"*",
"17",
";",
"}",
")",
".",
"join",
"(",
"','",
")",
"+",
"')'",
";",
"}",
"}"
] | Given an arbitrary string, create a rgba color
of a specified opacity to identify it visually.
@param {string} str any arbitrary string
@param {number} opacity an opacity value from 0 to 1
@returns {string} output color
@example
toColor('tom') //= 'rgba(187,153,68,0.75)'
toColor() //= 'rgba(0,0,0,0.74)' | [
"Given",
"an",
"arbitrary",
"string",
"create",
"a",
"rgba",
"color",
"of",
"a",
"specified",
"opacity",
"to",
"identify",
"it",
"visually",
"."
] | 05befd89d423dbade569d1e3d3e8542a1897a59f | https://github.com/mapbox/to-color/blob/05befd89d423dbade569d1e3d3e8542a1897a59f/index.js#L11-L25 |
20,575 | ostdotcom/cache | index.js | function(configStrategy) {
if (!configStrategy.hasOwnProperty('cache') || !configStrategy.cache.hasOwnProperty('engine')) {
throw 'CACHING_ENGINE parameter is missing.';
}
if (configStrategy.cache.engine === undefined) {
throw 'CACHING_ENGINE parameter is empty.';
}
// Grab the required details from the configStrategy.
const cacheEngine = configStrategy.cache.engine.toString();
let isConsistentBehaviour = configStrategy.cache.consistentBehavior;
// Sanitize isConsistentBehaviour
isConsistentBehaviour = isConsistentBehaviour === undefined ? true : isConsistentBehaviour != '0';
// Stores the endpoint for key generation of instanceMap.
let endpointDetails = null;
// Generate endpointDetails for key generation of instanceMap.
if (cacheEngine == 'redis') {
const redisMandatoryParams = ['host', 'port', 'password', 'enableTsl'];
// Check if all the mandatory connection parameters for Redis are available or not.
for (let i = 0; i < redisMandatoryParams.length; i++) {
if (!configStrategy.cache.hasOwnProperty(redisMandatoryParams[i])) {
throw 'Redis - mandatory connection parameters missing.';
}
if (configStrategy.cache[redisMandatoryParams[i]] === undefined) {
throw 'Redis - connection parameters are empty.';
}
}
endpointDetails =
configStrategy.cache.host.toLowerCase() +
'-' +
configStrategy.cache.port.toString() +
'-' +
configStrategy.cache.enableTsl.toString();
} else if (cacheEngine == 'memcached') {
if (!configStrategy.cache.hasOwnProperty('servers')) {
throw 'Memcached - mandatory connection parameters missing.';
}
if (configStrategy.cache.servers === undefined) {
throw 'MEMCACHE_SERVERS(configStrategy.cache.servers) parameter is empty. ';
}
endpointDetails = configStrategy.cache.servers.join(',').toLowerCase();
} else {
endpointDetails = configStrategy.cache.namespace || '';
}
return cacheEngine + '-' + isConsistentBehaviour.toString() + '-' + endpointDetails;
} | javascript | function(configStrategy) {
if (!configStrategy.hasOwnProperty('cache') || !configStrategy.cache.hasOwnProperty('engine')) {
throw 'CACHING_ENGINE parameter is missing.';
}
if (configStrategy.cache.engine === undefined) {
throw 'CACHING_ENGINE parameter is empty.';
}
// Grab the required details from the configStrategy.
const cacheEngine = configStrategy.cache.engine.toString();
let isConsistentBehaviour = configStrategy.cache.consistentBehavior;
// Sanitize isConsistentBehaviour
isConsistentBehaviour = isConsistentBehaviour === undefined ? true : isConsistentBehaviour != '0';
// Stores the endpoint for key generation of instanceMap.
let endpointDetails = null;
// Generate endpointDetails for key generation of instanceMap.
if (cacheEngine == 'redis') {
const redisMandatoryParams = ['host', 'port', 'password', 'enableTsl'];
// Check if all the mandatory connection parameters for Redis are available or not.
for (let i = 0; i < redisMandatoryParams.length; i++) {
if (!configStrategy.cache.hasOwnProperty(redisMandatoryParams[i])) {
throw 'Redis - mandatory connection parameters missing.';
}
if (configStrategy.cache[redisMandatoryParams[i]] === undefined) {
throw 'Redis - connection parameters are empty.';
}
}
endpointDetails =
configStrategy.cache.host.toLowerCase() +
'-' +
configStrategy.cache.port.toString() +
'-' +
configStrategy.cache.enableTsl.toString();
} else if (cacheEngine == 'memcached') {
if (!configStrategy.cache.hasOwnProperty('servers')) {
throw 'Memcached - mandatory connection parameters missing.';
}
if (configStrategy.cache.servers === undefined) {
throw 'MEMCACHE_SERVERS(configStrategy.cache.servers) parameter is empty. ';
}
endpointDetails = configStrategy.cache.servers.join(',').toLowerCase();
} else {
endpointDetails = configStrategy.cache.namespace || '';
}
return cacheEngine + '-' + isConsistentBehaviour.toString() + '-' + endpointDetails;
} | [
"function",
"(",
"configStrategy",
")",
"{",
"if",
"(",
"!",
"configStrategy",
".",
"hasOwnProperty",
"(",
"'cache'",
")",
"||",
"!",
"configStrategy",
".",
"cache",
".",
"hasOwnProperty",
"(",
"'engine'",
")",
")",
"{",
"throw",
"'CACHING_ENGINE parameter is missing.'",
";",
"}",
"if",
"(",
"configStrategy",
".",
"cache",
".",
"engine",
"===",
"undefined",
")",
"{",
"throw",
"'CACHING_ENGINE parameter is empty.'",
";",
"}",
"// Grab the required details from the configStrategy.",
"const",
"cacheEngine",
"=",
"configStrategy",
".",
"cache",
".",
"engine",
".",
"toString",
"(",
")",
";",
"let",
"isConsistentBehaviour",
"=",
"configStrategy",
".",
"cache",
".",
"consistentBehavior",
";",
"// Sanitize isConsistentBehaviour",
"isConsistentBehaviour",
"=",
"isConsistentBehaviour",
"===",
"undefined",
"?",
"true",
":",
"isConsistentBehaviour",
"!=",
"'0'",
";",
"// Stores the endpoint for key generation of instanceMap.",
"let",
"endpointDetails",
"=",
"null",
";",
"// Generate endpointDetails for key generation of instanceMap.",
"if",
"(",
"cacheEngine",
"==",
"'redis'",
")",
"{",
"const",
"redisMandatoryParams",
"=",
"[",
"'host'",
",",
"'port'",
",",
"'password'",
",",
"'enableTsl'",
"]",
";",
"// Check if all the mandatory connection parameters for Redis are available or not.",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"redisMandatoryParams",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"configStrategy",
".",
"cache",
".",
"hasOwnProperty",
"(",
"redisMandatoryParams",
"[",
"i",
"]",
")",
")",
"{",
"throw",
"'Redis - mandatory connection parameters missing.'",
";",
"}",
"if",
"(",
"configStrategy",
".",
"cache",
"[",
"redisMandatoryParams",
"[",
"i",
"]",
"]",
"===",
"undefined",
")",
"{",
"throw",
"'Redis - connection parameters are empty.'",
";",
"}",
"}",
"endpointDetails",
"=",
"configStrategy",
".",
"cache",
".",
"host",
".",
"toLowerCase",
"(",
")",
"+",
"'-'",
"+",
"configStrategy",
".",
"cache",
".",
"port",
".",
"toString",
"(",
")",
"+",
"'-'",
"+",
"configStrategy",
".",
"cache",
".",
"enableTsl",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"cacheEngine",
"==",
"'memcached'",
")",
"{",
"if",
"(",
"!",
"configStrategy",
".",
"cache",
".",
"hasOwnProperty",
"(",
"'servers'",
")",
")",
"{",
"throw",
"'Memcached - mandatory connection parameters missing.'",
";",
"}",
"if",
"(",
"configStrategy",
".",
"cache",
".",
"servers",
"===",
"undefined",
")",
"{",
"throw",
"'MEMCACHE_SERVERS(configStrategy.cache.servers) parameter is empty. '",
";",
"}",
"endpointDetails",
"=",
"configStrategy",
".",
"cache",
".",
"servers",
".",
"join",
"(",
"','",
")",
".",
"toLowerCase",
"(",
")",
";",
"}",
"else",
"{",
"endpointDetails",
"=",
"configStrategy",
".",
"cache",
".",
"namespace",
"||",
"''",
";",
"}",
"return",
"cacheEngine",
"+",
"'-'",
"+",
"isConsistentBehaviour",
".",
"toString",
"(",
")",
"+",
"'-'",
"+",
"endpointDetails",
";",
"}"
] | Creates the key for the instanceMap.
@returns {string} | [
"Creates",
"the",
"key",
"for",
"the",
"instanceMap",
"."
] | 5fd550e262fdf25479d3d0c417364c4dc7c45530 | https://github.com/ostdotcom/cache/blob/5fd550e262fdf25479d3d0c417364c4dc7c45530/index.js#L48-L99 | |
20,576 | ostdotcom/cache | lib/cache/implementer/InMemory.js | function(lifetimeInSec) {
lifetimeInSec = Number(lifetimeInSec);
if (isNaN(lifetimeInSec)) {
lifetimeInSec = 0;
}
let lifetime = lifetimeInSec * 1000;
if (lifetime <= 0) {
this.expires = Date.now();
} else {
this.expires = Date.now() + lifetime;
}
} | javascript | function(lifetimeInSec) {
lifetimeInSec = Number(lifetimeInSec);
if (isNaN(lifetimeInSec)) {
lifetimeInSec = 0;
}
let lifetime = lifetimeInSec * 1000;
if (lifetime <= 0) {
this.expires = Date.now();
} else {
this.expires = Date.now() + lifetime;
}
} | [
"function",
"(",
"lifetimeInSec",
")",
"{",
"lifetimeInSec",
"=",
"Number",
"(",
"lifetimeInSec",
")",
";",
"if",
"(",
"isNaN",
"(",
"lifetimeInSec",
")",
")",
"{",
"lifetimeInSec",
"=",
"0",
";",
"}",
"let",
"lifetime",
"=",
"lifetimeInSec",
"*",
"1000",
";",
"if",
"(",
"lifetime",
"<=",
"0",
")",
"{",
"this",
".",
"expires",
"=",
"Date",
".",
"now",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"expires",
"=",
"Date",
".",
"now",
"(",
")",
"+",
"lifetime",
";",
"}",
"}"
] | Sets the expiry timestamp of the record.
@param {number} lifetimeInSec life-time is seconds after which record is considered expired. | [
"Sets",
"the",
"expiry",
"timestamp",
"of",
"the",
"record",
"."
] | 5fd550e262fdf25479d3d0c417364c4dc7c45530 | https://github.com/ostdotcom/cache/blob/5fd550e262fdf25479d3d0c417364c4dc7c45530/lib/cache/implementer/InMemory.js#L591-L603 | |
20,577 | stellar/js-xdr | src/config.js | createTypedef | function createTypedef(context, typeName, value) {
if (value instanceof Reference) {
value = value.resolve(context);
}
context.results[typeName] = value;
return value;
} | javascript | function createTypedef(context, typeName, value) {
if (value instanceof Reference) {
value = value.resolve(context);
}
context.results[typeName] = value;
return value;
} | [
"function",
"createTypedef",
"(",
"context",
",",
"typeName",
",",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"Reference",
")",
"{",
"value",
"=",
"value",
".",
"resolve",
"(",
"context",
")",
";",
"}",
"context",
".",
"results",
"[",
"typeName",
"]",
"=",
"value",
";",
"return",
"value",
";",
"}"
] | let the reference resoltion system do it's thing the "constructor" for a typedef just returns the resolved value | [
"let",
"the",
"reference",
"resoltion",
"system",
"do",
"it",
"s",
"thing",
"the",
"constructor",
"for",
"a",
"typedef",
"just",
"returns",
"the",
"resolved",
"value"
] | 8a7e48e0eda432a33d0f68af00c5642f5706ac0a | https://github.com/stellar/js-xdr/blob/8a7e48e0eda432a33d0f68af00c5642f5706ac0a/src/config.js#L119-L125 |
20,578 | blackbaud/skyux-builder | config/webpack/alias-builder.js | setSpaAlias | function setSpaAlias(alias, moduleName, path) {
let resolvedPath = spaPath(path);
if (!fs.existsSync(resolvedPath)) {
resolvedPath = outPath(path);
}
alias['sky-pages-internal/' + moduleName] = resolvedPath;
} | javascript | function setSpaAlias(alias, moduleName, path) {
let resolvedPath = spaPath(path);
if (!fs.existsSync(resolvedPath)) {
resolvedPath = outPath(path);
}
alias['sky-pages-internal/' + moduleName] = resolvedPath;
} | [
"function",
"setSpaAlias",
"(",
"alias",
",",
"moduleName",
",",
"path",
")",
"{",
"let",
"resolvedPath",
"=",
"spaPath",
"(",
"path",
")",
";",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"resolvedPath",
")",
")",
"{",
"resolvedPath",
"=",
"outPath",
"(",
"path",
")",
";",
"}",
"alias",
"[",
"'sky-pages-internal/'",
"+",
"moduleName",
"]",
"=",
"resolvedPath",
";",
"}"
] | Sets an alias to the specified module using the SPA path if the file exists in the SPA;
otherwise it sets the alias to the file in SKY UX Builder.
@name setSpaAlias
@param {Object} alias
@param {String} moduleName
@param {String} path | [
"Sets",
"an",
"alias",
"to",
"the",
"specified",
"module",
"using",
"the",
"SPA",
"path",
"if",
"the",
"file",
"exists",
"in",
"the",
"SPA",
";",
"otherwise",
"it",
"sets",
"the",
"alias",
"to",
"the",
"file",
"in",
"SKY",
"UX",
"Builder",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/config/webpack/alias-builder.js#L24-L32 |
20,579 | blackbaud/skyux-builder | utils/host-utils.js | resolve | function resolve(url, localUrl, chunks, skyPagesConfig) {
let host = skyPagesConfig.skyux.host.url;
let config = {
scripts: getScripts(chunks),
localUrl: localUrl
};
if (skyPagesConfig.skyux.app && skyPagesConfig.skyux.app.externals) {
config.externals = skyPagesConfig.skyux.app.externals;
}
// Trim leading slash since getAppBase adds it
if (url && url.charAt(0) === '/') {
url = url.substring(1);
}
// Trim trailing slash since geAppBase adds it
if (host && host.charAt(host.length - 1) === '/') {
host = host.slice(0, -1);
}
const delimeter = url.indexOf('?') === -1 ? '?' : '&';
const encoded = new Buffer(JSON.stringify(config)).toString('base64');
const base = skyPagesConfigUtil.getAppBase(skyPagesConfig);
const resolved = `${host}${base}${url}${delimeter}local=true&_cfg=${encoded}`;
return resolved;
} | javascript | function resolve(url, localUrl, chunks, skyPagesConfig) {
let host = skyPagesConfig.skyux.host.url;
let config = {
scripts: getScripts(chunks),
localUrl: localUrl
};
if (skyPagesConfig.skyux.app && skyPagesConfig.skyux.app.externals) {
config.externals = skyPagesConfig.skyux.app.externals;
}
// Trim leading slash since getAppBase adds it
if (url && url.charAt(0) === '/') {
url = url.substring(1);
}
// Trim trailing slash since geAppBase adds it
if (host && host.charAt(host.length - 1) === '/') {
host = host.slice(0, -1);
}
const delimeter = url.indexOf('?') === -1 ? '?' : '&';
const encoded = new Buffer(JSON.stringify(config)).toString('base64');
const base = skyPagesConfigUtil.getAppBase(skyPagesConfig);
const resolved = `${host}${base}${url}${delimeter}local=true&_cfg=${encoded}`;
return resolved;
} | [
"function",
"resolve",
"(",
"url",
",",
"localUrl",
",",
"chunks",
",",
"skyPagesConfig",
")",
"{",
"let",
"host",
"=",
"skyPagesConfig",
".",
"skyux",
".",
"host",
".",
"url",
";",
"let",
"config",
"=",
"{",
"scripts",
":",
"getScripts",
"(",
"chunks",
")",
",",
"localUrl",
":",
"localUrl",
"}",
";",
"if",
"(",
"skyPagesConfig",
".",
"skyux",
".",
"app",
"&&",
"skyPagesConfig",
".",
"skyux",
".",
"app",
".",
"externals",
")",
"{",
"config",
".",
"externals",
"=",
"skyPagesConfig",
".",
"skyux",
".",
"app",
".",
"externals",
";",
"}",
"// Trim leading slash since getAppBase adds it",
"if",
"(",
"url",
"&&",
"url",
".",
"charAt",
"(",
"0",
")",
"===",
"'/'",
")",
"{",
"url",
"=",
"url",
".",
"substring",
"(",
"1",
")",
";",
"}",
"// Trim trailing slash since geAppBase adds it",
"if",
"(",
"host",
"&&",
"host",
".",
"charAt",
"(",
"host",
".",
"length",
"-",
"1",
")",
"===",
"'/'",
")",
"{",
"host",
"=",
"host",
".",
"slice",
"(",
"0",
",",
"-",
"1",
")",
";",
"}",
"const",
"delimeter",
"=",
"url",
".",
"indexOf",
"(",
"'?'",
")",
"===",
"-",
"1",
"?",
"'?'",
":",
"'&'",
";",
"const",
"encoded",
"=",
"new",
"Buffer",
"(",
"JSON",
".",
"stringify",
"(",
"config",
")",
")",
".",
"toString",
"(",
"'base64'",
")",
";",
"const",
"base",
"=",
"skyPagesConfigUtil",
".",
"getAppBase",
"(",
"skyPagesConfig",
")",
";",
"const",
"resolved",
"=",
"`",
"${",
"host",
"}",
"${",
"base",
"}",
"${",
"url",
"}",
"${",
"delimeter",
"}",
"${",
"encoded",
"}",
"`",
";",
"return",
"resolved",
";",
"}"
] | Creates a resolved host url.
@param {string} url
@param {string} localUrl
@param {Array} chunks
@param {Object} skyPagesConfig | [
"Creates",
"a",
"resolved",
"host",
"url",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/utils/host-utils.js#L14-L41 |
20,580 | blackbaud/skyux-builder | utils/host-utils.js | getScripts | function getScripts(chunks) {
let scripts = [];
// Used when skipping the build, short-circuit to return metadata
if (chunks.metadata) {
return chunks.metadata;
}
sorter.dependency(chunks).forEach((chunk) => {
scripts.push({
name: chunk.files[0]
});
});
return scripts;
} | javascript | function getScripts(chunks) {
let scripts = [];
// Used when skipping the build, short-circuit to return metadata
if (chunks.metadata) {
return chunks.metadata;
}
sorter.dependency(chunks).forEach((chunk) => {
scripts.push({
name: chunk.files[0]
});
});
return scripts;
} | [
"function",
"getScripts",
"(",
"chunks",
")",
"{",
"let",
"scripts",
"=",
"[",
"]",
";",
"// Used when skipping the build, short-circuit to return metadata",
"if",
"(",
"chunks",
".",
"metadata",
")",
"{",
"return",
"chunks",
".",
"metadata",
";",
"}",
"sorter",
".",
"dependency",
"(",
"chunks",
")",
".",
"forEach",
"(",
"(",
"chunk",
")",
"=>",
"{",
"scripts",
".",
"push",
"(",
"{",
"name",
":",
"chunk",
".",
"files",
"[",
"0",
"]",
"}",
")",
";",
"}",
")",
";",
"return",
"scripts",
";",
"}"
] | Sorts chunks into array of scripts.
@param {Array} chunks | [
"Sorts",
"chunks",
"into",
"array",
"of",
"scripts",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/utils/host-utils.js#L47-L62 |
20,581 | blackbaud/skyux-builder | config/webpack/serve.webpack.config.js | WebpackPluginDone | function WebpackPluginDone() {
let launched = false;
this.plugin('done', (stats) => {
if (!launched) {
launched = true;
browser(argv, skyPagesConfig, stats, this.options.devServer.port);
}
});
} | javascript | function WebpackPluginDone() {
let launched = false;
this.plugin('done', (stats) => {
if (!launched) {
launched = true;
browser(argv, skyPagesConfig, stats, this.options.devServer.port);
}
});
} | [
"function",
"WebpackPluginDone",
"(",
")",
"{",
"let",
"launched",
"=",
"false",
";",
"this",
".",
"plugin",
"(",
"'done'",
",",
"(",
"stats",
")",
"=>",
"{",
"if",
"(",
"!",
"launched",
")",
"{",
"launched",
"=",
"true",
";",
"browser",
"(",
"argv",
",",
"skyPagesConfig",
",",
"stats",
",",
"this",
".",
"options",
".",
"devServer",
".",
"port",
")",
";",
"}",
"}",
")",
";",
"}"
] | Opens the host service url.
@name WebpackPluginDone | [
"Opens",
"the",
"host",
"service",
"url",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/config/webpack/serve.webpack.config.js#L25-L34 |
20,582 | blackbaud/skyux-builder | lib/sky-pages-route-generator.js | getRoutesForConfig | function getRoutesForConfig(routes) {
return routes.map(route => ({
routePath: route.routePath === '?' ? '' : route.routePath.replace(/\#/g, ''),
routeParams: route.routeParams
}));
} | javascript | function getRoutesForConfig(routes) {
return routes.map(route => ({
routePath: route.routePath === '?' ? '' : route.routePath.replace(/\#/g, ''),
routeParams: route.routeParams
}));
} | [
"function",
"getRoutesForConfig",
"(",
"routes",
")",
"{",
"return",
"routes",
".",
"map",
"(",
"route",
"=>",
"(",
"{",
"routePath",
":",
"route",
".",
"routePath",
"===",
"'?'",
"?",
"''",
":",
"route",
".",
"routePath",
".",
"replace",
"(",
"/",
"\\#",
"/",
"g",
",",
"''",
")",
",",
"routeParams",
":",
"route",
".",
"routeParams",
"}",
")",
")",
";",
"}"
] | Only expose certain properties to SkyAppConfig. Specifically routeDefinition caused errors for skyux e2e in Windows. | [
"Only",
"expose",
"certain",
"properties",
"to",
"SkyAppConfig",
".",
"Specifically",
"routeDefinition",
"caused",
"errors",
"for",
"skyux",
"e2e",
"in",
"Windows",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/lib/sky-pages-route-generator.js#L306-L311 |
20,583 | blackbaud/skyux-builder | cli/e2e.js | killServers | function killServers(exitCode) {
logger.info('Cleaning up running servers');
if (seleniumServer) {
logger.info('Closing selenium server');
seleniumServer.kill();
seleniumServer = null;
}
// Catch protractor's "Kitchen Sink" error.
if (exitCode === 199) {
logger.warn('Supressing protractor\'s "kitchen sink" error 199');
exitCode = 0;
}
server.stop();
logger.info(`Execution Time: ${(new Date().getTime() - start) / 1000} seconds`);
logger.info(`Exiting process with ${exitCode}`);
process.exit(exitCode || 0);
} | javascript | function killServers(exitCode) {
logger.info('Cleaning up running servers');
if (seleniumServer) {
logger.info('Closing selenium server');
seleniumServer.kill();
seleniumServer = null;
}
// Catch protractor's "Kitchen Sink" error.
if (exitCode === 199) {
logger.warn('Supressing protractor\'s "kitchen sink" error 199');
exitCode = 0;
}
server.stop();
logger.info(`Execution Time: ${(new Date().getTime() - start) / 1000} seconds`);
logger.info(`Exiting process with ${exitCode}`);
process.exit(exitCode || 0);
} | [
"function",
"killServers",
"(",
"exitCode",
")",
"{",
"logger",
".",
"info",
"(",
"'Cleaning up running servers'",
")",
";",
"if",
"(",
"seleniumServer",
")",
"{",
"logger",
".",
"info",
"(",
"'Closing selenium server'",
")",
";",
"seleniumServer",
".",
"kill",
"(",
")",
";",
"seleniumServer",
"=",
"null",
";",
"}",
"// Catch protractor's \"Kitchen Sink\" error.",
"if",
"(",
"exitCode",
"===",
"199",
")",
"{",
"logger",
".",
"warn",
"(",
"'Supressing protractor\\'s \"kitchen sink\" error 199'",
")",
";",
"exitCode",
"=",
"0",
";",
"}",
"server",
".",
"stop",
"(",
")",
";",
"logger",
".",
"info",
"(",
"`",
"${",
"(",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
"-",
"start",
")",
"/",
"1000",
"}",
"`",
")",
";",
"logger",
".",
"info",
"(",
"`",
"${",
"exitCode",
"}",
"`",
")",
";",
"process",
".",
"exit",
"(",
"exitCode",
"||",
"0",
")",
";",
"}"
] | Handles killing off the selenium and webpack servers.
@name killServers | [
"Handles",
"killing",
"off",
"the",
"selenium",
"and",
"webpack",
"servers",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/cli/e2e.js#L27-L46 |
20,584 | blackbaud/skyux-builder | cli/e2e.js | spawnProtractor | function spawnProtractor(configPath, chunks, port, skyPagesConfig) {
logger.info('Running Protractor');
protractorLauncher.init(configPath, {
params: {
localUrl: `https://localhost:${port}`,
chunks: chunks,
skyPagesConfig: skyPagesConfig
}
});
process.on('exit', killServers);
} | javascript | function spawnProtractor(configPath, chunks, port, skyPagesConfig) {
logger.info('Running Protractor');
protractorLauncher.init(configPath, {
params: {
localUrl: `https://localhost:${port}`,
chunks: chunks,
skyPagesConfig: skyPagesConfig
}
});
process.on('exit', killServers);
} | [
"function",
"spawnProtractor",
"(",
"configPath",
",",
"chunks",
",",
"port",
",",
"skyPagesConfig",
")",
"{",
"logger",
".",
"info",
"(",
"'Running Protractor'",
")",
";",
"protractorLauncher",
".",
"init",
"(",
"configPath",
",",
"{",
"params",
":",
"{",
"localUrl",
":",
"`",
"${",
"port",
"}",
"`",
",",
"chunks",
":",
"chunks",
",",
"skyPagesConfig",
":",
"skyPagesConfig",
"}",
"}",
")",
";",
"process",
".",
"on",
"(",
"'exit'",
",",
"killServers",
")",
";",
"}"
] | Spawns the protractor command.
Perhaps this should be API driven?
@name spawnProtractor | [
"Spawns",
"the",
"protractor",
"command",
".",
"Perhaps",
"this",
"should",
"be",
"API",
"driven?"
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/cli/e2e.js#L53-L63 |
20,585 | blackbaud/skyux-builder | cli/e2e.js | getChromeDriverVersion | function getChromeDriverVersion() {
return new Promise(resolve => {
const defaultVersion = 'latest';
matcher.getChromeDriverVersion()
.then(result => {
if (result.chromeDriverVersion) {
resolve(result.chromeDriverVersion);
} else {
resolve(defaultVersion);
}
})
.catch(() => resolve(defaultVersion));
});
} | javascript | function getChromeDriverVersion() {
return new Promise(resolve => {
const defaultVersion = 'latest';
matcher.getChromeDriverVersion()
.then(result => {
if (result.chromeDriverVersion) {
resolve(result.chromeDriverVersion);
} else {
resolve(defaultVersion);
}
})
.catch(() => resolve(defaultVersion));
});
} | [
"function",
"getChromeDriverVersion",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"resolve",
"=>",
"{",
"const",
"defaultVersion",
"=",
"'latest'",
";",
"matcher",
".",
"getChromeDriverVersion",
"(",
")",
".",
"then",
"(",
"result",
"=>",
"{",
"if",
"(",
"result",
".",
"chromeDriverVersion",
")",
"{",
"resolve",
"(",
"result",
".",
"chromeDriverVersion",
")",
";",
"}",
"else",
"{",
"resolve",
"(",
"defaultVersion",
")",
";",
"}",
"}",
")",
".",
"catch",
"(",
"(",
")",
"=>",
"resolve",
"(",
"defaultVersion",
")",
")",
";",
"}",
")",
";",
"}"
] | Calls the getChromeDriverVersion method in our library, but handles any errors. | [
"Calls",
"the",
"getChromeDriverVersion",
"method",
"in",
"our",
"library",
"but",
"handles",
"any",
"errors",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/cli/e2e.js#L68-L82 |
20,586 | blackbaud/skyux-builder | cli/e2e.js | spawnSelenium | function spawnSelenium(configPath) {
const config = require(configPath).config;
return new Promise((resolve, reject) => {
logger.info('Spawning selenium...');
// Assumes we're running selenium ourselves, so we should prep it
if (config.seleniumAddress) {
logger.info('Installing Selenium...');
selenium.install({ logger: logger.info }, () => {
logger.info('Selenium installed. Starting...');
selenium.start((err, child) => {
if (err) {
reject(err);
return;
}
seleniumServer = child;
logger.info('Selenium server is ready.');
resolve();
});
});
// Otherwise we need to prep protractor's selenium
} else {
logger.info(`Getting webdriver version.`);
getChromeDriverVersion().then(version => {
logger.info(`Updating webdriver to version ${version}`);
const webdriverManagerPath = path.resolve(
'node_modules',
'.bin',
'webdriver-manager'
);
const results = spawn.sync(
webdriverManagerPath,
[
'update',
'--standalone',
'false',
'--gecko',
'false',
'--versions.chrome',
version
],
spawnOptions
);
if (results.error) {
reject(results.error);
return;
}
logger.info('Selenium server is ready.');
resolve();
});
}
});
} | javascript | function spawnSelenium(configPath) {
const config = require(configPath).config;
return new Promise((resolve, reject) => {
logger.info('Spawning selenium...');
// Assumes we're running selenium ourselves, so we should prep it
if (config.seleniumAddress) {
logger.info('Installing Selenium...');
selenium.install({ logger: logger.info }, () => {
logger.info('Selenium installed. Starting...');
selenium.start((err, child) => {
if (err) {
reject(err);
return;
}
seleniumServer = child;
logger.info('Selenium server is ready.');
resolve();
});
});
// Otherwise we need to prep protractor's selenium
} else {
logger.info(`Getting webdriver version.`);
getChromeDriverVersion().then(version => {
logger.info(`Updating webdriver to version ${version}`);
const webdriverManagerPath = path.resolve(
'node_modules',
'.bin',
'webdriver-manager'
);
const results = spawn.sync(
webdriverManagerPath,
[
'update',
'--standalone',
'false',
'--gecko',
'false',
'--versions.chrome',
version
],
spawnOptions
);
if (results.error) {
reject(results.error);
return;
}
logger.info('Selenium server is ready.');
resolve();
});
}
});
} | [
"function",
"spawnSelenium",
"(",
"configPath",
")",
"{",
"const",
"config",
"=",
"require",
"(",
"configPath",
")",
".",
"config",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"logger",
".",
"info",
"(",
"'Spawning selenium...'",
")",
";",
"// Assumes we're running selenium ourselves, so we should prep it",
"if",
"(",
"config",
".",
"seleniumAddress",
")",
"{",
"logger",
".",
"info",
"(",
"'Installing Selenium...'",
")",
";",
"selenium",
".",
"install",
"(",
"{",
"logger",
":",
"logger",
".",
"info",
"}",
",",
"(",
")",
"=>",
"{",
"logger",
".",
"info",
"(",
"'Selenium installed. Starting...'",
")",
";",
"selenium",
".",
"start",
"(",
"(",
"err",
",",
"child",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"reject",
"(",
"err",
")",
";",
"return",
";",
"}",
"seleniumServer",
"=",
"child",
";",
"logger",
".",
"info",
"(",
"'Selenium server is ready.'",
")",
";",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"// Otherwise we need to prep protractor's selenium",
"}",
"else",
"{",
"logger",
".",
"info",
"(",
"`",
"`",
")",
";",
"getChromeDriverVersion",
"(",
")",
".",
"then",
"(",
"version",
"=>",
"{",
"logger",
".",
"info",
"(",
"`",
"${",
"version",
"}",
"`",
")",
";",
"const",
"webdriverManagerPath",
"=",
"path",
".",
"resolve",
"(",
"'node_modules'",
",",
"'.bin'",
",",
"'webdriver-manager'",
")",
";",
"const",
"results",
"=",
"spawn",
".",
"sync",
"(",
"webdriverManagerPath",
",",
"[",
"'update'",
",",
"'--standalone'",
",",
"'false'",
",",
"'--gecko'",
",",
"'false'",
",",
"'--versions.chrome'",
",",
"version",
"]",
",",
"spawnOptions",
")",
";",
"if",
"(",
"results",
".",
"error",
")",
"{",
"reject",
"(",
"results",
".",
"error",
")",
";",
"return",
";",
"}",
"logger",
".",
"info",
"(",
"'Selenium server is ready.'",
")",
";",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"}"
] | Spawns the selenium server if directConnect is not enabled.
@name spawnSelenium | [
"Spawns",
"the",
"selenium",
"server",
"if",
"directConnect",
"is",
"not",
"enabled",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/cli/e2e.js#L88-L150 |
20,587 | blackbaud/skyux-builder | cli/e2e.js | spawnBuild | function spawnBuild(argv, skyPagesConfig, webpack) {
if (argv.build === false) {
logger.info('Skipping build step');
const file = 'dist/metadata.json';
if (!fs.existsSync(file)) {
logger.info(`Unable to skip build step. "${file}" not found.`);
} else {
return Promise.resolve({
metadata: fs.readJsonSync(file)
});
}
}
return build(argv, skyPagesConfig, webpack)
.then(stats => stats.toJson().chunks);
} | javascript | function spawnBuild(argv, skyPagesConfig, webpack) {
if (argv.build === false) {
logger.info('Skipping build step');
const file = 'dist/metadata.json';
if (!fs.existsSync(file)) {
logger.info(`Unable to skip build step. "${file}" not found.`);
} else {
return Promise.resolve({
metadata: fs.readJsonSync(file)
});
}
}
return build(argv, skyPagesConfig, webpack)
.then(stats => stats.toJson().chunks);
} | [
"function",
"spawnBuild",
"(",
"argv",
",",
"skyPagesConfig",
",",
"webpack",
")",
"{",
"if",
"(",
"argv",
".",
"build",
"===",
"false",
")",
"{",
"logger",
".",
"info",
"(",
"'Skipping build step'",
")",
";",
"const",
"file",
"=",
"'dist/metadata.json'",
";",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"file",
")",
")",
"{",
"logger",
".",
"info",
"(",
"`",
"${",
"file",
"}",
"`",
")",
";",
"}",
"else",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"{",
"metadata",
":",
"fs",
".",
"readJsonSync",
"(",
"file",
")",
"}",
")",
";",
"}",
"}",
"return",
"build",
"(",
"argv",
",",
"skyPagesConfig",
",",
"webpack",
")",
".",
"then",
"(",
"stats",
"=>",
"stats",
".",
"toJson",
"(",
")",
".",
"chunks",
")",
";",
"}"
] | Spawns the build process. Captures the config used. | [
"Spawns",
"the",
"build",
"process",
".",
"Captures",
"the",
"config",
"used",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/cli/e2e.js#L155-L172 |
20,588 | blackbaud/skyux-builder | cli/e2e.js | e2e | function e2e(command, argv, skyPagesConfig, webpack) {
start = new Date().getTime();
process.on('SIGINT', killServers);
const specsPath = path.resolve(process.cwd(), 'e2e/**/*.e2e-spec.ts');
const specsGlob = glob.sync(specsPath);
const configPath = configResolver.resolve(command, argv);
if (specsGlob.length === 0) {
logger.info('No spec files located. Skipping e2e command.');
return killServers(0);
}
server.start()
.then((port) => {
argv.assets = 'https://localhost:' + port;
// The assets URL is built by combining the assets URL above with
// the app's root directory, but in e2e tests the assets files
// are served directly from the root. This will back up a directory
// so that asset URLs are built relative to the root rather than
// the app's root directory.
argv.assetsrel = '../';
return Promise
.all([
spawnBuild(argv, skyPagesConfig, webpack),
port,
spawnSelenium(configPath)
]);
})
.then(([chunks, port]) => {
spawnProtractor(
configPath,
chunks,
port,
skyPagesConfig
);
})
.catch(err => {
logger.error(err);
killServers(1);
});
} | javascript | function e2e(command, argv, skyPagesConfig, webpack) {
start = new Date().getTime();
process.on('SIGINT', killServers);
const specsPath = path.resolve(process.cwd(), 'e2e/**/*.e2e-spec.ts');
const specsGlob = glob.sync(specsPath);
const configPath = configResolver.resolve(command, argv);
if (specsGlob.length === 0) {
logger.info('No spec files located. Skipping e2e command.');
return killServers(0);
}
server.start()
.then((port) => {
argv.assets = 'https://localhost:' + port;
// The assets URL is built by combining the assets URL above with
// the app's root directory, but in e2e tests the assets files
// are served directly from the root. This will back up a directory
// so that asset URLs are built relative to the root rather than
// the app's root directory.
argv.assetsrel = '../';
return Promise
.all([
spawnBuild(argv, skyPagesConfig, webpack),
port,
spawnSelenium(configPath)
]);
})
.then(([chunks, port]) => {
spawnProtractor(
configPath,
chunks,
port,
skyPagesConfig
);
})
.catch(err => {
logger.error(err);
killServers(1);
});
} | [
"function",
"e2e",
"(",
"command",
",",
"argv",
",",
"skyPagesConfig",
",",
"webpack",
")",
"{",
"start",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"process",
".",
"on",
"(",
"'SIGINT'",
",",
"killServers",
")",
";",
"const",
"specsPath",
"=",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"'e2e/**/*.e2e-spec.ts'",
")",
";",
"const",
"specsGlob",
"=",
"glob",
".",
"sync",
"(",
"specsPath",
")",
";",
"const",
"configPath",
"=",
"configResolver",
".",
"resolve",
"(",
"command",
",",
"argv",
")",
";",
"if",
"(",
"specsGlob",
".",
"length",
"===",
"0",
")",
"{",
"logger",
".",
"info",
"(",
"'No spec files located. Skipping e2e command.'",
")",
";",
"return",
"killServers",
"(",
"0",
")",
";",
"}",
"server",
".",
"start",
"(",
")",
".",
"then",
"(",
"(",
"port",
")",
"=>",
"{",
"argv",
".",
"assets",
"=",
"'https://localhost:'",
"+",
"port",
";",
"// The assets URL is built by combining the assets URL above with",
"// the app's root directory, but in e2e tests the assets files",
"// are served directly from the root. This will back up a directory",
"// so that asset URLs are built relative to the root rather than",
"// the app's root directory.",
"argv",
".",
"assetsrel",
"=",
"'../'",
";",
"return",
"Promise",
".",
"all",
"(",
"[",
"spawnBuild",
"(",
"argv",
",",
"skyPagesConfig",
",",
"webpack",
")",
",",
"port",
",",
"spawnSelenium",
"(",
"configPath",
")",
"]",
")",
";",
"}",
")",
".",
"then",
"(",
"(",
"[",
"chunks",
",",
"port",
"]",
")",
"=>",
"{",
"spawnProtractor",
"(",
"configPath",
",",
"chunks",
",",
"port",
",",
"skyPagesConfig",
")",
";",
"}",
")",
".",
"catch",
"(",
"err",
"=>",
"{",
"logger",
".",
"error",
"(",
"err",
")",
";",
"killServers",
"(",
"1",
")",
";",
"}",
")",
";",
"}"
] | Spawns the necessary commands for e2e.
Assumes build was ran.
@name e2e | [
"Spawns",
"the",
"necessary",
"commands",
"for",
"e2e",
".",
"Assumes",
"build",
"was",
"ran",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/cli/e2e.js#L179-L222 |
20,589 | blackbaud/skyux-builder | e2e/shared/common.js | bindServe | function bindServe() {
return new Promise((resolve, reject) => {
// Logging "warnings" but not rejecting test
webpackServer.stderr.on('data', data => log(data));
webpackServer.stdout.on('data', data => {
const dataAsString = log(data);
if (dataAsString.indexOf('webpack: Compiled successfully.') > -1) {
resolve(_port);
}
if (dataAsString.indexOf('webpack: Failed to compile.') > -1) {
reject(dataAsString);
}
});
});
} | javascript | function bindServe() {
return new Promise((resolve, reject) => {
// Logging "warnings" but not rejecting test
webpackServer.stderr.on('data', data => log(data));
webpackServer.stdout.on('data', data => {
const dataAsString = log(data);
if (dataAsString.indexOf('webpack: Compiled successfully.') > -1) {
resolve(_port);
}
if (dataAsString.indexOf('webpack: Failed to compile.') > -1) {
reject(dataAsString);
}
});
});
} | [
"function",
"bindServe",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"// Logging \"warnings\" but not rejecting test",
"webpackServer",
".",
"stderr",
".",
"on",
"(",
"'data'",
",",
"data",
"=>",
"log",
"(",
"data",
")",
")",
";",
"webpackServer",
".",
"stdout",
".",
"on",
"(",
"'data'",
",",
"data",
"=>",
"{",
"const",
"dataAsString",
"=",
"log",
"(",
"data",
")",
";",
"if",
"(",
"dataAsString",
".",
"indexOf",
"(",
"'webpack: Compiled successfully.'",
")",
">",
"-",
"1",
")",
"{",
"resolve",
"(",
"_port",
")",
";",
"}",
"if",
"(",
"dataAsString",
".",
"indexOf",
"(",
"'webpack: Failed to compile.'",
")",
">",
"-",
"1",
")",
"{",
"reject",
"(",
"dataAsString",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Adds event listeners to serve and resolves a promise. | [
"Adds",
"event",
"listeners",
"to",
"serve",
"and",
"resolves",
"a",
"promise",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/e2e/shared/common.js#L48-L63 |
20,590 | blackbaud/skyux-builder | e2e/shared/common.js | exec | function exec(cmd, args, opts) {
console.log(`Running command: ${cmd} ${args.join(' ')}`);
const cp = childProcessSpawn(cmd, args, opts);
cp.stdout.on('data', data => log(data));
cp.stderr.on('data', data => log(data));
return new Promise((resolve, reject) => {
cp.on('error', err => reject(log(err)));
cp.on('exit', code => resolve(code));
});
} | javascript | function exec(cmd, args, opts) {
console.log(`Running command: ${cmd} ${args.join(' ')}`);
const cp = childProcessSpawn(cmd, args, opts);
cp.stdout.on('data', data => log(data));
cp.stderr.on('data', data => log(data));
return new Promise((resolve, reject) => {
cp.on('error', err => reject(log(err)));
cp.on('exit', code => resolve(code));
});
} | [
"function",
"exec",
"(",
"cmd",
",",
"args",
",",
"opts",
")",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"cmd",
"}",
"${",
"args",
".",
"join",
"(",
"' '",
")",
"}",
"`",
")",
";",
"const",
"cp",
"=",
"childProcessSpawn",
"(",
"cmd",
",",
"args",
",",
"opts",
")",
";",
"cp",
".",
"stdout",
".",
"on",
"(",
"'data'",
",",
"data",
"=>",
"log",
"(",
"data",
")",
")",
";",
"cp",
".",
"stderr",
".",
"on",
"(",
"'data'",
",",
"data",
"=>",
"log",
"(",
"data",
")",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"cp",
".",
"on",
"(",
"'error'",
",",
"err",
"=>",
"reject",
"(",
"log",
"(",
"err",
")",
")",
")",
";",
"cp",
".",
"on",
"(",
"'exit'",
",",
"code",
"=>",
"resolve",
"(",
"code",
")",
")",
";",
"}",
")",
";",
"}"
] | Spawns a child_process and returns a promise.
@name exec | [
"Spawns",
"a",
"child_process",
"and",
"returns",
"a",
"promise",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/e2e/shared/common.js#L77-L88 |
20,591 | blackbaud/skyux-builder | e2e/shared/common.js | prepareBuild | function prepareBuild(config) {
function serve(exitCode) {
// Save our exitCode for testing
_exitCode = exitCode;
// Reset skyuxconfig.json
resetConfig();
return server.start('unused-root', tmp)
.then(port => browser.get(`https://localhost:${port}/dist/`));
}
writeConfig(config);
return new Promise((resolve, reject) => {
rimrafPromise(path.join(tmp, 'dist'))
.then(() => exec(`node`, [cliPath, `build`, `--logFormat`, `none`], cwdOpts))
.then(serve)
.then(resolve)
.catch(err => reject(err));
});
} | javascript | function prepareBuild(config) {
function serve(exitCode) {
// Save our exitCode for testing
_exitCode = exitCode;
// Reset skyuxconfig.json
resetConfig();
return server.start('unused-root', tmp)
.then(port => browser.get(`https://localhost:${port}/dist/`));
}
writeConfig(config);
return new Promise((resolve, reject) => {
rimrafPromise(path.join(tmp, 'dist'))
.then(() => exec(`node`, [cliPath, `build`, `--logFormat`, `none`], cwdOpts))
.then(serve)
.then(resolve)
.catch(err => reject(err));
});
} | [
"function",
"prepareBuild",
"(",
"config",
")",
"{",
"function",
"serve",
"(",
"exitCode",
")",
"{",
"// Save our exitCode for testing",
"_exitCode",
"=",
"exitCode",
";",
"// Reset skyuxconfig.json",
"resetConfig",
"(",
")",
";",
"return",
"server",
".",
"start",
"(",
"'unused-root'",
",",
"tmp",
")",
".",
"then",
"(",
"port",
"=>",
"browser",
".",
"get",
"(",
"`",
"${",
"port",
"}",
"`",
")",
")",
";",
"}",
"writeConfig",
"(",
"config",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"rimrafPromise",
"(",
"path",
".",
"join",
"(",
"tmp",
",",
"'dist'",
")",
")",
".",
"then",
"(",
"(",
")",
"=>",
"exec",
"(",
"`",
"`",
",",
"[",
"cliPath",
",",
"`",
"`",
",",
"`",
"`",
",",
"`",
"`",
"]",
",",
"cwdOpts",
")",
")",
".",
"then",
"(",
"serve",
")",
".",
"then",
"(",
"resolve",
")",
".",
"catch",
"(",
"err",
"=>",
"reject",
"(",
"err",
")",
")",
";",
"}",
")",
";",
"}"
] | Run build given the following skyuxconfig object.
Starts server and resolves when ready. | [
"Run",
"build",
"given",
"the",
"following",
"skyuxconfig",
"object",
".",
"Starts",
"server",
"and",
"resolves",
"when",
"ready",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/e2e/shared/common.js#L111-L134 |
20,592 | blackbaud/skyux-builder | e2e/shared/common.js | prepareServe | function prepareServe() {
if (webpackServer) {
return bindServe();
} else {
return new Promise((resolve, reject) => {
portfinder.getPortPromise()
.then(writeConfigServe)
.then(bindServe)
.then(resolve)
.catch(err => reject(err));
});
}
} | javascript | function prepareServe() {
if (webpackServer) {
return bindServe();
} else {
return new Promise((resolve, reject) => {
portfinder.getPortPromise()
.then(writeConfigServe)
.then(bindServe)
.then(resolve)
.catch(err => reject(err));
});
}
} | [
"function",
"prepareServe",
"(",
")",
"{",
"if",
"(",
"webpackServer",
")",
"{",
"return",
"bindServe",
"(",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"portfinder",
".",
"getPortPromise",
"(",
")",
".",
"then",
"(",
"writeConfigServe",
")",
".",
"then",
"(",
"bindServe",
")",
".",
"then",
"(",
"resolve",
")",
".",
"catch",
"(",
"err",
"=>",
"reject",
"(",
"err",
")",
")",
";",
"}",
")",
";",
"}",
"}"
] | Spawns `skyux serve` and resolves once webpack is ready. | [
"Spawns",
"skyux",
"serve",
"and",
"resolves",
"once",
"webpack",
"is",
"ready",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/e2e/shared/common.js#L139-L152 |
20,593 | blackbaud/skyux-builder | e2e/shared/common.js | rimrafPromise | function rimrafPromise(dir) {
return new Promise((resolve, reject) => {
rimraf(dir, err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
} | javascript | function rimrafPromise(dir) {
return new Promise((resolve, reject) => {
rimraf(dir, err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
} | [
"function",
"rimrafPromise",
"(",
"dir",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"rimraf",
"(",
"dir",
",",
"err",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"reject",
"(",
"err",
")",
";",
"}",
"else",
"{",
"resolve",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Wraps the rimraf command in a promise. | [
"Wraps",
"the",
"rimraf",
"command",
"in",
"a",
"promise",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/e2e/shared/common.js#L164-L174 |
20,594 | blackbaud/skyux-builder | e2e/shared/common.js | writeConfig | function writeConfig(json) {
if (!skyuxConfigOriginal) {
skyuxConfigOriginal = JSON.parse(fs.readFileSync(skyuxConfigPath));
}
fs.writeFileSync(skyuxConfigPath, JSON.stringify(json), 'utf8');
} | javascript | function writeConfig(json) {
if (!skyuxConfigOriginal) {
skyuxConfigOriginal = JSON.parse(fs.readFileSync(skyuxConfigPath));
}
fs.writeFileSync(skyuxConfigPath, JSON.stringify(json), 'utf8');
} | [
"function",
"writeConfig",
"(",
"json",
")",
"{",
"if",
"(",
"!",
"skyuxConfigOriginal",
")",
"{",
"skyuxConfigOriginal",
"=",
"JSON",
".",
"parse",
"(",
"fs",
".",
"readFileSync",
"(",
"skyuxConfigPath",
")",
")",
";",
"}",
"fs",
".",
"writeFileSync",
"(",
"skyuxConfigPath",
",",
"JSON",
".",
"stringify",
"(",
"json",
")",
",",
"'utf8'",
")",
";",
"}"
] | Writes the specified json to the skyuxconfig.json file | [
"Writes",
"the",
"specified",
"json",
"to",
"the",
"skyuxconfig",
".",
"json",
"file"
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/e2e/shared/common.js#L179-L185 |
20,595 | blackbaud/skyux-builder | e2e/shared/common.js | writeConfigServe | function writeConfigServe(port) {
return new Promise(resolve => {
_port = port;
const skyuxConfigWithPort = merge(true, skyuxConfigOriginal, {
app: {
port: port
}
});
writeConfig(skyuxConfigWithPort);
const args = [cliPath, `serve`, `-l`, `none`, `--logFormat`, `none`];
webpackServer = childProcessSpawn(`node`, args, cwdOpts);
resetConfig();
resolve();
});
} | javascript | function writeConfigServe(port) {
return new Promise(resolve => {
_port = port;
const skyuxConfigWithPort = merge(true, skyuxConfigOriginal, {
app: {
port: port
}
});
writeConfig(skyuxConfigWithPort);
const args = [cliPath, `serve`, `-l`, `none`, `--logFormat`, `none`];
webpackServer = childProcessSpawn(`node`, args, cwdOpts);
resetConfig();
resolve();
});
} | [
"function",
"writeConfigServe",
"(",
"port",
")",
"{",
"return",
"new",
"Promise",
"(",
"resolve",
"=>",
"{",
"_port",
"=",
"port",
";",
"const",
"skyuxConfigWithPort",
"=",
"merge",
"(",
"true",
",",
"skyuxConfigOriginal",
",",
"{",
"app",
":",
"{",
"port",
":",
"port",
"}",
"}",
")",
";",
"writeConfig",
"(",
"skyuxConfigWithPort",
")",
";",
"const",
"args",
"=",
"[",
"cliPath",
",",
"`",
"`",
",",
"`",
"`",
",",
"`",
"`",
",",
"`",
"`",
",",
"`",
"`",
"]",
";",
"webpackServer",
"=",
"childProcessSpawn",
"(",
"`",
"`",
",",
"args",
",",
"cwdOpts",
")",
";",
"resetConfig",
"(",
")",
";",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}"
] | Write the config needed for serve | [
"Write",
"the",
"config",
"needed",
"for",
"serve"
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/e2e/shared/common.js#L190-L205 |
20,596 | blackbaud/skyux-builder | cli/utils/server.js | start | function start(root, distPath) {
return new Promise((resolve, reject) => {
const dist = path.resolve(process.cwd(), distPath || 'dist');
logger.info('Creating web server');
app.use(cors());
logger.info(`Exposing static directory: ${dist}`);
app.use(express.static(dist));
if (root) {
logger.info(`Mapping server requests from ${root} to ${dist}`);
app.use(root, express.static(dist));
}
const options = {
cert: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.crt')),
key: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.key'))
};
server = https.createServer(options, app);
server.on('error', reject);
logger.info('Requesting open port...');
portfinder
.getPortPromise()
.then(port => {
logger.info(`Open port found: ${port}`);
logger.info('Starting web server...');
server.listen(port, 'localhost', () => {
logger.info('Web server running.');
resolve(port);
});
})
.catch(reject);
});
} | javascript | function start(root, distPath) {
return new Promise((resolve, reject) => {
const dist = path.resolve(process.cwd(), distPath || 'dist');
logger.info('Creating web server');
app.use(cors());
logger.info(`Exposing static directory: ${dist}`);
app.use(express.static(dist));
if (root) {
logger.info(`Mapping server requests from ${root} to ${dist}`);
app.use(root, express.static(dist));
}
const options = {
cert: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.crt')),
key: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.key'))
};
server = https.createServer(options, app);
server.on('error', reject);
logger.info('Requesting open port...');
portfinder
.getPortPromise()
.then(port => {
logger.info(`Open port found: ${port}`);
logger.info('Starting web server...');
server.listen(port, 'localhost', () => {
logger.info('Web server running.');
resolve(port);
});
})
.catch(reject);
});
} | [
"function",
"start",
"(",
"root",
",",
"distPath",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"dist",
"=",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"distPath",
"||",
"'dist'",
")",
";",
"logger",
".",
"info",
"(",
"'Creating web server'",
")",
";",
"app",
".",
"use",
"(",
"cors",
"(",
")",
")",
";",
"logger",
".",
"info",
"(",
"`",
"${",
"dist",
"}",
"`",
")",
";",
"app",
".",
"use",
"(",
"express",
".",
"static",
"(",
"dist",
")",
")",
";",
"if",
"(",
"root",
")",
"{",
"logger",
".",
"info",
"(",
"`",
"${",
"root",
"}",
"${",
"dist",
"}",
"`",
")",
";",
"app",
".",
"use",
"(",
"root",
",",
"express",
".",
"static",
"(",
"dist",
")",
")",
";",
"}",
"const",
"options",
"=",
"{",
"cert",
":",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"'../../ssl/server.crt'",
")",
")",
",",
"key",
":",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"'../../ssl/server.key'",
")",
")",
"}",
";",
"server",
"=",
"https",
".",
"createServer",
"(",
"options",
",",
"app",
")",
";",
"server",
".",
"on",
"(",
"'error'",
",",
"reject",
")",
";",
"logger",
".",
"info",
"(",
"'Requesting open port...'",
")",
";",
"portfinder",
".",
"getPortPromise",
"(",
")",
".",
"then",
"(",
"port",
"=>",
"{",
"logger",
".",
"info",
"(",
"`",
"${",
"port",
"}",
"`",
")",
";",
"logger",
".",
"info",
"(",
"'Starting web server...'",
")",
";",
"server",
".",
"listen",
"(",
"port",
",",
"'localhost'",
",",
"(",
")",
"=>",
"{",
"logger",
".",
"info",
"(",
"'Web server running.'",
")",
";",
"resolve",
"(",
"port",
")",
";",
"}",
")",
";",
"}",
")",
".",
"catch",
"(",
"reject",
")",
";",
"}",
")",
";",
"}"
] | Starts the httpServer
@name start | [
"Starts",
"the",
"httpServer"
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/cli/utils/server.js#L20-L56 |
20,597 | blackbaud/skyux-builder | config/webpack/common.webpack.config.js | getWebpackConfig | function getWebpackConfig(skyPagesConfig, argv = {}) {
const resolves = [
process.cwd(),
spaPath('node_modules'),
outPath('node_modules')
];
let alias = aliasBuilder.buildAliasList(skyPagesConfig);
const outConfigMode = skyPagesConfig && skyPagesConfig.skyux && skyPagesConfig.skyux.mode;
const logFormat = getLogFormat(skyPagesConfig, argv);
let appPath;
switch (outConfigMode) {
case 'advanced':
appPath = spaPath('src', 'main.ts');
break;
default:
appPath = outPath('src', 'main-internal.ts');
break;
}
let plugins = [
// Some properties are required on the root object passed to HtmlWebpackPlugin
new HtmlWebpackPlugin({
template: skyPagesConfig.runtime.app.template,
inject: skyPagesConfig.runtime.app.inject,
runtime: skyPagesConfig.runtime,
skyux: skyPagesConfig.skyux
}),
new CommonsChunkPlugin({
name: ['skyux', 'vendor', 'polyfills']
}),
new webpack.DefinePlugin({
'skyPagesConfig': JSON.stringify(skyPagesConfig)
}),
new LoaderOptionsPlugin({
options: {
context: __dirname,
skyPagesConfig: skyPagesConfig
}
}),
new ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)@angular/,
spaPath('src'),
{}
),
new OutputKeepAlivePlugin({
enabled: argv['output-keep-alive']
})
];
// Supporting a custom logging type of none
if (logFormat !== 'none') {
plugins.push(new SimpleProgressWebpackPlugin({
format: logFormat,
color: logger.logColor
}));
}
return {
entry: {
polyfills: [outPath('src', 'polyfills.ts')],
vendor: [outPath('src', 'vendor.ts')],
skyux: [outPath('src', 'skyux.ts')],
app: [appPath]
},
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: spaPath('dist'),
},
resolveLoader: {
modules: resolves
},
resolve: {
alias: alias,
modules: resolves,
extensions: [
'.js',
'.ts'
]
},
module: {
rules: [
{
enforce: 'pre',
test: /config\.ts$/,
loader: outPath('loader', 'sky-app-config'),
include: outPath('runtime')
},
{
enforce: 'pre',
test: [
/\.(html|s?css)$/,
/sky-pages\.module\.ts/
],
loader: outPath('loader', 'sky-assets')
},
{
enforce: 'pre',
test: /sky-pages\.module\.ts$/,
loader: outPath('loader', 'sky-pages-module')
},
{
enforce: 'pre',
loader: outPath('loader', 'sky-processor', 'preload'),
include: spaPath('src'),
exclude: /node_modules/
},
{
test: /\.s?css$/,
use: [
'raw-loader',
'sass-loader'
]
},
{
test: /\.html$/,
loader: 'raw-loader'
},
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
plugins
};
} | javascript | function getWebpackConfig(skyPagesConfig, argv = {}) {
const resolves = [
process.cwd(),
spaPath('node_modules'),
outPath('node_modules')
];
let alias = aliasBuilder.buildAliasList(skyPagesConfig);
const outConfigMode = skyPagesConfig && skyPagesConfig.skyux && skyPagesConfig.skyux.mode;
const logFormat = getLogFormat(skyPagesConfig, argv);
let appPath;
switch (outConfigMode) {
case 'advanced':
appPath = spaPath('src', 'main.ts');
break;
default:
appPath = outPath('src', 'main-internal.ts');
break;
}
let plugins = [
// Some properties are required on the root object passed to HtmlWebpackPlugin
new HtmlWebpackPlugin({
template: skyPagesConfig.runtime.app.template,
inject: skyPagesConfig.runtime.app.inject,
runtime: skyPagesConfig.runtime,
skyux: skyPagesConfig.skyux
}),
new CommonsChunkPlugin({
name: ['skyux', 'vendor', 'polyfills']
}),
new webpack.DefinePlugin({
'skyPagesConfig': JSON.stringify(skyPagesConfig)
}),
new LoaderOptionsPlugin({
options: {
context: __dirname,
skyPagesConfig: skyPagesConfig
}
}),
new ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)@angular/,
spaPath('src'),
{}
),
new OutputKeepAlivePlugin({
enabled: argv['output-keep-alive']
})
];
// Supporting a custom logging type of none
if (logFormat !== 'none') {
plugins.push(new SimpleProgressWebpackPlugin({
format: logFormat,
color: logger.logColor
}));
}
return {
entry: {
polyfills: [outPath('src', 'polyfills.ts')],
vendor: [outPath('src', 'vendor.ts')],
skyux: [outPath('src', 'skyux.ts')],
app: [appPath]
},
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: spaPath('dist'),
},
resolveLoader: {
modules: resolves
},
resolve: {
alias: alias,
modules: resolves,
extensions: [
'.js',
'.ts'
]
},
module: {
rules: [
{
enforce: 'pre',
test: /config\.ts$/,
loader: outPath('loader', 'sky-app-config'),
include: outPath('runtime')
},
{
enforce: 'pre',
test: [
/\.(html|s?css)$/,
/sky-pages\.module\.ts/
],
loader: outPath('loader', 'sky-assets')
},
{
enforce: 'pre',
test: /sky-pages\.module\.ts$/,
loader: outPath('loader', 'sky-pages-module')
},
{
enforce: 'pre',
loader: outPath('loader', 'sky-processor', 'preload'),
include: spaPath('src'),
exclude: /node_modules/
},
{
test: /\.s?css$/,
use: [
'raw-loader',
'sass-loader'
]
},
{
test: /\.html$/,
loader: 'raw-loader'
},
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
plugins
};
} | [
"function",
"getWebpackConfig",
"(",
"skyPagesConfig",
",",
"argv",
"=",
"{",
"}",
")",
"{",
"const",
"resolves",
"=",
"[",
"process",
".",
"cwd",
"(",
")",
",",
"spaPath",
"(",
"'node_modules'",
")",
",",
"outPath",
"(",
"'node_modules'",
")",
"]",
";",
"let",
"alias",
"=",
"aliasBuilder",
".",
"buildAliasList",
"(",
"skyPagesConfig",
")",
";",
"const",
"outConfigMode",
"=",
"skyPagesConfig",
"&&",
"skyPagesConfig",
".",
"skyux",
"&&",
"skyPagesConfig",
".",
"skyux",
".",
"mode",
";",
"const",
"logFormat",
"=",
"getLogFormat",
"(",
"skyPagesConfig",
",",
"argv",
")",
";",
"let",
"appPath",
";",
"switch",
"(",
"outConfigMode",
")",
"{",
"case",
"'advanced'",
":",
"appPath",
"=",
"spaPath",
"(",
"'src'",
",",
"'main.ts'",
")",
";",
"break",
";",
"default",
":",
"appPath",
"=",
"outPath",
"(",
"'src'",
",",
"'main-internal.ts'",
")",
";",
"break",
";",
"}",
"let",
"plugins",
"=",
"[",
"// Some properties are required on the root object passed to HtmlWebpackPlugin",
"new",
"HtmlWebpackPlugin",
"(",
"{",
"template",
":",
"skyPagesConfig",
".",
"runtime",
".",
"app",
".",
"template",
",",
"inject",
":",
"skyPagesConfig",
".",
"runtime",
".",
"app",
".",
"inject",
",",
"runtime",
":",
"skyPagesConfig",
".",
"runtime",
",",
"skyux",
":",
"skyPagesConfig",
".",
"skyux",
"}",
")",
",",
"new",
"CommonsChunkPlugin",
"(",
"{",
"name",
":",
"[",
"'skyux'",
",",
"'vendor'",
",",
"'polyfills'",
"]",
"}",
")",
",",
"new",
"webpack",
".",
"DefinePlugin",
"(",
"{",
"'skyPagesConfig'",
":",
"JSON",
".",
"stringify",
"(",
"skyPagesConfig",
")",
"}",
")",
",",
"new",
"LoaderOptionsPlugin",
"(",
"{",
"options",
":",
"{",
"context",
":",
"__dirname",
",",
"skyPagesConfig",
":",
"skyPagesConfig",
"}",
"}",
")",
",",
"new",
"ContextReplacementPlugin",
"(",
"// The (\\\\|\\/) piece accounts for path separators in *nix and Windows",
"/",
"angular(\\\\|\\/)core(\\\\|\\/)@angular",
"/",
",",
"spaPath",
"(",
"'src'",
")",
",",
"{",
"}",
")",
",",
"new",
"OutputKeepAlivePlugin",
"(",
"{",
"enabled",
":",
"argv",
"[",
"'output-keep-alive'",
"]",
"}",
")",
"]",
";",
"// Supporting a custom logging type of none",
"if",
"(",
"logFormat",
"!==",
"'none'",
")",
"{",
"plugins",
".",
"push",
"(",
"new",
"SimpleProgressWebpackPlugin",
"(",
"{",
"format",
":",
"logFormat",
",",
"color",
":",
"logger",
".",
"logColor",
"}",
")",
")",
";",
"}",
"return",
"{",
"entry",
":",
"{",
"polyfills",
":",
"[",
"outPath",
"(",
"'src'",
",",
"'polyfills.ts'",
")",
"]",
",",
"vendor",
":",
"[",
"outPath",
"(",
"'src'",
",",
"'vendor.ts'",
")",
"]",
",",
"skyux",
":",
"[",
"outPath",
"(",
"'src'",
",",
"'skyux.ts'",
")",
"]",
",",
"app",
":",
"[",
"appPath",
"]",
"}",
",",
"output",
":",
"{",
"filename",
":",
"'[name].js'",
",",
"chunkFilename",
":",
"'[id].chunk.js'",
",",
"path",
":",
"spaPath",
"(",
"'dist'",
")",
",",
"}",
",",
"resolveLoader",
":",
"{",
"modules",
":",
"resolves",
"}",
",",
"resolve",
":",
"{",
"alias",
":",
"alias",
",",
"modules",
":",
"resolves",
",",
"extensions",
":",
"[",
"'.js'",
",",
"'.ts'",
"]",
"}",
",",
"module",
":",
"{",
"rules",
":",
"[",
"{",
"enforce",
":",
"'pre'",
",",
"test",
":",
"/",
"config\\.ts$",
"/",
",",
"loader",
":",
"outPath",
"(",
"'loader'",
",",
"'sky-app-config'",
")",
",",
"include",
":",
"outPath",
"(",
"'runtime'",
")",
"}",
",",
"{",
"enforce",
":",
"'pre'",
",",
"test",
":",
"[",
"/",
"\\.(html|s?css)$",
"/",
",",
"/",
"sky-pages\\.module\\.ts",
"/",
"]",
",",
"loader",
":",
"outPath",
"(",
"'loader'",
",",
"'sky-assets'",
")",
"}",
",",
"{",
"enforce",
":",
"'pre'",
",",
"test",
":",
"/",
"sky-pages\\.module\\.ts$",
"/",
",",
"loader",
":",
"outPath",
"(",
"'loader'",
",",
"'sky-pages-module'",
")",
"}",
",",
"{",
"enforce",
":",
"'pre'",
",",
"loader",
":",
"outPath",
"(",
"'loader'",
",",
"'sky-processor'",
",",
"'preload'",
")",
",",
"include",
":",
"spaPath",
"(",
"'src'",
")",
",",
"exclude",
":",
"/",
"node_modules",
"/",
"}",
",",
"{",
"test",
":",
"/",
"\\.s?css$",
"/",
",",
"use",
":",
"[",
"'raw-loader'",
",",
"'sass-loader'",
"]",
"}",
",",
"{",
"test",
":",
"/",
"\\.html$",
"/",
",",
"loader",
":",
"'raw-loader'",
"}",
",",
"{",
"test",
":",
"/",
"\\.json$",
"/",
",",
"loader",
":",
"'json-loader'",
"}",
"]",
"}",
",",
"plugins",
"}",
";",
"}"
] | Called when loaded via require.
@name getWebpackConfig
@param {SkyPagesConfig} skyPagesConfig
@returns {WebpackConfig} webpackConfig | [
"Called",
"when",
"loaded",
"via",
"require",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/config/webpack/common.webpack.config.js#L41-L178 |
20,598 | blackbaud/skyux-builder | cli/version.js | version | function version() {
const packageJson = require(path.resolve(__dirname, '..', 'package.json'));
logger.info('@blackbaud/skyux-builder: %s', packageJson.version);
} | javascript | function version() {
const packageJson = require(path.resolve(__dirname, '..', 'package.json'));
logger.info('@blackbaud/skyux-builder: %s', packageJson.version);
} | [
"function",
"version",
"(",
")",
"{",
"const",
"packageJson",
"=",
"require",
"(",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"'..'",
",",
"'package.json'",
")",
")",
";",
"logger",
".",
"info",
"(",
"'@blackbaud/skyux-builder: %s'",
",",
"packageJson",
".",
"version",
")",
";",
"}"
] | Returns the version from package.json.
@name version | [
"Returns",
"the",
"version",
"from",
"package",
".",
"json",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/cli/version.js#L11-L14 |
20,599 | blackbaud/skyux-builder | cli/build-public-library.js | createBundle | function createBundle(skyPagesConfig, webpack) {
const webpackConfig = require('../config/webpack/build-public-library.webpack.config');
const config = webpackConfig.getWebpackConfig(skyPagesConfig);
return runCompiler(webpack, config);
} | javascript | function createBundle(skyPagesConfig, webpack) {
const webpackConfig = require('../config/webpack/build-public-library.webpack.config');
const config = webpackConfig.getWebpackConfig(skyPagesConfig);
return runCompiler(webpack, config);
} | [
"function",
"createBundle",
"(",
"skyPagesConfig",
",",
"webpack",
")",
"{",
"const",
"webpackConfig",
"=",
"require",
"(",
"'../config/webpack/build-public-library.webpack.config'",
")",
";",
"const",
"config",
"=",
"webpackConfig",
".",
"getWebpackConfig",
"(",
"skyPagesConfig",
")",
";",
"return",
"runCompiler",
"(",
"webpack",
",",
"config",
")",
";",
"}"
] | Creates a UMD JavaScript bundle.
@param {*} skyPagesConfig
@param {*} webpack | [
"Creates",
"a",
"UMD",
"JavaScript",
"bundle",
"."
] | fe8c622f12817552f85940abe194ddcb262e7b44 | https://github.com/blackbaud/skyux-builder/blob/fe8c622f12817552f85940abe194ddcb262e7b44/cli/build-public-library.js#L128-L132 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.