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
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
53,300 | copress/copress-component-oauth2 | lib/unorderedlist.js | UnorderedList | function UnorderedList(items) {
if (typeof items == 'string') {
items = items.split(' ');
}
this._items = items || [];
this.__defineGetter__('length', this._length);
} | javascript | function UnorderedList(items) {
if (typeof items == 'string') {
items = items.split(' ');
}
this._items = items || [];
this.__defineGetter__('length', this._length);
} | [
"function",
"UnorderedList",
"(",
"items",
")",
"{",
"if",
"(",
"typeof",
"items",
"==",
"'string'",
")",
"{",
"items",
"=",
"items",
".",
"split",
"(",
"' '",
")",
";",
"}",
"this",
".",
"_items",
"=",
"items",
"||",
"[",
"]",
";",
"this",
".",
"__defineGetter__",
"(",
"'length'",
",",
"this",
".",
"_length",
")",
";",
"}"
] | `UnorderedList` constructor.
@api public | [
"UnorderedList",
"constructor",
"."
] | 4819f379a0d42753bfd51e237c5c3aaddee37544 | https://github.com/copress/copress-component-oauth2/blob/4819f379a0d42753bfd51e237c5c3aaddee37544/lib/unorderedlist.js#L6-L12 |
53,301 | quartzjer/e3x-cs1a | cs1a.js | fold | function fold(count, buf)
{
if(!count || buf.length % 2) return buf;
var ret = buf.slice(0,buf.length/2);
for(i = 0; i < ret.length; i++) ret[i] = ret[i] ^ buf[i+ret.length];
return fold(count-1,ret);
} | javascript | function fold(count, buf)
{
if(!count || buf.length % 2) return buf;
var ret = buf.slice(0,buf.length/2);
for(i = 0; i < ret.length; i++) ret[i] = ret[i] ^ buf[i+ret.length];
return fold(count-1,ret);
} | [
"function",
"fold",
"(",
"count",
",",
"buf",
")",
"{",
"if",
"(",
"!",
"count",
"||",
"buf",
".",
"length",
"%",
"2",
")",
"return",
"buf",
";",
"var",
"ret",
"=",
"buf",
".",
"slice",
"(",
"0",
",",
"buf",
".",
"length",
"/",
"2",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"ret",
".",
"length",
";",
"i",
"++",
")",
"ret",
"[",
"i",
"]",
"=",
"ret",
"[",
"i",
"]",
"^",
"buf",
"[",
"i",
"+",
"ret",
".",
"length",
"]",
";",
"return",
"fold",
"(",
"count",
"-",
"1",
",",
"ret",
")",
";",
"}"
] | simple xor buffer folder | [
"simple",
"xor",
"buffer",
"folder"
] | 267bb9f6e2bf54cc379df090071c6c15b4718fea | https://github.com/quartzjer/e3x-cs1a/blob/267bb9f6e2bf54cc379df090071c6c15b4718fea/cs1a.js#L197-L203 |
53,302 | OpenCrisp/Crisp.PathJS | dist/crisp-path.js | pickReverseEach | function pickReverseEach( reverse, node, callback ) {
var test = type.call( node, 'Undefined' ) ||
node==='false' ||
node===false ||
(
type.call( node, 'Boolean' ) &&
!node.valueOf()
);
if ( test ) {
pickReverse.call( this, reverse, true, callback );
}
else if ( type.call( node.isBoolean, 'Function' ) ) {
if ( node.isBoolean.tick ) {
}
else {
pickReverse.call( this, reverse, ( ( node.isBoolean() && !node.valueOf() ) || !node ), callback );
}
}
else {
pickReverse.call( this, reverse, !node, callback );
}
} | javascript | function pickReverseEach( reverse, node, callback ) {
var test = type.call( node, 'Undefined' ) ||
node==='false' ||
node===false ||
(
type.call( node, 'Boolean' ) &&
!node.valueOf()
);
if ( test ) {
pickReverse.call( this, reverse, true, callback );
}
else if ( type.call( node.isBoolean, 'Function' ) ) {
if ( node.isBoolean.tick ) {
}
else {
pickReverse.call( this, reverse, ( ( node.isBoolean() && !node.valueOf() ) || !node ), callback );
}
}
else {
pickReverse.call( this, reverse, !node, callback );
}
} | [
"function",
"pickReverseEach",
"(",
"reverse",
",",
"node",
",",
"callback",
")",
"{",
"var",
"test",
"=",
"type",
".",
"call",
"(",
"node",
",",
"'Undefined'",
")",
"||",
"node",
"===",
"'false'",
"||",
"node",
"===",
"false",
"||",
"(",
"type",
".",
"call",
"(",
"node",
",",
"'Boolean'",
")",
"&&",
"!",
"node",
".",
"valueOf",
"(",
")",
")",
";",
"if",
"(",
"test",
")",
"{",
"pickReverse",
".",
"call",
"(",
"this",
",",
"reverse",
",",
"true",
",",
"callback",
")",
";",
"}",
"else",
"if",
"(",
"type",
".",
"call",
"(",
"node",
".",
"isBoolean",
",",
"'Function'",
")",
")",
"{",
"if",
"(",
"node",
".",
"isBoolean",
".",
"tick",
")",
"{",
"}",
"else",
"{",
"pickReverse",
".",
"call",
"(",
"this",
",",
"reverse",
",",
"(",
"(",
"node",
".",
"isBoolean",
"(",
")",
"&&",
"!",
"node",
".",
"valueOf",
"(",
")",
")",
"||",
"!",
"node",
")",
",",
"callback",
")",
";",
"}",
"}",
"else",
"{",
"pickReverse",
".",
"call",
"(",
"this",
",",
"reverse",
",",
"!",
"node",
",",
"callback",
")",
";",
"}",
"}"
] | reverse given node
@private
@param {external:Number} reverse
@param {*} node
@return {external:Boolean}
@memberOf util.path | [
"reverse",
"given",
"node"
] | e5ed81b22cdff4d8b6c157e62b8a0d3304f8a90a | https://github.com/OpenCrisp/Crisp.PathJS/blob/e5ed81b22cdff4d8b6c157e62b8a0d3304f8a90a/dist/crisp-path.js#L669-L692 |
53,303 | thomasfr/Timeliner.Core | lib/processTokens.js | processTokens | function processTokens(tokens, callback) {
"use strict";
var processFunctions = underscore.map(tokens, function (word) {
return function (cb) {
tokenizeWord(word, cb);
};
});
async.parallel(
processFunctions,
function (error, results) {
if (error) {
callback(error, null);
} else {
var normalizedTokens = [];
results.forEach(function (tokens) {
normalizedTokens = normalizedTokens.concat(tokens);
});
normalizedTokens.sort();
normalizedTokens = underscore.uniq(normalizedTokens, true);
callback(null, normalizedTokens);
}
}
);
} | javascript | function processTokens(tokens, callback) {
"use strict";
var processFunctions = underscore.map(tokens, function (word) {
return function (cb) {
tokenizeWord(word, cb);
};
});
async.parallel(
processFunctions,
function (error, results) {
if (error) {
callback(error, null);
} else {
var normalizedTokens = [];
results.forEach(function (tokens) {
normalizedTokens = normalizedTokens.concat(tokens);
});
normalizedTokens.sort();
normalizedTokens = underscore.uniq(normalizedTokens, true);
callback(null, normalizedTokens);
}
}
);
} | [
"function",
"processTokens",
"(",
"tokens",
",",
"callback",
")",
"{",
"\"use strict\"",
";",
"var",
"processFunctions",
"=",
"underscore",
".",
"map",
"(",
"tokens",
",",
"function",
"(",
"word",
")",
"{",
"return",
"function",
"(",
"cb",
")",
"{",
"tokenizeWord",
"(",
"word",
",",
"cb",
")",
";",
"}",
";",
"}",
")",
";",
"async",
".",
"parallel",
"(",
"processFunctions",
",",
"function",
"(",
"error",
",",
"results",
")",
"{",
"if",
"(",
"error",
")",
"{",
"callback",
"(",
"error",
",",
"null",
")",
";",
"}",
"else",
"{",
"var",
"normalizedTokens",
"=",
"[",
"]",
";",
"results",
".",
"forEach",
"(",
"function",
"(",
"tokens",
")",
"{",
"normalizedTokens",
"=",
"normalizedTokens",
".",
"concat",
"(",
"tokens",
")",
";",
"}",
")",
";",
"normalizedTokens",
".",
"sort",
"(",
")",
";",
"normalizedTokens",
"=",
"underscore",
".",
"uniq",
"(",
"normalizedTokens",
",",
"true",
")",
";",
"callback",
"(",
"null",
",",
"normalizedTokens",
")",
";",
"}",
"}",
")",
";",
"}"
] | Processes each word of the given tokens
@param String[] tokens Array of Strings
@param Function callback Callback function with this signature: function(error, String[])
@private | [
"Processes",
"each",
"word",
"of",
"the",
"given",
"tokens"
] | f776202c22c7ca2ee50deb1bae6130fd3dcfe7fc | https://github.com/thomasfr/Timeliner.Core/blob/f776202c22c7ca2ee50deb1bae6130fd3dcfe7fc/lib/processTokens.js#L12-L35 |
53,304 | sumanjs/karma-suman | src/adapter.js | getRelevantStackFrom | function getRelevantStackFrom (stack) {
var filteredStack = [];
var relevantStack = [];
stack = stack.split('\n');
for (var i = 0; i < stack.length; i += 1) {
if (isExternalStackEntry(stack[i])) {
filteredStack.push(stack[i])
}
}
// If the filtered stack is empty, i.e. the error originated entirely from within jasmine or karma, then the whole stack
// should be relevant.
if (filteredStack.length === 0) {
filteredStack = stack
}
for (i = 0; i < filteredStack.length; i += 1) {
if (filteredStack[i]) {
relevantStack.push(filteredStack[i])
}
}
return relevantStack
} | javascript | function getRelevantStackFrom (stack) {
var filteredStack = [];
var relevantStack = [];
stack = stack.split('\n');
for (var i = 0; i < stack.length; i += 1) {
if (isExternalStackEntry(stack[i])) {
filteredStack.push(stack[i])
}
}
// If the filtered stack is empty, i.e. the error originated entirely from within jasmine or karma, then the whole stack
// should be relevant.
if (filteredStack.length === 0) {
filteredStack = stack
}
for (i = 0; i < filteredStack.length; i += 1) {
if (filteredStack[i]) {
relevantStack.push(filteredStack[i])
}
}
return relevantStack
} | [
"function",
"getRelevantStackFrom",
"(",
"stack",
")",
"{",
"var",
"filteredStack",
"=",
"[",
"]",
";",
"var",
"relevantStack",
"=",
"[",
"]",
";",
"stack",
"=",
"stack",
".",
"split",
"(",
"'\\n'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"stack",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"isExternalStackEntry",
"(",
"stack",
"[",
"i",
"]",
")",
")",
"{",
"filteredStack",
".",
"push",
"(",
"stack",
"[",
"i",
"]",
")",
"}",
"}",
"// If the filtered stack is empty, i.e. the error originated entirely from within jasmine or karma, then the whole stack",
"// should be relevant.",
"if",
"(",
"filteredStack",
".",
"length",
"===",
"0",
")",
"{",
"filteredStack",
"=",
"stack",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"filteredStack",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"filteredStack",
"[",
"i",
"]",
")",
"{",
"relevantStack",
".",
"push",
"(",
"filteredStack",
"[",
"i",
"]",
")",
"}",
"}",
"return",
"relevantStack",
"}"
] | Returns relevant stack entries.
@param {String} stack Complete error stack trace.
@return {Array} A list of relevant stack entries. | [
"Returns",
"relevant",
"stack",
"entries",
"."
] | 7c5fa9044571c8e49f49c07abc5f493af3070dc4 | https://github.com/sumanjs/karma-suman/blob/7c5fa9044571c8e49f49c07abc5f493af3070dc4/src/adapter.js#L23-L48 |
53,305 | sumanjs/karma-suman | src/adapter.js | formatFailedStep | function formatFailedStep (step) {
// Safari seems to have no stack trace,
// so we just return the error message:
if (!step.stack) { return step.message }
var relevantMessage = [];
var relevantStack = [];
// Remove the message prior to processing the stack to prevent issues like
// https://github.com/karma-runner/karma-jasmine/issues/79
var stack = step.stack.replace('Error: ' + step.message, '');
var dirtyRelevantStack = getRelevantStackFrom(stack);
// PhantomJS returns multiline error message for errors coming from specs
// (for example when calling a non-existing function). This error is present
// in both `step.message` and `step.stack` at the same time, but stack seems
// preferable, so we iterate relevant stack, compare it to message:
for (var i = 0; i < dirtyRelevantStack.length; i += 1) {
if (typeof step.message === 'string' && step.message.indexOf(dirtyRelevantStack[i]) === -1) {
// Stack entry is not in the message,
// we consider it to be a relevant stack:
relevantStack.push(dirtyRelevantStack[i])
} else {
// Stack entry is already in the message,
// we consider it to be a suitable message alternative:
relevantMessage.push(dirtyRelevantStack[i])
}
}
// In most cases the above will leave us with an empty message...
if (relevantMessage.length === 0) {
// Let's reuse the original message:
relevantMessage.push(step.message);
// Now we probably have a repetition case where:
// relevantMessage: ["Expected true to be false."]
// relevantStack: ["Error: Expected true to be false.", ...]
if (relevantStack.length && relevantStack[0].indexOf(step.message) !== -1) {
// The message seems preferable, so we remove the first value from
// the stack to get rid of repetition :
relevantStack.shift()
}
}
// Example output:
// --------------------
// Chrome 40.0.2214 (Mac OS X 10.9.5) xxx should return false 1 FAILED
// Expected true to be false
// at /foo/bar/baz.spec.js:22:13
// at /foo/bar/baz.js:18:29
return relevantMessage.concat(relevantStack).join('\n')
} | javascript | function formatFailedStep (step) {
// Safari seems to have no stack trace,
// so we just return the error message:
if (!step.stack) { return step.message }
var relevantMessage = [];
var relevantStack = [];
// Remove the message prior to processing the stack to prevent issues like
// https://github.com/karma-runner/karma-jasmine/issues/79
var stack = step.stack.replace('Error: ' + step.message, '');
var dirtyRelevantStack = getRelevantStackFrom(stack);
// PhantomJS returns multiline error message for errors coming from specs
// (for example when calling a non-existing function). This error is present
// in both `step.message` and `step.stack` at the same time, but stack seems
// preferable, so we iterate relevant stack, compare it to message:
for (var i = 0; i < dirtyRelevantStack.length; i += 1) {
if (typeof step.message === 'string' && step.message.indexOf(dirtyRelevantStack[i]) === -1) {
// Stack entry is not in the message,
// we consider it to be a relevant stack:
relevantStack.push(dirtyRelevantStack[i])
} else {
// Stack entry is already in the message,
// we consider it to be a suitable message alternative:
relevantMessage.push(dirtyRelevantStack[i])
}
}
// In most cases the above will leave us with an empty message...
if (relevantMessage.length === 0) {
// Let's reuse the original message:
relevantMessage.push(step.message);
// Now we probably have a repetition case where:
// relevantMessage: ["Expected true to be false."]
// relevantStack: ["Error: Expected true to be false.", ...]
if (relevantStack.length && relevantStack[0].indexOf(step.message) !== -1) {
// The message seems preferable, so we remove the first value from
// the stack to get rid of repetition :
relevantStack.shift()
}
}
// Example output:
// --------------------
// Chrome 40.0.2214 (Mac OS X 10.9.5) xxx should return false 1 FAILED
// Expected true to be false
// at /foo/bar/baz.spec.js:22:13
// at /foo/bar/baz.js:18:29
return relevantMessage.concat(relevantStack).join('\n')
} | [
"function",
"formatFailedStep",
"(",
"step",
")",
"{",
"// Safari seems to have no stack trace,",
"// so we just return the error message:",
"if",
"(",
"!",
"step",
".",
"stack",
")",
"{",
"return",
"step",
".",
"message",
"}",
"var",
"relevantMessage",
"=",
"[",
"]",
";",
"var",
"relevantStack",
"=",
"[",
"]",
";",
"// Remove the message prior to processing the stack to prevent issues like",
"// https://github.com/karma-runner/karma-jasmine/issues/79",
"var",
"stack",
"=",
"step",
".",
"stack",
".",
"replace",
"(",
"'Error: '",
"+",
"step",
".",
"message",
",",
"''",
")",
";",
"var",
"dirtyRelevantStack",
"=",
"getRelevantStackFrom",
"(",
"stack",
")",
";",
"// PhantomJS returns multiline error message for errors coming from specs",
"// (for example when calling a non-existing function). This error is present",
"// in both `step.message` and `step.stack` at the same time, but stack seems",
"// preferable, so we iterate relevant stack, compare it to message:",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"dirtyRelevantStack",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"if",
"(",
"typeof",
"step",
".",
"message",
"===",
"'string'",
"&&",
"step",
".",
"message",
".",
"indexOf",
"(",
"dirtyRelevantStack",
"[",
"i",
"]",
")",
"===",
"-",
"1",
")",
"{",
"// Stack entry is not in the message,",
"// we consider it to be a relevant stack:",
"relevantStack",
".",
"push",
"(",
"dirtyRelevantStack",
"[",
"i",
"]",
")",
"}",
"else",
"{",
"// Stack entry is already in the message,",
"// we consider it to be a suitable message alternative:",
"relevantMessage",
".",
"push",
"(",
"dirtyRelevantStack",
"[",
"i",
"]",
")",
"}",
"}",
"// In most cases the above will leave us with an empty message...",
"if",
"(",
"relevantMessage",
".",
"length",
"===",
"0",
")",
"{",
"// Let's reuse the original message:",
"relevantMessage",
".",
"push",
"(",
"step",
".",
"message",
")",
";",
"// Now we probably have a repetition case where:",
"// relevantMessage: [\"Expected true to be false.\"]",
"// relevantStack: [\"Error: Expected true to be false.\", ...]",
"if",
"(",
"relevantStack",
".",
"length",
"&&",
"relevantStack",
"[",
"0",
"]",
".",
"indexOf",
"(",
"step",
".",
"message",
")",
"!==",
"-",
"1",
")",
"{",
"// The message seems preferable, so we remove the first value from",
"// the stack to get rid of repetition :",
"relevantStack",
".",
"shift",
"(",
")",
"}",
"}",
"// Example output:",
"// --------------------",
"// Chrome 40.0.2214 (Mac OS X 10.9.5) xxx should return false 1 FAILED",
"// Expected true to be false",
"// at /foo/bar/baz.spec.js:22:13",
"// at /foo/bar/baz.js:18:29",
"return",
"relevantMessage",
".",
"concat",
"(",
"relevantStack",
")",
".",
"join",
"(",
"'\\n'",
")",
"}"
] | Custom formatter for a failed step.
Different browsers report stack trace in different ways. This function
attempts to provide a concise, relevant error message by removing the
unnecessary stack traces coming from the testing framework itself as well
as possible repetition.
@see https://github.com/karma-runner/karma-jasmine/issues/60
@param {Object} step Step object with stack and message properties.
@return {String} Formatted step. | [
"Custom",
"formatter",
"for",
"a",
"failed",
"step",
"."
] | 7c5fa9044571c8e49f49c07abc5f493af3070dc4 | https://github.com/sumanjs/karma-suman/blob/7c5fa9044571c8e49f49c07abc5f493af3070dc4/src/adapter.js#L62-L114 |
53,306 | sumanjs/karma-suman | src/adapter.js | function (clientArguments) {
var grepRegex = /^--grep=(.*)$/;
if (Object.prototype.toString.call(clientArguments) === '[object Array]') {
var indexOfGrep = indexOf(clientArguments, '--grep');
if (indexOfGrep !== -1) {
return clientArguments[indexOfGrep + 1]
}
return map(filter(clientArguments, function (arg) {
return grepRegex.test(arg)
}), function (arg) {
return arg.replace(grepRegex, '$1')
})[0] || ''
} else if (typeof clientArguments === 'string') {
var match = /--grep=([^=]+)/.exec(clientArguments);
return match ? match[1] : ''
}
} | javascript | function (clientArguments) {
var grepRegex = /^--grep=(.*)$/;
if (Object.prototype.toString.call(clientArguments) === '[object Array]') {
var indexOfGrep = indexOf(clientArguments, '--grep');
if (indexOfGrep !== -1) {
return clientArguments[indexOfGrep + 1]
}
return map(filter(clientArguments, function (arg) {
return grepRegex.test(arg)
}), function (arg) {
return arg.replace(grepRegex, '$1')
})[0] || ''
} else if (typeof clientArguments === 'string') {
var match = /--grep=([^=]+)/.exec(clientArguments);
return match ? match[1] : ''
}
} | [
"function",
"(",
"clientArguments",
")",
"{",
"var",
"grepRegex",
"=",
"/",
"^--grep=(.*)$",
"/",
";",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"clientArguments",
")",
"===",
"'[object Array]'",
")",
"{",
"var",
"indexOfGrep",
"=",
"indexOf",
"(",
"clientArguments",
",",
"'--grep'",
")",
";",
"if",
"(",
"indexOfGrep",
"!==",
"-",
"1",
")",
"{",
"return",
"clientArguments",
"[",
"indexOfGrep",
"+",
"1",
"]",
"}",
"return",
"map",
"(",
"filter",
"(",
"clientArguments",
",",
"function",
"(",
"arg",
")",
"{",
"return",
"grepRegex",
".",
"test",
"(",
"arg",
")",
"}",
")",
",",
"function",
"(",
"arg",
")",
"{",
"return",
"arg",
".",
"replace",
"(",
"grepRegex",
",",
"'$1'",
")",
"}",
")",
"[",
"0",
"]",
"||",
"''",
"}",
"else",
"if",
"(",
"typeof",
"clientArguments",
"===",
"'string'",
")",
"{",
"var",
"match",
"=",
"/",
"--grep=([^=]+)",
"/",
".",
"exec",
"(",
"clientArguments",
")",
";",
"return",
"match",
"?",
"match",
"[",
"1",
"]",
":",
"''",
"}",
"}"
] | Extract grep option from karma config
@param {[Array|string]} clientArguments The karma client arguments
@return {string} The value of grep option by default empty string | [
"Extract",
"grep",
"option",
"from",
"karma",
"config"
] | 7c5fa9044571c8e49f49c07abc5f493af3070dc4 | https://github.com/sumanjs/karma-suman/blob/7c5fa9044571c8e49f49c07abc5f493af3070dc4/src/adapter.js#L280-L300 |
|
53,307 | sumanjs/karma-suman | src/adapter.js | createStartFn | function createStartFn (karma, jasmineEnv) {
function setOption (option, set) {
if (option != null) {
set(option)
}
}
// This function will be assigned to `window.__karma__.start`:
return function () {
console.log('suman started.');
window.__suman.tsrq.resume();
// var clientConfig = karma.config || {}
// var jasmineConfig = clientConfig.jasmine || {}
//
// jasmineEnv = jasmineEnv || window.jasmine.getEnv()
//
// setOption(jasmineConfig.stopOnFailure, jasmineEnv.throwOnExpectationFailure)
// setOption(jasmineConfig.seed, jasmineEnv.seed)
// setOption(jasmineConfig.random, jasmineEnv.randomizeTests)
//
// jasmineEnv.addReporter(new KarmaReporter(karma, jasmineEnv))
// jasmineEnv.execute()
}
} | javascript | function createStartFn (karma, jasmineEnv) {
function setOption (option, set) {
if (option != null) {
set(option)
}
}
// This function will be assigned to `window.__karma__.start`:
return function () {
console.log('suman started.');
window.__suman.tsrq.resume();
// var clientConfig = karma.config || {}
// var jasmineConfig = clientConfig.jasmine || {}
//
// jasmineEnv = jasmineEnv || window.jasmine.getEnv()
//
// setOption(jasmineConfig.stopOnFailure, jasmineEnv.throwOnExpectationFailure)
// setOption(jasmineConfig.seed, jasmineEnv.seed)
// setOption(jasmineConfig.random, jasmineEnv.randomizeTests)
//
// jasmineEnv.addReporter(new KarmaReporter(karma, jasmineEnv))
// jasmineEnv.execute()
}
} | [
"function",
"createStartFn",
"(",
"karma",
",",
"jasmineEnv",
")",
"{",
"function",
"setOption",
"(",
"option",
",",
"set",
")",
"{",
"if",
"(",
"option",
"!=",
"null",
")",
"{",
"set",
"(",
"option",
")",
"}",
"}",
"// This function will be assigned to `window.__karma__.start`:",
"return",
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'suman started.'",
")",
";",
"window",
".",
"__suman",
".",
"tsrq",
".",
"resume",
"(",
")",
";",
"// var clientConfig = karma.config || {}",
"// var jasmineConfig = clientConfig.jasmine || {}",
"//",
"// jasmineEnv = jasmineEnv || window.jasmine.getEnv()",
"//",
"// setOption(jasmineConfig.stopOnFailure, jasmineEnv.throwOnExpectationFailure)",
"// setOption(jasmineConfig.seed, jasmineEnv.seed)",
"// setOption(jasmineConfig.random, jasmineEnv.randomizeTests)",
"//",
"// jasmineEnv.addReporter(new KarmaReporter(karma, jasmineEnv))",
"// jasmineEnv.execute()",
"}",
"}"
] | Karma starter function factory.
This function is invoked from the wrapper.
@see adapter.wrapper
@param {Object} karma Karma runner instance.
@param {Object} [jasmineEnv] Optional Jasmine environment for testing.
@return {Function} Karma starter function. | [
"Karma",
"starter",
"function",
"factory",
"."
] | 7c5fa9044571c8e49f49c07abc5f493af3070dc4 | https://github.com/sumanjs/karma-suman/blob/7c5fa9044571c8e49f49c07abc5f493af3070dc4/src/adapter.js#L341-L369 |
53,308 | sendanor/nor-nopg | src/merge.js | _copy_property | function _copy_property(opts, key, a, b) {
debug.assert(opts).is('object');
debug.assert(key).is('string');
debug.assert(a).is('object');
debug.assert(b).is('object');
a[key] = b[key];
if(opts.cache && opts.cache._has_cursors && is.obj(b[key]) && b[key].hasOwnProperty('$id')) {
var f = opts.cache.findCursor(b, key);
if(f) {
//debug.log('Expanding cursor...');
opts.cache.addToCursor(f, a, key);
}
}
} | javascript | function _copy_property(opts, key, a, b) {
debug.assert(opts).is('object');
debug.assert(key).is('string');
debug.assert(a).is('object');
debug.assert(b).is('object');
a[key] = b[key];
if(opts.cache && opts.cache._has_cursors && is.obj(b[key]) && b[key].hasOwnProperty('$id')) {
var f = opts.cache.findCursor(b, key);
if(f) {
//debug.log('Expanding cursor...');
opts.cache.addToCursor(f, a, key);
}
}
} | [
"function",
"_copy_property",
"(",
"opts",
",",
"key",
",",
"a",
",",
"b",
")",
"{",
"debug",
".",
"assert",
"(",
"opts",
")",
".",
"is",
"(",
"'object'",
")",
";",
"debug",
".",
"assert",
"(",
"key",
")",
".",
"is",
"(",
"'string'",
")",
";",
"debug",
".",
"assert",
"(",
"a",
")",
".",
"is",
"(",
"'object'",
")",
";",
"debug",
".",
"assert",
"(",
"b",
")",
".",
"is",
"(",
"'object'",
")",
";",
"a",
"[",
"key",
"]",
"=",
"b",
"[",
"key",
"]",
";",
"if",
"(",
"opts",
".",
"cache",
"&&",
"opts",
".",
"cache",
".",
"_has_cursors",
"&&",
"is",
".",
"obj",
"(",
"b",
"[",
"key",
"]",
")",
"&&",
"b",
"[",
"key",
"]",
".",
"hasOwnProperty",
"(",
"'$id'",
")",
")",
"{",
"var",
"f",
"=",
"opts",
".",
"cache",
".",
"findCursor",
"(",
"b",
",",
"key",
")",
";",
"if",
"(",
"f",
")",
"{",
"//debug.log('Expanding cursor...');",
"opts",
".",
"cache",
".",
"addToCursor",
"(",
"f",
",",
"a",
",",
"key",
")",
";",
"}",
"}",
"}"
] | Copy property from a to b
@param opts {object} Options
@param key {string} The keyword of the property
@param a {object} Copy to
@param b {object} Copy from | [
"Copy",
"property",
"from",
"a",
"to",
"b"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/merge.js#L78-L94 |
53,309 | sendanor/nor-nopg | src/merge.js | merge_objects_ | function merge_objects_(b) {
if(is.func(b)) {
b = b();
}
debug.assert(b).is('object');
_merge_object(opts, a, b);
} | javascript | function merge_objects_(b) {
if(is.func(b)) {
b = b();
}
debug.assert(b).is('object');
_merge_object(opts, a, b);
} | [
"function",
"merge_objects_",
"(",
"b",
")",
"{",
"if",
"(",
"is",
".",
"func",
"(",
"b",
")",
")",
"{",
"b",
"=",
"b",
"(",
")",
";",
"}",
"debug",
".",
"assert",
"(",
"b",
")",
".",
"is",
"(",
"'object'",
")",
";",
"_merge_object",
"(",
"opts",
",",
"a",
",",
"b",
")",
";",
"}"
] | Merge `a` and `b` | [
"Merge",
"a",
"and",
"b"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/merge.js#L239-L245 |
53,310 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/solid-gauge.src.js | function (init) {
if (!init) {
this.startAngleRad = this.yAxis.startAngleRad;
H.seriesTypes.pie.prototype.animate.call(this, init);
}
} | javascript | function (init) {
if (!init) {
this.startAngleRad = this.yAxis.startAngleRad;
H.seriesTypes.pie.prototype.animate.call(this, init);
}
} | [
"function",
"(",
"init",
")",
"{",
"if",
"(",
"!",
"init",
")",
"{",
"this",
".",
"startAngleRad",
"=",
"this",
".",
"yAxis",
".",
"startAngleRad",
";",
"H",
".",
"seriesTypes",
".",
"pie",
".",
"prototype",
".",
"animate",
".",
"call",
"(",
"this",
",",
"init",
")",
";",
"}",
"}"
] | Extend the pie slice animation by animating from start angle and up | [
"Extend",
"the",
"pie",
"slice",
"animation",
"by",
"animating",
"from",
"start",
"angle",
"and",
"up"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/solid-gauge.src.js#L258-L264 |
|
53,311 | redisjs/jsr-server | lib/command/server/bgsave.js | execute | function execute(req, res) {
this.log.notice('background saving started by pid %s', process.pid);
function onSave(err) {
/* istanbul ignore next: not prepared to mock this right now */
if(err) return this.log.warning('background save failed: %s', err.message);
this.log.notice('background saving terminated with success')
}
Persistence.save(this.state.store, this.state.conf, onSave.bind(this));
res.send(null, Constants.BGSAVE);
} | javascript | function execute(req, res) {
this.log.notice('background saving started by pid %s', process.pid);
function onSave(err) {
/* istanbul ignore next: not prepared to mock this right now */
if(err) return this.log.warning('background save failed: %s', err.message);
this.log.notice('background saving terminated with success')
}
Persistence.save(this.state.store, this.state.conf, onSave.bind(this));
res.send(null, Constants.BGSAVE);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"this",
".",
"log",
".",
"notice",
"(",
"'background saving started by pid %s'",
",",
"process",
".",
"pid",
")",
";",
"function",
"onSave",
"(",
"err",
")",
"{",
"/* istanbul ignore next: not prepared to mock this right now */",
"if",
"(",
"err",
")",
"return",
"this",
".",
"log",
".",
"warning",
"(",
"'background save failed: %s'",
",",
"err",
".",
"message",
")",
";",
"this",
".",
"log",
".",
"notice",
"(",
"'background saving terminated with success'",
")",
"}",
"Persistence",
".",
"save",
"(",
"this",
".",
"state",
".",
"store",
",",
"this",
".",
"state",
".",
"conf",
",",
"onSave",
".",
"bind",
"(",
"this",
")",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"BGSAVE",
")",
";",
"}"
] | Respond to the BGSAVE command. | [
"Respond",
"to",
"the",
"BGSAVE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/bgsave.js#L20-L29 |
53,312 | redisjs/jsr-server | lib/command/server/bgsave.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(Persistence.saving) throw SaveInProgress;
} | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
if(Persistence.saving) throw SaveInProgress;
} | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"Persistence",
".",
"saving",
")",
"throw",
"SaveInProgress",
";",
"}"
] | Validate the BGSAVE command. | [
"Validate",
"the",
"BGSAVE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/bgsave.js#L34-L37 |
53,313 | redisjs/jsr-server | lib/slowlog.js | SlowLogRecord | function SlowLogRecord(cmd, args) {
this._now = Date.now();
this._cmd = [cmd].concat(args);
// start timer value when command execution started
this._start = process.hrtime();
} | javascript | function SlowLogRecord(cmd, args) {
this._now = Date.now();
this._cmd = [cmd].concat(args);
// start timer value when command execution started
this._start = process.hrtime();
} | [
"function",
"SlowLogRecord",
"(",
"cmd",
",",
"args",
")",
"{",
"this",
".",
"_now",
"=",
"Date",
".",
"now",
"(",
")",
";",
"this",
".",
"_cmd",
"=",
"[",
"cmd",
"]",
".",
"concat",
"(",
"args",
")",
";",
"// start timer value when command execution started",
"this",
".",
"_start",
"=",
"process",
".",
"hrtime",
"(",
")",
";",
"}"
] | Encapsulates a slowlog record. | [
"Encapsulates",
"a",
"slowlog",
"record",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L8-L14 |
53,314 | redisjs/jsr-server | lib/slowlog.js | isSlowerThan | function isSlowerThan(amount) {
// always logging
var diff = process.hrtime(this._start)
, micro = Math.round(((diff[0] * 1e9) + diff[1]) / 1e3);
if(amount === 0) return micro;
if(micro > amount) {
return micro;
}
return -1;
} | javascript | function isSlowerThan(amount) {
// always logging
var diff = process.hrtime(this._start)
, micro = Math.round(((diff[0] * 1e9) + diff[1]) / 1e3);
if(amount === 0) return micro;
if(micro > amount) {
return micro;
}
return -1;
} | [
"function",
"isSlowerThan",
"(",
"amount",
")",
"{",
"// always logging",
"var",
"diff",
"=",
"process",
".",
"hrtime",
"(",
"this",
".",
"_start",
")",
",",
"micro",
"=",
"Math",
".",
"round",
"(",
"(",
"(",
"diff",
"[",
"0",
"]",
"*",
"1e9",
")",
"+",
"diff",
"[",
"1",
"]",
")",
"/",
"1e3",
")",
";",
"if",
"(",
"amount",
"===",
"0",
")",
"return",
"micro",
";",
"if",
"(",
"micro",
">",
"amount",
")",
"{",
"return",
"micro",
";",
"}",
"return",
"-",
"1",
";",
"}"
] | Determine if this log record took longer than
the specified amount. | [
"Determine",
"if",
"this",
"log",
"record",
"took",
"longer",
"than",
"the",
"specified",
"amount",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L20-L29 |
53,315 | redisjs/jsr-server | lib/slowlog.js | toArray | function toArray(id, time) {
var o = [
id,
Math.round(this._now / 1000),
time,
this._cmd];
return o;
} | javascript | function toArray(id, time) {
var o = [
id,
Math.round(this._now / 1000),
time,
this._cmd];
return o;
} | [
"function",
"toArray",
"(",
"id",
",",
"time",
")",
"{",
"var",
"o",
"=",
"[",
"id",
",",
"Math",
".",
"round",
"(",
"this",
".",
"_now",
"/",
"1000",
")",
",",
"time",
",",
"this",
".",
"_cmd",
"]",
";",
"return",
"o",
";",
"}"
] | Convert this log record to an array, only called if
the command took longer than the configured slower than
amount.
@param id The id for the record.
@param time The execution time in microseconds. | [
"Convert",
"this",
"log",
"record",
"to",
"an",
"array",
"only",
"called",
"if",
"the",
"command",
"took",
"longer",
"than",
"the",
"configured",
"slower",
"than",
"amount",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L39-L46 |
53,316 | redisjs/jsr-server | lib/slowlog.js | SlowLog | function SlowLog(conf) {
this._conf = conf;
// log commands slower than this number of microseconds
// disabled by default
this._slowerThan = -1;
// maximum length of the slow log
this._maxLen = 128;
// set up log records array
this.reset();
// log record for the current executing command
this._record = null;
function onConfigLoad() {
this._slowerThan = conf.get(ConfigKey.SLOWLOG_LOG_SLOWER_THAN);
this._maxLen = conf.get(ConfigKey.SLOWLOG_MAX_LEN);
}
function onSlowerThan(key, value) {
this._slowerThan = value;
}
function onMaxLen(key, value) {
// minimum record length is one, if a user wishes
// to disable slow logs they should set slowlog-log-slower-than to -1
this._maxLen = Math.max(value, 1);
}
onConfigLoad = onConfigLoad.bind(this);
onSlowerThan = onSlowerThan.bind(this);
onMaxLen = onMaxLen.bind(this);
this._conf.once('load', onConfigLoad.bind(this));
this._conf.on(ConfigKey.SLOWLOG_LOG_SLOWER_THAN, onSlowerThan);
this._conf.on(ConfigKey.SLOWLOG_MAX_LEN, onMaxLen);
// bind stop here as it is called as a before
// function on the response
this.stop = this.stop.bind(this);
} | javascript | function SlowLog(conf) {
this._conf = conf;
// log commands slower than this number of microseconds
// disabled by default
this._slowerThan = -1;
// maximum length of the slow log
this._maxLen = 128;
// set up log records array
this.reset();
// log record for the current executing command
this._record = null;
function onConfigLoad() {
this._slowerThan = conf.get(ConfigKey.SLOWLOG_LOG_SLOWER_THAN);
this._maxLen = conf.get(ConfigKey.SLOWLOG_MAX_LEN);
}
function onSlowerThan(key, value) {
this._slowerThan = value;
}
function onMaxLen(key, value) {
// minimum record length is one, if a user wishes
// to disable slow logs they should set slowlog-log-slower-than to -1
this._maxLen = Math.max(value, 1);
}
onConfigLoad = onConfigLoad.bind(this);
onSlowerThan = onSlowerThan.bind(this);
onMaxLen = onMaxLen.bind(this);
this._conf.once('load', onConfigLoad.bind(this));
this._conf.on(ConfigKey.SLOWLOG_LOG_SLOWER_THAN, onSlowerThan);
this._conf.on(ConfigKey.SLOWLOG_MAX_LEN, onMaxLen);
// bind stop here as it is called as a before
// function on the response
this.stop = this.stop.bind(this);
} | [
"function",
"SlowLog",
"(",
"conf",
")",
"{",
"this",
".",
"_conf",
"=",
"conf",
";",
"// log commands slower than this number of microseconds",
"// disabled by default",
"this",
".",
"_slowerThan",
"=",
"-",
"1",
";",
"// maximum length of the slow log",
"this",
".",
"_maxLen",
"=",
"128",
";",
"// set up log records array",
"this",
".",
"reset",
"(",
")",
";",
"// log record for the current executing command",
"this",
".",
"_record",
"=",
"null",
";",
"function",
"onConfigLoad",
"(",
")",
"{",
"this",
".",
"_slowerThan",
"=",
"conf",
".",
"get",
"(",
"ConfigKey",
".",
"SLOWLOG_LOG_SLOWER_THAN",
")",
";",
"this",
".",
"_maxLen",
"=",
"conf",
".",
"get",
"(",
"ConfigKey",
".",
"SLOWLOG_MAX_LEN",
")",
";",
"}",
"function",
"onSlowerThan",
"(",
"key",
",",
"value",
")",
"{",
"this",
".",
"_slowerThan",
"=",
"value",
";",
"}",
"function",
"onMaxLen",
"(",
"key",
",",
"value",
")",
"{",
"// minimum record length is one, if a user wishes",
"// to disable slow logs they should set slowlog-log-slower-than to -1",
"this",
".",
"_maxLen",
"=",
"Math",
".",
"max",
"(",
"value",
",",
"1",
")",
";",
"}",
"onConfigLoad",
"=",
"onConfigLoad",
".",
"bind",
"(",
"this",
")",
";",
"onSlowerThan",
"=",
"onSlowerThan",
".",
"bind",
"(",
"this",
")",
";",
"onMaxLen",
"=",
"onMaxLen",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"_conf",
".",
"once",
"(",
"'load'",
",",
"onConfigLoad",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"_conf",
".",
"on",
"(",
"ConfigKey",
".",
"SLOWLOG_LOG_SLOWER_THAN",
",",
"onSlowerThan",
")",
";",
"this",
".",
"_conf",
".",
"on",
"(",
"ConfigKey",
".",
"SLOWLOG_MAX_LEN",
",",
"onMaxLen",
")",
";",
"// bind stop here as it is called as a before",
"// function on the response",
"this",
".",
"stop",
"=",
"this",
".",
"stop",
".",
"bind",
"(",
"this",
")",
";",
"}"
] | Encapsulates the slow log queries storage.
@param conf The server configuration. | [
"Encapsulates",
"the",
"slow",
"log",
"queries",
"storage",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L56-L99 |
53,317 | redisjs/jsr-server | lib/slowlog.js | start | function start(cmd, args) {
if(!this.enabled) return false;
this._record = new SlowLogRecord(cmd, args);
return this._record;
} | javascript | function start(cmd, args) {
if(!this.enabled) return false;
this._record = new SlowLogRecord(cmd, args);
return this._record;
} | [
"function",
"start",
"(",
"cmd",
",",
"args",
")",
"{",
"if",
"(",
"!",
"this",
".",
"enabled",
")",
"return",
"false",
";",
"this",
".",
"_record",
"=",
"new",
"SlowLogRecord",
"(",
"cmd",
",",
"args",
")",
";",
"return",
"this",
".",
"_record",
";",
"}"
] | Start timing command execution. | [
"Start",
"timing",
"command",
"execution",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L104-L108 |
53,318 | redisjs/jsr-server | lib/slowlog.js | stop | function stop() {
var time;
if(!this.enabled) return false;
time = this._record.isSlowerThan(this._slowerThan);
if(this._record && time > -1) {
this._records.unshift(this._record.toArray(id++, time));
if(this._records.length >= this._maxLen) {
this._records.pop();
}
}
} | javascript | function stop() {
var time;
if(!this.enabled) return false;
time = this._record.isSlowerThan(this._slowerThan);
if(this._record && time > -1) {
this._records.unshift(this._record.toArray(id++, time));
if(this._records.length >= this._maxLen) {
this._records.pop();
}
}
} | [
"function",
"stop",
"(",
")",
"{",
"var",
"time",
";",
"if",
"(",
"!",
"this",
".",
"enabled",
")",
"return",
"false",
";",
"time",
"=",
"this",
".",
"_record",
".",
"isSlowerThan",
"(",
"this",
".",
"_slowerThan",
")",
";",
"if",
"(",
"this",
".",
"_record",
"&&",
"time",
">",
"-",
"1",
")",
"{",
"this",
".",
"_records",
".",
"unshift",
"(",
"this",
".",
"_record",
".",
"toArray",
"(",
"id",
"++",
",",
"time",
")",
")",
";",
"if",
"(",
"this",
".",
"_records",
".",
"length",
">=",
"this",
".",
"_maxLen",
")",
"{",
"this",
".",
"_records",
".",
"pop",
"(",
")",
";",
"}",
"}",
"}"
] | Stop timing current command execution. | [
"Stop",
"timing",
"current",
"command",
"execution",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L113-L123 |
53,319 | redisjs/jsr-server | lib/slowlog.js | get | function get(amount) {
amount = amount !== undefined && amount >= 0 ? amount : 10;
amount = Math.min(amount, this._records.length);
return this._records.slice(0, amount);
} | javascript | function get(amount) {
amount = amount !== undefined && amount >= 0 ? amount : 10;
amount = Math.min(amount, this._records.length);
return this._records.slice(0, amount);
} | [
"function",
"get",
"(",
"amount",
")",
"{",
"amount",
"=",
"amount",
"!==",
"undefined",
"&&",
"amount",
">=",
"0",
"?",
"amount",
":",
"10",
";",
"amount",
"=",
"Math",
".",
"min",
"(",
"amount",
",",
"this",
".",
"_records",
".",
"length",
")",
";",
"return",
"this",
".",
"_records",
".",
"slice",
"(",
"0",
",",
"amount",
")",
";",
"}"
] | Get a list of slowlog records.
Suitable for invoking from SLOWLOG GET. | [
"Get",
"a",
"list",
"of",
"slowlog",
"records",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/slowlog.js#L130-L134 |
53,320 | redisjs/jsr-conf | lib/type/typedef.js | TypeDef | function TypeDef(arity, type, repeats) {
// arity for the parameter
this.arity = arity;
// type declarations as an array
this.type = type;
// does this value accumulate repeating declarations
this.repeats = repeats;
} | javascript | function TypeDef(arity, type, repeats) {
// arity for the parameter
this.arity = arity;
// type declarations as an array
this.type = type;
// does this value accumulate repeating declarations
this.repeats = repeats;
} | [
"function",
"TypeDef",
"(",
"arity",
",",
"type",
",",
"repeats",
")",
"{",
"// arity for the parameter",
"this",
".",
"arity",
"=",
"arity",
";",
"// type declarations as an array",
"this",
".",
"type",
"=",
"type",
";",
"// does this value accumulate repeating declarations",
"this",
".",
"repeats",
"=",
"repeats",
";",
"}"
] | Encapsulates a configuration type definition. | [
"Encapsulates",
"a",
"configuration",
"type",
"definition",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/type/typedef.js#L11-L20 |
53,321 | redisjs/jsr-conf | lib/type/typedef.js | validate | function validate(key, values) {
if(this.arity > 0 && values.length !== this.arity) {
throw new TypeDefError(
util.format('bad arity for \'%s\', expected %s got %s',
key, this.arity, values.length));
}
var types = Array.isArray(this.type) ? this.type : [this.type]
, i
, type
, val
, num
, coerced = []
, enumerable = false;
for(i = 0;i < types.length;i++) {
type = types[i];
val = values[i];
enumerable = Array.isArray(type);
if(enumerable) {
if(!~type.indexOf(val)) {
throw new TypeDefError(
util.format('enum error on key \'%s\', got \'%s\' expected one of %s',
key, val, type.join(', ')));
}
}
switch(type) {
case ByteSize:
val = ByteSize.parse(val);
break;
case Boolean:
if(val !== YES && val !== NO) {
throw new Error(
util.format('argument must be \'%s\' or \'%s\'', YES, NO));
}
val = val === YES ? true : false;
break;
case String:
// strings can be quoted
val = val.replace(/^"/, '').replace(/"$/, '');
break;
case Number:
num = parseInt(val);
if(isNaN(num) || !/^-?[0-9]+$/.test(val)) {
throw new TypeDefError(
util.format('number expected for \'%s\', got %s', key, val));
}
val = num;
break;
}
coerced[i] = val;
}
if(this.arity === 1 && !this.repeats) return coerced[0];
return Array.isArray(this.type) ? coerced : coerced[0];
} | javascript | function validate(key, values) {
if(this.arity > 0 && values.length !== this.arity) {
throw new TypeDefError(
util.format('bad arity for \'%s\', expected %s got %s',
key, this.arity, values.length));
}
var types = Array.isArray(this.type) ? this.type : [this.type]
, i
, type
, val
, num
, coerced = []
, enumerable = false;
for(i = 0;i < types.length;i++) {
type = types[i];
val = values[i];
enumerable = Array.isArray(type);
if(enumerable) {
if(!~type.indexOf(val)) {
throw new TypeDefError(
util.format('enum error on key \'%s\', got \'%s\' expected one of %s',
key, val, type.join(', ')));
}
}
switch(type) {
case ByteSize:
val = ByteSize.parse(val);
break;
case Boolean:
if(val !== YES && val !== NO) {
throw new Error(
util.format('argument must be \'%s\' or \'%s\'', YES, NO));
}
val = val === YES ? true : false;
break;
case String:
// strings can be quoted
val = val.replace(/^"/, '').replace(/"$/, '');
break;
case Number:
num = parseInt(val);
if(isNaN(num) || !/^-?[0-9]+$/.test(val)) {
throw new TypeDefError(
util.format('number expected for \'%s\', got %s', key, val));
}
val = num;
break;
}
coerced[i] = val;
}
if(this.arity === 1 && !this.repeats) return coerced[0];
return Array.isArray(this.type) ? coerced : coerced[0];
} | [
"function",
"validate",
"(",
"key",
",",
"values",
")",
"{",
"if",
"(",
"this",
".",
"arity",
">",
"0",
"&&",
"values",
".",
"length",
"!==",
"this",
".",
"arity",
")",
"{",
"throw",
"new",
"TypeDefError",
"(",
"util",
".",
"format",
"(",
"'bad arity for \\'%s\\', expected %s got %s'",
",",
"key",
",",
"this",
".",
"arity",
",",
"values",
".",
"length",
")",
")",
";",
"}",
"var",
"types",
"=",
"Array",
".",
"isArray",
"(",
"this",
".",
"type",
")",
"?",
"this",
".",
"type",
":",
"[",
"this",
".",
"type",
"]",
",",
"i",
",",
"type",
",",
"val",
",",
"num",
",",
"coerced",
"=",
"[",
"]",
",",
"enumerable",
"=",
"false",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"types",
".",
"length",
";",
"i",
"++",
")",
"{",
"type",
"=",
"types",
"[",
"i",
"]",
";",
"val",
"=",
"values",
"[",
"i",
"]",
";",
"enumerable",
"=",
"Array",
".",
"isArray",
"(",
"type",
")",
";",
"if",
"(",
"enumerable",
")",
"{",
"if",
"(",
"!",
"~",
"type",
".",
"indexOf",
"(",
"val",
")",
")",
"{",
"throw",
"new",
"TypeDefError",
"(",
"util",
".",
"format",
"(",
"'enum error on key \\'%s\\', got \\'%s\\' expected one of %s'",
",",
"key",
",",
"val",
",",
"type",
".",
"join",
"(",
"', '",
")",
")",
")",
";",
"}",
"}",
"switch",
"(",
"type",
")",
"{",
"case",
"ByteSize",
":",
"val",
"=",
"ByteSize",
".",
"parse",
"(",
"val",
")",
";",
"break",
";",
"case",
"Boolean",
":",
"if",
"(",
"val",
"!==",
"YES",
"&&",
"val",
"!==",
"NO",
")",
"{",
"throw",
"new",
"Error",
"(",
"util",
".",
"format",
"(",
"'argument must be \\'%s\\' or \\'%s\\''",
",",
"YES",
",",
"NO",
")",
")",
";",
"}",
"val",
"=",
"val",
"===",
"YES",
"?",
"true",
":",
"false",
";",
"break",
";",
"case",
"String",
":",
"// strings can be quoted",
"val",
"=",
"val",
".",
"replace",
"(",
"/",
"^\"",
"/",
",",
"''",
")",
".",
"replace",
"(",
"/",
"\"$",
"/",
",",
"''",
")",
";",
"break",
";",
"case",
"Number",
":",
"num",
"=",
"parseInt",
"(",
"val",
")",
";",
"if",
"(",
"isNaN",
"(",
"num",
")",
"||",
"!",
"/",
"^-?[0-9]+$",
"/",
".",
"test",
"(",
"val",
")",
")",
"{",
"throw",
"new",
"TypeDefError",
"(",
"util",
".",
"format",
"(",
"'number expected for \\'%s\\', got %s'",
",",
"key",
",",
"val",
")",
")",
";",
"}",
"val",
"=",
"num",
";",
"break",
";",
"}",
"coerced",
"[",
"i",
"]",
"=",
"val",
";",
"}",
"if",
"(",
"this",
".",
"arity",
"===",
"1",
"&&",
"!",
"this",
".",
"repeats",
")",
"return",
"coerced",
"[",
"0",
"]",
";",
"return",
"Array",
".",
"isArray",
"(",
"this",
".",
"type",
")",
"?",
"coerced",
":",
"coerced",
"[",
"0",
"]",
";",
"}"
] | Validate an array of values against this type
definition. | [
"Validate",
"an",
"array",
"of",
"values",
"against",
"this",
"type",
"definition",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/type/typedef.js#L26-L80 |
53,322 | redisjs/jsr-conf | lib/type/typedef.js | encode | function encode(key, value, stringify) {
var space = ' ', val = [], i, type = this.type;
function coerce(type, val) {
var out
, enumerable = Array.isArray(type);
if(enumerable) {
if(!~type.indexOf(val)) {
throw new TypeDefError(
util.format('enum error on key \'%s\', got \'%s\' expected one of %s',
key, val, type.join(', ')));
}
return '' + val;
}
switch(type) {
case ByteSize:
if(typeof val !== 'number') {
throw new TypeDefError(
util.format(
'byte size number expected for \'%s\', got %s', key, val));
}
out = ByteSize.humanize(val);
break;
case Boolean:
if(typeof val !== 'boolean') {
throw new TypeDefError(
util.format('boolean expected for \'%s\', got %s', key, val));
}
out = val === true ? YES : NO;
break;
case String:
// strings must be quoted to allow the empty string
out = '"' + val + '"';
break;
case Number:
if(typeof val !== 'number') {
throw new TypeDefError(
util.format('number expected for \'%s\', got %s', key, val));
}
// just coerce numbers to strings
out = '' + val;
break;
}
return out;
}
// simple types
if(!Array.isArray(this.type)) {
return (!stringify ? key + space : '') + coerce(this.type, value);
}
if(stringify && this.repeats) {
value.forEach(function(item) {
item.forEach(function(entry, i) {
val.push(coerce(type[i], entry));
})
});
return val.join(space);
}
for(i = 0;i < this.type.length;i++) {
if(this.arity > 1) {
// expecting value to be an array
val.push(coerce(this.type[i], value[i]));
}else{
val.push(coerce(this.type[i], value));
}
}
return key + space + val.join(space);
} | javascript | function encode(key, value, stringify) {
var space = ' ', val = [], i, type = this.type;
function coerce(type, val) {
var out
, enumerable = Array.isArray(type);
if(enumerable) {
if(!~type.indexOf(val)) {
throw new TypeDefError(
util.format('enum error on key \'%s\', got \'%s\' expected one of %s',
key, val, type.join(', ')));
}
return '' + val;
}
switch(type) {
case ByteSize:
if(typeof val !== 'number') {
throw new TypeDefError(
util.format(
'byte size number expected for \'%s\', got %s', key, val));
}
out = ByteSize.humanize(val);
break;
case Boolean:
if(typeof val !== 'boolean') {
throw new TypeDefError(
util.format('boolean expected for \'%s\', got %s', key, val));
}
out = val === true ? YES : NO;
break;
case String:
// strings must be quoted to allow the empty string
out = '"' + val + '"';
break;
case Number:
if(typeof val !== 'number') {
throw new TypeDefError(
util.format('number expected for \'%s\', got %s', key, val));
}
// just coerce numbers to strings
out = '' + val;
break;
}
return out;
}
// simple types
if(!Array.isArray(this.type)) {
return (!stringify ? key + space : '') + coerce(this.type, value);
}
if(stringify && this.repeats) {
value.forEach(function(item) {
item.forEach(function(entry, i) {
val.push(coerce(type[i], entry));
})
});
return val.join(space);
}
for(i = 0;i < this.type.length;i++) {
if(this.arity > 1) {
// expecting value to be an array
val.push(coerce(this.type[i], value[i]));
}else{
val.push(coerce(this.type[i], value));
}
}
return key + space + val.join(space);
} | [
"function",
"encode",
"(",
"key",
",",
"value",
",",
"stringify",
")",
"{",
"var",
"space",
"=",
"' '",
",",
"val",
"=",
"[",
"]",
",",
"i",
",",
"type",
"=",
"this",
".",
"type",
";",
"function",
"coerce",
"(",
"type",
",",
"val",
")",
"{",
"var",
"out",
",",
"enumerable",
"=",
"Array",
".",
"isArray",
"(",
"type",
")",
";",
"if",
"(",
"enumerable",
")",
"{",
"if",
"(",
"!",
"~",
"type",
".",
"indexOf",
"(",
"val",
")",
")",
"{",
"throw",
"new",
"TypeDefError",
"(",
"util",
".",
"format",
"(",
"'enum error on key \\'%s\\', got \\'%s\\' expected one of %s'",
",",
"key",
",",
"val",
",",
"type",
".",
"join",
"(",
"', '",
")",
")",
")",
";",
"}",
"return",
"''",
"+",
"val",
";",
"}",
"switch",
"(",
"type",
")",
"{",
"case",
"ByteSize",
":",
"if",
"(",
"typeof",
"val",
"!==",
"'number'",
")",
"{",
"throw",
"new",
"TypeDefError",
"(",
"util",
".",
"format",
"(",
"'byte size number expected for \\'%s\\', got %s'",
",",
"key",
",",
"val",
")",
")",
";",
"}",
"out",
"=",
"ByteSize",
".",
"humanize",
"(",
"val",
")",
";",
"break",
";",
"case",
"Boolean",
":",
"if",
"(",
"typeof",
"val",
"!==",
"'boolean'",
")",
"{",
"throw",
"new",
"TypeDefError",
"(",
"util",
".",
"format",
"(",
"'boolean expected for \\'%s\\', got %s'",
",",
"key",
",",
"val",
")",
")",
";",
"}",
"out",
"=",
"val",
"===",
"true",
"?",
"YES",
":",
"NO",
";",
"break",
";",
"case",
"String",
":",
"// strings must be quoted to allow the empty string",
"out",
"=",
"'\"'",
"+",
"val",
"+",
"'\"'",
";",
"break",
";",
"case",
"Number",
":",
"if",
"(",
"typeof",
"val",
"!==",
"'number'",
")",
"{",
"throw",
"new",
"TypeDefError",
"(",
"util",
".",
"format",
"(",
"'number expected for \\'%s\\', got %s'",
",",
"key",
",",
"val",
")",
")",
";",
"}",
"// just coerce numbers to strings",
"out",
"=",
"''",
"+",
"val",
";",
"break",
";",
"}",
"return",
"out",
";",
"}",
"// simple types",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"this",
".",
"type",
")",
")",
"{",
"return",
"(",
"!",
"stringify",
"?",
"key",
"+",
"space",
":",
"''",
")",
"+",
"coerce",
"(",
"this",
".",
"type",
",",
"value",
")",
";",
"}",
"if",
"(",
"stringify",
"&&",
"this",
".",
"repeats",
")",
"{",
"value",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"item",
".",
"forEach",
"(",
"function",
"(",
"entry",
",",
"i",
")",
"{",
"val",
".",
"push",
"(",
"coerce",
"(",
"type",
"[",
"i",
"]",
",",
"entry",
")",
")",
";",
"}",
")",
"}",
")",
";",
"return",
"val",
".",
"join",
"(",
"space",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"type",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"arity",
">",
"1",
")",
"{",
"// expecting value to be an array",
"val",
".",
"push",
"(",
"coerce",
"(",
"this",
".",
"type",
"[",
"i",
"]",
",",
"value",
"[",
"i",
"]",
")",
")",
";",
"}",
"else",
"{",
"val",
".",
"push",
"(",
"coerce",
"(",
"this",
".",
"type",
"[",
"i",
"]",
",",
"value",
")",
")",
";",
"}",
"}",
"return",
"key",
"+",
"space",
"+",
"val",
".",
"join",
"(",
"space",
")",
";",
"}"
] | Encode a type value back to a string suitable for
writing to a configuration file. | [
"Encode",
"a",
"type",
"value",
"back",
"to",
"a",
"string",
"suitable",
"for",
"writing",
"to",
"a",
"configuration",
"file",
"."
] | 97c5e2e77e1601c879a62dfc2d500df537eaaddd | https://github.com/redisjs/jsr-conf/blob/97c5e2e77e1601c879a62dfc2d500df537eaaddd/lib/type/typedef.js#L86-L157 |
53,323 | skerit/alchemy | lib/class/conduit.js | qualityCmp | function qualityCmp(a, b) {
if (a.quality === b.quality) {
return 0;
} else if (a.quality < b.quality) {
return 1;
} else {
return -1;
}
} | javascript | function qualityCmp(a, b) {
if (a.quality === b.quality) {
return 0;
} else if (a.quality < b.quality) {
return 1;
} else {
return -1;
}
} | [
"function",
"qualityCmp",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
".",
"quality",
"===",
"b",
".",
"quality",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"a",
".",
"quality",
"<",
"b",
".",
"quality",
")",
"{",
"return",
"1",
";",
"}",
"else",
"{",
"return",
"-",
"1",
";",
"}",
"}"
] | Sort the parsed accept-language header array
@author Jelle De Loecker <[email protected]>
@since 0.0.1
@version 0.0.1
@param {Object} a
@param {Object} b | [
"Sort",
"the",
"parsed",
"accept",
"-",
"language",
"header",
"array"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/class/conduit.js#L365-L373 |
53,324 | skerit/alchemy | lib/class/conduit.js | parseEncoding | function parseEncoding(s, i) {
var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/);
if (!match) return null;
var encoding = match[1];
var q = 1;
if (match[2]) {
var params = match[2].split(';');
for (var i = 0; i < params.length; i ++) {
var p = params[i].trim().split('=');
if (p[0] === 'q') {
q = parseFloat(p[1]);
break;
}
}
}
return {
encoding: encoding,
q: q,
i: i
};
} | javascript | function parseEncoding(s, i) {
var match = s.match(/^\s*(\S+?)\s*(?:;(.*))?$/);
if (!match) return null;
var encoding = match[1];
var q = 1;
if (match[2]) {
var params = match[2].split(';');
for (var i = 0; i < params.length; i ++) {
var p = params[i].trim().split('=');
if (p[0] === 'q') {
q = parseFloat(p[1]);
break;
}
}
}
return {
encoding: encoding,
q: q,
i: i
};
} | [
"function",
"parseEncoding",
"(",
"s",
",",
"i",
")",
"{",
"var",
"match",
"=",
"s",
".",
"match",
"(",
"/",
"^\\s*(\\S+?)\\s*(?:;(.*))?$",
"/",
")",
";",
"if",
"(",
"!",
"match",
")",
"return",
"null",
";",
"var",
"encoding",
"=",
"match",
"[",
"1",
"]",
";",
"var",
"q",
"=",
"1",
";",
"if",
"(",
"match",
"[",
"2",
"]",
")",
"{",
"var",
"params",
"=",
"match",
"[",
"2",
"]",
".",
"split",
"(",
"';'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"params",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"p",
"=",
"params",
"[",
"i",
"]",
".",
"trim",
"(",
")",
".",
"split",
"(",
"'='",
")",
";",
"if",
"(",
"p",
"[",
"0",
"]",
"===",
"'q'",
")",
"{",
"q",
"=",
"parseFloat",
"(",
"p",
"[",
"1",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"{",
"encoding",
":",
"encoding",
",",
"q",
":",
"q",
",",
"i",
":",
"i",
"}",
";",
"}"
] | Parses accept-encoding strings
@author jshttp
@author Jelle De Loecker <[email protected]>
@since 0.2.0
@version 0.2.0 | [
"Parses",
"accept",
"-",
"encoding",
"strings"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/class/conduit.js#L446-L469 |
53,325 | skerit/alchemy | lib/class/conduit.js | getMagic | function getMagic() {
var mmmagic;
if (magic || magic === false) {
return magic;
}
// Get mmmagic module
mmmagic = alchemy.use('mmmagic')
if (mmmagic) {
magic = new mmmagic.Magic(mmmagic.MAGIC_MIME_TYPE);
} else {
log.error('Could not load mmmagic module');
magic = false;
}
return magic;
} | javascript | function getMagic() {
var mmmagic;
if (magic || magic === false) {
return magic;
}
// Get mmmagic module
mmmagic = alchemy.use('mmmagic')
if (mmmagic) {
magic = new mmmagic.Magic(mmmagic.MAGIC_MIME_TYPE);
} else {
log.error('Could not load mmmagic module');
magic = false;
}
return magic;
} | [
"function",
"getMagic",
"(",
")",
"{",
"var",
"mmmagic",
";",
"if",
"(",
"magic",
"||",
"magic",
"===",
"false",
")",
"{",
"return",
"magic",
";",
"}",
"// Get mmmagic module",
"mmmagic",
"=",
"alchemy",
".",
"use",
"(",
"'mmmagic'",
")",
"if",
"(",
"mmmagic",
")",
"{",
"magic",
"=",
"new",
"mmmagic",
".",
"Magic",
"(",
"mmmagic",
".",
"MAGIC_MIME_TYPE",
")",
";",
"}",
"else",
"{",
"log",
".",
"error",
"(",
"'Could not load mmmagic module'",
")",
";",
"magic",
"=",
"false",
";",
"}",
"return",
"magic",
";",
"}"
] | Get the magic mimetype function
@author Jelle De Loecker <[email protected]>
@since 0.3.0
@version 0.3.0 | [
"Get",
"the",
"magic",
"mimetype",
"function"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/class/conduit.js#L2102-L2121 |
53,326 | hydrojs/doc | index.js | indent | function indent(node) {
var next = node;
var i = 0;
while (next) {
++i;
next = next.suite || next.parent;
}
return Array(i).join(' ');
} | javascript | function indent(node) {
var next = node;
var i = 0;
while (next) {
++i;
next = next.suite || next.parent;
}
return Array(i).join(' ');
} | [
"function",
"indent",
"(",
"node",
")",
"{",
"var",
"next",
"=",
"node",
";",
"var",
"i",
"=",
"0",
";",
"while",
"(",
"next",
")",
"{",
"++",
"i",
";",
"next",
"=",
"next",
".",
"suite",
"||",
"next",
".",
"parent",
";",
"}",
"return",
"Array",
"(",
"i",
")",
".",
"join",
"(",
"' '",
")",
";",
"}"
] | Return indent for suite|test.
@param {Suite|Test} node
@returns {String}
@api private | [
"Return",
"indent",
"for",
"suite|test",
"."
] | 59741051489a97c4800f9ee362110a263a274cd0 | https://github.com/hydrojs/doc/blob/59741051489a97c4800f9ee362110a263a274cd0/index.js#L15-L23 |
53,327 | blacksmithstudio/blockbase-express | driver.js | route | function route() {
configure()
middlewares()
for (let route of config.routes) {
if (route.type === 'view')
server[route.method](route.src, (req, res) => {
res.render(`${app.root}/views/${route.dest}.twig`, {})
})
if (route.type === 'controller') {
let [path, method] = route.dest.split('::')
let controller = function () {
if (!app.controllers)
return require(`${app.root}/controllers/${path.replace('.', '/')}`)(app)
if (path.split('.').length > 1)
return app.controllers[path.split('.')[0]][path.split('.')[1]]
else
return app.controllers[path]
}()
let func = wrapper(controller[method])
if (!func)
app.drivers.logger.error('blockbase-express - wrapper', `Undefined function ${controller}${method}`)
if (route.method === 'post' || route.method === 'put')
server[route.method](route.src, upload.any(), func)
else
server[route.method](route.src, func)
}
}
errors()
} | javascript | function route() {
configure()
middlewares()
for (let route of config.routes) {
if (route.type === 'view')
server[route.method](route.src, (req, res) => {
res.render(`${app.root}/views/${route.dest}.twig`, {})
})
if (route.type === 'controller') {
let [path, method] = route.dest.split('::')
let controller = function () {
if (!app.controllers)
return require(`${app.root}/controllers/${path.replace('.', '/')}`)(app)
if (path.split('.').length > 1)
return app.controllers[path.split('.')[0]][path.split('.')[1]]
else
return app.controllers[path]
}()
let func = wrapper(controller[method])
if (!func)
app.drivers.logger.error('blockbase-express - wrapper', `Undefined function ${controller}${method}`)
if (route.method === 'post' || route.method === 'put')
server[route.method](route.src, upload.any(), func)
else
server[route.method](route.src, func)
}
}
errors()
} | [
"function",
"route",
"(",
")",
"{",
"configure",
"(",
")",
"middlewares",
"(",
")",
"for",
"(",
"let",
"route",
"of",
"config",
".",
"routes",
")",
"{",
"if",
"(",
"route",
".",
"type",
"===",
"'view'",
")",
"server",
"[",
"route",
".",
"method",
"]",
"(",
"route",
".",
"src",
",",
"(",
"req",
",",
"res",
")",
"=>",
"{",
"res",
".",
"render",
"(",
"`",
"${",
"app",
".",
"root",
"}",
"${",
"route",
".",
"dest",
"}",
"`",
",",
"{",
"}",
")",
"}",
")",
"if",
"(",
"route",
".",
"type",
"===",
"'controller'",
")",
"{",
"let",
"[",
"path",
",",
"method",
"]",
"=",
"route",
".",
"dest",
".",
"split",
"(",
"'::'",
")",
"let",
"controller",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"app",
".",
"controllers",
")",
"return",
"require",
"(",
"`",
"${",
"app",
".",
"root",
"}",
"${",
"path",
".",
"replace",
"(",
"'.'",
",",
"'/'",
")",
"}",
"`",
")",
"(",
"app",
")",
"if",
"(",
"path",
".",
"split",
"(",
"'.'",
")",
".",
"length",
">",
"1",
")",
"return",
"app",
".",
"controllers",
"[",
"path",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"]",
"[",
"path",
".",
"split",
"(",
"'.'",
")",
"[",
"1",
"]",
"]",
"else",
"return",
"app",
".",
"controllers",
"[",
"path",
"]",
"}",
"(",
")",
"let",
"func",
"=",
"wrapper",
"(",
"controller",
"[",
"method",
"]",
")",
"if",
"(",
"!",
"func",
")",
"app",
".",
"drivers",
".",
"logger",
".",
"error",
"(",
"'blockbase-express - wrapper'",
",",
"`",
"${",
"controller",
"}",
"${",
"method",
"}",
"`",
")",
"if",
"(",
"route",
".",
"method",
"===",
"'post'",
"||",
"route",
".",
"method",
"===",
"'put'",
")",
"server",
"[",
"route",
".",
"method",
"]",
"(",
"route",
".",
"src",
",",
"upload",
".",
"any",
"(",
")",
",",
"func",
")",
"else",
"server",
"[",
"route",
".",
"method",
"]",
"(",
"route",
".",
"src",
",",
"func",
")",
"}",
"}",
"errors",
"(",
")",
"}"
] | Initialize the routes | [
"Initialize",
"the",
"routes"
] | b9d9fb710122f38a84090f47a4bb987d07f1adc4 | https://github.com/blacksmithstudio/blockbase-express/blob/b9d9fb710122f38a84090f47a4bb987d07f1adc4/driver.js#L66-L102 |
53,328 | blacksmithstudio/blockbase-express | driver.js | errors | function errors() {
// handling 404 errors from config.express['404_redirect'] property
if (config['404_redirect']) {
server.use(function (req, res, next) {
res.status(302)
res.writeHead(302, { 'Location': config['404_redirect'] })
res.end()
})
} else {
server.use(function (req, res, next) {
res.status(404).send({ message: 'not found' })
})
}
if (errorHandlers.length) {
for (let eh of errorHandlers) {
server.use(wrapper(eh))
}
}
//Default error handler
server.use((err, req, res, next) => {
if (!config.silent && !errorHandlers.length)
app.drivers.logger.error('Unhandled server error', err)
res.status(500)
.json({
message: err.message,
stack: process.env.NODE_ENV === 'production' ? undefined : err.stack
})
})
} | javascript | function errors() {
// handling 404 errors from config.express['404_redirect'] property
if (config['404_redirect']) {
server.use(function (req, res, next) {
res.status(302)
res.writeHead(302, { 'Location': config['404_redirect'] })
res.end()
})
} else {
server.use(function (req, res, next) {
res.status(404).send({ message: 'not found' })
})
}
if (errorHandlers.length) {
for (let eh of errorHandlers) {
server.use(wrapper(eh))
}
}
//Default error handler
server.use((err, req, res, next) => {
if (!config.silent && !errorHandlers.length)
app.drivers.logger.error('Unhandled server error', err)
res.status(500)
.json({
message: err.message,
stack: process.env.NODE_ENV === 'production' ? undefined : err.stack
})
})
} | [
"function",
"errors",
"(",
")",
"{",
"// handling 404 errors from config.express['404_redirect'] property",
"if",
"(",
"config",
"[",
"'404_redirect'",
"]",
")",
"{",
"server",
".",
"use",
"(",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"res",
".",
"status",
"(",
"302",
")",
"res",
".",
"writeHead",
"(",
"302",
",",
"{",
"'Location'",
":",
"config",
"[",
"'404_redirect'",
"]",
"}",
")",
"res",
".",
"end",
"(",
")",
"}",
")",
"}",
"else",
"{",
"server",
".",
"use",
"(",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"res",
".",
"status",
"(",
"404",
")",
".",
"send",
"(",
"{",
"message",
":",
"'not found'",
"}",
")",
"}",
")",
"}",
"if",
"(",
"errorHandlers",
".",
"length",
")",
"{",
"for",
"(",
"let",
"eh",
"of",
"errorHandlers",
")",
"{",
"server",
".",
"use",
"(",
"wrapper",
"(",
"eh",
")",
")",
"}",
"}",
"//Default error handler",
"server",
".",
"use",
"(",
"(",
"err",
",",
"req",
",",
"res",
",",
"next",
")",
"=>",
"{",
"if",
"(",
"!",
"config",
".",
"silent",
"&&",
"!",
"errorHandlers",
".",
"length",
")",
"app",
".",
"drivers",
".",
"logger",
".",
"error",
"(",
"'Unhandled server error'",
",",
"err",
")",
"res",
".",
"status",
"(",
"500",
")",
".",
"json",
"(",
"{",
"message",
":",
"err",
".",
"message",
",",
"stack",
":",
"process",
".",
"env",
".",
"NODE_ENV",
"===",
"'production'",
"?",
"undefined",
":",
"err",
".",
"stack",
"}",
")",
"}",
")",
"}"
] | Register error handlers | [
"Register",
"error",
"handlers"
] | b9d9fb710122f38a84090f47a4bb987d07f1adc4 | https://github.com/blacksmithstudio/blockbase-express/blob/b9d9fb710122f38a84090f47a4bb987d07f1adc4/driver.js#L107-L137 |
53,329 | redisjs/jsr-store | lib/command/set.js | sadd | function sadd(key /* member-1, member-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, val = this.getKey(key, req);
if(val === undefined) {
val = new Set();
this.setKey(key, val, undefined, undefined, undefined, req);
}
return val.sadd(args);
} | javascript | function sadd(key /* member-1, member-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, val = this.getKey(key, req);
if(val === undefined) {
val = new Set();
this.setKey(key, val, undefined, undefined, undefined, req);
}
return val.sadd(args);
} | [
"function",
"sadd",
"(",
"key",
"/* member-1, member-N, req */",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
".",
"pop",
"(",
")",
":",
"null",
",",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"{",
"val",
"=",
"new",
"Set",
"(",
")",
";",
"this",
".",
"setKey",
"(",
"key",
",",
"val",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"}",
"return",
"val",
".",
"sadd",
"(",
"args",
")",
";",
"}"
] | Add the specified members to the set stored at key. | [
"Add",
"the",
"specified",
"members",
"to",
"the",
"set",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L7-L16 |
53,330 | redisjs/jsr-store | lib/command/set.js | smembers | function smembers(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return [];
return val.data;
} | javascript | function smembers(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return [];
return val.data;
} | [
"function",
"smembers",
"(",
"key",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"[",
"]",
";",
"return",
"val",
".",
"data",
";",
"}"
] | Returns all the members of the set value stored at key. | [
"Returns",
"all",
"the",
"members",
"of",
"the",
"set",
"value",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L44-L48 |
53,331 | redisjs/jsr-store | lib/command/set.js | sismember | function sismember(key, member, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.sismember(member);
} | javascript | function sismember(key, member, req) {
var val = this.getKey(key, req);
if(val === undefined) return 0;
return val.sismember(member);
} | [
"function",
"sismember",
"(",
"key",
",",
"member",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"0",
";",
"return",
"val",
".",
"sismember",
"(",
"member",
")",
";",
"}"
] | Returns if member is a member of the set stored at key. | [
"Returns",
"if",
"member",
"is",
"a",
"member",
"of",
"the",
"set",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L53-L57 |
53,332 | redisjs/jsr-store | lib/command/set.js | spop | function spop(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
var element = val.spop();
if(val.scard() === 0) {
this.delKey(key, req);
}
return element;
} | javascript | function spop(key, req) {
var val = this.getKey(key, req);
if(val === undefined) return null;
var element = val.spop();
if(val.scard() === 0) {
this.delKey(key, req);
}
return element;
} | [
"function",
"spop",
"(",
"key",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"null",
";",
"var",
"element",
"=",
"val",
".",
"spop",
"(",
")",
";",
"if",
"(",
"val",
".",
"scard",
"(",
")",
"===",
"0",
")",
"{",
"this",
".",
"delKey",
"(",
"key",
",",
"req",
")",
";",
"}",
"return",
"element",
";",
"}"
] | Removes and returns a random element from the set value
stored at key. | [
"Removes",
"and",
"returns",
"a",
"random",
"element",
"from",
"the",
"set",
"value",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L63-L71 |
53,333 | redisjs/jsr-store | lib/command/set.js | srem | function srem(key /* member-1, member-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, val = this.getKey(key, req);
if(val === undefined) return 0;
var deleted = val.srem(args);
if(val.scard() === 0) {
this.delKey(key, req);
}
return deleted;
} | javascript | function srem(key /* member-1, member-N, req */) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, val = this.getKey(key, req);
if(val === undefined) return 0;
var deleted = val.srem(args);
if(val.scard() === 0) {
this.delKey(key, req);
}
return deleted;
} | [
"function",
"srem",
"(",
"key",
"/* member-1, member-N, req */",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
".",
"pop",
"(",
")",
":",
"null",
",",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"val",
"===",
"undefined",
")",
"return",
"0",
";",
"var",
"deleted",
"=",
"val",
".",
"srem",
"(",
"args",
")",
";",
"if",
"(",
"val",
".",
"scard",
"(",
")",
"===",
"0",
")",
"{",
"this",
".",
"delKey",
"(",
"key",
",",
"req",
")",
";",
"}",
"return",
"deleted",
";",
"}"
] | Remove the specified members from the set stored at key. | [
"Remove",
"the",
"specified",
"members",
"from",
"the",
"set",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L76-L86 |
53,334 | redisjs/jsr-store | lib/command/set.js | smove | function smove(source, destination, member, req) {
var src = this.getKey(source, req)
, dest = this.getKey(destination, req);
if(src === undefined || !src.sismember(member)) return 0;
if(dest === undefined) {
dest = new Set();
this.setKey(destination, dest, undefined, undefined, undefined, req);
}
//console.dir(member);
src.delKey(member);
dest.sadd([member]);
if(src.scard() === 0) {
this.delKey(source, req);
}
return 1;
} | javascript | function smove(source, destination, member, req) {
var src = this.getKey(source, req)
, dest = this.getKey(destination, req);
if(src === undefined || !src.sismember(member)) return 0;
if(dest === undefined) {
dest = new Set();
this.setKey(destination, dest, undefined, undefined, undefined, req);
}
//console.dir(member);
src.delKey(member);
dest.sadd([member]);
if(src.scard() === 0) {
this.delKey(source, req);
}
return 1;
} | [
"function",
"smove",
"(",
"source",
",",
"destination",
",",
"member",
",",
"req",
")",
"{",
"var",
"src",
"=",
"this",
".",
"getKey",
"(",
"source",
",",
"req",
")",
",",
"dest",
"=",
"this",
".",
"getKey",
"(",
"destination",
",",
"req",
")",
";",
"if",
"(",
"src",
"===",
"undefined",
"||",
"!",
"src",
".",
"sismember",
"(",
"member",
")",
")",
"return",
"0",
";",
"if",
"(",
"dest",
"===",
"undefined",
")",
"{",
"dest",
"=",
"new",
"Set",
"(",
")",
";",
"this",
".",
"setKey",
"(",
"destination",
",",
"dest",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"}",
"//console.dir(member);",
"src",
".",
"delKey",
"(",
"member",
")",
";",
"dest",
".",
"sadd",
"(",
"[",
"member",
"]",
")",
";",
"if",
"(",
"src",
".",
"scard",
"(",
")",
"===",
"0",
")",
"{",
"this",
".",
"delKey",
"(",
"source",
",",
"req",
")",
";",
"}",
"return",
"1",
";",
"}"
] | Move member from the set at source to the set at destination. | [
"Move",
"member",
"from",
"the",
"set",
"at",
"source",
"to",
"the",
"set",
"at",
"destination",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L91-L106 |
53,335 | redisjs/jsr-store | lib/command/set.js | sunion | function sunion(/* key-1, key-N, req*/) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, set
, src
, i;
set = new Set();
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) continue;
set.sadd(src.data);
}
return set.data;
} | javascript | function sunion(/* key-1, key-N, req*/) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, set
, src
, i;
set = new Set();
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) continue;
set.sadd(src.data);
}
return set.data;
} | [
"function",
"sunion",
"(",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
".",
"pop",
"(",
")",
":",
"null",
",",
"set",
",",
"src",
",",
"i",
";",
"set",
"=",
"new",
"Set",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"src",
"=",
"this",
".",
"getKey",
"(",
"args",
"[",
"i",
"]",
",",
"req",
")",
";",
"if",
"(",
"src",
"===",
"undefined",
")",
"continue",
";",
"set",
".",
"sadd",
"(",
"src",
".",
"data",
")",
";",
"}",
"return",
"set",
".",
"data",
";",
"}"
] | Returns the members of the set resulting from the union
of all the given sets. | [
"Returns",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"union",
"of",
"all",
"the",
"given",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L112-L125 |
53,336 | redisjs/jsr-store | lib/command/set.js | sunionstore | function sunionstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object'
? args[args.length - 1] : null;
var list = this.sunion.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefined, undefined, req);
}
return list.length;
} | javascript | function sunionstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length-1] === 'object'
? args[args.length - 1] : null;
var list = this.sunion.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefined, undefined, req);
}
return list.length;
} | [
"function",
"sunionstore",
"(",
"destination",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
":",
"null",
";",
"var",
"list",
"=",
"this",
".",
"sunion",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"if",
"(",
"list",
".",
"length",
")",
"{",
"this",
".",
"setKey",
"(",
"destination",
",",
"new",
"Set",
"(",
"list",
")",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"}",
"return",
"list",
".",
"length",
";",
"}"
] | Stores the members of the set resulting from the union
of all the given sets. | [
"Stores",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"union",
"of",
"all",
"the",
"given",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L131-L141 |
53,337 | redisjs/jsr-store | lib/command/set.js | sinter | function sinter(/* key-1, key-N, req*/) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, set = new Set()
, list
, src
, i;
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) return [];
set.sadd(src.data);
}
list = set.data.slice(0);
function filter(member) {
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i]);
if(!src.sismember(member)) return false;
}
return true;
}
list = list.filter(filter.bind(this));
return list;
} | javascript | function sinter(/* key-1, key-N, req*/) {
var args = slice.call(arguments, 0)
, req = typeof args[args.length-1] === 'object' ? args.pop() : null
, set = new Set()
, list
, src
, i;
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) return [];
set.sadd(src.data);
}
list = set.data.slice(0);
function filter(member) {
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i]);
if(!src.sismember(member)) return false;
}
return true;
}
list = list.filter(filter.bind(this));
return list;
} | [
"function",
"sinter",
"(",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
".",
"pop",
"(",
")",
":",
"null",
",",
"set",
"=",
"new",
"Set",
"(",
")",
",",
"list",
",",
"src",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"src",
"=",
"this",
".",
"getKey",
"(",
"args",
"[",
"i",
"]",
",",
"req",
")",
";",
"if",
"(",
"src",
"===",
"undefined",
")",
"return",
"[",
"]",
";",
"set",
".",
"sadd",
"(",
"src",
".",
"data",
")",
";",
"}",
"list",
"=",
"set",
".",
"data",
".",
"slice",
"(",
"0",
")",
";",
"function",
"filter",
"(",
"member",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"src",
"=",
"this",
".",
"getKey",
"(",
"args",
"[",
"i",
"]",
")",
";",
"if",
"(",
"!",
"src",
".",
"sismember",
"(",
"member",
")",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"list",
"=",
"list",
".",
"filter",
"(",
"filter",
".",
"bind",
"(",
"this",
")",
")",
";",
"return",
"list",
";",
"}"
] | Returns the members of the set resulting from the intersection
of all the given sets. | [
"Returns",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"intersection",
"of",
"all",
"the",
"given",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L147-L174 |
53,338 | redisjs/jsr-store | lib/command/set.js | sinterstore | function sinterstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args[args.length - 1] : null;
var list = this.sinter.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefined, undefined, req);
}
return list.length;
} | javascript | function sinterstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args[args.length - 1] : null;
var list = this.sinter.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefined, undefined, req);
}
return list.length;
} | [
"function",
"sinterstore",
"(",
"destination",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
":",
"null",
";",
"var",
"list",
"=",
"this",
".",
"sinter",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"if",
"(",
"list",
".",
"length",
")",
"{",
"this",
".",
"setKey",
"(",
"destination",
",",
"new",
"Set",
"(",
"list",
")",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"}",
"return",
"list",
".",
"length",
";",
"}"
] | Stores the members of the set resulting from the intersection
of all the given sets. | [
"Stores",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"intersection",
"of",
"all",
"the",
"given",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L180-L190 |
53,339 | redisjs/jsr-store | lib/command/set.js | sdiff | function sdiff(key /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object' ? args.pop() : null
, set = this.getKey(key, req)
, list
, src
, j
, i;
if(!set) return [];
list = set.data.slice(0);
for(j = 0;j < list.length;j++) {
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) continue;
if(src.sismember(list[j])) {
list.splice(j, 1);
j--;
break;
}
}
}
return list;
} | javascript | function sdiff(key /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object' ? args.pop() : null
, set = this.getKey(key, req)
, list
, src
, j
, i;
if(!set) return [];
list = set.data.slice(0);
for(j = 0;j < list.length;j++) {
for(i = 0;i < args.length;i++) {
src = this.getKey(args[i], req);
if(src === undefined) continue;
if(src.sismember(list[j])) {
list.splice(j, 1);
j--;
break;
}
}
}
return list;
} | [
"function",
"sdiff",
"(",
"key",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
".",
"pop",
"(",
")",
":",
"null",
",",
"set",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
",",
"list",
",",
"src",
",",
"j",
",",
"i",
";",
"if",
"(",
"!",
"set",
")",
"return",
"[",
"]",
";",
"list",
"=",
"set",
".",
"data",
".",
"slice",
"(",
"0",
")",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"list",
".",
"length",
";",
"j",
"++",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"src",
"=",
"this",
".",
"getKey",
"(",
"args",
"[",
"i",
"]",
",",
"req",
")",
";",
"if",
"(",
"src",
"===",
"undefined",
")",
"continue",
";",
"if",
"(",
"src",
".",
"sismember",
"(",
"list",
"[",
"j",
"]",
")",
")",
"{",
"list",
".",
"splice",
"(",
"j",
",",
"1",
")",
";",
"j",
"--",
";",
"break",
";",
"}",
"}",
"}",
"return",
"list",
";",
"}"
] | Returns the members of the set resulting from the difference
between the first set and successive sets. | [
"Returns",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"difference",
"between",
"the",
"first",
"set",
"and",
"successive",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L196-L222 |
53,340 | redisjs/jsr-store | lib/command/set.js | sdiffstore | function sdiffstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args[args.length - 1] : null;
var list = this.sdiff.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefined, undefined, req);
}
return list.length;
} | javascript | function sdiffstore(destination /* key-1, key-N, req*/) {
var args = slice.call(arguments, 1)
, req = typeof args[args.length - 1] === 'object'
? args[args.length - 1] : null;
var list = this.sdiff.apply(this, args);
if(list.length) {
this.setKey(
destination, new Set(list), undefined, undefined, undefined, req);
}
return list.length;
} | [
"function",
"sdiffstore",
"(",
"destination",
"/* key-1, key-N, req*/",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"req",
"=",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
":",
"null",
";",
"var",
"list",
"=",
"this",
".",
"sdiff",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"if",
"(",
"list",
".",
"length",
")",
"{",
"this",
".",
"setKey",
"(",
"destination",
",",
"new",
"Set",
"(",
"list",
")",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"}",
"return",
"list",
".",
"length",
";",
"}"
] | Stores the members of the set resulting from the difference
between the first set and successive sets. | [
"Stores",
"the",
"members",
"of",
"the",
"set",
"resulting",
"from",
"the",
"difference",
"between",
"the",
"first",
"set",
"and",
"successive",
"sets",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/set.js#L228-L238 |
53,341 | wunderbyte/grunt-spiritual-dox | tasks/spiritualdox.js | existence | function existence ( filepath ) {
var does = grunt.file.exists ( filepath );
if ( !does ) {
grunt.log.warn ( filepath + " not found." );
}
return does;
} | javascript | function existence ( filepath ) {
var does = grunt.file.exists ( filepath );
if ( !does ) {
grunt.log.warn ( filepath + " not found." );
}
return does;
} | [
"function",
"existence",
"(",
"filepath",
")",
"{",
"var",
"does",
"=",
"grunt",
".",
"file",
".",
"exists",
"(",
"filepath",
")",
";",
"if",
"(",
"!",
"does",
")",
"{",
"grunt",
".",
"log",
".",
"warn",
"(",
"filepath",
"+",
"\" not found.\"",
")",
";",
"}",
"return",
"does",
";",
"}"
] | Check file existence.
@param {String} filepath
@returns {boolean} | [
"Check",
"file",
"existence",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/tasks/spiritualdox.js#L113-L119 |
53,342 | 0of/ver-iterator | lib/git.js | clone | function clone(url, dir) {
_child_process2['default'].execSync('git clone ' + url, { cwd: _path2['default'].resolve(dir) });
} | javascript | function clone(url, dir) {
_child_process2['default'].execSync('git clone ' + url, { cwd: _path2['default'].resolve(dir) });
} | [
"function",
"clone",
"(",
"url",
",",
"dir",
")",
"{",
"_child_process2",
"[",
"'default'",
"]",
".",
"execSync",
"(",
"'git clone '",
"+",
"url",
",",
"{",
"cwd",
":",
"_path2",
"[",
"'default'",
"]",
".",
"resolve",
"(",
"dir",
")",
"}",
")",
";",
"}"
] | git clone from specific URL
@param {String} [url] git repo URL
@param {String} [dir] the dir the repo cloned into
@public | [
"git",
"clone",
"from",
"specific",
"URL"
] | a51726c02dfd14488190860f4d90903574ed8e37 | https://github.com/0of/ver-iterator/blob/a51726c02dfd14488190860f4d90903574ed8e37/lib/git.js#L30-L32 |
53,343 | 0of/ver-iterator | lib/git.js | listTags | function listTags(localRepoDir) {
var stdout = _child_process2['default'].execSync('git tag -l', { cwd: _path2['default'].resolve(localRepoDir) });
return stdout.toString().match(/[^\r\n]+/g).filter(function (v) {
return v.length !== 0;
}).map(function (v) {
return v.trim();
});
} | javascript | function listTags(localRepoDir) {
var stdout = _child_process2['default'].execSync('git tag -l', { cwd: _path2['default'].resolve(localRepoDir) });
return stdout.toString().match(/[^\r\n]+/g).filter(function (v) {
return v.length !== 0;
}).map(function (v) {
return v.trim();
});
} | [
"function",
"listTags",
"(",
"localRepoDir",
")",
"{",
"var",
"stdout",
"=",
"_child_process2",
"[",
"'default'",
"]",
".",
"execSync",
"(",
"'git tag -l'",
",",
"{",
"cwd",
":",
"_path2",
"[",
"'default'",
"]",
".",
"resolve",
"(",
"localRepoDir",
")",
"}",
")",
";",
"return",
"stdout",
".",
"toString",
"(",
")",
".",
"match",
"(",
"/",
"[^\\r\\n]+",
"/",
"g",
")",
".",
"filter",
"(",
"function",
"(",
"v",
")",
"{",
"return",
"v",
".",
"length",
"!==",
"0",
";",
"}",
")",
".",
"map",
"(",
"function",
"(",
"v",
")",
"{",
"return",
"v",
".",
"trim",
"(",
")",
";",
"}",
")",
";",
"}"
] | git list all the tags
@param {String} [localRepoDir] local repo dir
@public | [
"git",
"list",
"all",
"the",
"tags"
] | a51726c02dfd14488190860f4d90903574ed8e37 | https://github.com/0of/ver-iterator/blob/a51726c02dfd14488190860f4d90903574ed8e37/lib/git.js#L40-L47 |
53,344 | NicolasBoyer/wapitis | index.js | buildIndexFile | function buildIndexFile(isProd) {
return new Promise((resolve) => {
files.readFile(path.resolve(__dirname, ".includes/index.html"), (err, html) => {
if (err) throw err;
html = html.replace("$appDesc$", wapitisConfig.appDesc);
html = html.replace("$themeColor$", wapitisConfig.themeColor);
html = html.replace("$appName$", wapitisConfig.appName);
if (isProd) {
const quantumFile = JSON.parse(files.readFileSync(completeDistPath + "/quantum.json", "utf8"));
html = html.replace("$bundle$", `<script src="${quantumFile.bundle.relativePath}"></script>`);
files.remove(completeDistPath + "/quantum.json");
} else html = html.replace("$bundle$", '<script src="bundle.js"></script>');
files.appendFile(completeDistPath + "/index.html", html, true).then(() => resolve());
});
});
} | javascript | function buildIndexFile(isProd) {
return new Promise((resolve) => {
files.readFile(path.resolve(__dirname, ".includes/index.html"), (err, html) => {
if (err) throw err;
html = html.replace("$appDesc$", wapitisConfig.appDesc);
html = html.replace("$themeColor$", wapitisConfig.themeColor);
html = html.replace("$appName$", wapitisConfig.appName);
if (isProd) {
const quantumFile = JSON.parse(files.readFileSync(completeDistPath + "/quantum.json", "utf8"));
html = html.replace("$bundle$", `<script src="${quantumFile.bundle.relativePath}"></script>`);
files.remove(completeDistPath + "/quantum.json");
} else html = html.replace("$bundle$", '<script src="bundle.js"></script>');
files.appendFile(completeDistPath + "/index.html", html, true).then(() => resolve());
});
});
} | [
"function",
"buildIndexFile",
"(",
"isProd",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
")",
"=>",
"{",
"files",
".",
"readFile",
"(",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"\".includes/index.html\"",
")",
",",
"(",
"err",
",",
"html",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"throw",
"err",
";",
"html",
"=",
"html",
".",
"replace",
"(",
"\"$appDesc$\"",
",",
"wapitisConfig",
".",
"appDesc",
")",
";",
"html",
"=",
"html",
".",
"replace",
"(",
"\"$themeColor$\"",
",",
"wapitisConfig",
".",
"themeColor",
")",
";",
"html",
"=",
"html",
".",
"replace",
"(",
"\"$appName$\"",
",",
"wapitisConfig",
".",
"appName",
")",
";",
"if",
"(",
"isProd",
")",
"{",
"const",
"quantumFile",
"=",
"JSON",
".",
"parse",
"(",
"files",
".",
"readFileSync",
"(",
"completeDistPath",
"+",
"\"/quantum.json\"",
",",
"\"utf8\"",
")",
")",
";",
"html",
"=",
"html",
".",
"replace",
"(",
"\"$bundle$\"",
",",
"`",
"${",
"quantumFile",
".",
"bundle",
".",
"relativePath",
"}",
"`",
")",
";",
"files",
".",
"remove",
"(",
"completeDistPath",
"+",
"\"/quantum.json\"",
")",
";",
"}",
"else",
"html",
"=",
"html",
".",
"replace",
"(",
"\"$bundle$\"",
",",
"'<script src=\"bundle.js\"></script>'",
")",
";",
"files",
".",
"appendFile",
"(",
"completeDistPath",
"+",
"\"/index.html\"",
",",
"html",
",",
"true",
")",
".",
"then",
"(",
"(",
")",
"=>",
"resolve",
"(",
")",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Modify index file | [
"Modify",
"index",
"file"
] | e173c67f07b94f0c6b27b521f1113830a1f10302 | https://github.com/NicolasBoyer/wapitis/blob/e173c67f07b94f0c6b27b521f1113830a1f10302/index.js#L139-L154 |
53,345 | andrewscwei/requiem | src/dom/getChildRegistry.js | getChildRegistry | function getChildRegistry(element, findClosest) {
assert((element === window) || (element instanceof Node) || !element, 'Invalid element specified');
assertType(findClosest, 'boolean', true, `The parameter 'findClosest', if specified, must be a boolean value`);
if (!element || element === document || element === document.body) element = window;
if (element === window) {
if (!window.__private__) window.__private__ = {};
if (window.__private__.childRegistry === undefined) window.__private__.childRegistry = {};
}
if (element.__private__ && element.__private__.childRegistry) {
return element.__private__.childRegistry;
}
else if (findClosest === true) {
return getChildRegistry(element.parentNode);
}
else {
return null;
}
} | javascript | function getChildRegistry(element, findClosest) {
assert((element === window) || (element instanceof Node) || !element, 'Invalid element specified');
assertType(findClosest, 'boolean', true, `The parameter 'findClosest', if specified, must be a boolean value`);
if (!element || element === document || element === document.body) element = window;
if (element === window) {
if (!window.__private__) window.__private__ = {};
if (window.__private__.childRegistry === undefined) window.__private__.childRegistry = {};
}
if (element.__private__ && element.__private__.childRegistry) {
return element.__private__.childRegistry;
}
else if (findClosest === true) {
return getChildRegistry(element.parentNode);
}
else {
return null;
}
} | [
"function",
"getChildRegistry",
"(",
"element",
",",
"findClosest",
")",
"{",
"assert",
"(",
"(",
"element",
"===",
"window",
")",
"||",
"(",
"element",
"instanceof",
"Node",
")",
"||",
"!",
"element",
",",
"'Invalid element specified'",
")",
";",
"assertType",
"(",
"findClosest",
",",
"'boolean'",
",",
"true",
",",
"`",
"`",
")",
";",
"if",
"(",
"!",
"element",
"||",
"element",
"===",
"document",
"||",
"element",
"===",
"document",
".",
"body",
")",
"element",
"=",
"window",
";",
"if",
"(",
"element",
"===",
"window",
")",
"{",
"if",
"(",
"!",
"window",
".",
"__private__",
")",
"window",
".",
"__private__",
"=",
"{",
"}",
";",
"if",
"(",
"window",
".",
"__private__",
".",
"childRegistry",
"===",
"undefined",
")",
"window",
".",
"__private__",
".",
"childRegistry",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"element",
".",
"__private__",
"&&",
"element",
".",
"__private__",
".",
"childRegistry",
")",
"{",
"return",
"element",
".",
"__private__",
".",
"childRegistry",
";",
"}",
"else",
"if",
"(",
"findClosest",
"===",
"true",
")",
"{",
"return",
"getChildRegistry",
"(",
"element",
".",
"parentNode",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Gets the global child registry.
@param {Node} [element] - Target element.
@param {Node} [findClosest] - Specifies whether to keep seeking for a child
registry upwards in the DOM tree if the
target element doesn't have one.
@return {Object} The child registry.
@alias module:requiem~dom.getChildRegistry | [
"Gets",
"the",
"global",
"child",
"registry",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getChildRegistry.js#L20-L40 |
53,346 | lang-js/translate | index.js | translate | function translate(cldr, locale, opts) {
if (typeof cldr === 'string') return augment(interpolate(cldr, opts));
opts = opts || {};
var pluralize = lookup(locale, cldr._format || opts.pluralFormat, plural);
if (Array.isArray(cldr)) cldr = convertArray(cldr, pluralize, opts);
validate(cldr, pluralize);
var paramsObj = {};
var cases = toFunctions(cldr, pluralize, opts, paramsObj);
var paramsKeys = Object.keys(paramsObj);
var key = cldr._plural_key ||
opts.pluralKey ||
discoverKey(paramsKeys,
opts.discoverableKeys || {'smart_count':1, 'count':1, 'length':1, 'items':1, 'total':1},
opts.defaultPluralKey || 'smart_count');
var validatePluralKey = opts.validatePluralKey !== false;
var silentValidation = !!opts.validatePluralSilent;
var decimal = number.decimal[locale] || number.decimal.en;
var toLocaleString = opts.toLocaleString !== false;
return augment(function(params) {
if (typeof params === 'number') params = convertSmartCount(params, key);
var count = parseInt(params[key], 10);
if (validatePluralKey && isNaN(count)) {
if (silentValidation) return [];
throw new Error('expected "' + key + '" to be a number. got "' + (typeof params[key]) + '".');
}
if (toLocaleString) params = formatNumbers(params, decimal);
return (cases[count] || cases[pluralize(count || 0)])(params);
}, paramsKeys);
} | javascript | function translate(cldr, locale, opts) {
if (typeof cldr === 'string') return augment(interpolate(cldr, opts));
opts = opts || {};
var pluralize = lookup(locale, cldr._format || opts.pluralFormat, plural);
if (Array.isArray(cldr)) cldr = convertArray(cldr, pluralize, opts);
validate(cldr, pluralize);
var paramsObj = {};
var cases = toFunctions(cldr, pluralize, opts, paramsObj);
var paramsKeys = Object.keys(paramsObj);
var key = cldr._plural_key ||
opts.pluralKey ||
discoverKey(paramsKeys,
opts.discoverableKeys || {'smart_count':1, 'count':1, 'length':1, 'items':1, 'total':1},
opts.defaultPluralKey || 'smart_count');
var validatePluralKey = opts.validatePluralKey !== false;
var silentValidation = !!opts.validatePluralSilent;
var decimal = number.decimal[locale] || number.decimal.en;
var toLocaleString = opts.toLocaleString !== false;
return augment(function(params) {
if (typeof params === 'number') params = convertSmartCount(params, key);
var count = parseInt(params[key], 10);
if (validatePluralKey && isNaN(count)) {
if (silentValidation) return [];
throw new Error('expected "' + key + '" to be a number. got "' + (typeof params[key]) + '".');
}
if (toLocaleString) params = formatNumbers(params, decimal);
return (cases[count] || cases[pluralize(count || 0)])(params);
}, paramsKeys);
} | [
"function",
"translate",
"(",
"cldr",
",",
"locale",
",",
"opts",
")",
"{",
"if",
"(",
"typeof",
"cldr",
"===",
"'string'",
")",
"return",
"augment",
"(",
"interpolate",
"(",
"cldr",
",",
"opts",
")",
")",
";",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"pluralize",
"=",
"lookup",
"(",
"locale",
",",
"cldr",
".",
"_format",
"||",
"opts",
".",
"pluralFormat",
",",
"plural",
")",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"cldr",
")",
")",
"cldr",
"=",
"convertArray",
"(",
"cldr",
",",
"pluralize",
",",
"opts",
")",
";",
"validate",
"(",
"cldr",
",",
"pluralize",
")",
";",
"var",
"paramsObj",
"=",
"{",
"}",
";",
"var",
"cases",
"=",
"toFunctions",
"(",
"cldr",
",",
"pluralize",
",",
"opts",
",",
"paramsObj",
")",
";",
"var",
"paramsKeys",
"=",
"Object",
".",
"keys",
"(",
"paramsObj",
")",
";",
"var",
"key",
"=",
"cldr",
".",
"_plural_key",
"||",
"opts",
".",
"pluralKey",
"||",
"discoverKey",
"(",
"paramsKeys",
",",
"opts",
".",
"discoverableKeys",
"||",
"{",
"'smart_count'",
":",
"1",
",",
"'count'",
":",
"1",
",",
"'length'",
":",
"1",
",",
"'items'",
":",
"1",
",",
"'total'",
":",
"1",
"}",
",",
"opts",
".",
"defaultPluralKey",
"||",
"'smart_count'",
")",
";",
"var",
"validatePluralKey",
"=",
"opts",
".",
"validatePluralKey",
"!==",
"false",
";",
"var",
"silentValidation",
"=",
"!",
"!",
"opts",
".",
"validatePluralSilent",
";",
"var",
"decimal",
"=",
"number",
".",
"decimal",
"[",
"locale",
"]",
"||",
"number",
".",
"decimal",
".",
"en",
";",
"var",
"toLocaleString",
"=",
"opts",
".",
"toLocaleString",
"!==",
"false",
";",
"return",
"augment",
"(",
"function",
"(",
"params",
")",
"{",
"if",
"(",
"typeof",
"params",
"===",
"'number'",
")",
"params",
"=",
"convertSmartCount",
"(",
"params",
",",
"key",
")",
";",
"var",
"count",
"=",
"parseInt",
"(",
"params",
"[",
"key",
"]",
",",
"10",
")",
";",
"if",
"(",
"validatePluralKey",
"&&",
"isNaN",
"(",
"count",
")",
")",
"{",
"if",
"(",
"silentValidation",
")",
"return",
"[",
"]",
";",
"throw",
"new",
"Error",
"(",
"'expected \"'",
"+",
"key",
"+",
"'\" to be a number. got \"'",
"+",
"(",
"typeof",
"params",
"[",
"key",
"]",
")",
"+",
"'\".'",
")",
";",
"}",
"if",
"(",
"toLocaleString",
")",
"params",
"=",
"formatNumbers",
"(",
"params",
",",
"decimal",
")",
";",
"return",
"(",
"cases",
"[",
"count",
"]",
"||",
"cases",
"[",
"pluralize",
"(",
"count",
"||",
"0",
")",
"]",
")",
"(",
"params",
")",
";",
"}",
",",
"paramsKeys",
")",
";",
"}"
] | Compile a translation function
@param {String|Array|Object} cldr
@param {String} locale
@param {Object?} opts
@return {Function} | [
"Compile",
"a",
"translation",
"function"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L37-L75 |
53,347 | lang-js/translate | index.js | validate | function validate(cldr, pluralize) {
pluralize.formats.forEach(function(key) {
if (!cldr[key]) throw new Error('translation object missing required key "' + key + '"');
});
} | javascript | function validate(cldr, pluralize) {
pluralize.formats.forEach(function(key) {
if (!cldr[key]) throw new Error('translation object missing required key "' + key + '"');
});
} | [
"function",
"validate",
"(",
"cldr",
",",
"pluralize",
")",
"{",
"pluralize",
".",
"formats",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"!",
"cldr",
"[",
"key",
"]",
")",
"throw",
"new",
"Error",
"(",
"'translation object missing required key \"'",
"+",
"key",
"+",
"'\"'",
")",
";",
"}",
")",
";",
"}"
] | Validate a cldr against a pluralize function
@param {Object} cldr
@param {Function} pluralize | [
"Validate",
"a",
"cldr",
"against",
"a",
"pluralize",
"function"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L84-L88 |
53,348 | lang-js/translate | index.js | toFunctions | function toFunctions(cldr, pluralize, opts, paramsObj) {
return Object.keys(cldr).reduce(function(acc, key) {
if (key.indexOf('_') === 0) return acc;
var value = cldr[key];
if (typeof value !== 'string') return acc;
var t = acc[key] = interpolate(value, opts);
merge(paramsObj, t.params);
return acc;
}, {});
} | javascript | function toFunctions(cldr, pluralize, opts, paramsObj) {
return Object.keys(cldr).reduce(function(acc, key) {
if (key.indexOf('_') === 0) return acc;
var value = cldr[key];
if (typeof value !== 'string') return acc;
var t = acc[key] = interpolate(value, opts);
merge(paramsObj, t.params);
return acc;
}, {});
} | [
"function",
"toFunctions",
"(",
"cldr",
",",
"pluralize",
",",
"opts",
",",
"paramsObj",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"cldr",
")",
".",
"reduce",
"(",
"function",
"(",
"acc",
",",
"key",
")",
"{",
"if",
"(",
"key",
".",
"indexOf",
"(",
"'_'",
")",
"===",
"0",
")",
"return",
"acc",
";",
"var",
"value",
"=",
"cldr",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"value",
"!==",
"'string'",
")",
"return",
"acc",
";",
"var",
"t",
"=",
"acc",
"[",
"key",
"]",
"=",
"interpolate",
"(",
"value",
",",
"opts",
")",
";",
"merge",
"(",
"paramsObj",
",",
"t",
".",
"params",
")",
";",
"return",
"acc",
";",
"}",
",",
"{",
"}",
")",
";",
"}"
] | Convert a cldr object to an object of functions
@param {Object} cldr
@param {Function} pluralize
@param {Object} opts
@param {Object} paramsObj
@return {Object} | [
"Convert",
"a",
"cldr",
"object",
"to",
"an",
"object",
"of",
"functions"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L100-L109 |
53,349 | lang-js/translate | index.js | discoverKey | function discoverKey(arr, discoverableKeys, defaultKey) {
if (arr.length === 0) return defaultKey;
if (arr.length === 1) return arr[0];
for (var i = 0; i < arr.length; i++) {
if (discoverableKeys[arr[i]]) return arr[i];
}
return defaultKey;
} | javascript | function discoverKey(arr, discoverableKeys, defaultKey) {
if (arr.length === 0) return defaultKey;
if (arr.length === 1) return arr[0];
for (var i = 0; i < arr.length; i++) {
if (discoverableKeys[arr[i]]) return arr[i];
}
return defaultKey;
} | [
"function",
"discoverKey",
"(",
"arr",
",",
"discoverableKeys",
",",
"defaultKey",
")",
"{",
"if",
"(",
"arr",
".",
"length",
"===",
"0",
")",
"return",
"defaultKey",
";",
"if",
"(",
"arr",
".",
"length",
"===",
"1",
")",
"return",
"arr",
"[",
"0",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"discoverableKeys",
"[",
"arr",
"[",
"i",
"]",
"]",
")",
"return",
"arr",
"[",
"i",
"]",
";",
"}",
"return",
"defaultKey",
";",
"}"
] | Auto-discover the plural key
@param {Array} keys
@param {Object} discoverableKeys
@param {String} defaultKey
@return {String} | [
"Auto",
"-",
"discover",
"the",
"plural",
"key"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L120-L127 |
53,350 | lang-js/translate | index.js | augment | function augment(fn, keys) {
keys = keys || fn.params || [];
if (!Array.isArray(keys)) keys = Object.keys(keys);
fn.params = keys;
return fn;
} | javascript | function augment(fn, keys) {
keys = keys || fn.params || [];
if (!Array.isArray(keys)) keys = Object.keys(keys);
fn.params = keys;
return fn;
} | [
"function",
"augment",
"(",
"fn",
",",
"keys",
")",
"{",
"keys",
"=",
"keys",
"||",
"fn",
".",
"params",
"||",
"[",
"]",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"keys",
")",
")",
"keys",
"=",
"Object",
".",
"keys",
"(",
"keys",
")",
";",
"fn",
".",
"params",
"=",
"keys",
";",
"return",
"fn",
";",
"}"
] | Augment translate functions with params reduce functions
@param {Function} fn
@param {Array} keys
@return {Function} | [
"Augment",
"translate",
"functions",
"with",
"params",
"reduce",
"functions"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L137-L142 |
53,351 | lang-js/translate | index.js | lookup | function lookup(locale, format, obj) {
if (!locale) throw new Error('missing required "locale" parameter');
locale = locale.toLowerCase().replace('-', '_');
format = format || 'cardinal';
var p = obj[format];
if (!p) throw new Error('unsupported format "' + format + '"');
var fn = p[locale] || p[locale.split('_')[0]];
if (fn) return fn;
throw new Error('unsupported locale "' + locale + '"');
} | javascript | function lookup(locale, format, obj) {
if (!locale) throw new Error('missing required "locale" parameter');
locale = locale.toLowerCase().replace('-', '_');
format = format || 'cardinal';
var p = obj[format];
if (!p) throw new Error('unsupported format "' + format + '"');
var fn = p[locale] || p[locale.split('_')[0]];
if (fn) return fn;
throw new Error('unsupported locale "' + locale + '"');
} | [
"function",
"lookup",
"(",
"locale",
",",
"format",
",",
"obj",
")",
"{",
"if",
"(",
"!",
"locale",
")",
"throw",
"new",
"Error",
"(",
"'missing required \"locale\" parameter'",
")",
";",
"locale",
"=",
"locale",
".",
"toLowerCase",
"(",
")",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
";",
"format",
"=",
"format",
"||",
"'cardinal'",
";",
"var",
"p",
"=",
"obj",
"[",
"format",
"]",
";",
"if",
"(",
"!",
"p",
")",
"throw",
"new",
"Error",
"(",
"'unsupported format \"'",
"+",
"format",
"+",
"'\"'",
")",
";",
"var",
"fn",
"=",
"p",
"[",
"locale",
"]",
"||",
"p",
"[",
"locale",
".",
"split",
"(",
"'_'",
")",
"[",
"0",
"]",
"]",
";",
"if",
"(",
"fn",
")",
"return",
"fn",
";",
"throw",
"new",
"Error",
"(",
"'unsupported locale \"'",
"+",
"locale",
"+",
"'\"'",
")",
";",
"}"
] | Lookup the plural function given a locale
@param {String} locale
@param {String} format
@return {Function} | [
"Lookup",
"the",
"plural",
"function",
"given",
"a",
"locale"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L152-L162 |
53,352 | lang-js/translate | index.js | convertArray | function convertArray(arr, pluralize, opts) {
if (arr.length !== pluralize.count) throw new Error('missing required length of plural formats: expected ' + pluralize.count + '; got ' + arr.length);
return pluralize.formats.reduce(function(acc, key, i) {
acc[key] = arr[i];
return acc;
}, {});
} | javascript | function convertArray(arr, pluralize, opts) {
if (arr.length !== pluralize.count) throw new Error('missing required length of plural formats: expected ' + pluralize.count + '; got ' + arr.length);
return pluralize.formats.reduce(function(acc, key, i) {
acc[key] = arr[i];
return acc;
}, {});
} | [
"function",
"convertArray",
"(",
"arr",
",",
"pluralize",
",",
"opts",
")",
"{",
"if",
"(",
"arr",
".",
"length",
"!==",
"pluralize",
".",
"count",
")",
"throw",
"new",
"Error",
"(",
"'missing required length of plural formats: expected '",
"+",
"pluralize",
".",
"count",
"+",
"'; got '",
"+",
"arr",
".",
"length",
")",
";",
"return",
"pluralize",
".",
"formats",
".",
"reduce",
"(",
"function",
"(",
"acc",
",",
"key",
",",
"i",
")",
"{",
"acc",
"[",
"key",
"]",
"=",
"arr",
"[",
"i",
"]",
";",
"return",
"acc",
";",
"}",
",",
"{",
"}",
")",
";",
"}"
] | Convert an array input to a CLDR object
@param {Array} arr
@param {Function} pluralize
@param {Object} opts
@return {Object} | [
"Convert",
"an",
"array",
"input",
"to",
"a",
"CLDR",
"object"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L173-L180 |
53,353 | lang-js/translate | index.js | formatNumbers | function formatNumbers(prevParams, decimal) {
var params = {}, value;
for (var k in prevParams) {
value = prevParams[k];
params[k] = typeof value === 'number' ? decimal(value) : value;
}
return params;
} | javascript | function formatNumbers(prevParams, decimal) {
var params = {}, value;
for (var k in prevParams) {
value = prevParams[k];
params[k] = typeof value === 'number' ? decimal(value) : value;
}
return params;
} | [
"function",
"formatNumbers",
"(",
"prevParams",
",",
"decimal",
")",
"{",
"var",
"params",
"=",
"{",
"}",
",",
"value",
";",
"for",
"(",
"var",
"k",
"in",
"prevParams",
")",
"{",
"value",
"=",
"prevParams",
"[",
"k",
"]",
";",
"params",
"[",
"k",
"]",
"=",
"typeof",
"value",
"===",
"'number'",
"?",
"decimal",
"(",
"value",
")",
":",
"value",
";",
"}",
"return",
"params",
";",
"}"
] | Format numbers with lang-js-number | [
"Format",
"numbers",
"with",
"lang",
"-",
"js",
"-",
"number"
] | 5787347d4b08089ddfcf73349dbbd0bfa47cd1fa | https://github.com/lang-js/translate/blob/5787347d4b08089ddfcf73349dbbd0bfa47cd1fa/index.js#L200-L207 |
53,354 | fullstackers/bus.io-common | lib/controller.js | Controller | function Controller (message) {
if (!(message instanceof Message)) throw new Error('message must be an instanceof Message');
if (!(this instanceof Controller)) return new Controller(message);
debug('new controller');
events.EventEmitter.call(this);
this.message = message;
this.data = this.message.data;
} | javascript | function Controller (message) {
if (!(message instanceof Message)) throw new Error('message must be an instanceof Message');
if (!(this instanceof Controller)) return new Controller(message);
debug('new controller');
events.EventEmitter.call(this);
this.message = message;
this.data = this.message.data;
} | [
"function",
"Controller",
"(",
"message",
")",
"{",
"if",
"(",
"!",
"(",
"message",
"instanceof",
"Message",
")",
")",
"throw",
"new",
"Error",
"(",
"'message must be an instanceof Message'",
")",
";",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Controller",
")",
")",
"return",
"new",
"Controller",
"(",
"message",
")",
";",
"debug",
"(",
"'new controller'",
")",
";",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"message",
"=",
"message",
";",
"this",
".",
"data",
"=",
"this",
".",
"message",
".",
"data",
";",
"}"
] | When handling a message we use a controller
@param {Message} message
@throws Error | [
"When",
"handling",
"a",
"message",
"we",
"use",
"a",
"controller"
] | 9e081a15ba40c4233a936d4105465277da8578fd | https://github.com/fullstackers/bus.io-common/blob/9e081a15ba40c4233a936d4105465277da8578fd/lib/controller.js#L17-L31 |
53,355 | nathanhood/postcss-js-mixins | lib/helpers.js | toRgba | function toRgba(color, opacity = false) {
color = tinycolor(color);
if (opacity) {
color.setAlpha(calcOpacity(opacity));
}
return color.toRgbString();
} | javascript | function toRgba(color, opacity = false) {
color = tinycolor(color);
if (opacity) {
color.setAlpha(calcOpacity(opacity));
}
return color.toRgbString();
} | [
"function",
"toRgba",
"(",
"color",
",",
"opacity",
"=",
"false",
")",
"{",
"color",
"=",
"tinycolor",
"(",
"color",
")",
";",
"if",
"(",
"opacity",
")",
"{",
"color",
".",
"setAlpha",
"(",
"calcOpacity",
"(",
"opacity",
")",
")",
";",
"}",
"return",
"color",
".",
"toRgbString",
"(",
")",
";",
"}"
] | Convert color values to RGBa
@param {string} color
@param {string|boolean} opacity
@return {string} | [
"Convert",
"color",
"values",
"to",
"RGBa"
] | b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5 | https://github.com/nathanhood/postcss-js-mixins/blob/b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5/lib/helpers.js#L35-L43 |
53,356 | nathanhood/postcss-js-mixins | lib/helpers.js | isEmpty | function isEmpty(value) {
if (Array.isArray(value)) {
// If first item in array is undefined, we assume there are no parameters
// This happens as a result of using the rest operator in a mixin
return value.length === 0 || value[0] === undefined;
}
return value === undefined;
} | javascript | function isEmpty(value) {
if (Array.isArray(value)) {
// If first item in array is undefined, we assume there are no parameters
// This happens as a result of using the rest operator in a mixin
return value.length === 0 || value[0] === undefined;
}
return value === undefined;
} | [
"function",
"isEmpty",
"(",
"value",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"// If first item in array is undefined, we assume there are no parameters",
"// This happens as a result of using the rest operator in a mixin",
"return",
"value",
".",
"length",
"===",
"0",
"||",
"value",
"[",
"0",
"]",
"===",
"undefined",
";",
"}",
"return",
"value",
"===",
"undefined",
";",
"}"
] | Determine if value is empty
@param {*} value
@return {boolean} | [
"Determine",
"if",
"value",
"is",
"empty"
] | b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5 | https://github.com/nathanhood/postcss-js-mixins/blob/b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5/lib/helpers.js#L61-L69 |
53,357 | nathanhood/postcss-js-mixins | lib/helpers.js | isFraction | function isFraction(value) {
if (typeof value !== 'string') {
return false;
}
value = value.split('/');
return value.length === 2 && value[0] % 1 === 0 && value[1] % 1 === 0;
} | javascript | function isFraction(value) {
if (typeof value !== 'string') {
return false;
}
value = value.split('/');
return value.length === 2 && value[0] % 1 === 0 && value[1] % 1 === 0;
} | [
"function",
"isFraction",
"(",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!==",
"'string'",
")",
"{",
"return",
"false",
";",
"}",
"value",
"=",
"value",
".",
"split",
"(",
"'/'",
")",
";",
"return",
"value",
".",
"length",
"===",
"2",
"&&",
"value",
"[",
"0",
"]",
"%",
"1",
"===",
"0",
"&&",
"value",
"[",
"1",
"]",
"%",
"1",
"===",
"0",
";",
"}"
] | Determine if supplied argument is a fraction
@param {*} value
@returns {boolean} | [
"Determine",
"if",
"supplied",
"argument",
"is",
"a",
"fraction"
] | b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5 | https://github.com/nathanhood/postcss-js-mixins/blob/b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5/lib/helpers.js#L77-L85 |
53,358 | nathanhood/postcss-js-mixins | lib/helpers.js | prefix | function prefix(value, prefix, ignored = []) {
if (prefix === false) {
return value;
}
if (ignored.includes(prefix)) {
return toDashCase(value);
}
return prefix + '-' + toDashCase(value);
} | javascript | function prefix(value, prefix, ignored = []) {
if (prefix === false) {
return value;
}
if (ignored.includes(prefix)) {
return toDashCase(value);
}
return prefix + '-' + toDashCase(value);
} | [
"function",
"prefix",
"(",
"value",
",",
"prefix",
",",
"ignored",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"prefix",
"===",
"false",
")",
"{",
"return",
"value",
";",
"}",
"if",
"(",
"ignored",
".",
"includes",
"(",
"prefix",
")",
")",
"{",
"return",
"toDashCase",
"(",
"value",
")",
";",
"}",
"return",
"prefix",
"+",
"'-'",
"+",
"toDashCase",
"(",
"value",
")",
";",
"}"
] | Prefixes properties with supplied prefix
@param {string} value un-prefixed string
@param {string} prefix prefix
@param {Array} ignored
@return {[string]} | [
"Prefixes",
"properties",
"with",
"supplied",
"prefix"
] | b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5 | https://github.com/nathanhood/postcss-js-mixins/blob/b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5/lib/helpers.js#L157-L167 |
53,359 | nathanhood/postcss-js-mixins | lib/helpers.js | unit | function unit(value, property) {
let ignored = ['font-weight', 'opacity', 'content', 'columns', 'column-count'];
if (ignored.includes(property) || property === false || value === 0 || /\s/.test(value)) {
return value.toString();
}
if (! isUnit(value) && isNumber(value)) {
if (property === 'line-height') {
value += units.lineHeight;
} else {
value += units.default;
}
}
return value;
} | javascript | function unit(value, property) {
let ignored = ['font-weight', 'opacity', 'content', 'columns', 'column-count'];
if (ignored.includes(property) || property === false || value === 0 || /\s/.test(value)) {
return value.toString();
}
if (! isUnit(value) && isNumber(value)) {
if (property === 'line-height') {
value += units.lineHeight;
} else {
value += units.default;
}
}
return value;
} | [
"function",
"unit",
"(",
"value",
",",
"property",
")",
"{",
"let",
"ignored",
"=",
"[",
"'font-weight'",
",",
"'opacity'",
",",
"'content'",
",",
"'columns'",
",",
"'column-count'",
"]",
";",
"if",
"(",
"ignored",
".",
"includes",
"(",
"property",
")",
"||",
"property",
"===",
"false",
"||",
"value",
"===",
"0",
"||",
"/",
"\\s",
"/",
".",
"test",
"(",
"value",
")",
")",
"{",
"return",
"value",
".",
"toString",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isUnit",
"(",
"value",
")",
"&&",
"isNumber",
"(",
"value",
")",
")",
"{",
"if",
"(",
"property",
"===",
"'line-height'",
")",
"{",
"value",
"+=",
"units",
".",
"lineHeight",
";",
"}",
"else",
"{",
"value",
"+=",
"units",
".",
"default",
";",
"}",
"}",
"return",
"value",
";",
"}"
] | Append default unit to value if value is a unit
@param {string|number} value
@param {string|number} property
@return {string} | [
"Append",
"default",
"unit",
"to",
"value",
"if",
"value",
"is",
"a",
"unit"
] | b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5 | https://github.com/nathanhood/postcss-js-mixins/blob/b43e94b5eaa4b1f169d34ee98c65b8c94bee30b5/lib/helpers.js#L225-L241 |
53,360 | vkiding/judpack-lib | src/cordova/util.js | cdProjectRoot | function cdProjectRoot(dir) {
var projectRoot = this.isCordova(dir);
if (!projectRoot) {
throw new CordovaError('Current working directory is not a judpack project.');
}
if (!origCwd) {
origCwd = process.env.PWD || process.cwd();
}
process.env.PWD = projectRoot;
process.chdir(projectRoot);
return projectRoot;
} | javascript | function cdProjectRoot(dir) {
var projectRoot = this.isCordova(dir);
if (!projectRoot) {
throw new CordovaError('Current working directory is not a judpack project.');
}
if (!origCwd) {
origCwd = process.env.PWD || process.cwd();
}
process.env.PWD = projectRoot;
process.chdir(projectRoot);
return projectRoot;
} | [
"function",
"cdProjectRoot",
"(",
"dir",
")",
"{",
"var",
"projectRoot",
"=",
"this",
".",
"isCordova",
"(",
"dir",
")",
";",
"if",
"(",
"!",
"projectRoot",
")",
"{",
"throw",
"new",
"CordovaError",
"(",
"'Current working directory is not a judpack project.'",
")",
";",
"}",
"if",
"(",
"!",
"origCwd",
")",
"{",
"origCwd",
"=",
"process",
".",
"env",
".",
"PWD",
"||",
"process",
".",
"cwd",
"(",
")",
";",
"}",
"process",
".",
"env",
".",
"PWD",
"=",
"projectRoot",
";",
"process",
".",
"chdir",
"(",
"projectRoot",
")",
";",
"return",
"projectRoot",
";",
"}"
] | Cd to project root dir and return its path. Throw CordovaError if not in a Corodva project. | [
"Cd",
"to",
"project",
"root",
"dir",
"and",
"return",
"its",
"path",
".",
"Throw",
"CordovaError",
"if",
"not",
"in",
"a",
"Corodva",
"project",
"."
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/util.js#L160-L171 |
53,361 | vkiding/judpack-lib | src/cordova/util.js | deleteSvnFolders | function deleteSvnFolders(dir) {
var contents = fs.readdirSync(dir);
contents.forEach(function(entry) {
var fullpath = path.join(dir, entry);
if (fs.statSync(fullpath).isDirectory()) {
if (entry == '.svn') {
shell.rm('-rf', fullpath);
} else module.exports.deleteSvnFolders(fullpath);
}
});
} | javascript | function deleteSvnFolders(dir) {
var contents = fs.readdirSync(dir);
contents.forEach(function(entry) {
var fullpath = path.join(dir, entry);
if (fs.statSync(fullpath).isDirectory()) {
if (entry == '.svn') {
shell.rm('-rf', fullpath);
} else module.exports.deleteSvnFolders(fullpath);
}
});
} | [
"function",
"deleteSvnFolders",
"(",
"dir",
")",
"{",
"var",
"contents",
"=",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
";",
"contents",
".",
"forEach",
"(",
"function",
"(",
"entry",
")",
"{",
"var",
"fullpath",
"=",
"path",
".",
"join",
"(",
"dir",
",",
"entry",
")",
";",
"if",
"(",
"fs",
".",
"statSync",
"(",
"fullpath",
")",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"entry",
"==",
"'.svn'",
")",
"{",
"shell",
".",
"rm",
"(",
"'-rf'",
",",
"fullpath",
")",
";",
"}",
"else",
"module",
".",
"exports",
".",
"deleteSvnFolders",
"(",
"fullpath",
")",
";",
"}",
"}",
")",
";",
"}"
] | Recursively deletes .svn folders from a target path | [
"Recursively",
"deletes",
".",
"svn",
"folders",
"from",
"a",
"target",
"path"
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/util.js#L204-L214 |
53,362 | vkiding/judpack-lib | src/cordova/util.js | findPlugins | function findPlugins(pluginPath) {
var plugins = [],
stats;
if (exports.existsSync(pluginPath)) {
plugins = fs.readdirSync(pluginPath).filter(function (fileName) {
stats = fs.statSync(path.join(pluginPath, fileName));
return fileName != '.svn' && fileName != 'CVS' && stats.isDirectory();
});
}
return plugins;
} | javascript | function findPlugins(pluginPath) {
var plugins = [],
stats;
if (exports.existsSync(pluginPath)) {
plugins = fs.readdirSync(pluginPath).filter(function (fileName) {
stats = fs.statSync(path.join(pluginPath, fileName));
return fileName != '.svn' && fileName != 'CVS' && stats.isDirectory();
});
}
return plugins;
} | [
"function",
"findPlugins",
"(",
"pluginPath",
")",
"{",
"var",
"plugins",
"=",
"[",
"]",
",",
"stats",
";",
"if",
"(",
"exports",
".",
"existsSync",
"(",
"pluginPath",
")",
")",
"{",
"plugins",
"=",
"fs",
".",
"readdirSync",
"(",
"pluginPath",
")",
".",
"filter",
"(",
"function",
"(",
"fileName",
")",
"{",
"stats",
"=",
"fs",
".",
"statSync",
"(",
"path",
".",
"join",
"(",
"pluginPath",
",",
"fileName",
")",
")",
";",
"return",
"fileName",
"!=",
"'.svn'",
"&&",
"fileName",
"!=",
"'CVS'",
"&&",
"stats",
".",
"isDirectory",
"(",
")",
";",
"}",
")",
";",
"}",
"return",
"plugins",
";",
"}"
] | list the directories in the path, ignoring any files | [
"list",
"the",
"directories",
"in",
"the",
"path",
"ignoring",
"any",
"files"
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/util.js#L246-L258 |
53,363 | vkiding/judpack-lib | src/cordova/util.js | getAvailableNpmVersions | function getAvailableNpmVersions(module_name) {
var npm = require('npm');
return Q.nfcall(npm.load).then(function () {
return Q.ninvoke(npm.commands, 'view', [module_name, 'versions'], /* silent = */ true).then(function (result) {
// result is an object in the form:
// {'<version>': {versions: ['1.2.3', '1.2.4', ...]}}
// (where <version> is the latest version)
return result[Object.keys(result)[0]].versions;
});
});
} | javascript | function getAvailableNpmVersions(module_name) {
var npm = require('npm');
return Q.nfcall(npm.load).then(function () {
return Q.ninvoke(npm.commands, 'view', [module_name, 'versions'], /* silent = */ true).then(function (result) {
// result is an object in the form:
// {'<version>': {versions: ['1.2.3', '1.2.4', ...]}}
// (where <version> is the latest version)
return result[Object.keys(result)[0]].versions;
});
});
} | [
"function",
"getAvailableNpmVersions",
"(",
"module_name",
")",
"{",
"var",
"npm",
"=",
"require",
"(",
"'npm'",
")",
";",
"return",
"Q",
".",
"nfcall",
"(",
"npm",
".",
"load",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"Q",
".",
"ninvoke",
"(",
"npm",
".",
"commands",
",",
"'view'",
",",
"[",
"module_name",
",",
"'versions'",
"]",
",",
"/* silent = */",
"true",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"// result is an object in the form:",
"// {'<version>': {versions: ['1.2.3', '1.2.4', ...]}}",
"// (where <version> is the latest version)",
"return",
"result",
"[",
"Object",
".",
"keys",
"(",
"result",
")",
"[",
"0",
"]",
"]",
".",
"versions",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Returns a promise for an array of versions available for the specified npm module.
@param {string} module_name - npm module name.
@returns {Promise} Promise for an array of versions. | [
"Returns",
"a",
"promise",
"for",
"an",
"array",
"of",
"versions",
"available",
"for",
"the",
"specified",
"npm",
"module",
"."
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/util.js#L438-L448 |
53,364 | redisjs/jsr-server | lib/command/server/flushall.js | execute | function execute(req, res) {
// TODO: ensure a conflict is triggered on all watched keys
this.store.flushall();
res.send(null, Constants.OK);
} | javascript | function execute(req, res) {
// TODO: ensure a conflict is triggered on all watched keys
this.store.flushall();
res.send(null, Constants.OK);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"// TODO: ensure a conflict is triggered on all watched keys",
"this",
".",
"store",
".",
"flushall",
"(",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the FLUSHALL command. | [
"Respond",
"to",
"the",
"FLUSHALL",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/flushall.js#L17-L21 |
53,365 | solid-live/solidbot | lib/bots/chain.js | bot | function bot(job, done) {
var jobs = job.data.jobs
console.log(job.data.jobs)
if (!jobs) {
done()
return
}
for (var i = 0; i < jobs.length; i++) {
var j = jobs[i]
debug('Running : ' + j)
}
done()
} | javascript | function bot(job, done) {
var jobs = job.data.jobs
console.log(job.data.jobs)
if (!jobs) {
done()
return
}
for (var i = 0; i < jobs.length; i++) {
var j = jobs[i]
debug('Running : ' + j)
}
done()
} | [
"function",
"bot",
"(",
"job",
",",
"done",
")",
"{",
"var",
"jobs",
"=",
"job",
".",
"data",
".",
"jobs",
"console",
".",
"log",
"(",
"job",
".",
"data",
".",
"jobs",
")",
"if",
"(",
"!",
"jobs",
")",
"{",
"done",
"(",
")",
"return",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"jobs",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"j",
"=",
"jobs",
"[",
"i",
"]",
"debug",
"(",
"'Running : '",
"+",
"j",
")",
"}",
"done",
"(",
")",
"}"
] | runs a chained command
@param {object} job A kue job.
@param {object} done Called after done. | [
"runs",
"a",
"chained",
"command"
] | c91bfef38ab01f7f88fb6bf1b1bc4875aea0ceda | https://github.com/solid-live/solidbot/blob/c91bfef38ab01f7f88fb6bf1b1bc4875aea0ceda/lib/bots/chain.js#L12-L27 |
53,366 | Fovea/jackbone | examples/todolist/js/main.js | function($li, model) {
$li.attr('todo-cid', model.cid);
$li.toggleClass('todo-done', model.done);
$li.text(model.title);
} | javascript | function($li, model) {
$li.attr('todo-cid', model.cid);
$li.toggleClass('todo-done', model.done);
$li.text(model.title);
} | [
"function",
"(",
"$li",
",",
"model",
")",
"{",
"$li",
".",
"attr",
"(",
"'todo-cid'",
",",
"model",
".",
"cid",
")",
";",
"$li",
".",
"toggleClass",
"(",
"'todo-done'",
",",
"model",
".",
"done",
")",
";",
"$li",
".",
"text",
"(",
"model",
".",
"title",
")",
";",
"}"
] | Change a row in the list | [
"Change",
"a",
"row",
"in",
"the",
"list"
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/examples/todolist/js/main.js#L85-L89 |
|
53,367 | Fovea/jackbone | examples/todolist/js/main.js | function (e) {
if (e && e.preventDefault) e.preventDefault();
var $el = $(e.target);
var cid = $el.attr('todo-cid');
if (cid) {
this.options.toggleItem(cid);
}
return false;
} | javascript | function (e) {
if (e && e.preventDefault) e.preventDefault();
var $el = $(e.target);
var cid = $el.attr('todo-cid');
if (cid) {
this.options.toggleItem(cid);
}
return false;
} | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
"&&",
"e",
".",
"preventDefault",
")",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"$el",
"=",
"$",
"(",
"e",
".",
"target",
")",
";",
"var",
"cid",
"=",
"$el",
".",
"attr",
"(",
"'todo-cid'",
")",
";",
"if",
"(",
"cid",
")",
"{",
"this",
".",
"options",
".",
"toggleItem",
"(",
"cid",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Handles click on the listview Retrieves the cid of the object, calls Controller's `toggleItem` method if the clicked element contains a valid `todo-cid`. | [
"Handles",
"click",
"on",
"the",
"listview",
"Retrieves",
"the",
"cid",
"of",
"the",
"object",
"calls",
"Controller",
"s",
"toggleItem",
"method",
"if",
"the",
"clicked",
"element",
"contains",
"a",
"valid",
"todo",
"-",
"cid",
"."
] | 94631030d20c6ff5c331cb824e135120f60c4ff2 | https://github.com/Fovea/jackbone/blob/94631030d20c6ff5c331cb824e135120f60c4ff2/examples/todolist/js/main.js#L134-L142 |
|
53,368 | chatphrase/caress | lib/caress.js | parseTextBody | function parseTextBody(req, res, next){
if (req.body === undefined) {
req.body = '';
req.on('data', function(chunk){ req.body += chunk });
req.on('end', next);
} else {
next();
}
} | javascript | function parseTextBody(req, res, next){
if (req.body === undefined) {
req.body = '';
req.on('data', function(chunk){ req.body += chunk });
req.on('end', next);
} else {
next();
}
} | [
"function",
"parseTextBody",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"req",
".",
"body",
"===",
"undefined",
")",
"{",
"req",
".",
"body",
"=",
"''",
";",
"req",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"chunk",
")",
"{",
"req",
".",
"body",
"+=",
"chunk",
"}",
")",
";",
"req",
".",
"on",
"(",
"'end'",
",",
"next",
")",
";",
"}",
"else",
"{",
"next",
"(",
")",
";",
"}",
"}"
] | Middleware to handle text bodies. | [
"Middleware",
"to",
"handle",
"text",
"bodies",
"."
] | 1634c127e90c8140baf5e2803a2938ffaf0414c4 | https://github.com/chatphrase/caress/blob/1634c127e90c8140baf5e2803a2938ffaf0414c4/lib/caress.js#L33-L41 |
53,369 | noblesamurai/noblerecord | src/model.js | reload | function reload() {
var params = {}
params[model.primary] = me[model.primary]
var act = new NobleMachine(model.find(params));
act.next(function(newInst) {
if (newInst) {
for (var col in model.columns) {
me[col] = newInst[col];
}
act.toNext(me);
} else {
for (var key in model.columns) {
me[key] = undefined
}
act.toNext(null);
}
});
return act;
} | javascript | function reload() {
var params = {}
params[model.primary] = me[model.primary]
var act = new NobleMachine(model.find(params));
act.next(function(newInst) {
if (newInst) {
for (var col in model.columns) {
me[col] = newInst[col];
}
act.toNext(me);
} else {
for (var key in model.columns) {
me[key] = undefined
}
act.toNext(null);
}
});
return act;
} | [
"function",
"reload",
"(",
")",
"{",
"var",
"params",
"=",
"{",
"}",
"params",
"[",
"model",
".",
"primary",
"]",
"=",
"me",
"[",
"model",
".",
"primary",
"]",
"var",
"act",
"=",
"new",
"NobleMachine",
"(",
"model",
".",
"find",
"(",
"params",
")",
")",
";",
"act",
".",
"next",
"(",
"function",
"(",
"newInst",
")",
"{",
"if",
"(",
"newInst",
")",
"{",
"for",
"(",
"var",
"col",
"in",
"model",
".",
"columns",
")",
"{",
"me",
"[",
"col",
"]",
"=",
"newInst",
"[",
"col",
"]",
";",
"}",
"act",
".",
"toNext",
"(",
"me",
")",
";",
"}",
"else",
"{",
"for",
"(",
"var",
"key",
"in",
"model",
".",
"columns",
")",
"{",
"me",
"[",
"key",
"]",
"=",
"undefined",
"}",
"act",
".",
"toNext",
"(",
"null",
")",
";",
"}",
"}",
")",
";",
"return",
"act",
";",
"}"
] | Reloads the object's properties with the current database values. | [
"Reloads",
"the",
"object",
"s",
"properties",
"with",
"the",
"current",
"database",
"values",
"."
] | fc7d3aac186598c4c7023f5448979d4162ab5e38 | https://github.com/noblesamurai/noblerecord/blob/fc7d3aac186598c4c7023f5448979d4162ab5e38/src/model.js#L120-L144 |
53,370 | noblesamurai/noblerecord | src/model.js | destroy | function destroy() {
var act = new NobleMachine(function() {
if (me.onDestroy) {
var preact = me.onDestroy();
if (preact && preact.start instanceof Function) {
act.toNext(preact)
return;
}
}
});
act.next(function() {
var sql = "DELETE FROM " + model.table
+ " WHERE `" + model.primary + "` = " + me[model.primary];
act.toNext(db_query(sql));
});
act.next(function() {
logger.log("Successfully deleted `" + model.ident + "` record `" + me[model.primary] + "`");
for (var param in me) {
delete me[param];
}
});
act.error(function(err) {
logger.error("Error deleting `" + model.ident + "` record: " + JSON.stringify(err));
act.emitError(err);
});
return act;
} | javascript | function destroy() {
var act = new NobleMachine(function() {
if (me.onDestroy) {
var preact = me.onDestroy();
if (preact && preact.start instanceof Function) {
act.toNext(preact)
return;
}
}
});
act.next(function() {
var sql = "DELETE FROM " + model.table
+ " WHERE `" + model.primary + "` = " + me[model.primary];
act.toNext(db_query(sql));
});
act.next(function() {
logger.log("Successfully deleted `" + model.ident + "` record `" + me[model.primary] + "`");
for (var param in me) {
delete me[param];
}
});
act.error(function(err) {
logger.error("Error deleting `" + model.ident + "` record: " + JSON.stringify(err));
act.emitError(err);
});
return act;
} | [
"function",
"destroy",
"(",
")",
"{",
"var",
"act",
"=",
"new",
"NobleMachine",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"me",
".",
"onDestroy",
")",
"{",
"var",
"preact",
"=",
"me",
".",
"onDestroy",
"(",
")",
";",
"if",
"(",
"preact",
"&&",
"preact",
".",
"start",
"instanceof",
"Function",
")",
"{",
"act",
".",
"toNext",
"(",
"preact",
")",
"return",
";",
"}",
"}",
"}",
")",
";",
"act",
".",
"next",
"(",
"function",
"(",
")",
"{",
"var",
"sql",
"=",
"\"DELETE FROM \"",
"+",
"model",
".",
"table",
"+",
"\" WHERE `\"",
"+",
"model",
".",
"primary",
"+",
"\"` = \"",
"+",
"me",
"[",
"model",
".",
"primary",
"]",
";",
"act",
".",
"toNext",
"(",
"db_query",
"(",
"sql",
")",
")",
";",
"}",
")",
";",
"act",
".",
"next",
"(",
"function",
"(",
")",
"{",
"logger",
".",
"log",
"(",
"\"Successfully deleted `\"",
"+",
"model",
".",
"ident",
"+",
"\"` record `\"",
"+",
"me",
"[",
"model",
".",
"primary",
"]",
"+",
"\"`\"",
")",
";",
"for",
"(",
"var",
"param",
"in",
"me",
")",
"{",
"delete",
"me",
"[",
"param",
"]",
";",
"}",
"}",
")",
";",
"act",
".",
"error",
"(",
"function",
"(",
"err",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error deleting `\"",
"+",
"model",
".",
"ident",
"+",
"\"` record: \"",
"+",
"JSON",
".",
"stringify",
"(",
"err",
")",
")",
";",
"act",
".",
"emitError",
"(",
"err",
")",
";",
"}",
")",
";",
"return",
"act",
";",
"}"
] | Removes this object's corresponding database row. | [
"Removes",
"this",
"object",
"s",
"corresponding",
"database",
"row",
"."
] | fc7d3aac186598c4c7023f5448979d4162ab5e38 | https://github.com/noblesamurai/noblerecord/blob/fc7d3aac186598c4c7023f5448979d4162ab5e38/src/model.js#L149-L181 |
53,371 | noblesamurai/noblerecord | src/model.js | setValue | function setValue(key, val) {
//util.log(key + ": " + JSON.stringify(val));
if (val === null) {
me.values[key] = null;
} else if (val === undefined) {
me.values[key] = undefined;
} else {
type = model.columns[key]['DATA_TYPE'];
switch (type) {
case 'datetime':
case 'timestamp':
me.values[key] = new Date(val);
break;
case 'text':
case 'varchar':
me.values[key] = val.toString();
break;
case 'int':
case 'tinyint':
if (model.columns[key]['COLUMN_TYPE'] == 'tinyint(1)') {
me.values[key] = !!val // Boolean
} else {
me.values[key] = parseInt(val);
}
break;
default:
me.values[key] = val;
}
}
} | javascript | function setValue(key, val) {
//util.log(key + ": " + JSON.stringify(val));
if (val === null) {
me.values[key] = null;
} else if (val === undefined) {
me.values[key] = undefined;
} else {
type = model.columns[key]['DATA_TYPE'];
switch (type) {
case 'datetime':
case 'timestamp':
me.values[key] = new Date(val);
break;
case 'text':
case 'varchar':
me.values[key] = val.toString();
break;
case 'int':
case 'tinyint':
if (model.columns[key]['COLUMN_TYPE'] == 'tinyint(1)') {
me.values[key] = !!val // Boolean
} else {
me.values[key] = parseInt(val);
}
break;
default:
me.values[key] = val;
}
}
} | [
"function",
"setValue",
"(",
"key",
",",
"val",
")",
"{",
"//util.log(key + \": \" + JSON.stringify(val));",
"if",
"(",
"val",
"===",
"null",
")",
"{",
"me",
".",
"values",
"[",
"key",
"]",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"val",
"===",
"undefined",
")",
"{",
"me",
".",
"values",
"[",
"key",
"]",
"=",
"undefined",
";",
"}",
"else",
"{",
"type",
"=",
"model",
".",
"columns",
"[",
"key",
"]",
"[",
"'DATA_TYPE'",
"]",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"'datetime'",
":",
"case",
"'timestamp'",
":",
"me",
".",
"values",
"[",
"key",
"]",
"=",
"new",
"Date",
"(",
"val",
")",
";",
"break",
";",
"case",
"'text'",
":",
"case",
"'varchar'",
":",
"me",
".",
"values",
"[",
"key",
"]",
"=",
"val",
".",
"toString",
"(",
")",
";",
"break",
";",
"case",
"'int'",
":",
"case",
"'tinyint'",
":",
"if",
"(",
"model",
".",
"columns",
"[",
"key",
"]",
"[",
"'COLUMN_TYPE'",
"]",
"==",
"'tinyint(1)'",
")",
"{",
"me",
".",
"values",
"[",
"key",
"]",
"=",
"!",
"!",
"val",
"// Boolean",
"}",
"else",
"{",
"me",
".",
"values",
"[",
"key",
"]",
"=",
"parseInt",
"(",
"val",
")",
";",
"}",
"break",
";",
"default",
":",
"me",
".",
"values",
"[",
"key",
"]",
"=",
"val",
";",
"}",
"}",
"}"
] | Generic setter for SQL-correspondent values. Forces typecasting for database compatibility. | [
"Generic",
"setter",
"for",
"SQL",
"-",
"correspondent",
"values",
".",
"Forces",
"typecasting",
"for",
"database",
"compatibility",
"."
] | fc7d3aac186598c4c7023f5448979d4162ab5e38 | https://github.com/noblesamurai/noblerecord/blob/fc7d3aac186598c4c7023f5448979d4162ab5e38/src/model.js#L184-L215 |
53,372 | Nazariglez/perenquen | lib/pixi/src/interaction/InteractionManager.js | InteractionManager | function InteractionManager(renderer, options)
{
options = options || {};
/**
* The renderer this interaction manager works for.
*
* @member {SystemRenderer}
*/
this.renderer = renderer;
/**
* Should default browser actions automatically be prevented.
*
* @member {boolean}
* @default true
*/
this.autoPreventDefault = options.autoPreventDefault !== undefined ? options.autoPreventDefault : true;
/**
* As this frequency increases the interaction events will be checked more often.
*
* @member {number}
* @default 10
*/
this.interactionFrequency = options.interactionFrequency || 10;
/**
* The mouse data
*
* @member {InteractionData}
*/
this.mouse = new InteractionData();
/**
* An event data object to handle all the event tracking/dispatching
*
* @member {EventData}
*/
this.eventData = {
stopped: false,
target: null,
type: null,
data: this.mouse,
stopPropagation:function(){
this.stopped = true;
}
};
/**
* Tiny little interactiveData pool !
*
* @member {Array}
*/
this.interactiveDataPool = [];
/**
* The DOM element to bind to.
*
* @member {HTMLElement}
* @private
*/
this.interactionDOMElement = null;
/**
* Have events been attached to the dom element?
*
* @member {boolean}
* @private
*/
this.eventsAdded = false;
//this will make it so that you don't have to call bind all the time
/**
* @member {Function}
*/
this.onMouseUp = this.onMouseUp.bind(this);
this.processMouseUp = this.processMouseUp.bind( this );
/**
* @member {Function}
*/
this.onMouseDown = this.onMouseDown.bind(this);
this.processMouseDown = this.processMouseDown.bind( this );
/**
* @member {Function}
*/
this.onMouseMove = this.onMouseMove.bind( this );
this.processMouseMove = this.processMouseMove.bind( this );
/**
* @member {Function}
*/
this.onMouseOut = this.onMouseOut.bind(this);
this.processMouseOverOut = this.processMouseOverOut.bind( this );
/**
* @member {Function}
*/
this.onTouchStart = this.onTouchStart.bind(this);
this.processTouchStart = this.processTouchStart.bind(this);
/**
* @member {Function}
*/
this.onTouchEnd = this.onTouchEnd.bind(this);
this.processTouchEnd = this.processTouchEnd.bind(this);
/**
* @member {Function}
*/
this.onTouchMove = this.onTouchMove.bind(this);
this.processTouchMove = this.processTouchMove.bind(this);
/**
* @member {number}
*/
this.last = 0;
/**
* The css style of the cursor that is being used
* @member {string}
*/
this.currentCursorStyle = 'inherit';
/**
* Internal cached var
* @member {Point}
* @private
*/
this._tempPoint = new core.Point();
/**
* The current resolution
* @member {number}
*/
this.resolution = 1;
this.setTargetElement(this.renderer.view, this.renderer.resolution);
} | javascript | function InteractionManager(renderer, options)
{
options = options || {};
/**
* The renderer this interaction manager works for.
*
* @member {SystemRenderer}
*/
this.renderer = renderer;
/**
* Should default browser actions automatically be prevented.
*
* @member {boolean}
* @default true
*/
this.autoPreventDefault = options.autoPreventDefault !== undefined ? options.autoPreventDefault : true;
/**
* As this frequency increases the interaction events will be checked more often.
*
* @member {number}
* @default 10
*/
this.interactionFrequency = options.interactionFrequency || 10;
/**
* The mouse data
*
* @member {InteractionData}
*/
this.mouse = new InteractionData();
/**
* An event data object to handle all the event tracking/dispatching
*
* @member {EventData}
*/
this.eventData = {
stopped: false,
target: null,
type: null,
data: this.mouse,
stopPropagation:function(){
this.stopped = true;
}
};
/**
* Tiny little interactiveData pool !
*
* @member {Array}
*/
this.interactiveDataPool = [];
/**
* The DOM element to bind to.
*
* @member {HTMLElement}
* @private
*/
this.interactionDOMElement = null;
/**
* Have events been attached to the dom element?
*
* @member {boolean}
* @private
*/
this.eventsAdded = false;
//this will make it so that you don't have to call bind all the time
/**
* @member {Function}
*/
this.onMouseUp = this.onMouseUp.bind(this);
this.processMouseUp = this.processMouseUp.bind( this );
/**
* @member {Function}
*/
this.onMouseDown = this.onMouseDown.bind(this);
this.processMouseDown = this.processMouseDown.bind( this );
/**
* @member {Function}
*/
this.onMouseMove = this.onMouseMove.bind( this );
this.processMouseMove = this.processMouseMove.bind( this );
/**
* @member {Function}
*/
this.onMouseOut = this.onMouseOut.bind(this);
this.processMouseOverOut = this.processMouseOverOut.bind( this );
/**
* @member {Function}
*/
this.onTouchStart = this.onTouchStart.bind(this);
this.processTouchStart = this.processTouchStart.bind(this);
/**
* @member {Function}
*/
this.onTouchEnd = this.onTouchEnd.bind(this);
this.processTouchEnd = this.processTouchEnd.bind(this);
/**
* @member {Function}
*/
this.onTouchMove = this.onTouchMove.bind(this);
this.processTouchMove = this.processTouchMove.bind(this);
/**
* @member {number}
*/
this.last = 0;
/**
* The css style of the cursor that is being used
* @member {string}
*/
this.currentCursorStyle = 'inherit';
/**
* Internal cached var
* @member {Point}
* @private
*/
this._tempPoint = new core.Point();
/**
* The current resolution
* @member {number}
*/
this.resolution = 1;
this.setTargetElement(this.renderer.view, this.renderer.resolution);
} | [
"function",
"InteractionManager",
"(",
"renderer",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"/**\n * The renderer this interaction manager works for.\n *\n * @member {SystemRenderer}\n */",
"this",
".",
"renderer",
"=",
"renderer",
";",
"/**\n * Should default browser actions automatically be prevented.\n *\n * @member {boolean}\n * @default true\n */",
"this",
".",
"autoPreventDefault",
"=",
"options",
".",
"autoPreventDefault",
"!==",
"undefined",
"?",
"options",
".",
"autoPreventDefault",
":",
"true",
";",
"/**\n * As this frequency increases the interaction events will be checked more often.\n *\n * @member {number}\n * @default 10\n */",
"this",
".",
"interactionFrequency",
"=",
"options",
".",
"interactionFrequency",
"||",
"10",
";",
"/**\n * The mouse data\n *\n * @member {InteractionData}\n */",
"this",
".",
"mouse",
"=",
"new",
"InteractionData",
"(",
")",
";",
"/**\n * An event data object to handle all the event tracking/dispatching\n *\n * @member {EventData}\n */",
"this",
".",
"eventData",
"=",
"{",
"stopped",
":",
"false",
",",
"target",
":",
"null",
",",
"type",
":",
"null",
",",
"data",
":",
"this",
".",
"mouse",
",",
"stopPropagation",
":",
"function",
"(",
")",
"{",
"this",
".",
"stopped",
"=",
"true",
";",
"}",
"}",
";",
"/**\n * Tiny little interactiveData pool !\n *\n * @member {Array}\n */",
"this",
".",
"interactiveDataPool",
"=",
"[",
"]",
";",
"/**\n * The DOM element to bind to.\n *\n * @member {HTMLElement}\n * @private\n */",
"this",
".",
"interactionDOMElement",
"=",
"null",
";",
"/**\n * Have events been attached to the dom element?\n *\n * @member {boolean}\n * @private\n */",
"this",
".",
"eventsAdded",
"=",
"false",
";",
"//this will make it so that you don't have to call bind all the time",
"/**\n * @member {Function}\n */",
"this",
".",
"onMouseUp",
"=",
"this",
".",
"onMouseUp",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"processMouseUp",
"=",
"this",
".",
"processMouseUp",
".",
"bind",
"(",
"this",
")",
";",
"/**\n * @member {Function}\n */",
"this",
".",
"onMouseDown",
"=",
"this",
".",
"onMouseDown",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"processMouseDown",
"=",
"this",
".",
"processMouseDown",
".",
"bind",
"(",
"this",
")",
";",
"/**\n * @member {Function}\n */",
"this",
".",
"onMouseMove",
"=",
"this",
".",
"onMouseMove",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"processMouseMove",
"=",
"this",
".",
"processMouseMove",
".",
"bind",
"(",
"this",
")",
";",
"/**\n * @member {Function}\n */",
"this",
".",
"onMouseOut",
"=",
"this",
".",
"onMouseOut",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"processMouseOverOut",
"=",
"this",
".",
"processMouseOverOut",
".",
"bind",
"(",
"this",
")",
";",
"/**\n * @member {Function}\n */",
"this",
".",
"onTouchStart",
"=",
"this",
".",
"onTouchStart",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"processTouchStart",
"=",
"this",
".",
"processTouchStart",
".",
"bind",
"(",
"this",
")",
";",
"/**\n * @member {Function}\n */",
"this",
".",
"onTouchEnd",
"=",
"this",
".",
"onTouchEnd",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"processTouchEnd",
"=",
"this",
".",
"processTouchEnd",
".",
"bind",
"(",
"this",
")",
";",
"/**\n * @member {Function}\n */",
"this",
".",
"onTouchMove",
"=",
"this",
".",
"onTouchMove",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"processTouchMove",
"=",
"this",
".",
"processTouchMove",
".",
"bind",
"(",
"this",
")",
";",
"/**\n * @member {number}\n */",
"this",
".",
"last",
"=",
"0",
";",
"/**\n * The css style of the cursor that is being used\n * @member {string}\n */",
"this",
".",
"currentCursorStyle",
"=",
"'inherit'",
";",
"/**\n * Internal cached var\n * @member {Point}\n * @private\n */",
"this",
".",
"_tempPoint",
"=",
"new",
"core",
".",
"Point",
"(",
")",
";",
"/**\n * The current resolution\n * @member {number}\n */",
"this",
".",
"resolution",
"=",
"1",
";",
"this",
".",
"setTargetElement",
"(",
"this",
".",
"renderer",
".",
"view",
",",
"this",
".",
"renderer",
".",
"resolution",
")",
";",
"}"
] | The interaction manager deals with mouse and touch events. Any DisplayObject can be interactive
if its interactive parameter is set to true
This manager also supports multitouch.
@class
@memberof PIXI.interaction
@param renderer {CanvasRenderer|WebGLRenderer} A reference to the current renderer
@param [options] {object}
@param [options.autoPreventDefault=true] {boolean} Should the manager automatically prevent default browser actions.
@param [options.interactionFrequency=10] {number} Frequency increases the interaction events will be checked. | [
"The",
"interaction",
"manager",
"deals",
"with",
"mouse",
"and",
"touch",
"events",
".",
"Any",
"DisplayObject",
"can",
"be",
"interactive",
"if",
"its",
"interactive",
"parameter",
"is",
"set",
"to",
"true",
"This",
"manager",
"also",
"supports",
"multitouch",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/interaction/InteractionManager.js#L22-L165 |
53,373 | integreat-io/great-uri-template | lib/filters/lower.js | lower | function lower (value) {
if (value === null || value === undefined) {
return value
}
return String.prototype.toLowerCase.call(value)
} | javascript | function lower (value) {
if (value === null || value === undefined) {
return value
}
return String.prototype.toLowerCase.call(value)
} | [
"function",
"lower",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"null",
"||",
"value",
"===",
"undefined",
")",
"{",
"return",
"value",
"}",
"return",
"String",
".",
"prototype",
".",
"toLowerCase",
".",
"call",
"(",
"value",
")",
"}"
] | Returns the value in lower case.
@param {string} value - The value
@returns {string} Lower case value | [
"Returns",
"the",
"value",
"in",
"lower",
"case",
"."
] | 0e896ead0567737cf31a4a8b76a26cfa6ce60759 | https://github.com/integreat-io/great-uri-template/blob/0e896ead0567737cf31a4a8b76a26cfa6ce60759/lib/filters/lower.js#L6-L11 |
53,374 | dalekjs/dalek-reporter-html | index.js | Reporter | function Reporter (opts) {
this.events = opts.events;
this.config = opts.config;
this.temporaryAssertions = [];
this.temp = {};
var defaultReportFolder = 'report/dalek';
this.dest = this.config.get('html-reporter') && this.config.get('html-reporter').dest ? this.config.get('html-reporter').dest : defaultReportFolder;
this.loadTemplates();
this.initOutputHandlers();
this.startListening();
} | javascript | function Reporter (opts) {
this.events = opts.events;
this.config = opts.config;
this.temporaryAssertions = [];
this.temp = {};
var defaultReportFolder = 'report/dalek';
this.dest = this.config.get('html-reporter') && this.config.get('html-reporter').dest ? this.config.get('html-reporter').dest : defaultReportFolder;
this.loadTemplates();
this.initOutputHandlers();
this.startListening();
} | [
"function",
"Reporter",
"(",
"opts",
")",
"{",
"this",
".",
"events",
"=",
"opts",
".",
"events",
";",
"this",
".",
"config",
"=",
"opts",
".",
"config",
";",
"this",
".",
"temporaryAssertions",
"=",
"[",
"]",
";",
"this",
".",
"temp",
"=",
"{",
"}",
";",
"var",
"defaultReportFolder",
"=",
"'report/dalek'",
";",
"this",
".",
"dest",
"=",
"this",
".",
"config",
".",
"get",
"(",
"'html-reporter'",
")",
"&&",
"this",
".",
"config",
".",
"get",
"(",
"'html-reporter'",
")",
".",
"dest",
"?",
"this",
".",
"config",
".",
"get",
"(",
"'html-reporter'",
")",
".",
"dest",
":",
"defaultReportFolder",
";",
"this",
".",
"loadTemplates",
"(",
")",
";",
"this",
".",
"initOutputHandlers",
"(",
")",
";",
"this",
".",
"startListening",
"(",
")",
";",
"}"
] | The HTML reporter can produce a set of HTML files with the results of your testrun.
The reporter can be installed with the following command:
```bash
$ npm install dalek-reporter-html --save-dev
```
By default the files will be written to the `report/dalek/` folder,
you can change this by adding a config option to the your Dalekfile
```javascript
"html-reporter": {
"dest": "your/folder"
}
```
If you would like to use the reporter (in addition to the std. console reporter),
you can start dalek with a special command line argument
```bash
$ dalek your_test.js -r console,html
```
or you can add it to your Dalekfile
```javascript
"reporter": ["console", "html"]
```
@class Reporter
@constructor
@part html
@api | [
"The",
"HTML",
"reporter",
"can",
"produce",
"a",
"set",
"of",
"HTML",
"files",
"with",
"the",
"results",
"of",
"your",
"testrun",
"."
] | af32ea029e2341a6c9705c38f071f9d9d93a66dd | https://github.com/dalekjs/dalek-reporter-html/blob/af32ea029e2341a6c9705c38f071f9d9d93a66dd/index.js#L72-L84 |
53,375 | dalekjs/dalek-reporter-html | index.js | function () {
// render stylesheets
var precss = fs.readFileSync(__dirname + '/themes/default/styl/default.styl', 'utf8');
stylus.render(precss, { filename: 'default.css' }, function(err, css){
if (err) {
throw err;
}
this.styles = css;
}.bind(this));
// collect client js (to be inined later)
this.js = fs.readFileSync(__dirname + '/themes/default/js/default.js', 'utf8');
// register handlebars helpers
Handlebars.registerHelper('roundNumber', function (number) {
return Math.round(number * Math.pow(10, 2)) / Math.pow(10, 2);
});
// collect & compile templates
this.templates = {};
this.templates.test = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/test.hbs', 'utf8'));
this.templates.wrapper = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/wrapper.hbs', 'utf8'));
this.templates.testresult = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/tests.hbs', 'utf8'));
this.templates.banner = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/banner.hbs', 'utf8'));
this.templates.detail = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/detail.hbs', 'utf8'));
return this;
} | javascript | function () {
// render stylesheets
var precss = fs.readFileSync(__dirname + '/themes/default/styl/default.styl', 'utf8');
stylus.render(precss, { filename: 'default.css' }, function(err, css){
if (err) {
throw err;
}
this.styles = css;
}.bind(this));
// collect client js (to be inined later)
this.js = fs.readFileSync(__dirname + '/themes/default/js/default.js', 'utf8');
// register handlebars helpers
Handlebars.registerHelper('roundNumber', function (number) {
return Math.round(number * Math.pow(10, 2)) / Math.pow(10, 2);
});
// collect & compile templates
this.templates = {};
this.templates.test = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/test.hbs', 'utf8'));
this.templates.wrapper = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/wrapper.hbs', 'utf8'));
this.templates.testresult = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/tests.hbs', 'utf8'));
this.templates.banner = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/banner.hbs', 'utf8'));
this.templates.detail = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/detail.hbs', 'utf8'));
return this;
} | [
"function",
"(",
")",
"{",
"// render stylesheets",
"var",
"precss",
"=",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/themes/default/styl/default.styl'",
",",
"'utf8'",
")",
";",
"stylus",
".",
"render",
"(",
"precss",
",",
"{",
"filename",
":",
"'default.css'",
"}",
",",
"function",
"(",
"err",
",",
"css",
")",
"{",
"if",
"(",
"err",
")",
"{",
"throw",
"err",
";",
"}",
"this",
".",
"styles",
"=",
"css",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"// collect client js (to be inined later)",
"this",
".",
"js",
"=",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/themes/default/js/default.js'",
",",
"'utf8'",
")",
";",
"// register handlebars helpers",
"Handlebars",
".",
"registerHelper",
"(",
"'roundNumber'",
",",
"function",
"(",
"number",
")",
"{",
"return",
"Math",
".",
"round",
"(",
"number",
"*",
"Math",
".",
"pow",
"(",
"10",
",",
"2",
")",
")",
"/",
"Math",
".",
"pow",
"(",
"10",
",",
"2",
")",
";",
"}",
")",
";",
"// collect & compile templates",
"this",
".",
"templates",
"=",
"{",
"}",
";",
"this",
".",
"templates",
".",
"test",
"=",
"Handlebars",
".",
"compile",
"(",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/themes/default/hbs/test.hbs'",
",",
"'utf8'",
")",
")",
";",
"this",
".",
"templates",
".",
"wrapper",
"=",
"Handlebars",
".",
"compile",
"(",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/themes/default/hbs/wrapper.hbs'",
",",
"'utf8'",
")",
")",
";",
"this",
".",
"templates",
".",
"testresult",
"=",
"Handlebars",
".",
"compile",
"(",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/themes/default/hbs/tests.hbs'",
",",
"'utf8'",
")",
")",
";",
"this",
".",
"templates",
".",
"banner",
"=",
"Handlebars",
".",
"compile",
"(",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/themes/default/hbs/banner.hbs'",
",",
"'utf8'",
")",
")",
";",
"this",
".",
"templates",
".",
"detail",
"=",
"Handlebars",
".",
"compile",
"(",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/themes/default/hbs/detail.hbs'",
",",
"'utf8'",
")",
")",
";",
"return",
"this",
";",
"}"
] | Loads and prepares all the templates for
CSS, JS & HTML
@method loadTemplates
@chainable | [
"Loads",
"and",
"prepares",
"all",
"the",
"templates",
"for",
"CSS",
"JS",
"&",
"HTML"
] | af32ea029e2341a6c9705c38f071f9d9d93a66dd | https://github.com/dalekjs/dalek-reporter-html/blob/af32ea029e2341a6c9705c38f071f9d9d93a66dd/index.js#L121-L149 |
|
53,376 | dalekjs/dalek-reporter-html | index.js | function (data) {
this.detailContents.testResult = data;
this.detailContents.styles = this.styles;
this.detailContents.js = this.js;
fs.writeFileSync(this.dest + '/details/' + data.id + '.html', this.templates.detail(this.detailContents), 'utf8');
return this;
} | javascript | function (data) {
this.detailContents.testResult = data;
this.detailContents.styles = this.styles;
this.detailContents.js = this.js;
fs.writeFileSync(this.dest + '/details/' + data.id + '.html', this.templates.detail(this.detailContents), 'utf8');
return this;
} | [
"function",
"(",
"data",
")",
"{",
"this",
".",
"detailContents",
".",
"testResult",
"=",
"data",
";",
"this",
".",
"detailContents",
".",
"styles",
"=",
"this",
".",
"styles",
";",
"this",
".",
"detailContents",
".",
"js",
"=",
"this",
".",
"js",
";",
"fs",
".",
"writeFileSync",
"(",
"this",
".",
"dest",
"+",
"'/details/'",
"+",
"data",
".",
"id",
"+",
"'.html'",
",",
"this",
".",
"templates",
".",
"detail",
"(",
"this",
".",
"detailContents",
")",
",",
"'utf8'",
")",
";",
"return",
"this",
";",
"}"
] | Writes a detail page to the file system
@method finishDetailPage
@param {object} data Event data
@chainable | [
"Writes",
"a",
"detail",
"page",
"to",
"the",
"file",
"system"
] | af32ea029e2341a6c9705c38f071f9d9d93a66dd | https://github.com/dalekjs/dalek-reporter-html/blob/af32ea029e2341a6c9705c38f071f9d9d93a66dd/index.js#L223-L229 |
|
53,377 | dalekjs/dalek-reporter-html | index.js | function (data) {
var body = '';
var contents = '';
var tests = '';
var banner = '';
// add test results
var keys = Object.keys(this.output.test);
keys.forEach(function (key) {
tests += this.output.test[key];
}.bind(this));
// compile the test result template
body = this.templates.testresult({result: data, tests: tests});
// compile the banner
banner = this.templates.banner({status: data.status});
// compile the contents within the wrapper template
contents = this.templates.wrapper({styles: this.styles, js: this.js, banner: banner, body: body});
// save the main test output file
this.events.emit('report:written', {type: 'html', dest: this.dest});
this._recursiveMakeDirSync(this.dest + '/details');
fs.writeFileSync(this.dest + '/index.html', contents, 'utf8');
return this;
} | javascript | function (data) {
var body = '';
var contents = '';
var tests = '';
var banner = '';
// add test results
var keys = Object.keys(this.output.test);
keys.forEach(function (key) {
tests += this.output.test[key];
}.bind(this));
// compile the test result template
body = this.templates.testresult({result: data, tests: tests});
// compile the banner
banner = this.templates.banner({status: data.status});
// compile the contents within the wrapper template
contents = this.templates.wrapper({styles: this.styles, js: this.js, banner: banner, body: body});
// save the main test output file
this.events.emit('report:written', {type: 'html', dest: this.dest});
this._recursiveMakeDirSync(this.dest + '/details');
fs.writeFileSync(this.dest + '/index.html', contents, 'utf8');
return this;
} | [
"function",
"(",
"data",
")",
"{",
"var",
"body",
"=",
"''",
";",
"var",
"contents",
"=",
"''",
";",
"var",
"tests",
"=",
"''",
";",
"var",
"banner",
"=",
"''",
";",
"// add test results",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"this",
".",
"output",
".",
"test",
")",
";",
"keys",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"tests",
"+=",
"this",
".",
"output",
".",
"test",
"[",
"key",
"]",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"// compile the test result template",
"body",
"=",
"this",
".",
"templates",
".",
"testresult",
"(",
"{",
"result",
":",
"data",
",",
"tests",
":",
"tests",
"}",
")",
";",
"// compile the banner",
"banner",
"=",
"this",
".",
"templates",
".",
"banner",
"(",
"{",
"status",
":",
"data",
".",
"status",
"}",
")",
";",
"// compile the contents within the wrapper template",
"contents",
"=",
"this",
".",
"templates",
".",
"wrapper",
"(",
"{",
"styles",
":",
"this",
".",
"styles",
",",
"js",
":",
"this",
".",
"js",
",",
"banner",
":",
"banner",
",",
"body",
":",
"body",
"}",
")",
";",
"// save the main test output file",
"this",
".",
"events",
".",
"emit",
"(",
"'report:written'",
",",
"{",
"type",
":",
"'html'",
",",
"dest",
":",
"this",
".",
"dest",
"}",
")",
";",
"this",
".",
"_recursiveMakeDirSync",
"(",
"this",
".",
"dest",
"+",
"'/details'",
")",
";",
"fs",
".",
"writeFileSync",
"(",
"this",
".",
"dest",
"+",
"'/index.html'",
",",
"contents",
",",
"'utf8'",
")",
";",
"return",
"this",
";",
"}"
] | Writes the index page to the filesystem
@method outputRunnerFinished
@param {object} data Event data
@chainable | [
"Writes",
"the",
"index",
"page",
"to",
"the",
"filesystem"
] | af32ea029e2341a6c9705c38f071f9d9d93a66dd | https://github.com/dalekjs/dalek-reporter-html/blob/af32ea029e2341a6c9705c38f071f9d9d93a66dd/index.js#L252-L278 |
|
53,378 | dalekjs/dalek-reporter-html | index.js | function (data) {
data.assertionInfo = this.temporaryAssertions;
data.browser = this.temp.browser;
this.output.test[data.id] = this.templates.test(data);
this.temporaryAssertions = [];
return this;
} | javascript | function (data) {
data.assertionInfo = this.temporaryAssertions;
data.browser = this.temp.browser;
this.output.test[data.id] = this.templates.test(data);
this.temporaryAssertions = [];
return this;
} | [
"function",
"(",
"data",
")",
"{",
"data",
".",
"assertionInfo",
"=",
"this",
".",
"temporaryAssertions",
";",
"data",
".",
"browser",
"=",
"this",
".",
"temp",
".",
"browser",
";",
"this",
".",
"output",
".",
"test",
"[",
"data",
".",
"id",
"]",
"=",
"this",
".",
"templates",
".",
"test",
"(",
"data",
")",
";",
"this",
".",
"temporaryAssertions",
"=",
"[",
"]",
";",
"return",
"this",
";",
"}"
] | Pushes an test result to the index output queue
@method outputTestFinished
@param {object} data Event data
@chainable | [
"Pushes",
"an",
"test",
"result",
"to",
"the",
"index",
"output",
"queue"
] | af32ea029e2341a6c9705c38f071f9d9d93a66dd | https://github.com/dalekjs/dalek-reporter-html/blob/af32ea029e2341a6c9705c38f071f9d9d93a66dd/index.js#L301-L307 |
|
53,379 | Meesayen/gladius-forge | index.js | function() {
var src = config.paths.src;
var out = config.paths.out;
src.base = src.base || 'src/';
src.styles = src.styles || 'styles/';
src.scripts = src.scripts || 'scripts/';
src.esnextExtension = src.esnextExtension || '.es6';
src.views = src.templates || '../views/';
src.partials = src.partials !== null ? src.partials : 'partials/';
out.base = out.base || 'public/';
var processed = {
src: {
styles: src.base + src.styles + '**/*' + plugins.styles.ext,
scripts: src.base + src.scripts,
es6: src.base + src.scripts + '**/*' + src.esnextExtension,
esnextExt: src.esnextExtension,
js: src.base + src.scripts + '**/*.js',
views: src.base + src.views + '**/*',
partials: src.base + src.views + src.partials + '**/*' + plugins.tpls.ext,
tmp: src.base + 'temp/'
},
out: {
base: out.base,
styles: out.base + (out.styles || 'css/'),
js: out.base + (out.scripts || 'js/')
}
};
return processed;
} | javascript | function() {
var src = config.paths.src;
var out = config.paths.out;
src.base = src.base || 'src/';
src.styles = src.styles || 'styles/';
src.scripts = src.scripts || 'scripts/';
src.esnextExtension = src.esnextExtension || '.es6';
src.views = src.templates || '../views/';
src.partials = src.partials !== null ? src.partials : 'partials/';
out.base = out.base || 'public/';
var processed = {
src: {
styles: src.base + src.styles + '**/*' + plugins.styles.ext,
scripts: src.base + src.scripts,
es6: src.base + src.scripts + '**/*' + src.esnextExtension,
esnextExt: src.esnextExtension,
js: src.base + src.scripts + '**/*.js',
views: src.base + src.views + '**/*',
partials: src.base + src.views + src.partials + '**/*' + plugins.tpls.ext,
tmp: src.base + 'temp/'
},
out: {
base: out.base,
styles: out.base + (out.styles || 'css/'),
js: out.base + (out.scripts || 'js/')
}
};
return processed;
} | [
"function",
"(",
")",
"{",
"var",
"src",
"=",
"config",
".",
"paths",
".",
"src",
";",
"var",
"out",
"=",
"config",
".",
"paths",
".",
"out",
";",
"src",
".",
"base",
"=",
"src",
".",
"base",
"||",
"'src/'",
";",
"src",
".",
"styles",
"=",
"src",
".",
"styles",
"||",
"'styles/'",
";",
"src",
".",
"scripts",
"=",
"src",
".",
"scripts",
"||",
"'scripts/'",
";",
"src",
".",
"esnextExtension",
"=",
"src",
".",
"esnextExtension",
"||",
"'.es6'",
";",
"src",
".",
"views",
"=",
"src",
".",
"templates",
"||",
"'../views/'",
";",
"src",
".",
"partials",
"=",
"src",
".",
"partials",
"!==",
"null",
"?",
"src",
".",
"partials",
":",
"'partials/'",
";",
"out",
".",
"base",
"=",
"out",
".",
"base",
"||",
"'public/'",
";",
"var",
"processed",
"=",
"{",
"src",
":",
"{",
"styles",
":",
"src",
".",
"base",
"+",
"src",
".",
"styles",
"+",
"'**/*'",
"+",
"plugins",
".",
"styles",
".",
"ext",
",",
"scripts",
":",
"src",
".",
"base",
"+",
"src",
".",
"scripts",
",",
"es6",
":",
"src",
".",
"base",
"+",
"src",
".",
"scripts",
"+",
"'**/*'",
"+",
"src",
".",
"esnextExtension",
",",
"esnextExt",
":",
"src",
".",
"esnextExtension",
",",
"js",
":",
"src",
".",
"base",
"+",
"src",
".",
"scripts",
"+",
"'**/*.js'",
",",
"views",
":",
"src",
".",
"base",
"+",
"src",
".",
"views",
"+",
"'**/*'",
",",
"partials",
":",
"src",
".",
"base",
"+",
"src",
".",
"views",
"+",
"src",
".",
"partials",
"+",
"'**/*'",
"+",
"plugins",
".",
"tpls",
".",
"ext",
",",
"tmp",
":",
"src",
".",
"base",
"+",
"'temp/'",
"}",
",",
"out",
":",
"{",
"base",
":",
"out",
".",
"base",
",",
"styles",
":",
"out",
".",
"base",
"+",
"(",
"out",
".",
"styles",
"||",
"'css/'",
")",
",",
"js",
":",
"out",
".",
"base",
"+",
"(",
"out",
".",
"scripts",
"||",
"'js/'",
")",
"}",
"}",
";",
"return",
"processed",
";",
"}"
] | paths normalization helper | [
"paths",
"normalization",
"helper"
] | fa3e0280cf306f2b9232f302e1af7e9c54462199 | https://github.com/Meesayen/gladius-forge/blob/fa3e0280cf306f2b9232f302e1af7e9c54462199/index.js#L30-L62 |
|
53,380 | Meesayen/gladius-forge | index.js | function(_gulp, _config) {
if (!_gulp) {
throw 'Error: A Gulp instance should be passed to the gulpConfig method.';
}
gulp = _gulp;
config = _config || { paths: { src: {}, out: {} } };
plugins = elaboratePlugins();
paths = elaboratePaths();
lrport = _config.liveReloadPort || lrport;
server = _config.server || (console.error(
'An Express server should be passed in the configuration.')),
serverport = _config.port || serverport;
cleanTmp = function(done) {
del(paths.src.tmp, { force: _config.forceClean || false }, done);
};
} | javascript | function(_gulp, _config) {
if (!_gulp) {
throw 'Error: A Gulp instance should be passed to the gulpConfig method.';
}
gulp = _gulp;
config = _config || { paths: { src: {}, out: {} } };
plugins = elaboratePlugins();
paths = elaboratePaths();
lrport = _config.liveReloadPort || lrport;
server = _config.server || (console.error(
'An Express server should be passed in the configuration.')),
serverport = _config.port || serverport;
cleanTmp = function(done) {
del(paths.src.tmp, { force: _config.forceClean || false }, done);
};
} | [
"function",
"(",
"_gulp",
",",
"_config",
")",
"{",
"if",
"(",
"!",
"_gulp",
")",
"{",
"throw",
"'Error: A Gulp instance should be passed to the gulpConfig method.'",
";",
"}",
"gulp",
"=",
"_gulp",
";",
"config",
"=",
"_config",
"||",
"{",
"paths",
":",
"{",
"src",
":",
"{",
"}",
",",
"out",
":",
"{",
"}",
"}",
"}",
";",
"plugins",
"=",
"elaboratePlugins",
"(",
")",
";",
"paths",
"=",
"elaboratePaths",
"(",
")",
";",
"lrport",
"=",
"_config",
".",
"liveReloadPort",
"||",
"lrport",
";",
"server",
"=",
"_config",
".",
"server",
"||",
"(",
"console",
".",
"error",
"(",
"'An Express server should be passed in the configuration.'",
")",
")",
",",
"serverport",
"=",
"_config",
".",
"port",
"||",
"serverport",
";",
"cleanTmp",
"=",
"function",
"(",
"done",
")",
"{",
"del",
"(",
"paths",
".",
"src",
".",
"tmp",
",",
"{",
"force",
":",
"_config",
".",
"forceClean",
"||",
"false",
"}",
",",
"done",
")",
";",
"}",
";",
"}"
] | Gladius Forge configuration function.
@param {Object} _gulp: The gulp instance created from the gulpfile.js
@param {Object} config: Configuration object | [
"Gladius",
"Forge",
"configuration",
"function",
"."
] | fa3e0280cf306f2b9232f302e1af7e9c54462199 | https://github.com/Meesayen/gladius-forge/blob/fa3e0280cf306f2b9232f302e1af7e9c54462199/index.js#L150-L168 |
|
53,381 | Meesayen/gladius-forge | index.js | function(addExtraWatchers) {
/* Watchers -------------------------------------------------------------- */
gulp.task('watch', ['serve'], function () {
gulp.watch(paths.src.es6, ['bundle-js:dev:clean']);
gulp.watch(paths.src.js, ['bundle-js:dev:clean']);
gulp.watch(paths.src.styles, ['styles']);
gulp.watch(paths.src.views, ['tpl-reload']);
gulp.watch(paths.out.base + '**/*', ['reload']);
addExtraWatchers && addExtraWatchers(gulp);
});
} | javascript | function(addExtraWatchers) {
/* Watchers -------------------------------------------------------------- */
gulp.task('watch', ['serve'], function () {
gulp.watch(paths.src.es6, ['bundle-js:dev:clean']);
gulp.watch(paths.src.js, ['bundle-js:dev:clean']);
gulp.watch(paths.src.styles, ['styles']);
gulp.watch(paths.src.views, ['tpl-reload']);
gulp.watch(paths.out.base + '**/*', ['reload']);
addExtraWatchers && addExtraWatchers(gulp);
});
} | [
"function",
"(",
"addExtraWatchers",
")",
"{",
"/* Watchers -------------------------------------------------------------- */",
"gulp",
".",
"task",
"(",
"'watch'",
",",
"[",
"'serve'",
"]",
",",
"function",
"(",
")",
"{",
"gulp",
".",
"watch",
"(",
"paths",
".",
"src",
".",
"es6",
",",
"[",
"'bundle-js:dev:clean'",
"]",
")",
";",
"gulp",
".",
"watch",
"(",
"paths",
".",
"src",
".",
"js",
",",
"[",
"'bundle-js:dev:clean'",
"]",
")",
";",
"gulp",
".",
"watch",
"(",
"paths",
".",
"src",
".",
"styles",
",",
"[",
"'styles'",
"]",
")",
";",
"gulp",
".",
"watch",
"(",
"paths",
".",
"src",
".",
"views",
",",
"[",
"'tpl-reload'",
"]",
")",
";",
"gulp",
".",
"watch",
"(",
"paths",
".",
"out",
".",
"base",
"+",
"'**/*'",
",",
"[",
"'reload'",
"]",
")",
";",
"addExtraWatchers",
"&&",
"addExtraWatchers",
"(",
"gulp",
")",
";",
"}",
")",
";",
"}"
] | Gladius Forge watchers setup function. It takes a list of extra watchers
to add to the process.
@param {list<function>} extraWatchers: List of extra watchers to add. | [
"Gladius",
"Forge",
"watchers",
"setup",
"function",
".",
"It",
"takes",
"a",
"list",
"of",
"extra",
"watchers",
"to",
"add",
"to",
"the",
"process",
"."
] | fa3e0280cf306f2b9232f302e1af7e9c54462199 | https://github.com/Meesayen/gladius-forge/blob/fa3e0280cf306f2b9232f302e1af7e9c54462199/index.js#L493-L504 |
|
53,382 | Meesayen/gladius-forge | index.js | function(extensions) {
var
extensions = extensions || {},
devExts = extensions.development || [],
testExts = extensions.test || [],
prodExts = extensions.production || [];
gulp.task('default', ['development']);
gulp.task('post-install-development', [
'karma:dev',
'styles',
'bundle-js:dev:clean',
'tpl-precompile',
'watch'
].concat(devExts));
gulp.task('development', ['install-dev-dep'], function() {
gulp.start('post-install-development');
});
gulp.task('post-install-test', [
'lint',
'karma'
].concat(testExts), cleanTmp);
gulp.task('test', ['install-dev-dep'], function() {
gulp.start('post-install-test');
});
gulp.task('post-install-production', [
'styles',
'bundle-js:clean',
'tpl-precompile'
].concat(prodExts));
gulp.task('production', ['install-dep'], function() {
gulp.start('post-install-production');
});
} | javascript | function(extensions) {
var
extensions = extensions || {},
devExts = extensions.development || [],
testExts = extensions.test || [],
prodExts = extensions.production || [];
gulp.task('default', ['development']);
gulp.task('post-install-development', [
'karma:dev',
'styles',
'bundle-js:dev:clean',
'tpl-precompile',
'watch'
].concat(devExts));
gulp.task('development', ['install-dev-dep'], function() {
gulp.start('post-install-development');
});
gulp.task('post-install-test', [
'lint',
'karma'
].concat(testExts), cleanTmp);
gulp.task('test', ['install-dev-dep'], function() {
gulp.start('post-install-test');
});
gulp.task('post-install-production', [
'styles',
'bundle-js:clean',
'tpl-precompile'
].concat(prodExts));
gulp.task('production', ['install-dep'], function() {
gulp.start('post-install-production');
});
} | [
"function",
"(",
"extensions",
")",
"{",
"var",
"extensions",
"=",
"extensions",
"||",
"{",
"}",
",",
"devExts",
"=",
"extensions",
".",
"development",
"||",
"[",
"]",
",",
"testExts",
"=",
"extensions",
".",
"test",
"||",
"[",
"]",
",",
"prodExts",
"=",
"extensions",
".",
"production",
"||",
"[",
"]",
";",
"gulp",
".",
"task",
"(",
"'default'",
",",
"[",
"'development'",
"]",
")",
";",
"gulp",
".",
"task",
"(",
"'post-install-development'",
",",
"[",
"'karma:dev'",
",",
"'styles'",
",",
"'bundle-js:dev:clean'",
",",
"'tpl-precompile'",
",",
"'watch'",
"]",
".",
"concat",
"(",
"devExts",
")",
")",
";",
"gulp",
".",
"task",
"(",
"'development'",
",",
"[",
"'install-dev-dep'",
"]",
",",
"function",
"(",
")",
"{",
"gulp",
".",
"start",
"(",
"'post-install-development'",
")",
";",
"}",
")",
";",
"gulp",
".",
"task",
"(",
"'post-install-test'",
",",
"[",
"'lint'",
",",
"'karma'",
"]",
".",
"concat",
"(",
"testExts",
")",
",",
"cleanTmp",
")",
";",
"gulp",
".",
"task",
"(",
"'test'",
",",
"[",
"'install-dev-dep'",
"]",
",",
"function",
"(",
")",
"{",
"gulp",
".",
"start",
"(",
"'post-install-test'",
")",
";",
"}",
")",
";",
"gulp",
".",
"task",
"(",
"'post-install-production'",
",",
"[",
"'styles'",
",",
"'bundle-js:clean'",
",",
"'tpl-precompile'",
"]",
".",
"concat",
"(",
"prodExts",
")",
")",
";",
"gulp",
".",
"task",
"(",
"'production'",
",",
"[",
"'install-dep'",
"]",
",",
"function",
"(",
")",
"{",
"gulp",
".",
"start",
"(",
"'post-install-production'",
")",
";",
"}",
")",
";",
"}"
] | Gladius Forge main tasks setup function. It can extend main tasks with
extra externally defined tasks via an "extension" parameter.
@param {Object} extensions: object descriptor of extra tasks to add for
each main task. | [
"Gladius",
"Forge",
"main",
"tasks",
"setup",
"function",
".",
"It",
"can",
"extend",
"main",
"tasks",
"with",
"extra",
"externally",
"defined",
"tasks",
"via",
"an",
"extension",
"parameter",
"."
] | fa3e0280cf306f2b9232f302e1af7e9c54462199 | https://github.com/Meesayen/gladius-forge/blob/fa3e0280cf306f2b9232f302e1af7e9c54462199/index.js#L513-L549 |
|
53,383 | mprinc/qpp | index.js | function(name, resourcesNo, waitForMoreDemandingConsumers, debug){
/**
@memberof! qpp.SemaphoreMultiReservation#
@var {string} name - name of the semaphore
*/
this.name = name || "semaphore";
resourcesNo = resourcesNo || 1;
/**
@memberof! qpp.SemaphoreMultiReservation#
@private
@var {string} initialResources - initial (total) number of resources that semaphore has
*/
this.initialResources = resourcesNo;
/**
@memberof! qpp.SemaphoreMultiReservation#
@var {string} resourcesNo - currently available number of resources
*/
this.resourcesNo = resourcesNo;
/**
@memberof! qpp.SemaphoreMultiReservation#
@private
@var {string} waitingQueue - queue holding the list of waiting consumers (functions) for available resources
*/
this.waitingQueue = [];
/**
@memberof! qpp.SemaphoreMultiReservation#
@var {boolean} waitForMoreDemandingConsumers=true - defines if consumer can allocate resources even if other consumer waits for available resources (but needs more resources than currently available)
@example
var s = new Semaphore('s', 3);
var wP1 = s.wait(1); // fine, 2 resources left available
var wP2 = s.wait(3); // not fine (consumer 1 has to release)
// wP3 will be fine and resolved if {@link this.waitForMoreDemandingConsumers} === false
// or not fine and not resolved until consumer 1's resources are released (signaled)
// if {@link this.waitForMoreDemandingConsumers} === true (default)
var wP3 = s.wait(2);
*/
this.waitForMoreDemandingConsumers = typeof waitForMoreDemandingConsumers !== 'undefined' ? waitForMoreDemandingConsumers : true;
/**
@memberof! qpp.SemaphoreMultiReservation#
@var {boolean} debug - defines if debugging messages should be shown during Semaphore operations
*/
this.debug = typeof debug !== 'undefined' ? debug : false;
} | javascript | function(name, resourcesNo, waitForMoreDemandingConsumers, debug){
/**
@memberof! qpp.SemaphoreMultiReservation#
@var {string} name - name of the semaphore
*/
this.name = name || "semaphore";
resourcesNo = resourcesNo || 1;
/**
@memberof! qpp.SemaphoreMultiReservation#
@private
@var {string} initialResources - initial (total) number of resources that semaphore has
*/
this.initialResources = resourcesNo;
/**
@memberof! qpp.SemaphoreMultiReservation#
@var {string} resourcesNo - currently available number of resources
*/
this.resourcesNo = resourcesNo;
/**
@memberof! qpp.SemaphoreMultiReservation#
@private
@var {string} waitingQueue - queue holding the list of waiting consumers (functions) for available resources
*/
this.waitingQueue = [];
/**
@memberof! qpp.SemaphoreMultiReservation#
@var {boolean} waitForMoreDemandingConsumers=true - defines if consumer can allocate resources even if other consumer waits for available resources (but needs more resources than currently available)
@example
var s = new Semaphore('s', 3);
var wP1 = s.wait(1); // fine, 2 resources left available
var wP2 = s.wait(3); // not fine (consumer 1 has to release)
// wP3 will be fine and resolved if {@link this.waitForMoreDemandingConsumers} === false
// or not fine and not resolved until consumer 1's resources are released (signaled)
// if {@link this.waitForMoreDemandingConsumers} === true (default)
var wP3 = s.wait(2);
*/
this.waitForMoreDemandingConsumers = typeof waitForMoreDemandingConsumers !== 'undefined' ? waitForMoreDemandingConsumers : true;
/**
@memberof! qpp.SemaphoreMultiReservation#
@var {boolean} debug - defines if debugging messages should be shown during Semaphore operations
*/
this.debug = typeof debug !== 'undefined' ? debug : false;
} | [
"function",
"(",
"name",
",",
"resourcesNo",
",",
"waitForMoreDemandingConsumers",
",",
"debug",
")",
"{",
"/**\n\t\t@memberof! qpp.SemaphoreMultiReservation#\n\t\t@var {string} name - name of the semaphore\n\t\t*/",
"this",
".",
"name",
"=",
"name",
"||",
"\"semaphore\"",
";",
"resourcesNo",
"=",
"resourcesNo",
"||",
"1",
";",
"/**\n\t\t@memberof! qpp.SemaphoreMultiReservation#\n\t\t@private\n\t\t@var {string} initialResources - initial (total) number of resources that semaphore has\n\t\t*/",
"this",
".",
"initialResources",
"=",
"resourcesNo",
";",
"/**\n\t\t@memberof! qpp.SemaphoreMultiReservation#\n\t\t@var {string} resourcesNo - currently available number of resources\n\t\t*/",
"this",
".",
"resourcesNo",
"=",
"resourcesNo",
";",
"/**\n\t\t@memberof! qpp.SemaphoreMultiReservation#\n\t\t@private\n\t\t@var {string} waitingQueue - queue holding the list of waiting consumers (functions) for available resources\n\t\t*/",
"this",
".",
"waitingQueue",
"=",
"[",
"]",
";",
"/**\n\t\t@memberof! qpp.SemaphoreMultiReservation#\n\t\t@var {boolean} waitForMoreDemandingConsumers=true - defines if consumer can allocate resources even if other consumer waits for available resources (but needs more resources than currently available)\n\t\t@example\n\t\tvar s = new Semaphore('s', 3);\n\t\tvar wP1 = s.wait(1); // fine, 2 resources left available\n\t\tvar wP2 = s.wait(3); // not fine (consumer 1 has to release)\n\t\t// wP3 will be fine and resolved if {@link this.waitForMoreDemandingConsumers} === false\n\t\t// or not fine and not resolved until consumer 1's resources are released (signaled)\n\t\t// if {@link this.waitForMoreDemandingConsumers} === true (default)\n\t\tvar wP3 = s.wait(2);\n\t\t*/",
"this",
".",
"waitForMoreDemandingConsumers",
"=",
"typeof",
"waitForMoreDemandingConsumers",
"!==",
"'undefined'",
"?",
"waitForMoreDemandingConsumers",
":",
"true",
";",
"/**\n\t\t@memberof! qpp.SemaphoreMultiReservation#\n\t\t@var {boolean} debug - defines if debugging messages should be shown during Semaphore operations\n\t\t*/",
"this",
".",
"debug",
"=",
"typeof",
"debug",
"!==",
"'undefined'",
"?",
"debug",
":",
"false",
";",
"}"
] | Constructor function. Creates a new semaphore with optional name and resources number
@classdesc This is a class that provides promises enabled semaphores.
It differs from the class Semaphore (@see {@link qpp.Semaphore} ) in a way
it supports allocation of more than one resource in one wait() call
@example
Example of 3 groups
var QPP = require('qpp');
var s = new QPP.SemaphoreMultiReservation('Nebojsa tower', 5);
group 1
setTimeout(function(){
s.wait(3) // 3 people
.then(function(){ // resource is available, consuming resource
console.log("Group 1: Let's run to the top!");
setTimeout(function(){
console.log("Group 1: Great experience, but they ask us to leave!")
s.signal(3); // releasing resource (toilet)
}, parseInt(Math.random()*1500)+1);
});
}, parseInt(Math.random()*100)+1);
group 2
setTimeout(function(){
s.wait(4) // 4 people
.then(function(){ // resource is available, consuming resource
console.log("Group 2: Tower is available for us!");
setTimeout(function(){
console.log("Group 2: Let's give the space for others!")
s.signal(4); // releasing resource (toilet)
}, parseInt(Math.random()*500)+1);
});
}, parseInt(Math.random()*100)+1);
group 3
setTimeout(function(){
s.wait(2) // 2 people
.then(function(){ // resource is available, consuming resource
console.log("Group 3: Hey, i have to show you the view!");
setTimeout(function(){
console.log("Group 3: Ah, we could stay here forever!")
s.signal(2); // releasing resource (toilet)
}, parseInt(Math.random()*100)+1);
});
}, parseInt(Math.random()*100)+1);
This is the most interesting scenario:
Group 2: Tower is available for us
Group 2: Let's give the space for others
Group 3: Hey, i have to show you the view
Group 1: Let's run to the top
Group 3: Ah, we could stay here forever
Group 1: Great experience, but they ask us to leave!
Because both group 1 and 3 ended up at the top of the towe simultaneously
(there were enough of resources to allocate for both (2+3<=5))
For more examples, please check unit tests for @see qpp.mapBandwidth
@memberof qpp
@exports qpp.Semaphore
@class qpp.SemaphoreMultiReservation
@param {string} [name="semaphore"] - The name of the created semaphore
@param {number(integer)} [resourcesNo=1] - The total numer of resources available
@param {boolean} [debug=false] - Defines if debugging messages should be shown during Semaphore operations
@param {boolean} [waitForMoreDemandingConsumers=true] - Defines if consumer can allocate resources even if other consumer waits for available resources (but needs more resources than currently available)
@param {boolean} [debug=false] - Defines if debugging messages should be shown during Semaphore operations | [
"Constructor",
"function",
".",
"Creates",
"a",
"new",
"semaphore",
"with",
"optional",
"name",
"and",
"resources",
"number"
] | 379d132c61b06d54dc532947c1bcd7029665739d | https://github.com/mprinc/qpp/blob/379d132c61b06d54dc532947c1bcd7029665739d/index.js#L362-L407 |
|
53,384 | mprinc/qpp | index.js | function(resourcesNo, debug){
resourcesNo = resourcesNo || 1;
/**
@memberof! qpp.SemaphoresHash#
@var {Array.<string,QPP.Semaphore>} semaphores - array hash of semaphores
*/
this.semaphores = {};
/**
@memberof! qpp.SemaphoresHash#
@private
@var {string} initialResources - initial (total) number of resources that SemaphoresHash has
*/
this.initialResources = resourcesNo;
/**
@memberof! qpp.SemaphoresHash#
@var {boolean} debug - defines if debugging messages should be shown during SemaphoresHash operations
*/
this.debug = typeof debug !== 'undefined' ? debug : false;
} | javascript | function(resourcesNo, debug){
resourcesNo = resourcesNo || 1;
/**
@memberof! qpp.SemaphoresHash#
@var {Array.<string,QPP.Semaphore>} semaphores - array hash of semaphores
*/
this.semaphores = {};
/**
@memberof! qpp.SemaphoresHash#
@private
@var {string} initialResources - initial (total) number of resources that SemaphoresHash has
*/
this.initialResources = resourcesNo;
/**
@memberof! qpp.SemaphoresHash#
@var {boolean} debug - defines if debugging messages should be shown during SemaphoresHash operations
*/
this.debug = typeof debug !== 'undefined' ? debug : false;
} | [
"function",
"(",
"resourcesNo",
",",
"debug",
")",
"{",
"resourcesNo",
"=",
"resourcesNo",
"||",
"1",
";",
"/**\n\t\t@memberof! qpp.SemaphoresHash#\n\t\t@var {Array.<string,QPP.Semaphore>} semaphores - array hash of semaphores\n\t\t*/",
"this",
".",
"semaphores",
"=",
"{",
"}",
";",
"/**\n\t\t@memberof! qpp.SemaphoresHash#\n\t\t@private\n\t\t@var {string} initialResources - initial (total) number of resources that SemaphoresHash has\n\t\t*/",
"this",
".",
"initialResources",
"=",
"resourcesNo",
";",
"/**\n\t\t@memberof! qpp.SemaphoresHash#\n\t\t@var {boolean} debug - defines if debugging messages should be shown during SemaphoresHash operations\n\t\t*/",
"this",
".",
"debug",
"=",
"typeof",
"debug",
"!==",
"'undefined'",
"?",
"debug",
":",
"false",
";",
"}"
] | Constructor function. Creates a new SemaphoresHash with optional and resources number
@classdesc This is a class that provides promises enabled SemaphoresHashes.
It is possible to create a SemaphoresHash with a name and speciffic number of resources that we can wait for to get available,
and release them when we do not need them anymore
@example
Example of two consumers
var QPP = require('./..');
var s = new QPP.SemaphoresHash();
s.create('test1');
s.wait('test1');
s.wait('test2'); // semaphore 'test2' is implictly created when we try to listen for it (no need for explicit create)
s.signal('test2');
s.signal('test1');
For more examples, please check demo code and unit tests for @see qpp.SemaphoresHash
@memberof qpp
@alias qpp.SemaphoresHash
@exports qpp.SemaphoresHash
@class qpp.SemaphoresHash
@param {string} [name="SemaphoresHash"] - The name of the created SemaphoresHash
@param {number(integer)} [resourcesNo=1] - The total numer of resources available
@param {boolean} [debug=false] - Defines if debugging messages should be shown during SemaphoresHash operations | [
"Constructor",
"function",
".",
"Creates",
"a",
"new",
"SemaphoresHash",
"with",
"optional",
"and",
"resources",
"number"
] | 379d132c61b06d54dc532947c1bcd7029665739d | https://github.com/mprinc/qpp/blob/379d132c61b06d54dc532947c1bcd7029665739d/index.js#L535-L554 |
|
53,385 | appache/appache | src/core/plugins/inherit/addInheritance.js | buildConfig | function buildConfig(
config, items, item, inheritableConfigs = {}, visitedItems = []
) {
let { id } = item
if (visitedItems.includes(id)) {
throw new Error(`Item "${id}" has cyclic dependencies`)
}
let _extends = item.extends || DEFAULT
let inheritedConfig = inheritableConfigs[_extends]
visitedItems.push(id)
if (!inheritedConfig) {
let parent = findOneById(items, _extends)
if (!parent) {
throw new Error(`Item "${id}" tries to extend a non-existent item`)
}
parent = buildConfig(
config, items, parent, inheritableConfigs, visitedItems
)
inheritedConfig = extractInheritableConfig(config, parent)
inheritableConfigs[parent.id] = inheritedConfig
}
return mergeConfigs(inheritedConfig, item)
} | javascript | function buildConfig(
config, items, item, inheritableConfigs = {}, visitedItems = []
) {
let { id } = item
if (visitedItems.includes(id)) {
throw new Error(`Item "${id}" has cyclic dependencies`)
}
let _extends = item.extends || DEFAULT
let inheritedConfig = inheritableConfigs[_extends]
visitedItems.push(id)
if (!inheritedConfig) {
let parent = findOneById(items, _extends)
if (!parent) {
throw new Error(`Item "${id}" tries to extend a non-existent item`)
}
parent = buildConfig(
config, items, parent, inheritableConfigs, visitedItems
)
inheritedConfig = extractInheritableConfig(config, parent)
inheritableConfigs[parent.id] = inheritedConfig
}
return mergeConfigs(inheritedConfig, item)
} | [
"function",
"buildConfig",
"(",
"config",
",",
"items",
",",
"item",
",",
"inheritableConfigs",
"=",
"{",
"}",
",",
"visitedItems",
"=",
"[",
"]",
")",
"{",
"let",
"{",
"id",
"}",
"=",
"item",
"if",
"(",
"visitedItems",
".",
"includes",
"(",
"id",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"id",
"}",
"`",
")",
"}",
"let",
"_extends",
"=",
"item",
".",
"extends",
"||",
"DEFAULT",
"let",
"inheritedConfig",
"=",
"inheritableConfigs",
"[",
"_extends",
"]",
"visitedItems",
".",
"push",
"(",
"id",
")",
"if",
"(",
"!",
"inheritedConfig",
")",
"{",
"let",
"parent",
"=",
"findOneById",
"(",
"items",
",",
"_extends",
")",
"if",
"(",
"!",
"parent",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"id",
"}",
"`",
")",
"}",
"parent",
"=",
"buildConfig",
"(",
"config",
",",
"items",
",",
"parent",
",",
"inheritableConfigs",
",",
"visitedItems",
")",
"inheritedConfig",
"=",
"extractInheritableConfig",
"(",
"config",
",",
"parent",
")",
"inheritableConfigs",
"[",
"parent",
".",
"id",
"]",
"=",
"inheritedConfig",
"}",
"return",
"mergeConfigs",
"(",
"inheritedConfig",
",",
"item",
")",
"}"
] | Mutates inheritableConfigs and visitedItems | [
"Mutates",
"inheritableConfigs",
"and",
"visitedItems"
] | 6f6f6534367a2e8ab1ec6672bdc169a124083ea9 | https://github.com/appache/appache/blob/6f6f6534367a2e8ab1ec6672bdc169a124083ea9/src/core/plugins/inherit/addInheritance.js#L49-L77 |
53,386 | jasonsites/proxy-es-aws | src/cli.js | setCliConfiguration | function setCliConfiguration() {
return yargs
.usage('usage: $0 [options] <aws-elasticsearch-cluster-endpoint>')
.option('h', {
alias: 'host',
default: HOST || '127.0.0.1',
demand: false,
describe: 'Host IP Address',
type: 'string',
})
.option('p', {
alias: 'port',
default: PORT || 9200,
demand: false,
describe: 'Host Port',
type: 'number',
})
.option('r', {
alias: 'region',
default: REGION || 'us-west-2',
demand: false,
describe: 'AWS region',
type: 'string',
})
.option('e', {
alias: 'endpoint',
default: ENDPOINT,
demand: true,
describe: 'AWS Elasticsearch Endpoint',
type: 'string',
})
.option('c', {
alias: 'profile',
default: AWS_PROFILE || 'default',
demand: false,
describe: 'AWS Credentials Profile',
type: 'string',
})
.option('d', {
alias: 'debug',
default: DEBUG || false,
demand: false,
describe: 'Provides debug logging',
type: 'boolean',
})
.help()
.version()
.strict()
} | javascript | function setCliConfiguration() {
return yargs
.usage('usage: $0 [options] <aws-elasticsearch-cluster-endpoint>')
.option('h', {
alias: 'host',
default: HOST || '127.0.0.1',
demand: false,
describe: 'Host IP Address',
type: 'string',
})
.option('p', {
alias: 'port',
default: PORT || 9200,
demand: false,
describe: 'Host Port',
type: 'number',
})
.option('r', {
alias: 'region',
default: REGION || 'us-west-2',
demand: false,
describe: 'AWS region',
type: 'string',
})
.option('e', {
alias: 'endpoint',
default: ENDPOINT,
demand: true,
describe: 'AWS Elasticsearch Endpoint',
type: 'string',
})
.option('c', {
alias: 'profile',
default: AWS_PROFILE || 'default',
demand: false,
describe: 'AWS Credentials Profile',
type: 'string',
})
.option('d', {
alias: 'debug',
default: DEBUG || false,
demand: false,
describe: 'Provides debug logging',
type: 'boolean',
})
.help()
.version()
.strict()
} | [
"function",
"setCliConfiguration",
"(",
")",
"{",
"return",
"yargs",
".",
"usage",
"(",
"'usage: $0 [options] <aws-elasticsearch-cluster-endpoint>'",
")",
".",
"option",
"(",
"'h'",
",",
"{",
"alias",
":",
"'host'",
",",
"default",
":",
"HOST",
"||",
"'127.0.0.1'",
",",
"demand",
":",
"false",
",",
"describe",
":",
"'Host IP Address'",
",",
"type",
":",
"'string'",
",",
"}",
")",
".",
"option",
"(",
"'p'",
",",
"{",
"alias",
":",
"'port'",
",",
"default",
":",
"PORT",
"||",
"9200",
",",
"demand",
":",
"false",
",",
"describe",
":",
"'Host Port'",
",",
"type",
":",
"'number'",
",",
"}",
")",
".",
"option",
"(",
"'r'",
",",
"{",
"alias",
":",
"'region'",
",",
"default",
":",
"REGION",
"||",
"'us-west-2'",
",",
"demand",
":",
"false",
",",
"describe",
":",
"'AWS region'",
",",
"type",
":",
"'string'",
",",
"}",
")",
".",
"option",
"(",
"'e'",
",",
"{",
"alias",
":",
"'endpoint'",
",",
"default",
":",
"ENDPOINT",
",",
"demand",
":",
"true",
",",
"describe",
":",
"'AWS Elasticsearch Endpoint'",
",",
"type",
":",
"'string'",
",",
"}",
")",
".",
"option",
"(",
"'c'",
",",
"{",
"alias",
":",
"'profile'",
",",
"default",
":",
"AWS_PROFILE",
"||",
"'default'",
",",
"demand",
":",
"false",
",",
"describe",
":",
"'AWS Credentials Profile'",
",",
"type",
":",
"'string'",
",",
"}",
")",
".",
"option",
"(",
"'d'",
",",
"{",
"alias",
":",
"'debug'",
",",
"default",
":",
"DEBUG",
"||",
"false",
",",
"demand",
":",
"false",
",",
"describe",
":",
"'Provides debug logging'",
",",
"type",
":",
"'boolean'",
",",
"}",
")",
".",
"help",
"(",
")",
".",
"version",
"(",
")",
".",
"strict",
"(",
")",
"}"
] | Defines CLI options
@return {Object} | [
"Defines",
"CLI",
"options"
] | b2625106d877fea76f74b0b88ed8568a8ff61612 | https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/cli.js#L26-L74 |
53,387 | jmjuanes/minsql | lib/create.js | CreateRows | function CreateRows(obj)
{
//Start the output
var out = '';
//Get all
for(var key in obj)
{
//Check the out
if(out !== '')
{
//Add a comma
out = out + ', ';
}
//Add the row
out = out + key + ' ' + obj[key];
}
//Return the output
return out;
} | javascript | function CreateRows(obj)
{
//Start the output
var out = '';
//Get all
for(var key in obj)
{
//Check the out
if(out !== '')
{
//Add a comma
out = out + ', ';
}
//Add the row
out = out + key + ' ' + obj[key];
}
//Return the output
return out;
} | [
"function",
"CreateRows",
"(",
"obj",
")",
"{",
"//Start the output",
"var",
"out",
"=",
"''",
";",
"//Get all",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"//Check the out",
"if",
"(",
"out",
"!==",
"''",
")",
"{",
"//Add a comma",
"out",
"=",
"out",
"+",
"', '",
";",
"}",
"//Add the row",
"out",
"=",
"out",
"+",
"key",
"+",
"' '",
"+",
"obj",
"[",
"key",
"]",
";",
"}",
"//Return the output",
"return",
"out",
";",
"}"
] | Create the Rows | [
"Create",
"the",
"Rows"
] | 80eddd97e858545997b30e3c9bc067d5fc2df5a0 | https://github.com/jmjuanes/minsql/blob/80eddd97e858545997b30e3c9bc067d5fc2df5a0/lib/create.js#L33-L54 |
53,388 | pkrll/JavaScript | Progressbar/Example/progressbar-1.1.js | function () {
if (this.settings.parentElement === false)
return this.createErrorMessage("No parent element set!");
// This is the container in
// which the bar resides
this.progressBar = $("<progress>").attr({
"id": "progress-bar",
"value": 0,
"max": 100
}).appendTo(this.settings.parentElement);
this.progressLabel = $("<div>").attr({
"class": "progress-bar-label"
}).html("0%").appendTo(this.settings.parentElement);
var div = $("<div>").html(this.settings.name).appendTo(this.settings.parentElement);
} | javascript | function () {
if (this.settings.parentElement === false)
return this.createErrorMessage("No parent element set!");
// This is the container in
// which the bar resides
this.progressBar = $("<progress>").attr({
"id": "progress-bar",
"value": 0,
"max": 100
}).appendTo(this.settings.parentElement);
this.progressLabel = $("<div>").attr({
"class": "progress-bar-label"
}).html("0%").appendTo(this.settings.parentElement);
var div = $("<div>").html(this.settings.name).appendTo(this.settings.parentElement);
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"settings",
".",
"parentElement",
"===",
"false",
")",
"return",
"this",
".",
"createErrorMessage",
"(",
"\"No parent element set!\"",
")",
";",
"// This is the container in",
"// which the bar resides",
"this",
".",
"progressBar",
"=",
"$",
"(",
"\"<progress>\"",
")",
".",
"attr",
"(",
"{",
"\"id\"",
":",
"\"progress-bar\"",
",",
"\"value\"",
":",
"0",
",",
"\"max\"",
":",
"100",
"}",
")",
".",
"appendTo",
"(",
"this",
".",
"settings",
".",
"parentElement",
")",
";",
"this",
".",
"progressLabel",
"=",
"$",
"(",
"\"<div>\"",
")",
".",
"attr",
"(",
"{",
"\"class\"",
":",
"\"progress-bar-label\"",
"}",
")",
".",
"html",
"(",
"\"0%\"",
")",
".",
"appendTo",
"(",
"this",
".",
"settings",
".",
"parentElement",
")",
";",
"var",
"div",
"=",
"$",
"(",
"\"<div>\"",
")",
".",
"html",
"(",
"this",
".",
"settings",
".",
"name",
")",
".",
"appendTo",
"(",
"this",
".",
"settings",
".",
"parentElement",
")",
";",
"}"
] | Creates the progress bar element | [
"Creates",
"the",
"progress",
"bar",
"element"
] | 2757281c61e14895694d921b98a699a96cb6d346 | https://github.com/pkrll/JavaScript/blob/2757281c61e14895694d921b98a699a96cb6d346/Progressbar/Example/progressbar-1.1.js#L56-L70 |
|
53,389 | pkrll/JavaScript | Progressbar/Example/progressbar-1.1.js | function (progress) {
var _this = this;
this.progressBar.animate({
value: progress
}, 1, function() {
_this.onProgress(progress);
});
this.progress = progress;
} | javascript | function (progress) {
var _this = this;
this.progressBar.animate({
value: progress
}, 1, function() {
_this.onProgress(progress);
});
this.progress = progress;
} | [
"function",
"(",
"progress",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"this",
".",
"progressBar",
".",
"animate",
"(",
"{",
"value",
":",
"progress",
"}",
",",
"1",
",",
"function",
"(",
")",
"{",
"_this",
".",
"onProgress",
"(",
"progress",
")",
";",
"}",
")",
";",
"this",
".",
"progress",
"=",
"progress",
";",
"}"
] | Animates the progress bar | [
"Animates",
"the",
"progress",
"bar"
] | 2757281c61e14895694d921b98a699a96cb6d346 | https://github.com/pkrll/JavaScript/blob/2757281c61e14895694d921b98a699a96cb6d346/Progressbar/Example/progressbar-1.1.js#L72-L80 |
|
53,390 | vowsjs/cli-easy | lib/cli-easy/batch.js | onExec | function onExec (err, stdout, stderr) {
callback(null, {
err: err,
stdout: stdout,
stderr: stderr
});
} | javascript | function onExec (err, stdout, stderr) {
callback(null, {
err: err,
stdout: stdout,
stderr: stderr
});
} | [
"function",
"onExec",
"(",
"err",
",",
"stdout",
",",
"stderr",
")",
"{",
"callback",
"(",
"null",
",",
"{",
"err",
":",
"err",
",",
"stdout",
":",
"stdout",
",",
"stderr",
":",
"stderr",
"}",
")",
";",
"}"
] | Combine results in one object and pass them to callback Add err to result, because we want it to be a part of test assertions | [
"Combine",
"results",
"in",
"one",
"object",
"and",
"pass",
"them",
"to",
"callback",
"Add",
"err",
"to",
"result",
"because",
"we",
"want",
"it",
"to",
"be",
"a",
"part",
"of",
"test",
"assertions"
] | ad9e5aa789d78d827c6ab4f336087d6df08fdb12 | https://github.com/vowsjs/cli-easy/blob/ad9e5aa789d78d827c6ab4f336087d6df08fdb12/lib/cli-easy/batch.js#L117-L123 |
53,391 | PanthR/panthrMath | panthrMath/distributions/nbinom.js | pnbinom | function pnbinom(size, prob, lowerTail, logp) {
logp = logp === true;
lowerTail = lowerTail !== false;
return function(x) {
if (utils.hasNaN(x, size, prob) ||
size < 0 || prob <= 0 || prob > 1 ||
utils.isInfinite(size)) {
return NaN;
}
if (size === 0) {
return utils.adjustLower(x >= 0 ? 1 : 0, lowerTail, logp);
}
if (x < 0) { return utils.adjustLower(0, lowerTail, logp); }
x = Math.floor(x + 1e-14);
return beta.pbeta(size, x + 1, lowerTail, logp)(prob);
};
} | javascript | function pnbinom(size, prob, lowerTail, logp) {
logp = logp === true;
lowerTail = lowerTail !== false;
return function(x) {
if (utils.hasNaN(x, size, prob) ||
size < 0 || prob <= 0 || prob > 1 ||
utils.isInfinite(size)) {
return NaN;
}
if (size === 0) {
return utils.adjustLower(x >= 0 ? 1 : 0, lowerTail, logp);
}
if (x < 0) { return utils.adjustLower(0, lowerTail, logp); }
x = Math.floor(x + 1e-14);
return beta.pbeta(size, x + 1, lowerTail, logp)(prob);
};
} | [
"function",
"pnbinom",
"(",
"size",
",",
"prob",
",",
"lowerTail",
",",
"logp",
")",
"{",
"logp",
"=",
"logp",
"===",
"true",
";",
"lowerTail",
"=",
"lowerTail",
"!==",
"false",
";",
"return",
"function",
"(",
"x",
")",
"{",
"if",
"(",
"utils",
".",
"hasNaN",
"(",
"x",
",",
"size",
",",
"prob",
")",
"||",
"size",
"<",
"0",
"||",
"prob",
"<=",
"0",
"||",
"prob",
">",
"1",
"||",
"utils",
".",
"isInfinite",
"(",
"size",
")",
")",
"{",
"return",
"NaN",
";",
"}",
"if",
"(",
"size",
"===",
"0",
")",
"{",
"return",
"utils",
".",
"adjustLower",
"(",
"x",
">=",
"0",
"?",
"1",
":",
"0",
",",
"lowerTail",
",",
"logp",
")",
";",
"}",
"if",
"(",
"x",
"<",
"0",
")",
"{",
"return",
"utils",
".",
"adjustLower",
"(",
"0",
",",
"lowerTail",
",",
"logp",
")",
";",
"}",
"x",
"=",
"Math",
".",
"floor",
"(",
"x",
"+",
"1e-14",
")",
";",
"return",
"beta",
".",
"pbeta",
"(",
"size",
",",
"x",
"+",
"1",
",",
"lowerTail",
",",
"logp",
")",
"(",
"prob",
")",
";",
"}",
";",
"}"
] | Evaluates the lower-tail cdf at `x` for the negative binomial distribution.
`size` must be strictly positive, and `prob` must be in `(0, 1]`.
`lowerTail` defaults to `true`; if `lowerTail` is `false`, returns
the upper tail probability instead.
`logp` defaults to `false`; if `logp` is `true`, returns the logarithm
of the result.
@fullName pnbinom(size, prob, lowerTail, logp)(x)
@memberof nbinom | [
"Evaluates",
"the",
"lower",
"-",
"tail",
"cdf",
"at",
"x",
"for",
"the",
"negative",
"binomial",
"distribution",
"."
] | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/distributions/nbinom.js#L91-L111 |
53,392 | PanthR/panthrMath | panthrMath/distributions/nbinom.js | rnbinom | function rnbinom(size, prob) {
var rg;
if (size <= 0 || prob <= 0 || prob > 1) {
return function() { return NaN; };
}
if (prob === 1) { return function() { return 0; }; }
rg = rgamma(size, (1 - prob) / prob);
return function() { return rpois(rg())(); };
} | javascript | function rnbinom(size, prob) {
var rg;
if (size <= 0 || prob <= 0 || prob > 1) {
return function() { return NaN; };
}
if (prob === 1) { return function() { return 0; }; }
rg = rgamma(size, (1 - prob) / prob);
return function() { return rpois(rg())(); };
} | [
"function",
"rnbinom",
"(",
"size",
",",
"prob",
")",
"{",
"var",
"rg",
";",
"if",
"(",
"size",
"<=",
"0",
"||",
"prob",
"<=",
"0",
"||",
"prob",
">",
"1",
")",
"{",
"return",
"function",
"(",
")",
"{",
"return",
"NaN",
";",
"}",
";",
"}",
"if",
"(",
"prob",
"===",
"1",
")",
"{",
"return",
"function",
"(",
")",
"{",
"return",
"0",
";",
"}",
";",
"}",
"rg",
"=",
"rgamma",
"(",
"size",
",",
"(",
"1",
"-",
"prob",
")",
"/",
"prob",
")",
";",
"return",
"function",
"(",
")",
"{",
"return",
"rpois",
"(",
"rg",
"(",
")",
")",
"(",
")",
";",
"}",
";",
"}"
] | Returns a random variate from the negative binomial distribution.
`size` must be strictly positive, and `prob` must be in `(0, 1]`.
@fullName rnbinom(size, prob)()
@memberof nbinom | [
"Returns",
"a",
"random",
"variate",
"from",
"the",
"negative",
"binomial",
"distribution",
"."
] | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/distributions/nbinom.js#L182-L191 |
53,393 | PanthR/panthrMath | panthrMath/distributions/nbinom.js | function(size, prob) {
return {
d: function(x, logp) { return dnbinom(size, prob, logp)(x); },
p: function(q, lowerTail, logp) {
return pnbinom(size, prob, lowerTail, logp)(q);
},
q: function(p, lowerTail, logp) {
return qnbinom(size, prob, lowerTail, logp)(p);
},
r: function() { return rnbinom(size, prob)(); }
};
} | javascript | function(size, prob) {
return {
d: function(x, logp) { return dnbinom(size, prob, logp)(x); },
p: function(q, lowerTail, logp) {
return pnbinom(size, prob, lowerTail, logp)(q);
},
q: function(p, lowerTail, logp) {
return qnbinom(size, prob, lowerTail, logp)(p);
},
r: function() { return rnbinom(size, prob)(); }
};
} | [
"function",
"(",
"size",
",",
"prob",
")",
"{",
"return",
"{",
"d",
":",
"function",
"(",
"x",
",",
"logp",
")",
"{",
"return",
"dnbinom",
"(",
"size",
",",
"prob",
",",
"logp",
")",
"(",
"x",
")",
";",
"}",
",",
"p",
":",
"function",
"(",
"q",
",",
"lowerTail",
",",
"logp",
")",
"{",
"return",
"pnbinom",
"(",
"size",
",",
"prob",
",",
"lowerTail",
",",
"logp",
")",
"(",
"q",
")",
";",
"}",
",",
"q",
":",
"function",
"(",
"p",
",",
"lowerTail",
",",
"logp",
")",
"{",
"return",
"qnbinom",
"(",
"size",
",",
"prob",
",",
"lowerTail",
",",
"logp",
")",
"(",
"p",
")",
";",
"}",
",",
"r",
":",
"function",
"(",
")",
"{",
"return",
"rnbinom",
"(",
"size",
",",
"prob",
")",
"(",
")",
";",
"}",
"}",
";",
"}"
] | Returns an object representing a negative binomial distribution with
given parameters `size` and `prob`. The object has
properties `d`, `p`, `q`, `r`.
`size` must be strictly positive, and `prob` must be in `(0, 1]`.
```
nbinom(size, prob).d(x, logp) // same as dnbinom(size, prob, logp)(x)
nbinom(size, prob).p(x, lowerTail, logp) // same as pnbinom(size, prob, lowerTail, logp)(x)
nbinom(size, prob).q(x, lowerTail, logp) // same as qnbinom(size, prob, lowerTail, logp)(x)
nbinom(size, prob).r() // same as rnbinom(size, prob)()
```
@memberof nbinom | [
"Returns",
"an",
"object",
"representing",
"a",
"negative",
"binomial",
"distribution",
"with",
"given",
"parameters",
"size",
"and",
"prob",
".",
"The",
"object",
"has",
"properties",
"d",
"p",
"q",
"r",
"."
] | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/distributions/nbinom.js#L209-L220 |
|
53,394 | taoyuan/wide | lib/logger.js | emit | function emit(name, next) {
var transport = that.transports[name];
if ((transport.level && that.levels[transport.level] <= that.levels[level])
|| (!transport.level && that.levels[that.level] <= that.levels[level])) {
transport.log(rec, function (err) {
if (err) {
err.transport = transport;
cb(err);
return next();
}
that.emit('logging', transport, rec);
next();
});
} else {
next();
}
} | javascript | function emit(name, next) {
var transport = that.transports[name];
if ((transport.level && that.levels[transport.level] <= that.levels[level])
|| (!transport.level && that.levels[that.level] <= that.levels[level])) {
transport.log(rec, function (err) {
if (err) {
err.transport = transport;
cb(err);
return next();
}
that.emit('logging', transport, rec);
next();
});
} else {
next();
}
} | [
"function",
"emit",
"(",
"name",
",",
"next",
")",
"{",
"var",
"transport",
"=",
"that",
".",
"transports",
"[",
"name",
"]",
";",
"if",
"(",
"(",
"transport",
".",
"level",
"&&",
"that",
".",
"levels",
"[",
"transport",
".",
"level",
"]",
"<=",
"that",
".",
"levels",
"[",
"level",
"]",
")",
"||",
"(",
"!",
"transport",
".",
"level",
"&&",
"that",
".",
"levels",
"[",
"that",
".",
"level",
"]",
"<=",
"that",
".",
"levels",
"[",
"level",
"]",
")",
")",
"{",
"transport",
".",
"log",
"(",
"rec",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"err",
".",
"transport",
"=",
"transport",
";",
"cb",
"(",
"err",
")",
";",
"return",
"next",
"(",
")",
";",
"}",
"that",
".",
"emit",
"(",
"'logging'",
",",
"transport",
",",
"rec",
")",
";",
"next",
"(",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"next",
"(",
")",
";",
"}",
"}"
] | Log for each transport and emit 'logging' event | [
"Log",
"for",
"each",
"transport",
"and",
"emit",
"logging",
"event"
] | a3bc92580f43c56001d8a6d72b45b0e44ba3a7c6 | https://github.com/taoyuan/wide/blob/a3bc92580f43c56001d8a6d72b45b0e44ba3a7c6/lib/logger.js#L290-L306 |
53,395 | taoyuan/wide | lib/logger.js | cb | function cb(err) {
if (callback) {
if (err) return callback(err);
callback(null, rec);
}
callback = null;
if (!err) {
that.emit('logged', rec);
}
} | javascript | function cb(err) {
if (callback) {
if (err) return callback(err);
callback(null, rec);
}
callback = null;
if (!err) {
that.emit('logged', rec);
}
} | [
"function",
"cb",
"(",
"err",
")",
"{",
"if",
"(",
"callback",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"callback",
"(",
"null",
",",
"rec",
")",
";",
"}",
"callback",
"=",
"null",
";",
"if",
"(",
"!",
"err",
")",
"{",
"that",
".",
"emit",
"(",
"'logged'",
",",
"rec",
")",
";",
"}",
"}"
] | Respond to the callback | [
"Respond",
"to",
"the",
"callback"
] | a3bc92580f43c56001d8a6d72b45b0e44ba3a7c6 | https://github.com/taoyuan/wide/blob/a3bc92580f43c56001d8a6d72b45b0e44ba3a7c6/lib/logger.js#L311-L320 |
53,396 | taoyuan/wide | lib/logger.js | queryTransport | function queryTransport(transport, next) {
if (options.query) {
options.query = transport.formatQuery(query);
}
transport.query(options, function (err, results) {
if (err) {
return next(err);
}
next(null, transport.formatResults(results, options.format));
});
} | javascript | function queryTransport(transport, next) {
if (options.query) {
options.query = transport.formatQuery(query);
}
transport.query(options, function (err, results) {
if (err) {
return next(err);
}
next(null, transport.formatResults(results, options.format));
});
} | [
"function",
"queryTransport",
"(",
"transport",
",",
"next",
")",
"{",
"if",
"(",
"options",
".",
"query",
")",
"{",
"options",
".",
"query",
"=",
"transport",
".",
"formatQuery",
"(",
"query",
")",
";",
"}",
"transport",
".",
"query",
"(",
"options",
",",
"function",
"(",
"err",
",",
"results",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"next",
"(",
"err",
")",
";",
"}",
"next",
"(",
"null",
",",
"transport",
".",
"formatResults",
"(",
"results",
",",
"options",
".",
"format",
")",
")",
";",
"}",
")",
";",
"}"
] | Helper function to query a single transport | [
"Helper",
"function",
"to",
"query",
"a",
"single",
"transport"
] | a3bc92580f43c56001d8a6d72b45b0e44ba3a7c6 | https://github.com/taoyuan/wide/blob/a3bc92580f43c56001d8a6d72b45b0e44ba3a7c6/lib/logger.js#L360-L372 |
53,397 | taoyuan/wide | lib/logger.js | addResults | function addResults(transport, next) {
queryTransport(transport, function (err, result) {
//
// queryTransport could potentially invoke the callback
// multiple times since Transport code can be unpredictable.
//
if (next) {
result = err || result;
if (result) {
results[transport.name] = result;
}
next();
}
next = null;
});
} | javascript | function addResults(transport, next) {
queryTransport(transport, function (err, result) {
//
// queryTransport could potentially invoke the callback
// multiple times since Transport code can be unpredictable.
//
if (next) {
result = err || result;
if (result) {
results[transport.name] = result;
}
next();
}
next = null;
});
} | [
"function",
"addResults",
"(",
"transport",
",",
"next",
")",
"{",
"queryTransport",
"(",
"transport",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"//",
"// queryTransport could potentially invoke the callback",
"// multiple times since Transport code can be unpredictable.",
"//",
"if",
"(",
"next",
")",
"{",
"result",
"=",
"err",
"||",
"result",
";",
"if",
"(",
"result",
")",
"{",
"results",
"[",
"transport",
".",
"name",
"]",
"=",
"result",
";",
"}",
"next",
"(",
")",
";",
"}",
"next",
"=",
"null",
";",
"}",
")",
";",
"}"
] | Helper function to accumulate the results from `queryTransport` into the `results`. | [
"Helper",
"function",
"to",
"accumulate",
"the",
"results",
"from",
"queryTransport",
"into",
"the",
"results",
"."
] | a3bc92580f43c56001d8a6d72b45b0e44ba3a7c6 | https://github.com/taoyuan/wide/blob/a3bc92580f43c56001d8a6d72b45b0e44ba3a7c6/lib/logger.js#L378-L395 |
53,398 | aureooms/js-grammar | lib/ll1/first.js | first | function first(FIRST, rule) {
var terminals = new Set();
var read = true;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = rule[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var x = _step.value;
if (!read) break;
read = false;
if (x.type === 'leaf') {
terminals.add(x.terminal);
break;
}
(0, _util.setaddall)(terminals, (0, _jsItertools.filter)(function (y) {
return y !== _grammar.EW;
}, FIRST.get(x.nonterminal)));
read |= (0, _jsItertools.any)((0, _jsItertools.map)(function (y) {
return y === _grammar.EW;
}, FIRST.get(x.nonterminal)));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
if (read) terminals.add(_grammar.EW);
return terminals;
} | javascript | function first(FIRST, rule) {
var terminals = new Set();
var read = true;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = rule[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var x = _step.value;
if (!read) break;
read = false;
if (x.type === 'leaf') {
terminals.add(x.terminal);
break;
}
(0, _util.setaddall)(terminals, (0, _jsItertools.filter)(function (y) {
return y !== _grammar.EW;
}, FIRST.get(x.nonterminal)));
read |= (0, _jsItertools.any)((0, _jsItertools.map)(function (y) {
return y === _grammar.EW;
}, FIRST.get(x.nonterminal)));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
if (read) terminals.add(_grammar.EW);
return terminals;
} | [
"function",
"first",
"(",
"FIRST",
",",
"rule",
")",
"{",
"var",
"terminals",
"=",
"new",
"Set",
"(",
")",
";",
"var",
"read",
"=",
"true",
";",
"var",
"_iteratorNormalCompletion",
"=",
"true",
";",
"var",
"_didIteratorError",
"=",
"false",
";",
"var",
"_iteratorError",
"=",
"undefined",
";",
"try",
"{",
"for",
"(",
"var",
"_iterator",
"=",
"rule",
"[",
"Symbol",
".",
"iterator",
"]",
"(",
")",
",",
"_step",
";",
"!",
"(",
"_iteratorNormalCompletion",
"=",
"(",
"_step",
"=",
"_iterator",
".",
"next",
"(",
")",
")",
".",
"done",
")",
";",
"_iteratorNormalCompletion",
"=",
"true",
")",
"{",
"var",
"x",
"=",
"_step",
".",
"value",
";",
"if",
"(",
"!",
"read",
")",
"break",
";",
"read",
"=",
"false",
";",
"if",
"(",
"x",
".",
"type",
"===",
"'leaf'",
")",
"{",
"terminals",
".",
"add",
"(",
"x",
".",
"terminal",
")",
";",
"break",
";",
"}",
"(",
"0",
",",
"_util",
".",
"setaddall",
")",
"(",
"terminals",
",",
"(",
"0",
",",
"_jsItertools",
".",
"filter",
")",
"(",
"function",
"(",
"y",
")",
"{",
"return",
"y",
"!==",
"_grammar",
".",
"EW",
";",
"}",
",",
"FIRST",
".",
"get",
"(",
"x",
".",
"nonterminal",
")",
")",
")",
";",
"read",
"|=",
"(",
"0",
",",
"_jsItertools",
".",
"any",
")",
"(",
"(",
"0",
",",
"_jsItertools",
".",
"map",
")",
"(",
"function",
"(",
"y",
")",
"{",
"return",
"y",
"===",
"_grammar",
".",
"EW",
";",
"}",
",",
"FIRST",
".",
"get",
"(",
"x",
".",
"nonterminal",
")",
")",
")",
";",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"_didIteratorError",
"=",
"true",
";",
"_iteratorError",
"=",
"err",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"!",
"_iteratorNormalCompletion",
"&&",
"_iterator",
".",
"return",
"!=",
"null",
")",
"{",
"_iterator",
".",
"return",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"_didIteratorError",
")",
"{",
"throw",
"_iteratorError",
";",
"}",
"}",
"}",
"if",
"(",
"read",
")",
"terminals",
".",
"add",
"(",
"_grammar",
".",
"EW",
")",
";",
"return",
"terminals",
";",
"}"
] | Generate FIRST set for any rule given the FIRST sets for the nonterminals.
@param {Map} FIRST
@param {Array} rule
@returns {Set} | [
"Generate",
"FIRST",
"set",
"for",
"any",
"rule",
"given",
"the",
"FIRST",
"sets",
"for",
"the",
"nonterminals",
"."
] | 28c4d1a3175327b33766c34539eab317303e26c5 | https://github.com/aureooms/js-grammar/blob/28c4d1a3175327b33766c34539eab317303e26c5/lib/ll1/first.js#L21-L63 |
53,399 | vivangkumar/node-data-structures | lib/Iterator.js | function() {
this._nextCalled = true;
if(this._collection.size() > 0) {
if(this._hasNextCalled) {
this._hasNextCalled = false;
this._pos --;
}
this._pos ++;
this._nextElement = this._collection.getAll()[this._pos];
if(this._nextElement !== undefined) {
return this._nextElement;
} else {
throw new Error("No such element.");
}
}
} | javascript | function() {
this._nextCalled = true;
if(this._collection.size() > 0) {
if(this._hasNextCalled) {
this._hasNextCalled = false;
this._pos --;
}
this._pos ++;
this._nextElement = this._collection.getAll()[this._pos];
if(this._nextElement !== undefined) {
return this._nextElement;
} else {
throw new Error("No such element.");
}
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"_nextCalled",
"=",
"true",
";",
"if",
"(",
"this",
".",
"_collection",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"this",
".",
"_hasNextCalled",
")",
"{",
"this",
".",
"_hasNextCalled",
"=",
"false",
";",
"this",
".",
"_pos",
"--",
";",
"}",
"this",
".",
"_pos",
"++",
";",
"this",
".",
"_nextElement",
"=",
"this",
".",
"_collection",
".",
"getAll",
"(",
")",
"[",
"this",
".",
"_pos",
"]",
";",
"if",
"(",
"this",
".",
"_nextElement",
"!==",
"undefined",
")",
"{",
"return",
"this",
".",
"_nextElement",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"No such element.\"",
")",
";",
"}",
"}",
"}"
] | Returns the next element in the iteration.
@throws Error | [
"Returns",
"the",
"next",
"element",
"in",
"the",
"iteration",
"."
] | 703d0795fba9d15534fa149f605d54fcfe0844e0 | https://github.com/vivangkumar/node-data-structures/blob/703d0795fba9d15534fa149f605d54fcfe0844e0/lib/Iterator.js#L34-L51 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.