repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
jasonsites/proxy-es-aws | src/aws.js | sendAWSRequest | function sendAWSRequest(req) {
return new Promise((resolve, reject) => {
const send = new AWS.NodeHttpClient()
send.handleRequest(req, null, (res) => {
let body = ''
res.on('data', (chunk) => {
body += chunk
})
res.on('end', () => {
const { headers, statusCode } = res
... | javascript | function sendAWSRequest(req) {
return new Promise((resolve, reject) => {
const send = new AWS.NodeHttpClient()
send.handleRequest(req, null, (res) => {
let body = ''
res.on('data', (chunk) => {
body += chunk
})
res.on('end', () => {
const { headers, statusCode } = res
... | [
"function",
"sendAWSRequest",
"(",
"req",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"send",
"=",
"new",
"AWS",
".",
"NodeHttpClient",
"(",
")",
"send",
".",
"handleRequest",
"(",
"req",
",",
"nul... | AWS HTTP request handler
@param {String} req - signed aws request
@return {Promise} | [
"AWS",
"HTTP",
"request",
"handler"
] | b2625106d877fea76f74b0b88ed8568a8ff61612 | https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/aws.js#L84-L105 | train |
jasonsites/proxy-es-aws | src/aws.js | signAWSRequest | function signAWSRequest({ credentials, request }) {
const signer = new AWS.Signers.V4(request, 'es')
signer.addAuthorization(credentials, new Date())
return request
} | javascript | function signAWSRequest({ credentials, request }) {
const signer = new AWS.Signers.V4(request, 'es')
signer.addAuthorization(credentials, new Date())
return request
} | [
"function",
"signAWSRequest",
"(",
"{",
"credentials",
",",
"request",
"}",
")",
"{",
"const",
"signer",
"=",
"new",
"AWS",
".",
"Signers",
".",
"V4",
"(",
"request",
",",
"'es'",
")",
"signer",
".",
"addAuthorization",
"(",
"credentials",
",",
"new",
"D... | Signs an AWS HTTP Request object with the provided AWS Credentials object
@param {Object} param.credentials - aws credentials object
@param {Object} param.request - aws http request object
@return {Object} signed request | [
"Signs",
"an",
"AWS",
"HTTP",
"Request",
"object",
"with",
"the",
"provided",
"AWS",
"Credentials",
"object"
] | b2625106d877fea76f74b0b88ed8568a8ff61612 | https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/aws.js#L131-L135 | train |
byron-dupreez/aws-stream-consumer-core | identify.js | resolveAndSetEventIdAndSeqNos | function resolveAndSetEventIdAndSeqNos(record, userRecord, state, context) {
// Get the resolveEventIdAndSeqNos function to use
const resolveEventIdAndSeqNos = settings.getResolveEventIdAndSeqNosFunction(context);
if (!resolveEventIdAndSeqNos) {
const errMsg = `FATAL - Cannot resolve event id & sequence numb... | javascript | function resolveAndSetEventIdAndSeqNos(record, userRecord, state, context) {
// Get the resolveEventIdAndSeqNos function to use
const resolveEventIdAndSeqNos = settings.getResolveEventIdAndSeqNosFunction(context);
if (!resolveEventIdAndSeqNos) {
const errMsg = `FATAL - Cannot resolve event id & sequence numb... | [
"function",
"resolveAndSetEventIdAndSeqNos",
"(",
"record",
",",
"userRecord",
",",
"state",
",",
"context",
")",
"{",
"// Get the resolveEventIdAndSeqNos function to use",
"const",
"resolveEventIdAndSeqNos",
"=",
"settings",
".",
"getResolveEventIdAndSeqNosFunction",
"(",
"c... | Resolves the eventID, eventSeqNo and optional eventSubSeqNo for the given record & optional user record using the
configured `resolveEventIdAndSeqNos` function and then updates the given message or unusable record state with the
resolved values.
@param {Record} record - the record from which to resolve its eventID and ... | [
"Resolves",
"the",
"eventID",
"eventSeqNo",
"and",
"optional",
"eventSubSeqNo",
"for",
"the",
"given",
"record",
"&",
"optional",
"user",
"record",
"using",
"the",
"configured",
"resolveEventIdAndSeqNos",
"function",
"and",
"then",
"updates",
"the",
"given",
"messag... | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/identify.js#L87-L110 | train |
byron-dupreez/aws-stream-consumer-core | identify.js | setMessageIdsAndSeqNos | function setMessageIdsAndSeqNos(state, messageIdsAndSeqNos) {
const {ids, keys, seqNos} = messageIdsAndSeqNos || {};
setIds(state, ids);
setKeys(state, keys);
setSeqNos(state, seqNos);
return state;
} | javascript | function setMessageIdsAndSeqNos(state, messageIdsAndSeqNos) {
const {ids, keys, seqNos} = messageIdsAndSeqNos || {};
setIds(state, ids);
setKeys(state, keys);
setSeqNos(state, seqNos);
return state;
} | [
"function",
"setMessageIdsAndSeqNos",
"(",
"state",
",",
"messageIdsAndSeqNos",
")",
"{",
"const",
"{",
"ids",
",",
"keys",
",",
"seqNos",
"}",
"=",
"messageIdsAndSeqNos",
"||",
"{",
"}",
";",
"setIds",
"(",
"state",
",",
"ids",
")",
";",
"setKeys",
"(",
... | Updates the given message state with the given message ids, keys & sequence numbers & event id & sequence numbers.
@param {MessageState} state - the message state to be updated
@param {MessageIdsAndSeqNos} messageIdsAndSeqNos | [
"Updates",
"the",
"given",
"message",
"state",
"with",
"the",
"given",
"message",
"ids",
"keys",
"&",
"sequence",
"numbers",
"&",
"event",
"id",
"&",
"sequence",
"numbers",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/identify.js#L192-L200 | train |
staticbuild/staticbuild | lib/devserver/app.js | init | function init(targetBuild) {
// CONSIDER: The `|| StaticBuild.current` isn't really necessary.
build = targetBuild || StaticBuild.current;
initViewEngines();
// Request Pipeline
initFavicon();
initLogging();
initApiProxy();
initParsing();
initCssLESS();
initSASS();
initViewRouting();
initErrorHa... | javascript | function init(targetBuild) {
// CONSIDER: The `|| StaticBuild.current` isn't really necessary.
build = targetBuild || StaticBuild.current;
initViewEngines();
// Request Pipeline
initFavicon();
initLogging();
initApiProxy();
initParsing();
initCssLESS();
initSASS();
initViewRouting();
initErrorHa... | [
"function",
"init",
"(",
"targetBuild",
")",
"{",
"// CONSIDER: The `|| StaticBuild.current` isn't really necessary.",
"build",
"=",
"targetBuild",
"||",
"StaticBuild",
".",
"current",
";",
"initViewEngines",
"(",
")",
";",
"// Request Pipeline",
"initFavicon",
"(",
")",
... | Initializes the Express app without running it.
@param {StaticBuild} [targetBuild] The target build. | [
"Initializes",
"the",
"Express",
"app",
"without",
"running",
"it",
"."
] | 73891a9a719de46ba07c26a10ce36c43da34ff0e | https://github.com/staticbuild/staticbuild/blob/73891a9a719de46ba07c26a10ce36c43da34ff0e/lib/devserver/app.js#L34-L47 | train |
troybetz/common-vimeo | lib/prepare-embed.js | prepareEmbed | function prepareEmbed(embedID) {
var embed = document.getElementById(embedID);
if (!isEmbeddedVideo(embed)) {
throw new Error('embed must be an iframe');
}
enableAPIControl(embed);
} | javascript | function prepareEmbed(embedID) {
var embed = document.getElementById(embedID);
if (!isEmbeddedVideo(embed)) {
throw new Error('embed must be an iframe');
}
enableAPIControl(embed);
} | [
"function",
"prepareEmbed",
"(",
"embedID",
")",
"{",
"var",
"embed",
"=",
"document",
".",
"getElementById",
"(",
"embedID",
")",
";",
"if",
"(",
"!",
"isEmbeddedVideo",
"(",
"embed",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'embed must be an iframe'",... | Prepare an iframe for API control.
Embedded Vimeo videos require `api` & `player_id`
parameters set to be controlled.
@param {String} embedID - id of iframe to prepare | [
"Prepare",
"an",
"iframe",
"for",
"API",
"control",
"."
] | c978bbf75cef73872c476369dd6d7363e2dddc39 | https://github.com/troybetz/common-vimeo/blob/c978bbf75cef73872c476369dd6d7363e2dddc39/lib/prepare-embed.js#L16-L24 | train |
troybetz/common-vimeo | lib/prepare-embed.js | isAPIEnabled | function isAPIEnabled(embed) {
var regex = '\/?api=1&player_id=' + embed.id;
regex = new RegExp(regex);
return regex.test(embed.src);
} | javascript | function isAPIEnabled(embed) {
var regex = '\/?api=1&player_id=' + embed.id;
regex = new RegExp(regex);
return regex.test(embed.src);
} | [
"function",
"isAPIEnabled",
"(",
"embed",
")",
"{",
"var",
"regex",
"=",
"'\\/?api=1&player_id='",
"+",
"embed",
".",
"id",
";",
"regex",
"=",
"new",
"RegExp",
"(",
"regex",
")",
";",
"return",
"regex",
".",
"test",
"(",
"embed",
".",
"src",
")",
";",
... | Determine if required `src` parameters are included in `embed`
@param {Object} embed
@returns {Boolean} | [
"Determine",
"if",
"required",
"src",
"parameters",
"are",
"included",
"in",
"embed"
] | c978bbf75cef73872c476369dd6d7363e2dddc39 | https://github.com/troybetz/common-vimeo/blob/c978bbf75cef73872c476369dd6d7363e2dddc39/lib/prepare-embed.js#L45-L49 | train |
redisjs/jsr-server | lib/request.js | Request | function Request(conn, cmd, args) {
// current connection
this.conn = conn;
// command name
this.cmd = cmd;
// command arguments may be modified
// during validation
this.args = args;
// raw command arguments, injected by the server
this.raw = null;
// server will inject this
// based upon th... | javascript | function Request(conn, cmd, args) {
// current connection
this.conn = conn;
// command name
this.cmd = cmd;
// command arguments may be modified
// during validation
this.args = args;
// raw command arguments, injected by the server
this.raw = null;
// server will inject this
// based upon th... | [
"function",
"Request",
"(",
"conn",
",",
"cmd",
",",
"args",
")",
"{",
"// current connection",
"this",
".",
"conn",
"=",
"conn",
";",
"// command name",
"this",
".",
"cmd",
"=",
"cmd",
";",
"// command arguments may be modified",
"// during validation",
"this",
... | Encapsulate a connection request.
@param conn The connection handling the request.
@param cmd The command to execute.
@param args The command arguments. | [
"Encapsulate",
"a",
"connection",
"request",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/request.js#L8-L41 | train |
redisjs/jsr-server | lib/request.js | destroy | function destroy() {
this.conn = null;
this.cmd = null;
this.args = null;
this.db = null;
this.info = null;
this.conf = null;
this.def = null;
} | javascript | function destroy() {
this.conn = null;
this.cmd = null;
this.args = null;
this.db = null;
this.info = null;
this.conf = null;
this.def = null;
} | [
"function",
"destroy",
"(",
")",
"{",
"this",
".",
"conn",
"=",
"null",
";",
"this",
".",
"cmd",
"=",
"null",
";",
"this",
".",
"args",
"=",
"null",
";",
"this",
".",
"db",
"=",
"null",
";",
"this",
".",
"info",
"=",
"null",
";",
"this",
".",
... | Destroy this request. | [
"Destroy",
"this",
"request",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/request.js#L46-L54 | train |
redisjs/jsr-server | lib/command/pubsub/subscribe.js | execute | function execute(req, res) {
this.state.pubsub.subscribe(req.conn, req.args);
} | javascript | function execute(req, res) {
this.state.pubsub.subscribe(req.conn, req.args);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"this",
".",
"state",
".",
"pubsub",
".",
"subscribe",
"(",
"req",
".",
"conn",
",",
"req",
".",
"args",
")",
";",
"}"
] | Respond to the SUBSCRIBE command. | [
"Respond",
"to",
"the",
"SUBSCRIBE",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/pubsub/subscribe.js#L17-L19 | train |
sendanor/nor-nopg | src/bin/nopg.js | markdown_table | function markdown_table (headers, table) {
// FIXME: Implement better markdown table formating
return ARRAY([headers, [ "---", "---" ]]).concat(table).map(cols => '| ' + ARRAY(cols).join(' | ') + ' |').join('\n');
} | javascript | function markdown_table (headers, table) {
// FIXME: Implement better markdown table formating
return ARRAY([headers, [ "---", "---" ]]).concat(table).map(cols => '| ' + ARRAY(cols).join(' | ') + ' |').join('\n');
} | [
"function",
"markdown_table",
"(",
"headers",
",",
"table",
")",
"{",
"// FIXME: Implement better markdown table formating",
"return",
"ARRAY",
"(",
"[",
"headers",
",",
"[",
"\"---\"",
",",
"\"---\"",
"]",
"]",
")",
".",
"concat",
"(",
"table",
")",
".",
"map... | Returns markdown formated table
@param headers
@param table
@returns {number} | [
"Returns",
"markdown",
"formated",
"table"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/bin/nopg.js#L61-L64 | train |
ENOW-IJI/ENOW-console | dist/src/group.js | _orphan | function _orphan(_el) {
var id = _jsPlumb.getId(_el);
var pos = _jsPlumb.getOffset(_el);
_el.parentNode.removeChild(_el);
_jsPlumb.getContainer().appendChild(_el);
_jsPlumb.setPosition(_el, pos);
delete _el._jsPlumbGroup;
_unbindDragHan... | javascript | function _orphan(_el) {
var id = _jsPlumb.getId(_el);
var pos = _jsPlumb.getOffset(_el);
_el.parentNode.removeChild(_el);
_jsPlumb.getContainer().appendChild(_el);
_jsPlumb.setPosition(_el, pos);
delete _el._jsPlumbGroup;
_unbindDragHan... | [
"function",
"_orphan",
"(",
"_el",
")",
"{",
"var",
"id",
"=",
"_jsPlumb",
".",
"getId",
"(",
"_el",
")",
";",
"var",
"pos",
"=",
"_jsPlumb",
".",
"getOffset",
"(",
"_el",
")",
";",
"_el",
".",
"parentNode",
".",
"removeChild",
"(",
"_el",
")",
";"... | orphaning an element means taking it out of the group and adding it to the main jsplumb container. | [
"orphaning",
"an",
"element",
"means",
"taking",
"it",
"out",
"of",
"the",
"group",
"and",
"adding",
"it",
"to",
"the",
"main",
"jsplumb",
"container",
"."
] | f241ed4e645a7da0cd1a6ca86e896a5b73be53e5 | https://github.com/ENOW-IJI/ENOW-console/blob/f241ed4e645a7da0cd1a6ca86e896a5b73be53e5/dist/src/group.js#L539-L548 | train |
ENOW-IJI/ENOW-console | dist/src/group.js | _pruneOrOrphan | function _pruneOrOrphan(p) {
if (!_isInsideParent(p.el, p.pos)) {
p.el._jsPlumbGroup.remove(p.el);
if (prune) {
_jsPlumb.remove(p.el);
} else {
_orphan(p.el);
}
}
} | javascript | function _pruneOrOrphan(p) {
if (!_isInsideParent(p.el, p.pos)) {
p.el._jsPlumbGroup.remove(p.el);
if (prune) {
_jsPlumb.remove(p.el);
} else {
_orphan(p.el);
}
}
} | [
"function",
"_pruneOrOrphan",
"(",
"p",
")",
"{",
"if",
"(",
"!",
"_isInsideParent",
"(",
"p",
".",
"el",
",",
"p",
".",
"pos",
")",
")",
"{",
"p",
".",
"el",
".",
"_jsPlumbGroup",
".",
"remove",
"(",
"p",
".",
"el",
")",
";",
"if",
"(",
"prune... | remove an element from the group, then either prune it from the jsplumb instance, or just orphan it. | [
"remove",
"an",
"element",
"from",
"the",
"group",
"then",
"either",
"prune",
"it",
"from",
"the",
"jsplumb",
"instance",
"or",
"just",
"orphan",
"it",
"."
] | f241ed4e645a7da0cd1a6ca86e896a5b73be53e5 | https://github.com/ENOW-IJI/ENOW-console/blob/f241ed4e645a7da0cd1a6ca86e896a5b73be53e5/dist/src/group.js#L553-L562 | train |
ENOW-IJI/ENOW-console | dist/src/group.js | _revalidate | function _revalidate(_el) {
var id = _jsPlumb.getId(_el);
_jsPlumb.revalidate(_el);
_jsPlumb.dragManager.revalidateParent(_el, id);
} | javascript | function _revalidate(_el) {
var id = _jsPlumb.getId(_el);
_jsPlumb.revalidate(_el);
_jsPlumb.dragManager.revalidateParent(_el, id);
} | [
"function",
"_revalidate",
"(",
"_el",
")",
"{",
"var",
"id",
"=",
"_jsPlumb",
".",
"getId",
"(",
"_el",
")",
";",
"_jsPlumb",
".",
"revalidate",
"(",
"_el",
")",
";",
"_jsPlumb",
".",
"dragManager",
".",
"revalidateParent",
"(",
"_el",
",",
"id",
")",... | redraws the element | [
"redraws",
"the",
"element"
] | f241ed4e645a7da0cd1a6ca86e896a5b73be53e5 | https://github.com/ENOW-IJI/ENOW-console/blob/f241ed4e645a7da0cd1a6ca86e896a5b73be53e5/dist/src/group.js#L567-L571 | train |
IonicaBizau/camelo | lib/index.js | camelo | function camelo(input, regex, uc) {
regex = regex || DEFAULT_SPLIT;
var splits = null;
if (Array.isArray(regex)) {
regex = new RegExp(regex.map(reEscape).join("|"), "g");
} else if (typeof regex === "boolean") {
uc = regex;
regex = DEFAULT_SPLIT;
}
splits = input.spli... | javascript | function camelo(input, regex, uc) {
regex = regex || DEFAULT_SPLIT;
var splits = null;
if (Array.isArray(regex)) {
regex = new RegExp(regex.map(reEscape).join("|"), "g");
} else if (typeof regex === "boolean") {
uc = regex;
regex = DEFAULT_SPLIT;
}
splits = input.spli... | [
"function",
"camelo",
"(",
"input",
",",
"regex",
",",
"uc",
")",
"{",
"regex",
"=",
"regex",
"||",
"DEFAULT_SPLIT",
";",
"var",
"splits",
"=",
"null",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"regex",
")",
")",
"{",
"regex",
"=",
"new",
"RegE... | camelo
Converts an input string into camel-case style.
@name camelo
@function
@param {String} input The input string.
@param {Regex|String|Array} regex A regular expression, a string character or an array of strings used to split the input string.
@param {Boolean} uc If `true`, it will uppercase the first word as well... | [
"camelo",
"Converts",
"an",
"input",
"string",
"into",
"camel",
"-",
"case",
"style",
"."
] | abc9c956b29acad48d2600f1cd83bda762a5ab88 | https://github.com/IonicaBizau/camelo/blob/abc9c956b29acad48d2600f1cd83bda762a5ab88/lib/index.js#L20-L40 | train |
AndiDittrich/Node.cluster-magic | lib/worker-manager.js | startWorker | function startWorker(triggeredByError=false){
return new Promise(function(resolve){
// default restart delay
let restartDelay = 0;
// worker restart because of died process ?
if (triggeredByError === true){
// increment restart counter
_restartCounter++;
... | javascript | function startWorker(triggeredByError=false){
return new Promise(function(resolve){
// default restart delay
let restartDelay = 0;
// worker restart because of died process ?
if (triggeredByError === true){
// increment restart counter
_restartCounter++;
... | [
"function",
"startWorker",
"(",
"triggeredByError",
"=",
"false",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"// default restart delay",
"let",
"restartDelay",
"=",
"0",
";",
"// worker restart because of died process ?",
"if",
... | start a new worker | [
"start",
"a",
"new",
"worker"
] | b6b1d49164055ff8cbaaf679c208b62beba3ccbe | https://github.com/AndiDittrich/Node.cluster-magic/blob/b6b1d49164055ff8cbaaf679c208b62beba3ccbe/lib/worker-manager.js#L16-L48 | train |
AndiDittrich/Node.cluster-magic | lib/worker-manager.js | stopWorker | function stopWorker(worker){
return new Promise(function(resolve, reject){
// set kill timeout
const killTimeout = setTimeout(() => {
// kill the worker
worker.kill();
// failed to disconnect within given time
reject(new Error(`process ${w... | javascript | function stopWorker(worker){
return new Promise(function(resolve, reject){
// set kill timeout
const killTimeout = setTimeout(() => {
// kill the worker
worker.kill();
// failed to disconnect within given time
reject(new Error(`process ${w... | [
"function",
"stopWorker",
"(",
"worker",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// set kill timeout",
"const",
"killTimeout",
"=",
"setTimeout",
"(",
"(",
")",
"=>",
"{",
"// kill the worker",
"worker",... | worker gracefull shutdown | [
"worker",
"gracefull",
"shutdown"
] | b6b1d49164055ff8cbaaf679c208b62beba3ccbe | https://github.com/AndiDittrich/Node.cluster-magic/blob/b6b1d49164055ff8cbaaf679c208b62beba3ccbe/lib/worker-manager.js#L51-L75 | train |
AndiDittrich/Node.cluster-magic | lib/worker-manager.js | shutdown | function shutdown(){
// trigger stop on all workers
// catch errors thrown by killed workers
return Promise.all(Object.values(_cluster.workers).map(worker => stopWorker(worker).catch(err => _logger.error(err))));
} | javascript | function shutdown(){
// trigger stop on all workers
// catch errors thrown by killed workers
return Promise.all(Object.values(_cluster.workers).map(worker => stopWorker(worker).catch(err => _logger.error(err))));
} | [
"function",
"shutdown",
"(",
")",
"{",
"// trigger stop on all workers",
"// catch errors thrown by killed workers",
"return",
"Promise",
".",
"all",
"(",
"Object",
".",
"values",
"(",
"_cluster",
".",
"workers",
")",
".",
"map",
"(",
"worker",
"=>",
"stopWorker",
... | shutdown all workers | [
"shutdown",
"all",
"workers"
] | b6b1d49164055ff8cbaaf679c208b62beba3ccbe | https://github.com/AndiDittrich/Node.cluster-magic/blob/b6b1d49164055ff8cbaaf679c208b62beba3ccbe/lib/worker-manager.js#L78-L82 | train |
psiphi75/ss-logger | index.js | setOutput | function setOutput(output) {
if (!output ||
typeof output.log !== 'function') {
throw Error('logger.setOutput: expect an object as the parameter with "log" and "error" properties.');
}
outputFunctions = {
log: output.log,
error: (typeof outp... | javascript | function setOutput(output) {
if (!output ||
typeof output.log !== 'function') {
throw Error('logger.setOutput: expect an object as the parameter with "log" and "error" properties.');
}
outputFunctions = {
log: output.log,
error: (typeof outp... | [
"function",
"setOutput",
"(",
"output",
")",
"{",
"if",
"(",
"!",
"output",
"||",
"typeof",
"output",
".",
"log",
"!==",
"'function'",
")",
"{",
"throw",
"Error",
"(",
"'logger.setOutput: expect an object as the parameter with \"log\" and \"error\" properties.'",
")",
... | By default the `error` and `warn` levels log output to `console.error`, while all other
levels log output to `console.log`.
@param {Object} output - An object with 'log' and 'error' functions.
@throws {Error}
@example
log.setOutput({
error: myErrorStream
log: myLogStream
}); | [
"By",
"default",
"the",
"error",
"and",
"warn",
"levels",
"log",
"output",
"to",
"console",
".",
"error",
"while",
"all",
"other",
"levels",
"log",
"output",
"to",
"console",
".",
"log",
"."
] | f6042397b3403dbf864c3eba094978ffe8e93dea | https://github.com/psiphi75/ss-logger/blob/f6042397b3403dbf864c3eba094978ffe8e93dea/index.js#L142-L151 | train |
psiphi75/ss-logger | index.js | joinMsgArgs | function joinMsgArgs(msgArgs) {
if (!msgArgs) {
return '';
}
return msgArgs.map((arg) => {
if (arg === null) {
return 'null';
} else if (typeof arg === 'undefined') {
return 'undefined';
} else if (typeof arg ===... | javascript | function joinMsgArgs(msgArgs) {
if (!msgArgs) {
return '';
}
return msgArgs.map((arg) => {
if (arg === null) {
return 'null';
} else if (typeof arg === 'undefined') {
return 'undefined';
} else if (typeof arg ===... | [
"function",
"joinMsgArgs",
"(",
"msgArgs",
")",
"{",
"if",
"(",
"!",
"msgArgs",
")",
"{",
"return",
"''",
";",
"}",
"return",
"msgArgs",
".",
"map",
"(",
"(",
"arg",
")",
"=>",
"{",
"if",
"(",
"arg",
"===",
"null",
")",
"{",
"return",
"'null'",
"... | Create the logging functions | [
"Create",
"the",
"logging",
"functions"
] | f6042397b3403dbf864c3eba094978ffe8e93dea | https://github.com/psiphi75/ss-logger/blob/f6042397b3403dbf864c3eba094978ffe8e93dea/index.js#L160-L181 | train |
psiphi75/ss-logger | index.js | writeLog | function writeLog(levelName, varArgs) { // eslint-disable-line no-unused-vars
const args = [].slice.call(arguments);
args.splice(0, 1);
const str = format(new Date(), levelName, label, args);
if (LEVELS[levelName] <= LEVELS.warn) {
outputFunctions.error(str)... | javascript | function writeLog(levelName, varArgs) { // eslint-disable-line no-unused-vars
const args = [].slice.call(arguments);
args.splice(0, 1);
const str = format(new Date(), levelName, label, args);
if (LEVELS[levelName] <= LEVELS.warn) {
outputFunctions.error(str)... | [
"function",
"writeLog",
"(",
"levelName",
",",
"varArgs",
")",
"{",
"// eslint-disable-line no-unused-vars",
"const",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"args",
".",
"splice",
"(",
"0",
",",
"1",
")",
";",
"cons... | Create the log for writing.
@param {string} levelName - The name of the level to log at.
@param {...*} varArgs - The parameters of the original log.
@private | [
"Create",
"the",
"log",
"for",
"writing",
"."
] | f6042397b3403dbf864c3eba094978ffe8e93dea | https://github.com/psiphi75/ss-logger/blob/f6042397b3403dbf864c3eba094978ffe8e93dea/index.js#L207-L218 | train |
jesusgoku/arrispwod | src/index.js | genPassOfDay | function genPassOfDay(d, s = DEFAULT_SEED) {
if (!(d instanceof Date)) {
throw new TypeError('Date is not a Date instance');
}
if (typeof s !== 'string') {
throw new TypeError('Seed is not a String instance');
}
if (s.length < 1) {
throw new Error('Seed min length: 1');
}
const seed = s.rep... | javascript | function genPassOfDay(d, s = DEFAULT_SEED) {
if (!(d instanceof Date)) {
throw new TypeError('Date is not a Date instance');
}
if (typeof s !== 'string') {
throw new TypeError('Seed is not a String instance');
}
if (s.length < 1) {
throw new Error('Seed min length: 1');
}
const seed = s.rep... | [
"function",
"genPassOfDay",
"(",
"d",
",",
"s",
"=",
"DEFAULT_SEED",
")",
"{",
"if",
"(",
"!",
"(",
"d",
"instanceof",
"Date",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'Date is not a Date instance'",
")",
";",
"}",
"if",
"(",
"typeof",
"s",
"!... | Generate Pass of the day for Arris Router
@param {Date} d - Date for calculate password
@param {String} s - Seed for generate password. Min length: 1 | [
"Generate",
"Pass",
"of",
"the",
"day",
"for",
"Arris",
"Router"
] | 59a5e8708f59a0424b27004b52d53a5e95df047c | https://github.com/jesusgoku/arrispwod/blob/59a5e8708f59a0424b27004b52d53a5e95df047c/src/index.js#L36-L75 | train |
linyngfly/omelo-admin | lib/consoleService.js | function(args) {
let service = args.service;
let record = args.record;
if (!service || !record || !record.module || !record.enable) {
return;
}
if (service.master) {
record.module.masterHandler(service.agent, null, function(err) {
logger.error('interval push should not have a callback.');
});
} else {
... | javascript | function(args) {
let service = args.service;
let record = args.record;
if (!service || !record || !record.module || !record.enable) {
return;
}
if (service.master) {
record.module.masterHandler(service.agent, null, function(err) {
logger.error('interval push should not have a callback.');
});
} else {
... | [
"function",
"(",
"args",
")",
"{",
"let",
"service",
"=",
"args",
".",
"service",
";",
"let",
"record",
"=",
"args",
".",
"record",
";",
"if",
"(",
"!",
"service",
"||",
"!",
"record",
"||",
"!",
"record",
".",
"module",
"||",
"!",
"record",
".",
... | run schedule job
@param {Object} args argments
@api private | [
"run",
"schedule",
"job"
] | 1cd692c16ab63b9c0d4009535f300f2ca584b691 | https://github.com/linyngfly/omelo-admin/blob/1cd692c16ab63b9c0d4009535f300f2ca584b691/lib/consoleService.js#L317-L333 | train | |
jaredhanson/node-xtraverse | lib/collection.js | wrap | function wrap(nodes) {
nodes = nodes || [];
if ('string' == typeof nodes) {
nodes = new DOMParser().parseFromString(nodes);
}
if (nodes.attrNS && nodes._related) {
// attempt to re-wrap Collection, return it directly
return nodes;
} else if (nodes.documentElement) {
nodes = [ nodes.documentEl... | javascript | function wrap(nodes) {
nodes = nodes || [];
if ('string' == typeof nodes) {
nodes = new DOMParser().parseFromString(nodes);
}
if (nodes.attrNS && nodes._related) {
// attempt to re-wrap Collection, return it directly
return nodes;
} else if (nodes.documentElement) {
nodes = [ nodes.documentEl... | [
"function",
"wrap",
"(",
"nodes",
")",
"{",
"nodes",
"=",
"nodes",
"||",
"[",
"]",
";",
"if",
"(",
"'string'",
"==",
"typeof",
"nodes",
")",
"{",
"nodes",
"=",
"new",
"DOMParser",
"(",
")",
".",
"parseFromString",
"(",
"nodes",
")",
";",
"}",
"if",... | Wraps and returns a new collection of elements.
Examples:
$('<xml/>');
@param {String|Node|Collection|Array} nodes XML string or DOM nodes to wrap.
@return {Collection} The wrapped nodes.
@api public | [
"Wraps",
"and",
"returns",
"a",
"new",
"collection",
"of",
"elements",
"."
] | ae5433a53600591d263385e12fbbacc32499d676 | https://github.com/jaredhanson/node-xtraverse/blob/ae5433a53600591d263385e12fbbacc32499d676/lib/collection.js#L20-L35 | train |
jaredhanson/node-xtraverse | lib/collection.js | unique | function unique(ar) {
var a = []
, i = -1
, j
, has;
while (++i < ar.length) {
j = -1;
has = false;
while (++j < a.length) {
if (a[j] === ar[i]) {
has = true;
break;
}
}
if (!has) { a.push(ar[i]); }
}
return a;
} | javascript | function unique(ar) {
var a = []
, i = -1
, j
, has;
while (++i < ar.length) {
j = -1;
has = false;
while (++j < a.length) {
if (a[j] === ar[i]) {
has = true;
break;
}
}
if (!has) { a.push(ar[i]); }
}
return a;
} | [
"function",
"unique",
"(",
"ar",
")",
"{",
"var",
"a",
"=",
"[",
"]",
",",
"i",
"=",
"-",
"1",
",",
"j",
",",
"has",
";",
"while",
"(",
"++",
"i",
"<",
"ar",
".",
"length",
")",
"{",
"j",
"=",
"-",
"1",
";",
"has",
"=",
"false",
";",
"w... | Returns an array consisting of unique elements.
@param {Array} ar
@return {Array}
@api private | [
"Returns",
"an",
"array",
"consisting",
"of",
"unique",
"elements",
"."
] | ae5433a53600591d263385e12fbbacc32499d676 | https://github.com/jaredhanson/node-xtraverse/blob/ae5433a53600591d263385e12fbbacc32499d676/lib/collection.js#L44-L61 | train |
jaredhanson/node-xtraverse | lib/collection.js | Collection | function Collection(nodes) {
this.length = 0;
if (nodes) {
nodes = unique(nodes);
this.length = nodes.length;
// add each node to an index-based property on collection, in order to
// appear "array"-like
for (var i = 0, len = nodes.length; i < len; i++) {
this[i] = nodes[i];
}
}
} | javascript | function Collection(nodes) {
this.length = 0;
if (nodes) {
nodes = unique(nodes);
this.length = nodes.length;
// add each node to an index-based property on collection, in order to
// appear "array"-like
for (var i = 0, len = nodes.length; i < len; i++) {
this[i] = nodes[i];
}
}
} | [
"function",
"Collection",
"(",
"nodes",
")",
"{",
"this",
".",
"length",
"=",
"0",
";",
"if",
"(",
"nodes",
")",
"{",
"nodes",
"=",
"unique",
"(",
"nodes",
")",
";",
"this",
".",
"length",
"=",
"nodes",
".",
"length",
";",
"// add each node to an index... | Creates an instance of `Collection`.
@constructor
@param {Array} nodes DOM elements to wrap.
@api protected | [
"Creates",
"an",
"instance",
"of",
"Collection",
"."
] | ae5433a53600591d263385e12fbbacc32499d676 | https://github.com/jaredhanson/node-xtraverse/blob/ae5433a53600591d263385e12fbbacc32499d676/lib/collection.js#L71-L82 | train |
philipbordallo/eslint-config | src/utilities/disableRules.js | disableRules | async function disableRules(rules) {
return Object.keys(rules)
.reduce((collection, rule) => ({
...collection,
[rule]: OFF,
}), {});
} | javascript | async function disableRules(rules) {
return Object.keys(rules)
.reduce((collection, rule) => ({
...collection,
[rule]: OFF,
}), {});
} | [
"async",
"function",
"disableRules",
"(",
"rules",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"rules",
")",
".",
"reduce",
"(",
"(",
"collection",
",",
"rule",
")",
"=>",
"(",
"{",
"...",
"collection",
",",
"[",
"rule",
"]",
":",
"OFF",
",",
"... | Automatically disable all rules given a rules list
@param {Object} rules - Rules to disable
@returns {Promise} A promise to return a rules list with each rule disabled | [
"Automatically",
"disable",
"all",
"rules",
"given",
"a",
"rules",
"list"
] | a2f1bff442fdb8ee622f842f075fa10d555302a4 | https://github.com/philipbordallo/eslint-config/blob/a2f1bff442fdb8ee622f842f075fa10d555302a4/src/utilities/disableRules.js#L9-L15 | train |
inviqa/deck-task-registry | src/build/build.js | build | function build (conf, undertaker, done) {
return undertaker.series(
require('./clean').bind(null, conf, undertaker),
undertaker.parallel(
require('../scripts/lintScripts').bind(null, conf, undertaker),
require('../styles/lintStyles').bind(null, conf, undertaker)
),
undertaker.parallel(
... | javascript | function build (conf, undertaker, done) {
return undertaker.series(
require('./clean').bind(null, conf, undertaker),
undertaker.parallel(
require('../scripts/lintScripts').bind(null, conf, undertaker),
require('../styles/lintStyles').bind(null, conf, undertaker)
),
undertaker.parallel(
... | [
"function",
"build",
"(",
"conf",
",",
"undertaker",
",",
"done",
")",
"{",
"return",
"undertaker",
".",
"series",
"(",
"require",
"(",
"'./clean'",
")",
".",
"bind",
"(",
"null",
",",
"conf",
",",
"undertaker",
")",
",",
"undertaker",
".",
"parallel",
... | Run all test and build tasks with maximum concurrency.
@param {ConfigParser} conf A configuration parser object.
@param {Undertaker} undertaker An Undertaker instance.
@param {Function} done A callback to call on task completion/
@returns {Stream} A stream of files. | [
"Run",
"all",
"test",
"and",
"build",
"tasks",
"with",
"maximum",
"concurrency",
"."
] | 4c31787b978e9d99a47052e090d4589a50cd3015 | https://github.com/inviqa/deck-task-registry/blob/4c31787b978e9d99a47052e090d4589a50cd3015/src/build/build.js#L12-L27 | train |
pkrll/JavaScript | Tooltip/Source/tooltip-1.1.js | function () {
// Remove the other tooltips
// if it was requested.
if (this.reset !== false)
this.resetTooltip();
// Create the tooltip elements
var container = $("<div>").attr({
"class": "error-label-container"
}).a... | javascript | function () {
// Remove the other tooltips
// if it was requested.
if (this.reset !== false)
this.resetTooltip();
// Create the tooltip elements
var container = $("<div>").attr({
"class": "error-label-container"
}).a... | [
"function",
"(",
")",
"{",
"// Remove the other tooltips",
"// if it was requested.",
"if",
"(",
"this",
".",
"reset",
"!==",
"false",
")",
"this",
".",
"resetTooltip",
"(",
")",
";",
"// Create the tooltip elements",
"var",
"container",
"=",
"$",
"(",
"\"<div>\""... | Create the tooltip | [
"Create",
"the",
"tooltip"
] | 2757281c61e14895694d921b98a699a96cb6d346 | https://github.com/pkrll/JavaScript/blob/2757281c61e14895694d921b98a699a96cb6d346/Tooltip/Source/tooltip-1.1.js#L139-L165 | train | |
redisjs/jsr-store | lib/database.js | Database | function Database(store, opts) {
opts = opts || {};
// the store that holds this database
this._store = store;
// do not coerce values to strings
this.raw = opts.raw !== undefined ? opts.raw : true;
// pattern matcher
this.pattern = opts.pattern || new Pattern();
this.options = opts;
// set up in... | javascript | function Database(store, opts) {
opts = opts || {};
// the store that holds this database
this._store = store;
// do not coerce values to strings
this.raw = opts.raw !== undefined ? opts.raw : true;
// pattern matcher
this.pattern = opts.pattern || new Pattern();
this.options = opts;
// set up in... | [
"function",
"Database",
"(",
"store",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"// the store that holds this database",
"this",
".",
"_store",
"=",
"store",
";",
"// do not coerce values to strings",
"this",
".",
"raw",
"=",
"opts",
"."... | Represents a collection of key value pairs as a database.
This module allows for a request object to be passed as the
last argument to each command. The request object will then be
passed as an argument when emitting on a write event by key.
This allows transactional semantics whereby a connection needs to
know if a ... | [
"Represents",
"a",
"collection",
"of",
"key",
"value",
"pairs",
"as",
"a",
"database",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/database.js#L24-L56 | train |
redisjs/jsr-resp | lib/encoder.js | Encoder | function Encoder(options) {
options = options || {};
Transform.call(this, {objectMode: true});
// string length chunk for bulk strings, strings large than this amount
// are broken over process ticks so as not to block the event loop
// note this is character length, not byte length
this.strlen = options.s... | javascript | function Encoder(options) {
options = options || {};
Transform.call(this, {objectMode: true});
// string length chunk for bulk strings, strings large than this amount
// are broken over process ticks so as not to block the event loop
// note this is character length, not byte length
this.strlen = options.s... | [
"function",
"Encoder",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"Transform",
".",
"call",
"(",
"this",
",",
"{",
"objectMode",
":",
"true",
"}",
")",
";",
"// string length chunk for bulk strings, strings large than this amount",
... | Class for encoding javascript types to RESP messages.
Public methods throw an error on an attempt to encode
an invalid type.
Stream methods emit an error event. | [
"Class",
"for",
"encoding",
"javascript",
"types",
"to",
"RESP",
"messages",
"."
] | 9f998fc65a4494a358fca296adfe37fc5fb3f03c | https://github.com/redisjs/jsr-resp/blob/9f998fc65a4494a358fca296adfe37fc5fb3f03c/lib/encoder.js#L16-L34 | train |
redisjs/jsr-resp | lib/encoder.js | pack | function pack(arr, buf) {
assert(Array.isArray(arr), 'array expected');
var i;
buf = buf || new Buffer(0);
buf = _preamble(buf, arr);
for(i = 0;i < arr.length;i++) {
buf = _arr(buf, arr[i]);
}
return buf;
} | javascript | function pack(arr, buf) {
assert(Array.isArray(arr), 'array expected');
var i;
buf = buf || new Buffer(0);
buf = _preamble(buf, arr);
for(i = 0;i < arr.length;i++) {
buf = _arr(buf, arr[i]);
}
return buf;
} | [
"function",
"pack",
"(",
"arr",
",",
"buf",
")",
"{",
"assert",
"(",
"Array",
".",
"isArray",
"(",
"arr",
")",
",",
"'array expected'",
")",
";",
"var",
"i",
";",
"buf",
"=",
"buf",
"||",
"new",
"Buffer",
"(",
"0",
")",
";",
"buf",
"=",
"_preambl... | Pack an array of arrays.
Typcially used when a caller wishes to pack multiple command arrays.
@param arr An array of arrays.
@param buf A buffer to append the encoded contents to (optional).
@return A buffer with the RESP encoded contents. | [
"Pack",
"an",
"array",
"of",
"arrays",
"."
] | 9f998fc65a4494a358fca296adfe37fc5fb3f03c | https://github.com/redisjs/jsr-resp/blob/9f998fc65a4494a358fca296adfe37fc5fb3f03c/lib/encoder.js#L135-L144 | train |
redisjs/jsr-resp | lib/encoder.js | value | function value(val, buf, simple) {
buf = buf || new Buffer(0);
var type = typeof val;
// coerce booleans to integers
val = type === 'boolean' ? Number(val) : val;
// treat floats as strings
if(type === 'number' && parseInt(val) !== val) {
val = '' + val;
}
// String instances are treated as simpl... | javascript | function value(val, buf, simple) {
buf = buf || new Buffer(0);
var type = typeof val;
// coerce booleans to integers
val = type === 'boolean' ? Number(val) : val;
// treat floats as strings
if(type === 'number' && parseInt(val) !== val) {
val = '' + val;
}
// String instances are treated as simpl... | [
"function",
"value",
"(",
"val",
",",
"buf",
",",
"simple",
")",
"{",
"buf",
"=",
"buf",
"||",
"new",
"Buffer",
"(",
"0",
")",
";",
"var",
"type",
"=",
"typeof",
"val",
";",
"// coerce booleans to integers",
"val",
"=",
"type",
"===",
"'boolean'",
"?",... | Encode a single javascript value.
@param val The value to encode.
@param buf A buffer to append the encoded contents to (optional).
@param simple Force a string value to be treated as a simple string.
@return A buffer with the RESP encoded contents. | [
"Encode",
"a",
"single",
"javascript",
"value",
"."
] | 9f998fc65a4494a358fca296adfe37fc5fb3f03c | https://github.com/redisjs/jsr-resp/blob/9f998fc65a4494a358fca296adfe37fc5fb3f03c/lib/encoder.js#L170-L207 | train |
molecuel/mlcl_wishlist | index.js | function() {
var self = this;
molecuel.once('mlcl::elements::registrations:pre', function(module) {
elements = module;
self.wishlistSchema = {
name: { type: String, list: true, trim: true},
creation: { type: Date, 'default': Date.now, form: {readonly: true}},
entries: {
},
l... | javascript | function() {
var self = this;
molecuel.once('mlcl::elements::registrations:pre', function(module) {
elements = module;
self.wishlistSchema = {
name: { type: String, list: true, trim: true},
creation: { type: Date, 'default': Date.now, form: {readonly: true}},
entries: {
},
l... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"molecuel",
".",
"once",
"(",
"'mlcl::elements::registrations:pre'",
",",
"function",
"(",
"module",
")",
"{",
"elements",
"=",
"module",
";",
"self",
".",
"wishlistSchema",
"=",
"{",
"name",
":",... | This module serves wishlist database element
@constructor | [
"This",
"module",
"serves",
"wishlist",
"database",
"element"
] | 7cbe5c2924a41201449de9963a48e144c60b68a4 | https://github.com/molecuel/mlcl_wishlist/blob/7cbe5c2924a41201449de9963a48e144c60b68a4/index.js#L13-L44 | train | |
gfax/junkyard-brawl | src/util.js | baseWeight | function baseWeight(player, target, card, game) {
let weight = card.damage || 0
weight += Math.min(player.maxHp - player.hp, (parseInt(card.hp) || 0))
weight += card.missTurns / 2 || 0
// Prefer to contact weaker targets
weight += ((target.maxHp - player.hp) / 10)
// Unstoppable cards are instantly more v... | javascript | function baseWeight(player, target, card, game) {
let weight = card.damage || 0
weight += Math.min(player.maxHp - player.hp, (parseInt(card.hp) || 0))
weight += card.missTurns / 2 || 0
// Prefer to contact weaker targets
weight += ((target.maxHp - player.hp) / 10)
// Unstoppable cards are instantly more v... | [
"function",
"baseWeight",
"(",
"player",
",",
"target",
",",
"card",
",",
"game",
")",
"{",
"let",
"weight",
"=",
"card",
".",
"damage",
"||",
"0",
"weight",
"+=",
"Math",
".",
"min",
"(",
"player",
".",
"maxHp",
"-",
"player",
".",
"hp",
",",
"(",... | Calculate the base weight for a card play | [
"Calculate",
"the",
"base",
"weight",
"for",
"a",
"card",
"play"
] | 5e1b9d3b622ffa6e602c7abe51995269a43423e1 | https://github.com/gfax/junkyard-brawl/blob/5e1b9d3b622ffa6e602c7abe51995269a43423e1/src/util.js#L26-L45 | train |
gfax/junkyard-brawl | src/util.js | findNext | function findNext(array, item) {
return array[(Util.findIndex(array, el => el === item) + 1) % array.length]
} | javascript | function findNext(array, item) {
return array[(Util.findIndex(array, el => el === item) + 1) % array.length]
} | [
"function",
"findNext",
"(",
"array",
",",
"item",
")",
"{",
"return",
"array",
"[",
"(",
"Util",
".",
"findIndex",
"(",
"array",
",",
"el",
"=>",
"el",
"===",
"item",
")",
"+",
"1",
")",
"%",
"array",
".",
"length",
"]",
"}"
] | Return the next item in an array. If there is no next, return the first. | [
"Return",
"the",
"next",
"item",
"in",
"an",
"array",
".",
"If",
"there",
"is",
"no",
"next",
"return",
"the",
"first",
"."
] | 5e1b9d3b622ffa6e602c7abe51995269a43423e1 | https://github.com/gfax/junkyard-brawl/blob/5e1b9d3b622ffa6e602c7abe51995269a43423e1/src/util.js#L48-L50 | train |
gfax/junkyard-brawl | src/util.js | getAttackResults | function getAttackResults(_cards) {
// Force the cards into an array. Clone is too
// to avoid side effects from the simulation.
const cards = Util.clone(Array.isArray(_cards) ? _cards : [_cards])
const Junkyard = require('./junkyard')
const game = new Junkyard('1', '')
game.addPlayer('2', '')
game.addPla... | javascript | function getAttackResults(_cards) {
// Force the cards into an array. Clone is too
// to avoid side effects from the simulation.
const cards = Util.clone(Array.isArray(_cards) ? _cards : [_cards])
const Junkyard = require('./junkyard')
const game = new Junkyard('1', '')
game.addPlayer('2', '')
game.addPla... | [
"function",
"getAttackResults",
"(",
"_cards",
")",
"{",
"// Force the cards into an array. Clone is too",
"// to avoid side effects from the simulation.",
"const",
"cards",
"=",
"Util",
".",
"clone",
"(",
"Array",
".",
"isArray",
"(",
"_cards",
")",
"?",
"_cards",
":",... | Determine an attack's damages by simulating playing it | [
"Determine",
"an",
"attack",
"s",
"damages",
"by",
"simulating",
"playing",
"it"
] | 5e1b9d3b622ffa6e602c7abe51995269a43423e1 | https://github.com/gfax/junkyard-brawl/blob/5e1b9d3b622ffa6e602c7abe51995269a43423e1/src/util.js#L53-L70 | train |
gfax/junkyard-brawl | src/util.js | getCardWeight | function getCardWeight(player, target, card, game) {
let moves = []
if (card.validPlays) {
moves = card.validPlays(player, target, game)
}
if (card.validCounters && target.discard.length) {
moves = card.validCounters(player, target, game)
}
if (card.validDisasters) {
moves = card.validDisasters(... | javascript | function getCardWeight(player, target, card, game) {
let moves = []
if (card.validPlays) {
moves = card.validPlays(player, target, game)
}
if (card.validCounters && target.discard.length) {
moves = card.validCounters(player, target, game)
}
if (card.validDisasters) {
moves = card.validDisasters(... | [
"function",
"getCardWeight",
"(",
"player",
",",
"target",
",",
"card",
",",
"game",
")",
"{",
"let",
"moves",
"=",
"[",
"]",
"if",
"(",
"card",
".",
"validPlays",
")",
"{",
"moves",
"=",
"card",
".",
"validPlays",
"(",
"player",
",",
"target",
",",
... | Return a cards best weight | [
"Return",
"a",
"cards",
"best",
"weight"
] | 5e1b9d3b622ffa6e602c7abe51995269a43423e1 | https://github.com/gfax/junkyard-brawl/blob/5e1b9d3b622ffa6e602c7abe51995269a43423e1/src/util.js#L73-L88 | train |
gfax/junkyard-brawl | src/util.js | getPlayerCounters | function getPlayerCounters(player, attacker, game) {
return player.hand
.map((card) => {
return card.validCounters ? card.validCounters(player, attacker, game) : []
})
.reduce((acc, array) => {
return acc.concat(array)
}, [])
.sort((counterA, counterB) => counterB.weight - counterA.wei... | javascript | function getPlayerCounters(player, attacker, game) {
return player.hand
.map((card) => {
return card.validCounters ? card.validCounters(player, attacker, game) : []
})
.reduce((acc, array) => {
return acc.concat(array)
}, [])
.sort((counterA, counterB) => counterB.weight - counterA.wei... | [
"function",
"getPlayerCounters",
"(",
"player",
",",
"attacker",
",",
"game",
")",
"{",
"return",
"player",
".",
"hand",
".",
"map",
"(",
"(",
"card",
")",
"=>",
"{",
"return",
"card",
".",
"validCounters",
"?",
"card",
".",
"validCounters",
"(",
"player... | Get a list of possible counter moves, sorted by best option | [
"Get",
"a",
"list",
"of",
"possible",
"counter",
"moves",
"sorted",
"by",
"best",
"option"
] | 5e1b9d3b622ffa6e602c7abe51995269a43423e1 | https://github.com/gfax/junkyard-brawl/blob/5e1b9d3b622ffa6e602c7abe51995269a43423e1/src/util.js#L91-L100 | train |
gfax/junkyard-brawl | src/util.js | getPlayerDisasters | function getPlayerDisasters(player, game) {
return player.hand
.map((card) => {
return card.validDisasters ? card.validDisasters(player, game) : []
})
.reduce((acc, array) => {
return acc.concat(array)
}, [])
.sort((disasterA, disasterB) => disasterB.weight - disasterA.weight)
} | javascript | function getPlayerDisasters(player, game) {
return player.hand
.map((card) => {
return card.validDisasters ? card.validDisasters(player, game) : []
})
.reduce((acc, array) => {
return acc.concat(array)
}, [])
.sort((disasterA, disasterB) => disasterB.weight - disasterA.weight)
} | [
"function",
"getPlayerDisasters",
"(",
"player",
",",
"game",
")",
"{",
"return",
"player",
".",
"hand",
".",
"map",
"(",
"(",
"card",
")",
"=>",
"{",
"return",
"card",
".",
"validDisasters",
"?",
"card",
".",
"validDisasters",
"(",
"player",
",",
"game"... | Get a list of possible disaster moves, sorted by best option | [
"Get",
"a",
"list",
"of",
"possible",
"disaster",
"moves",
"sorted",
"by",
"best",
"option"
] | 5e1b9d3b622ffa6e602c7abe51995269a43423e1 | https://github.com/gfax/junkyard-brawl/blob/5e1b9d3b622ffa6e602c7abe51995269a43423e1/src/util.js#L103-L112 | train |
gfax/junkyard-brawl | src/util.js | getPlayerPlays | function getPlayerPlays(player, game) {
// Shuffle so that equal-weighted players aren't
// always prioritized by their turn order
return Util.shuffle(game.players)
.reduce((plays, target) => {
if (player === target) {
return plays
}
return plays.concat(
player.hand
... | javascript | function getPlayerPlays(player, game) {
// Shuffle so that equal-weighted players aren't
// always prioritized by their turn order
return Util.shuffle(game.players)
.reduce((plays, target) => {
if (player === target) {
return plays
}
return plays.concat(
player.hand
... | [
"function",
"getPlayerPlays",
"(",
"player",
",",
"game",
")",
"{",
"// Shuffle so that equal-weighted players aren't",
"// always prioritized by their turn order",
"return",
"Util",
".",
"shuffle",
"(",
"game",
".",
"players",
")",
".",
"reduce",
"(",
"(",
"plays",
"... | Get a list of possible moves a player can play, sorted by best option | [
"Get",
"a",
"list",
"of",
"possible",
"moves",
"a",
"player",
"can",
"play",
"sorted",
"by",
"best",
"option"
] | 5e1b9d3b622ffa6e602c7abe51995269a43423e1 | https://github.com/gfax/junkyard-brawl/blob/5e1b9d3b622ffa6e602c7abe51995269a43423e1/src/util.js#L115-L134 | train |
gfax/junkyard-brawl | src/util.js | remove | function remove(array, fn) {
const idx = array.findIndex(fn)
if (idx !== -1) {
array.splice(idx, 1)
}
} | javascript | function remove(array, fn) {
const idx = array.findIndex(fn)
if (idx !== -1) {
array.splice(idx, 1)
}
} | [
"function",
"remove",
"(",
"array",
",",
"fn",
")",
"{",
"const",
"idx",
"=",
"array",
".",
"findIndex",
"(",
"fn",
")",
"if",
"(",
"idx",
"!==",
"-",
"1",
")",
"{",
"array",
".",
"splice",
"(",
"idx",
",",
"1",
")",
"}",
"}"
] | Remove one copy of a matched item from an array given a predicate function | [
"Remove",
"one",
"copy",
"of",
"a",
"matched",
"item",
"from",
"an",
"array",
"given",
"a",
"predicate",
"function"
] | 5e1b9d3b622ffa6e602c7abe51995269a43423e1 | https://github.com/gfax/junkyard-brawl/blob/5e1b9d3b622ffa6e602c7abe51995269a43423e1/src/util.js#L137-L142 | train |
xsolon/spexplorerjs | webapi/src/components/string/funcs.js | function (arr, groupSize) {
var groups = [];
groupSize = groupSize || 100;
arr.forEach(function (n, i) {
var index = Math.trunc(i / groupSize);
if (groups.length === index) {
groups.push([]);
}
groups[index].push(n);
});
return groups;
} | javascript | function (arr, groupSize) {
var groups = [];
groupSize = groupSize || 100;
arr.forEach(function (n, i) {
var index = Math.trunc(i / groupSize);
if (groups.length === index) {
groups.push([]);
}
groups[index].push(n);
});
return groups;
} | [
"function",
"(",
"arr",
",",
"groupSize",
")",
"{",
"var",
"groups",
"=",
"[",
"]",
";",
"groupSize",
"=",
"groupSize",
"||",
"100",
";",
"arr",
".",
"forEach",
"(",
"function",
"(",
"n",
",",
"i",
")",
"{",
"var",
"index",
"=",
"Math",
".",
"tru... | Divide array into an array of arrays of size groupSize
@param {Array} arr
@param {integer} groupSize | [
"Divide",
"array",
"into",
"an",
"array",
"of",
"arrays",
"of",
"size",
"groupSize"
] | 4e9b410864afb731f88e84414984fa18ac5705f1 | https://github.com/xsolon/spexplorerjs/blob/4e9b410864afb731f88e84414984fa18ac5705f1/webapi/src/components/string/funcs.js#L70-L81 | train | |
tolokoban/ToloFrameWork | ker/mod/webgl.math.js | normalize | function normalize(arr) {
const n = copy(arr);
let len = 0;
for (const v of n) len += v * v;
if (len > 0) {
const coeff = 1 / Math.sqrt(len);
for (let k = 0; k < n.length; k++) {
n[k] *= coeff;
}
}
return n;
} | javascript | function normalize(arr) {
const n = copy(arr);
let len = 0;
for (const v of n) len += v * v;
if (len > 0) {
const coeff = 1 / Math.sqrt(len);
for (let k = 0; k < n.length; k++) {
n[k] *= coeff;
}
}
return n;
} | [
"function",
"normalize",
"(",
"arr",
")",
"{",
"const",
"n",
"=",
"copy",
"(",
"arr",
")",
";",
"let",
"len",
"=",
"0",
";",
"for",
"(",
"const",
"v",
"of",
"n",
")",
"len",
"+=",
"v",
"*",
"v",
";",
"if",
"(",
"len",
">",
"0",
")",
"{",
... | Make a vector have a length of 1.
@param {Float32Array} arr - Input vector.
@returns {Float32Array} A new vector. | [
"Make",
"a",
"vector",
"have",
"a",
"length",
"of",
"1",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/webgl.math.js#L71-L82 | train |
tolokoban/ToloFrameWork | ker/mod/webgl.math.js | perspective4 | function perspective4(fieldAngle, aspect, near, far, result) {
result = result || new Float32Array(16);
var f = Math.tan(Math.PI * 0.5 - 0.5 * fieldAngle);
var rangeInv = 1.0 / (near - far);
result[0] = f / aspect;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[... | javascript | function perspective4(fieldAngle, aspect, near, far, result) {
result = result || new Float32Array(16);
var f = Math.tan(Math.PI * 0.5 - 0.5 * fieldAngle);
var rangeInv = 1.0 / (near - far);
result[0] = f / aspect;
result[1] = 0;
result[2] = 0;
result[3] = 0;
result[4] = 0;
result[... | [
"function",
"perspective4",
"(",
"fieldAngle",
",",
"aspect",
",",
"near",
",",
"far",
",",
"result",
")",
"{",
"result",
"=",
"result",
"||",
"new",
"Float32Array",
"(",
"16",
")",
";",
"var",
"f",
"=",
"Math",
".",
"tan",
"(",
"Math",
".",
"PI",
... | Define the `frustum`.
@param {number} fieldAngle - View angle in radians. Maximum is PI.
@param {number} aspect - (width / height) of the canvas.
@param {number} near - Clip every Z lower than `near`.
@param {number} far - Clip every Z greater than `far`. | [
"Define",
"the",
"frustum",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/webgl.math.js#L144-L170 | train |
wavesoft/gulp-jbb | index.js | streamOutput | function streamOutput( callback ) {
return function(err, filenames) {
if (err) {
callback(err, null);
} else {
// Create read streams from each input
var streams = []
for (var i=0; i<filenames.suffix.length; i++)
streams.push([
fs.createReadStream( filenames.basename + filenames.suffix[i]),
... | javascript | function streamOutput( callback ) {
return function(err, filenames) {
if (err) {
callback(err, null);
} else {
// Create read streams from each input
var streams = []
for (var i=0; i<filenames.suffix.length; i++)
streams.push([
fs.createReadStream( filenames.basename + filenames.suffix[i]),
... | [
"function",
"streamOutput",
"(",
"callback",
")",
"{",
"return",
"function",
"(",
"err",
",",
"filenames",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
",",
"null",
")",
";",
"}",
"else",
"{",
"// Create read streams from each input",
"var... | Read resulting bundle and return a stream with it | [
"Read",
"resulting",
"bundle",
"and",
"return",
"a",
"stream",
"with",
"it"
] | d6a41efff91615d9a643c3b9332dadd3a4faa242 | https://github.com/wavesoft/gulp-jbb/blob/d6a41efff91615d9a643c3b9332dadd3a4faa242/index.js#L34-L50 | train |
wavesoft/gulp-jbb | index.js | processAsBuffer | function processAsBuffer( file ) {
return function( callback ) {
var json = JSON.parse(file.contents);
callback( json, path.dirname(file.path) );
}
} | javascript | function processAsBuffer( file ) {
return function( callback ) {
var json = JSON.parse(file.contents);
callback( json, path.dirname(file.path) );
}
} | [
"function",
"processAsBuffer",
"(",
"file",
")",
"{",
"return",
"function",
"(",
"callback",
")",
"{",
"var",
"json",
"=",
"JSON",
".",
"parse",
"(",
"file",
".",
"contents",
")",
";",
"callback",
"(",
"json",
",",
"path",
".",
"dirname",
"(",
"file",
... | Parse input file as buffer and return the JSON-parsed string | [
"Parse",
"input",
"file",
"as",
"buffer",
"and",
"return",
"the",
"JSON",
"-",
"parsed",
"string"
] | d6a41efff91615d9a643c3b9332dadd3a4faa242 | https://github.com/wavesoft/gulp-jbb/blob/d6a41efff91615d9a643c3b9332dadd3a4faa242/index.js#L55-L60 | train |
wavesoft/gulp-jbb | index.js | compileJBB | function compileJBB( config, parseCallback, resultCallback ) {
// Continue compiling the JBB bundle
var compile = function( bundleJSON, bundlePath, tempName ) {
// Update path in config
if (!config['path'])
config['path'] = path.dirname(bundlePath);
// Create the JBB bundle
JBBCompiler.compile(
bund... | javascript | function compileJBB( config, parseCallback, resultCallback ) {
// Continue compiling the JBB bundle
var compile = function( bundleJSON, bundlePath, tempName ) {
// Update path in config
if (!config['path'])
config['path'] = path.dirname(bundlePath);
// Create the JBB bundle
JBBCompiler.compile(
bund... | [
"function",
"compileJBB",
"(",
"config",
",",
"parseCallback",
",",
"resultCallback",
")",
"{",
"// Continue compiling the JBB bundle",
"var",
"compile",
"=",
"function",
"(",
"bundleJSON",
",",
"bundlePath",
",",
"tempName",
")",
"{",
"// Update path in config",
"if"... | Helper function to compile the JBB bundle according to
the configuration options and return the temporary filename
were the bundle was created. | [
"Helper",
"function",
"to",
"compile",
"the",
"JBB",
"bundle",
"according",
"to",
"the",
"configuration",
"options",
"and",
"return",
"the",
"temporary",
"filename",
"were",
"the",
"bundle",
"was",
"created",
"."
] | d6a41efff91615d9a643c3b9332dadd3a4faa242 | https://github.com/wavesoft/gulp-jbb/blob/d6a41efff91615d9a643c3b9332dadd3a4faa242/index.js#L77-L137 | train |
wavesoft/gulp-jbb | index.js | function( bundleJSON, bundlePath, tempName ) {
// Update path in config
if (!config['path'])
config['path'] = path.dirname(bundlePath);
// Create the JBB bundle
JBBCompiler.compile(
bundleJSON,
tempName,
config,
function() {
// Check for sparse bundles
if (config['sparse']) {
... | javascript | function( bundleJSON, bundlePath, tempName ) {
// Update path in config
if (!config['path'])
config['path'] = path.dirname(bundlePath);
// Create the JBB bundle
JBBCompiler.compile(
bundleJSON,
tempName,
config,
function() {
// Check for sparse bundles
if (config['sparse']) {
... | [
"function",
"(",
"bundleJSON",
",",
"bundlePath",
",",
"tempName",
")",
"{",
"// Update path in config",
"if",
"(",
"!",
"config",
"[",
"'path'",
"]",
")",
"config",
"[",
"'path'",
"]",
"=",
"path",
".",
"dirname",
"(",
"bundlePath",
")",
";",
"// Create t... | Continue compiling the JBB bundle | [
"Continue",
"compiling",
"the",
"JBB",
"bundle"
] | d6a41efff91615d9a643c3b9332dadd3a4faa242 | https://github.com/wavesoft/gulp-jbb/blob/d6a41efff91615d9a643c3b9332dadd3a4faa242/index.js#L80-L113 | train | |
wavesoft/gulp-jbb | index.js | function( err, streams ) {
// Get base name
var path = originalFile.path;
var parts = path.split("."); parts.pop();
var baseName = parts.join(".");
// Push each stream to output
for (var i=0; i<streams.length; i++) {
var f = originalFile.clone();
f.contents = streams[i][0]; // C... | javascript | function( err, streams ) {
// Get base name
var path = originalFile.path;
var parts = path.split("."); parts.pop();
var baseName = parts.join(".");
// Push each stream to output
for (var i=0; i<streams.length; i++) {
var f = originalFile.clone();
f.contents = streams[i][0]; // C... | [
"function",
"(",
"err",
",",
"streams",
")",
"{",
"// Get base name",
"var",
"path",
"=",
"originalFile",
".",
"path",
";",
"var",
"parts",
"=",
"path",
".",
"split",
"(",
"\".\"",
")",
";",
"parts",
".",
"pop",
"(",
")",
";",
"var",
"baseName",
"=",... | Call when finished with compression | [
"Call",
"when",
"finished",
"with",
"compression"
] | d6a41efff91615d9a643c3b9332dadd3a4faa242 | https://github.com/wavesoft/gulp-jbb/blob/d6a41efff91615d9a643c3b9332dadd3a4faa242/index.js#L158-L176 | train | |
redisjs/jsr-server | lib/signals.js | signals | function signals() {
/**
* Signal handler.
*/
function interrupt(signal) {
this.log.notice('received %s, scheduling shutdown', signal);
this.shutdown(0, process.exit);
}
interrupt = interrupt.bind(this);
function iterate(signal) {
/* test environment listener leak */
if(process.list... | javascript | function signals() {
/**
* Signal handler.
*/
function interrupt(signal) {
this.log.notice('received %s, scheduling shutdown', signal);
this.shutdown(0, process.exit);
}
interrupt = interrupt.bind(this);
function iterate(signal) {
/* test environment listener leak */
if(process.list... | [
"function",
"signals",
"(",
")",
"{",
"/**\n * Signal handler.\n */",
"function",
"interrupt",
"(",
"signal",
")",
"{",
"this",
".",
"log",
".",
"notice",
"(",
"'received %s, scheduling shutdown'",
",",
"signal",
")",
";",
"this",
".",
"shutdown",
"(",
"0",... | Register listeners for signals that trigger a shutdown. | [
"Register",
"listeners",
"for",
"signals",
"that",
"trigger",
"a",
"shutdown",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/signals.js#L4-L27 | train |
StupidStudio/stupid-deferred | deferred.js | promiseThen | function promiseThen(success, reject, notify){
/**
* @define {object} Return a new promise
*/
var def = Deferred();
/**
* Resolved promise
* @example example
* @param {string} A string key for the event system
* @param {function} A callback when event is triggered
* @return {object} Returns ... | javascript | function promiseThen(success, reject, notify){
/**
* @define {object} Return a new promise
*/
var def = Deferred();
/**
* Resolved promise
* @example example
* @param {string} A string key for the event system
* @param {function} A callback when event is triggered
* @return {object} Returns ... | [
"function",
"promiseThen",
"(",
"success",
",",
"reject",
",",
"notify",
")",
"{",
"/**\n\t\t * @define {object} Return a new promise\n\t\t */",
"var",
"def",
"=",
"Deferred",
"(",
")",
";",
"/**\n\t\t * Resolved promise\n\t\t * @example example\n\t\t * @param {string} A string k... | Promise then method
This is for chaining promis callbacks
@example promiseFunction().then(
function(){ // success },
function(){ // rejected },
function(){ // notify }
).then( ... );
@param {function} sucess Success callback
@param {function} reject Reject callback
@param {function} notify notify callback
@return {obje... | [
"Promise",
"then",
"method",
"This",
"is",
"for",
"chaining",
"promis",
"callbacks"
] | d5e6aa8cf3b89e9faf58a811cd6e42df986ef0af | https://github.com/StupidStudio/stupid-deferred/blob/d5e6aa8cf3b89e9faf58a811cd6e42df986ef0af/deferred.js#L47-L94 | train |
StupidStudio/stupid-deferred | deferred.js | resolve | function resolve(){
var args = Array.prototype.slice.call(arguments);
event.trigger('resolve', args);
} | javascript | function resolve(){
var args = Array.prototype.slice.call(arguments);
event.trigger('resolve', args);
} | [
"function",
"resolve",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"event",
".",
"trigger",
"(",
"'resolve'",
",",
"args",
")",
";",
"}"
] | Deferred methods to trigger the promise
@example def.resolve(args)
@example def.reject(args)
@example def.notify(args) | [
"Deferred",
"methods",
"to",
"trigger",
"the",
"promise"
] | d5e6aa8cf3b89e9faf58a811cd6e42df986ef0af | https://github.com/StupidStudio/stupid-deferred/blob/d5e6aa8cf3b89e9faf58a811cd6e42df986ef0af/deferred.js#L124-L127 | train |
gethuman/pancakes-angular | lib/pancakes.angular.plugin.js | PancakesAngularPlugin | function PancakesAngularPlugin(opts) {
this.templateDir = path.join(__dirname, 'transformers');
this.pancakes = opts.pluginOptions.pancakes;
// initialize Jyt plugins
this.registerJytPlugins();
// initialize all directives and load them into memory
this.initDirectives(opts);
// i... | javascript | function PancakesAngularPlugin(opts) {
this.templateDir = path.join(__dirname, 'transformers');
this.pancakes = opts.pluginOptions.pancakes;
// initialize Jyt plugins
this.registerJytPlugins();
// initialize all directives and load them into memory
this.initDirectives(opts);
// i... | [
"function",
"PancakesAngularPlugin",
"(",
"opts",
")",
"{",
"this",
".",
"templateDir",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'transformers'",
")",
";",
"this",
".",
"pancakes",
"=",
"opts",
".",
"pluginOptions",
".",
"pancakes",
";",
"// initial... | Constructor for the pancakes angular plugin
@param opts
@constructor | [
"Constructor",
"for",
"the",
"pancakes",
"angular",
"plugin"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/pancakes.angular.plugin.js#L27-L50 | train |
mattstyles/octofish | lib/octofish.js | function( path, cb ) {
// Set the content path
octofish.setContentPath( path );
// Use the content path to retrieve content
octofish.github.repos.getContent( octofish.config.contentOpts, function ( err, res ) {
var data = null;
// Handle any error
i... | javascript | function( path, cb ) {
// Set the content path
octofish.setContentPath( path );
// Use the content path to retrieve content
octofish.github.repos.getContent( octofish.config.contentOpts, function ( err, res ) {
var data = null;
// Handle any error
i... | [
"function",
"(",
"path",
",",
"cb",
")",
"{",
"// Set the content path",
"octofish",
".",
"setContentPath",
"(",
"path",
")",
";",
"// Use the content path to retrieve content",
"octofish",
".",
"github",
".",
"repos",
".",
"getContent",
"(",
"octofish",
".",
"con... | getContent
gets the content from github repo set up in config
@param cb - the callback to fire on success - passes in the collected data | [
"getContent",
"gets",
"the",
"content",
"from",
"github",
"repo",
"set",
"up",
"in",
"config"
] | 24e3d7e662a9551bcd5f158e94d56f05f75171ab | https://github.com/mattstyles/octofish/blob/24e3d7e662a9551bcd5f158e94d56f05f75171ab/lib/octofish.js#L79-L110 | train | |
mattstyles/octofish | lib/octofish.js | function( authType ) {
switch ( authType.toLowerCase() ) {
case 'basic':
console.log( 'Attempting to use basic authorisation' );
getBasicAuth() ? cb_success() : cb_failure();
break;
case 'oauth':
... | javascript | function( authType ) {
switch ( authType.toLowerCase() ) {
case 'basic':
console.log( 'Attempting to use basic authorisation' );
getBasicAuth() ? cb_success() : cb_failure();
break;
case 'oauth':
... | [
"function",
"(",
"authType",
")",
"{",
"switch",
"(",
"authType",
".",
"toLowerCase",
"(",
")",
")",
"{",
"case",
"'basic'",
":",
"console",
".",
"log",
"(",
"'Attempting to use basic authorisation'",
")",
";",
"getBasicAuth",
"(",
")",
"?",
"cb_success",
"(... | Gets the correct method for building an authentication object to pass to github
@param authType { basic || oauth }
@return calls the correct function for building an auth object || null | [
"Gets",
"the",
"correct",
"method",
"for",
"building",
"an",
"authentication",
"object",
"to",
"pass",
"to",
"github"
] | 24e3d7e662a9551bcd5f158e94d56f05f75171ab | https://github.com/mattstyles/octofish/blob/24e3d7e662a9551bcd5f158e94d56f05f75171ab/lib/octofish.js#L127-L148 | train | |
mattstyles/octofish | lib/octofish.js | function() {
auth.type = 'basic';
auth.username = process.env.GHusername || octofish.config.auth.username || null;
auth.password = process.env.GHpassword || octofish.config.auth.password || null;
if ( !auth.password || !auth.username ) {
return false;
... | javascript | function() {
auth.type = 'basic';
auth.username = process.env.GHusername || octofish.config.auth.username || null;
auth.password = process.env.GHpassword || octofish.config.auth.password || null;
if ( !auth.password || !auth.username ) {
return false;
... | [
"function",
"(",
")",
"{",
"auth",
".",
"type",
"=",
"'basic'",
";",
"auth",
".",
"username",
"=",
"process",
".",
"env",
".",
"GHusername",
"||",
"octofish",
".",
"config",
".",
"auth",
".",
"username",
"||",
"null",
";",
"auth",
".",
"password",
"=... | Completes basic authorisation or returns false on failure
@todo Currently only checks that a username and password have been specified, not that they have successfully completed authentication
@return {Boolean} | [
"Completes",
"basic",
"authorisation",
"or",
"returns",
"false",
"on",
"failure"
] | 24e3d7e662a9551bcd5f158e94d56f05f75171ab | https://github.com/mattstyles/octofish/blob/24e3d7e662a9551bcd5f158e94d56f05f75171ab/lib/octofish.js#L163-L175 | train | |
magicdawn/predator-kit | lib/index.js | Predator | function Predator(options) {
if (!(this instanceof Predator)) {
return new Predator(options);
}
if (!options || !options.app) {
throw new Error('options.app is required');
}
// 主目录
this.home = pathFn.resolve(options.home || '.');
// app
this.app = options.app;
// build 目录
this.buildDir =... | javascript | function Predator(options) {
if (!(this instanceof Predator)) {
return new Predator(options);
}
if (!options || !options.app) {
throw new Error('options.app is required');
}
// 主目录
this.home = pathFn.resolve(options.home || '.');
// app
this.app = options.app;
// build 目录
this.buildDir =... | [
"function",
"Predator",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Predator",
")",
")",
"{",
"return",
"new",
"Predator",
"(",
"options",
")",
";",
"}",
"if",
"(",
"!",
"options",
"||",
"!",
"options",
".",
"app",
")",
"{... | Preadtor class def
options
- home: 主目录
- app: koa app
- buildDir: build static files | [
"Preadtor",
"class",
"def"
] | aa6b7b3094a278a536a731639611556f76e5a8b9 | https://github.com/magicdawn/predator-kit/blob/aa6b7b3094a278a536a731639611556f76e5a8b9/lib/index.js#L39-L56 | train |
node-neatly/neatly | lib/module.js | createQueuePusher | function createQueuePusher(providerName, method, insertMethod, queue) {
return function() {
let args = arguments;
// Add provide method to invokeQueue to execute it on bootstrap.
(queue || invokeQueue)[insertMethod || 'push'](function provide(injector) {
// Get provider
let provider = injector.get(... | javascript | function createQueuePusher(providerName, method, insertMethod, queue) {
return function() {
let args = arguments;
// Add provide method to invokeQueue to execute it on bootstrap.
(queue || invokeQueue)[insertMethod || 'push'](function provide(injector) {
// Get provider
let provider = injector.get(... | [
"function",
"createQueuePusher",
"(",
"providerName",
",",
"method",
",",
"insertMethod",
",",
"queue",
")",
"{",
"return",
"function",
"(",
")",
"{",
"let",
"args",
"=",
"arguments",
";",
"// Add provide method to invokeQueue to execute it on bootstrap.",
"(",
"queue... | Helper to create a function which adds a provide-method to invokeQueue.
@param {String} providerName $provide | $injector
@param {String} method method to execute on provider
@param {String} insertMethod native array-methods (default: push)
@return {Object} self | [
"Helper",
"to",
"create",
"a",
"function",
"which",
"adds",
"a",
"provide",
"-",
"method",
"to",
"invokeQueue",
"."
] | 732d9729bce84013b5516fe7c239dd672d138dd8 | https://github.com/node-neatly/neatly/blob/732d9729bce84013b5516fe7c239dd672d138dd8/lib/module.js#L24-L46 | train |
sbyrnes/bloom.js | bloom.js | estimateFalsePositiveRate | function estimateFalsePositiveRate(numValues, numBuckets, numHashes)
{
// Formula for false positives is (1-e^(-kn/m))^k
// k - number of hashes
// n - number of set entries
// m - number of buckets
var expectedFalsePositivesRate = Math.pow((1 - Math.exp(-numHashes * numValues / numBuckets)), numHashes);
return... | javascript | function estimateFalsePositiveRate(numValues, numBuckets, numHashes)
{
// Formula for false positives is (1-e^(-kn/m))^k
// k - number of hashes
// n - number of set entries
// m - number of buckets
var expectedFalsePositivesRate = Math.pow((1 - Math.exp(-numHashes * numValues / numBuckets)), numHashes);
return... | [
"function",
"estimateFalsePositiveRate",
"(",
"numValues",
",",
"numBuckets",
",",
"numHashes",
")",
"{",
"// Formula for false positives is (1-e^(-kn/m))^k",
"// k - number of hashes",
"// n - number of set entries",
"// m - number of buckets",
"var",
"expectedFalsePositivesRate",
"... | Estimate the false positive rate for a given set of usage parameters
@param numValues The number of unique values in the set to be added to the filter.
@param numBuckets The number of unique buckets (bits) in the filter
@param numHashes The number of hashes to use.
@return Estimated false positive percentage as a float... | [
"Estimate",
"the",
"false",
"positive",
"rate",
"for",
"a",
"given",
"set",
"of",
"usage",
"parameters"
] | e93fdbda2e1aabd7895c5625f3ad5f845f949aad | https://github.com/sbyrnes/bloom.js/blob/e93fdbda2e1aabd7895c5625f3ad5f845f949aad/bloom.js#L106-L115 | train |
redisjs/jsr-client | lib/multi.js | _reset | function _reset() {
this._queue = [];
this._commands = [{cmd: Constants.MAP.multi.name, args: []}];
this._multi = false;
} | javascript | function _reset() {
this._queue = [];
this._commands = [{cmd: Constants.MAP.multi.name, args: []}];
this._multi = false;
} | [
"function",
"_reset",
"(",
")",
"{",
"this",
".",
"_queue",
"=",
"[",
"]",
";",
"this",
".",
"_commands",
"=",
"[",
"{",
"cmd",
":",
"Constants",
".",
"MAP",
".",
"multi",
".",
"name",
",",
"args",
":",
"[",
"]",
"}",
"]",
";",
"this",
".",
"... | Reset the multi so that it may be used again. | [
"Reset",
"the",
"multi",
"so",
"that",
"it",
"may",
"be",
"used",
"again",
"."
] | be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b | https://github.com/redisjs/jsr-client/blob/be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b/lib/multi.js#L25-L29 | train |
redisjs/jsr-client | lib/multi.js | _abort | function _abort(err) {
this._queue = null;
this._commands = null;
// listen for the event so we can clean reference
function onError() {
this._client = null;
}
this._client.once('error', onError.bind(this));
this._client.emit('error', err);
} | javascript | function _abort(err) {
this._queue = null;
this._commands = null;
// listen for the event so we can clean reference
function onError() {
this._client = null;
}
this._client.once('error', onError.bind(this));
this._client.emit('error', err);
} | [
"function",
"_abort",
"(",
"err",
")",
"{",
"this",
".",
"_queue",
"=",
"null",
";",
"this",
".",
"_commands",
"=",
"null",
";",
"// listen for the event so we can clean reference",
"function",
"onError",
"(",
")",
"{",
"this",
".",
"_client",
"=",
"null",
"... | Abort with an error. | [
"Abort",
"with",
"an",
"error",
"."
] | be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b | https://github.com/redisjs/jsr-client/blob/be90dd5c062e4efb38d5b7f91d3ad9f43174cb3b/lib/multi.js#L35-L44 | train |
ksmithut/confess | lib/load-file.js | loadFile | function loadFile(filepath, defaultObj) {
defaultObj = defaultObj || {};
if (!isFile(filepath)) { return defaultObj; }
var extension = path.extname(filepath).replace(/^\./, '');
var contents = supportedExtensions[extension](filepath);
return assign({}, defaultObj, contents);
} | javascript | function loadFile(filepath, defaultObj) {
defaultObj = defaultObj || {};
if (!isFile(filepath)) { return defaultObj; }
var extension = path.extname(filepath).replace(/^\./, '');
var contents = supportedExtensions[extension](filepath);
return assign({}, defaultObj, contents);
} | [
"function",
"loadFile",
"(",
"filepath",
",",
"defaultObj",
")",
"{",
"defaultObj",
"=",
"defaultObj",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"isFile",
"(",
"filepath",
")",
")",
"{",
"return",
"defaultObj",
";",
"}",
"var",
"extension",
"=",
"path",
"."... | Loads a file, if it exists. If it doesn't, then return the default object or empty object | [
"Loads",
"a",
"file",
"if",
"it",
"exists",
".",
"If",
"it",
"doesn",
"t",
"then",
"return",
"the",
"default",
"object",
"or",
"empty",
"object"
] | 937976ebfb52aa2cc9a5b337be28ee790ce9c403 | https://github.com/ksmithut/confess/blob/937976ebfb52aa2cc9a5b337be28ee790ce9c403/lib/load-file.js#L18-L27 | train |
jneurock/gulp-viking-posts | index.js | createPost | function createPost( file, options ) {
resetDoc();
var _formatDate = options && typeof options.formatDate === 'function' ?
options.formatDate : formatDate,
post = new Post();
// Parse front matter to get as many post attributes as possible
parseFrontMatter( file, post, options );
// Get category from pa... | javascript | function createPost( file, options ) {
resetDoc();
var _formatDate = options && typeof options.formatDate === 'function' ?
options.formatDate : formatDate,
post = new Post();
// Parse front matter to get as many post attributes as possible
parseFrontMatter( file, post, options );
// Get category from pa... | [
"function",
"createPost",
"(",
"file",
",",
"options",
")",
"{",
"resetDoc",
"(",
")",
";",
"var",
"_formatDate",
"=",
"options",
"&&",
"typeof",
"options",
".",
"formatDate",
"===",
"'function'",
"?",
"options",
".",
"formatDate",
":",
"formatDate",
",",
... | Create a post object
@param {Object} file
@param {Object} [options]
@returns {string} post object as a string | [
"Create",
"a",
"post",
"object"
] | e14b19a6fe743c9525af0448d8988589961f936a | https://github.com/jneurock/gulp-viking-posts/blob/e14b19a6fe743c9525af0448d8988589961f936a/index.js#L30-L81 | train |
jneurock/gulp-viking-posts | index.js | formatDate | function formatDate( date ) {
var dateString = '';
date = new Date( date );
dateString = date.getMonth() + 1;
dateString += '/';
dateString += date.getDate();
dateString += '/';
dateString += date.getFullYear();
return dateString;
} | javascript | function formatDate( date ) {
var dateString = '';
date = new Date( date );
dateString = date.getMonth() + 1;
dateString += '/';
dateString += date.getDate();
dateString += '/';
dateString += date.getFullYear();
return dateString;
} | [
"function",
"formatDate",
"(",
"date",
")",
"{",
"var",
"dateString",
"=",
"''",
";",
"date",
"=",
"new",
"Date",
"(",
"date",
")",
";",
"dateString",
"=",
"date",
".",
"getMonth",
"(",
")",
"+",
"1",
";",
"dateString",
"+=",
"'/'",
";",
"dateString"... | Format a date
@param {(Object|string)} date The date object to format
@returns {string} | [
"Format",
"a",
"date"
] | e14b19a6fe743c9525af0448d8988589961f936a | https://github.com/jneurock/gulp-viking-posts/blob/e14b19a6fe743c9525af0448d8988589961f936a/index.js#L89-L102 | train |
jneurock/gulp-viking-posts | index.js | getCategoryFromPath | function getCategoryFromPath( file ) {
var category = '',
i = 0,
parts = file.path.split('/'),
len = parts.length,
last = len - 1;
for ( ; i < len; i++ ) {
/*
* If previous path part is "posts" and the
* current path part isn't the last path part
*/
if ( parts[i - 1] === 'posts' && i !== l... | javascript | function getCategoryFromPath( file ) {
var category = '',
i = 0,
parts = file.path.split('/'),
len = parts.length,
last = len - 1;
for ( ; i < len; i++ ) {
/*
* If previous path part is "posts" and the
* current path part isn't the last path part
*/
if ( parts[i - 1] === 'posts' && i !== l... | [
"function",
"getCategoryFromPath",
"(",
"file",
")",
"{",
"var",
"category",
"=",
"''",
",",
"i",
"=",
"0",
",",
"parts",
"=",
"file",
".",
"path",
".",
"split",
"(",
"'/'",
")",
",",
"len",
"=",
"parts",
".",
"length",
",",
"last",
"=",
"len",
"... | Get post category from file path
@param {Object} file
@returns {string} | [
"Get",
"post",
"category",
"from",
"file",
"path"
] | e14b19a6fe743c9525af0448d8988589961f936a | https://github.com/jneurock/gulp-viking-posts/blob/e14b19a6fe743c9525af0448d8988589961f936a/index.js#L110-L133 | train |
jneurock/gulp-viking-posts | index.js | getTitleFromPath | function getTitleFromPath( file, options ) {
var _titleSeparator = options && options.titleSeparator ?
options.titleSeparator : titleSeparator,
i = 0,
parts = file.path.split('/'),
fileParts = parts[parts.length - 1].split('.'),
filename = fileParts[0],
fileNameParts = filename.split( _titleSeparat... | javascript | function getTitleFromPath( file, options ) {
var _titleSeparator = options && options.titleSeparator ?
options.titleSeparator : titleSeparator,
i = 0,
parts = file.path.split('/'),
fileParts = parts[parts.length - 1].split('.'),
filename = fileParts[0],
fileNameParts = filename.split( _titleSeparat... | [
"function",
"getTitleFromPath",
"(",
"file",
",",
"options",
")",
"{",
"var",
"_titleSeparator",
"=",
"options",
"&&",
"options",
".",
"titleSeparator",
"?",
"options",
".",
"titleSeparator",
":",
"titleSeparator",
",",
"i",
"=",
"0",
",",
"parts",
"=",
"fil... | Get post title from file path
@param {Object} file
@param {Object} [options]
@returns {string} | [
"Get",
"post",
"title",
"from",
"file",
"path"
] | e14b19a6fe743c9525af0448d8988589961f936a | https://github.com/jneurock/gulp-viking-posts/blob/e14b19a6fe743c9525af0448d8988589961f936a/index.js#L167-L186 | train |
jneurock/gulp-viking-posts | index.js | highlightPostSyntax | function highlightPostSyntax( post ) {
var codeTags = [],
i = 0,
len = 0;
doc = doc || createDom( post.content );
codeTags = doc.querySelectorAll('pre code');
len = codeTags.length;
for ( ; i < len; i++ ) {
// Replace class names beginning with "lang-" with "language-" for Highlight.js
codeTags[i]... | javascript | function highlightPostSyntax( post ) {
var codeTags = [],
i = 0,
len = 0;
doc = doc || createDom( post.content );
codeTags = doc.querySelectorAll('pre code');
len = codeTags.length;
for ( ; i < len; i++ ) {
// Replace class names beginning with "lang-" with "language-" for Highlight.js
codeTags[i]... | [
"function",
"highlightPostSyntax",
"(",
"post",
")",
"{",
"var",
"codeTags",
"=",
"[",
"]",
",",
"i",
"=",
"0",
",",
"len",
"=",
"0",
";",
"doc",
"=",
"doc",
"||",
"createDom",
"(",
"post",
".",
"content",
")",
";",
"codeTags",
"=",
"doc",
".",
"... | Parse any code blocks in the post content and highlight syntax
@param {Object} post | [
"Parse",
"any",
"code",
"blocks",
"in",
"the",
"post",
"content",
"and",
"highlight",
"syntax"
] | e14b19a6fe743c9525af0448d8988589961f936a | https://github.com/jneurock/gulp-viking-posts/blob/e14b19a6fe743c9525af0448d8988589961f936a/index.js#L193-L214 | train |
jneurock/gulp-viking-posts | index.js | isCustomFrontMatter | function isCustomFrontMatter( attr ) {
if ( attr !== 'title' && attr !== 'category' && attr !== 'content' &&
attr !== 'created' && attr !== 'excerpt' && attr !== 'updated' ) {
return true;
} else {
return false;
}
} | javascript | function isCustomFrontMatter( attr ) {
if ( attr !== 'title' && attr !== 'category' && attr !== 'content' &&
attr !== 'created' && attr !== 'excerpt' && attr !== 'updated' ) {
return true;
} else {
return false;
}
} | [
"function",
"isCustomFrontMatter",
"(",
"attr",
")",
"{",
"if",
"(",
"attr",
"!==",
"'title'",
"&&",
"attr",
"!==",
"'category'",
"&&",
"attr",
"!==",
"'content'",
"&&",
"attr",
"!==",
"'created'",
"&&",
"attr",
"!==",
"'excerpt'",
"&&",
"attr",
"!==",
"'u... | Check if front matter attribute is custom or not
@param {string} attr The attribute name
@returns {boolean} | [
"Check",
"if",
"front",
"matter",
"attribute",
"is",
"custom",
"or",
"not"
] | e14b19a6fe743c9525af0448d8988589961f936a | https://github.com/jneurock/gulp-viking-posts/blob/e14b19a6fe743c9525af0448d8988589961f936a/index.js#L222-L233 | train |
jneurock/gulp-viking-posts | index.js | parseFrontMatter | function parseFrontMatter( file, post, options ) {
var _formatDate = options && typeof options.formatDate === 'function' ?
options.formatDate : formatDate,
content = frontMatter( file.contents.toString() ),
prop = '';
if ( content.attributes ) {
post.category = content.attributes.category || '';
post... | javascript | function parseFrontMatter( file, post, options ) {
var _formatDate = options && typeof options.formatDate === 'function' ?
options.formatDate : formatDate,
content = frontMatter( file.contents.toString() ),
prop = '';
if ( content.attributes ) {
post.category = content.attributes.category || '';
post... | [
"function",
"parseFrontMatter",
"(",
"file",
",",
"post",
",",
"options",
")",
"{",
"var",
"_formatDate",
"=",
"options",
"&&",
"typeof",
"options",
".",
"formatDate",
"===",
"'function'",
"?",
"options",
".",
"formatDate",
":",
"formatDate",
",",
"content",
... | Parse YAML front matter from post
@param {Object} file The post file object
@param {Object} post The new post object we're working with
@param {Object} [options] | [
"Parse",
"YAML",
"front",
"matter",
"from",
"post"
] | e14b19a6fe743c9525af0448d8988589961f936a | https://github.com/jneurock/gulp-viking-posts/blob/e14b19a6fe743c9525af0448d8988589961f936a/index.js#L242-L277 | train |
jneurock/gulp-viking-posts | index.js | sortPosts | function sortPosts( a, b ) {
var dateA = new Date( a.created ),
dateB = new Date( b.created );
// See if dates match
if ( dateB - dateA === 0 ) {
// See if categories are the same
if ( a.category === b.category ) {
// Sort by title
return a.title.localeCompare( b.title );
// Sort by category
} ... | javascript | function sortPosts( a, b ) {
var dateA = new Date( a.created ),
dateB = new Date( b.created );
// See if dates match
if ( dateB - dateA === 0 ) {
// See if categories are the same
if ( a.category === b.category ) {
// Sort by title
return a.title.localeCompare( b.title );
// Sort by category
} ... | [
"function",
"sortPosts",
"(",
"a",
",",
"b",
")",
"{",
"var",
"dateA",
"=",
"new",
"Date",
"(",
"a",
".",
"created",
")",
",",
"dateB",
"=",
"new",
"Date",
"(",
"b",
".",
"created",
")",
";",
"// See if dates match",
"if",
"(",
"dateB",
"-",
"dateA... | Sort posts. By default posts are sorted by
date descending, category, title
@param {Object} a
@param {Object} b | [
"Sort",
"posts",
".",
"By",
"default",
"posts",
"are",
"sorted",
"by",
"date",
"descending",
"category",
"title"
] | e14b19a6fe743c9525af0448d8988589961f936a | https://github.com/jneurock/gulp-viking-posts/blob/e14b19a6fe743c9525af0448d8988589961f936a/index.js#L341-L366 | train |
jneurock/gulp-viking-posts | index.js | removePostsContent | function removePostsContent( posts, options ) {
var _sortPosts = options && typeof options.sortPosts === 'function' ?
options.sortPosts : sortPosts,
i = 0,
len = 0;
// Posts should be objects separated by commas but not wrapped in []
posts = JSON.parse( '[' + posts.contents.toString() + ']' );
len = po... | javascript | function removePostsContent( posts, options ) {
var _sortPosts = options && typeof options.sortPosts === 'function' ?
options.sortPosts : sortPosts,
i = 0,
len = 0;
// Posts should be objects separated by commas but not wrapped in []
posts = JSON.parse( '[' + posts.contents.toString() + ']' );
len = po... | [
"function",
"removePostsContent",
"(",
"posts",
",",
"options",
")",
"{",
"var",
"_sortPosts",
"=",
"options",
"&&",
"typeof",
"options",
".",
"sortPosts",
"===",
"'function'",
"?",
"options",
".",
"sortPosts",
":",
"sortPosts",
",",
"i",
"=",
"0",
",",
"l... | Iterate over posts objects and delete the content property
@param {string} posts
@param {Object} [options]
@returns {string} | [
"Iterate",
"over",
"posts",
"objects",
"and",
"delete",
"the",
"content",
"property"
] | e14b19a6fe743c9525af0448d8988589961f936a | https://github.com/jneurock/gulp-viking-posts/blob/e14b19a6fe743c9525af0448d8988589961f936a/index.js#L375-L396 | train |
geometryzen/generic-rbtree | build/module/RBTree.js | diamondLeftToVic | function diamondLeftToVic(lead) {
var m = lead.p;
var z = lead;
var x = z.l;
var y = x.r;
var a = y.l;
var b = y.r;
x.flag = false;
y.l = x;
x.p = y;
y.r = z;
z.p = y;
x.r = a;
a.p = x;
z.l = b;
b.p = z;
if (m.r === lead) {
m.r = y;
}
else ... | javascript | function diamondLeftToVic(lead) {
var m = lead.p;
var z = lead;
var x = z.l;
var y = x.r;
var a = y.l;
var b = y.r;
x.flag = false;
y.l = x;
x.p = y;
y.r = z;
z.p = y;
x.r = a;
a.p = x;
z.l = b;
b.p = z;
if (m.r === lead) {
m.r = y;
}
else ... | [
"function",
"diamondLeftToVic",
"(",
"lead",
")",
"{",
"var",
"m",
"=",
"lead",
".",
"p",
";",
"var",
"z",
"=",
"lead",
";",
"var",
"x",
"=",
"z",
".",
"l",
";",
"var",
"y",
"=",
"x",
".",
"r",
";",
"var",
"a",
"=",
"y",
".",
"l",
";",
"v... | z, x, y are in diamond-left formation.
z is the initial leader and is black.
x and y are initially red.
z moves right and back.
y takes the lead.
children a,b of y are adopted by x and z.
x becomes black.
z y
x => x z
y a b
a b | [
"z",
"x",
"y",
"are",
"in",
"diamond",
"-",
"left",
"formation",
".",
"z",
"is",
"the",
"initial",
"leader",
"and",
"is",
"black",
".",
"x",
"and",
"y",
"are",
"initially",
"red",
"."
] | edac467bcf6bde1b8614926d846ce773ecddc7d9 | https://github.com/geometryzen/generic-rbtree/blob/edac467bcf6bde1b8614926d846ce773ecddc7d9/build/module/RBTree.js#L252-L276 | train |
geometryzen/generic-rbtree | build/module/RBTree.js | rbInsertFixup | function rbInsertFixup(tree, n) {
// When inserting the node (at any place other than the root), we always color it red.
// This is so that we don't violate the height invariant.
// However, this may violate the color invariant, which we address by recursing back up the tree.
n.flag = true;
if (!n.p... | javascript | function rbInsertFixup(tree, n) {
// When inserting the node (at any place other than the root), we always color it red.
// This is so that we don't violate the height invariant.
// However, this may violate the color invariant, which we address by recursing back up the tree.
n.flag = true;
if (!n.p... | [
"function",
"rbInsertFixup",
"(",
"tree",
",",
"n",
")",
"{",
"// When inserting the node (at any place other than the root), we always color it red.",
"// This is so that we don't violate the height invariant.",
"// However, this may violate the color invariant, which we address by recursing ba... | In this algorithm we start with the node that has been inserted and make our way up the tree.
This requires carefully maintaining parent pointers. | [
"In",
"this",
"algorithm",
"we",
"start",
"with",
"the",
"node",
"that",
"has",
"been",
"inserted",
"and",
"make",
"our",
"way",
"up",
"the",
"tree",
".",
"This",
"requires",
"carefully",
"maintaining",
"parent",
"pointers",
"."
] | edac467bcf6bde1b8614926d846ce773ecddc7d9 | https://github.com/geometryzen/generic-rbtree/blob/edac467bcf6bde1b8614926d846ce773ecddc7d9/build/module/RBTree.js#L425-L482 | train |
geometryzen/generic-rbtree | build/module/RBTree.js | glb | function glb(tree, node, key, comp, low) {
if (node === tree.z) {
return low;
}
else if (comp(key, node.key) >= 0) {
// The node key is a valid lower bound, but may not be the greatest.
// Take the right link in search of larger keys.
return maxNode(node, glb(tree, node.r, ke... | javascript | function glb(tree, node, key, comp, low) {
if (node === tree.z) {
return low;
}
else if (comp(key, node.key) >= 0) {
// The node key is a valid lower bound, but may not be the greatest.
// Take the right link in search of larger keys.
return maxNode(node, glb(tree, node.r, ke... | [
"function",
"glb",
"(",
"tree",
",",
"node",
",",
"key",
",",
"comp",
",",
"low",
")",
"{",
"if",
"(",
"node",
"===",
"tree",
".",
"z",
")",
"{",
"return",
"low",
";",
"}",
"else",
"if",
"(",
"comp",
"(",
"key",
",",
"node",
".",
"key",
")",
... | Recursive implementation to compute the Greatest Lower Bound.
The largest key such that glb <= key. | [
"Recursive",
"implementation",
"to",
"compute",
"the",
"Greatest",
"Lower",
"Bound",
".",
"The",
"largest",
"key",
"such",
"that",
"glb",
"<",
"=",
"key",
"."
] | edac467bcf6bde1b8614926d846ce773ecddc7d9 | https://github.com/geometryzen/generic-rbtree/blob/edac467bcf6bde1b8614926d846ce773ecddc7d9/build/module/RBTree.js#L487-L500 | train |
geometryzen/generic-rbtree | build/module/RBTree.js | lub | function lub(tree, node, key, comp, high) {
if (node === tree.z) {
return high;
}
else if (comp(key, node.key) <= 0) {
// The node key is a valid upper bound, but may not be the least.
return minNode(node, lub(tree, node.l, key, comp, high), comp);
}
else {
// Take th... | javascript | function lub(tree, node, key, comp, high) {
if (node === tree.z) {
return high;
}
else if (comp(key, node.key) <= 0) {
// The node key is a valid upper bound, but may not be the least.
return minNode(node, lub(tree, node.l, key, comp, high), comp);
}
else {
// Take th... | [
"function",
"lub",
"(",
"tree",
",",
"node",
",",
"key",
",",
"comp",
",",
"high",
")",
"{",
"if",
"(",
"node",
"===",
"tree",
".",
"z",
")",
"{",
"return",
"high",
";",
"}",
"else",
"if",
"(",
"comp",
"(",
"key",
",",
"node",
".",
"key",
")"... | Recursive implementation to compute the Least Upper Bound.
The smallest key such that key <= lub. | [
"Recursive",
"implementation",
"to",
"compute",
"the",
"Least",
"Upper",
"Bound",
".",
"The",
"smallest",
"key",
"such",
"that",
"key",
"<",
"=",
"lub",
"."
] | edac467bcf6bde1b8614926d846ce773ecddc7d9 | https://github.com/geometryzen/generic-rbtree/blob/edac467bcf6bde1b8614926d846ce773ecddc7d9/build/module/RBTree.js#L505-L517 | train |
byu-oit/sans-server-middleware | bin/middleware.js | Middleware | function Middleware(name) {
if (!(this instanceof Middleware)) return new Middleware(name);
this.name = name || '';
Object.defineProperty(this, '_', {
enumerable: false,
configurable: false,
value: {
length: 0,
ordered: null,
weights: new Map()
... | javascript | function Middleware(name) {
if (!(this instanceof Middleware)) return new Middleware(name);
this.name = name || '';
Object.defineProperty(this, '_', {
enumerable: false,
configurable: false,
value: {
length: 0,
ordered: null,
weights: new Map()
... | [
"function",
"Middleware",
"(",
"name",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Middleware",
")",
")",
"return",
"new",
"Middleware",
"(",
"name",
")",
";",
"this",
".",
"name",
"=",
"name",
"||",
"''",
";",
"Object",
".",
"defineProperty"... | Create a new middleware instance.
@params {string} [name='']
@returns {Middleware}
@constructor | [
"Create",
"a",
"new",
"middleware",
"instance",
"."
] | c42430aa558b4edee205bd9180d24d74022607ae | https://github.com/byu-oit/sans-server-middleware/blob/c42430aa558b4edee205bd9180d24d74022607ae/bin/middleware.js#L29-L50 | train |
byu-oit/sans-server-middleware | bin/middleware.js | function(err, req, res, next) {
function done(error) {
log(req, util.format('middleware-end %s', name));
next(error);
}
if (err && !errHandler) {
log(req, util.format('skipped %s Hook is not for error handling', name));
next(err);
} else... | javascript | function(err, req, res, next) {
function done(error) {
log(req, util.format('middleware-end %s', name));
next(error);
}
if (err && !errHandler) {
log(req, util.format('skipped %s Hook is not for error handling', name));
next(err);
} else... | [
"function",
"(",
"err",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"function",
"done",
"(",
"error",
")",
"{",
"log",
"(",
"req",
",",
"util",
".",
"format",
"(",
"'middleware-end %s'",
",",
"name",
")",
")",
";",
"next",
"(",
"error",
")",
"... | create a wrapper around the middleware | [
"create",
"a",
"wrapper",
"around",
"the",
"middleware"
] | c42430aa558b4edee205bd9180d24d74022607ae | https://github.com/byu-oit/sans-server-middleware/blob/c42430aa558b4edee205bd9180d24d74022607ae/bin/middleware.js#L79-L103 | train | |
nfroidure/common-services | src/delay.js | create | function create(delay) {
let timeoutId;
let _reject;
const promise = new Promise((resolve, reject) => {
_reject = reject;
timeoutId = setTimeout(() => {
resolve();
pendingPromises.delete(promise);
}, delay);
});
pendingPromises.set(promise, {
timeoutId,
... | javascript | function create(delay) {
let timeoutId;
let _reject;
const promise = new Promise((resolve, reject) => {
_reject = reject;
timeoutId = setTimeout(() => {
resolve();
pendingPromises.delete(promise);
}, delay);
});
pendingPromises.set(promise, {
timeoutId,
... | [
"function",
"create",
"(",
"delay",
")",
"{",
"let",
"timeoutId",
";",
"let",
"_reject",
";",
"const",
"promise",
"=",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"_reject",
"=",
"reject",
";",
"timeoutId",
"=",
"setTimeout",
... | Create a new delay
@param {Number} delay The delay in ms
@return {Promise}
A promise to be resolved after that delay
or rejected if it is cancelled.
@example
await delay.create(1000);
console.log('1000 ms elapsed!'); | [
"Create",
"a",
"new",
"delay"
] | 09df32597fe798777abec0ef1f3a994e91046085 | https://github.com/nfroidure/common-services/blob/09df32597fe798777abec0ef1f3a994e91046085/src/delay.js#L52-L69 | train |
nfroidure/common-services | src/delay.js | clear | async function clear(promise) {
if (!pendingPromises.has(promise)) {
return Promise.reject(new YError('E_BAD_DELAY'));
}
const { timeoutId, reject } = pendingPromises.get(promise);
clearTimeout(timeoutId);
reject(new YError('E_DELAY_CLEARED'));
pendingPromises.delete(promise);
log('de... | javascript | async function clear(promise) {
if (!pendingPromises.has(promise)) {
return Promise.reject(new YError('E_BAD_DELAY'));
}
const { timeoutId, reject } = pendingPromises.get(promise);
clearTimeout(timeoutId);
reject(new YError('E_DELAY_CLEARED'));
pendingPromises.delete(promise);
log('de... | [
"async",
"function",
"clear",
"(",
"promise",
")",
"{",
"if",
"(",
"!",
"pendingPromises",
".",
"has",
"(",
"promise",
")",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"new",
"YError",
"(",
"'E_BAD_DELAY'",
")",
")",
";",
"}",
"const",
"{",
"t... | Cancel an earlier created delay
@param {Promise} promise
The promise of the delay to cancel
@return {Promise}
A promise resolved when cancellation is done.
@example
try {
const delayPromise = delay.create(1000);
await Promise.all(delayPromise, delay.clear(delayPromise));
console.log('1000 ms elapsed!');
} catch (err... | [
"Cancel",
"an",
"earlier",
"created",
"delay"
] | 09df32597fe798777abec0ef1f3a994e91046085 | https://github.com/nfroidure/common-services/blob/09df32597fe798777abec0ef1f3a994e91046085/src/delay.js#L90-L100 | train |
bholloway/browserify-anonymous-labeler | lib/get-field.js | getField | function getField(field) {
return function map(element) {
if (element) {
if (Array.isArray(element)) {
return element.map(map).join('');
}
else if (typeof element === 'string') {
return element;
}
else if (typeof element === 'object') {
return element[field];
... | javascript | function getField(field) {
return function map(element) {
if (element) {
if (Array.isArray(element)) {
return element.map(map).join('');
}
else if (typeof element === 'string') {
return element;
}
else if (typeof element === 'object') {
return element[field];
... | [
"function",
"getField",
"(",
"field",
")",
"{",
"return",
"function",
"map",
"(",
"element",
")",
"{",
"if",
"(",
"element",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"element",
")",
")",
"{",
"return",
"element",
".",
"map",
"(",
"map",
"... | Get the string representation of the element from the given field where present, else the value itself.
@param {string} field The field of the element to consider
@returns {function} A method that performs the action on a given element | [
"Get",
"the",
"string",
"representation",
"of",
"the",
"element",
"from",
"the",
"given",
"field",
"where",
"present",
"else",
"the",
"value",
"itself",
"."
] | 651b124eefe8d1a567b2a03a0b8a3dfea87c2703 | https://github.com/bholloway/browserify-anonymous-labeler/blob/651b124eefe8d1a567b2a03a0b8a3dfea87c2703/lib/get-field.js#L8-L23 | train |
redisjs/jsr-server | lib/command/server/command.js | getList | function getList() {
if(!COMMAND_LIST) {
COMMAND_LIST = [];
for(var z in this.execs) {
COMMAND_LIST.push(this.execs[z].definition.getDefinition());
}
}
return COMMAND_LIST;
} | javascript | function getList() {
if(!COMMAND_LIST) {
COMMAND_LIST = [];
for(var z in this.execs) {
COMMAND_LIST.push(this.execs[z].definition.getDefinition());
}
}
return COMMAND_LIST;
} | [
"function",
"getList",
"(",
")",
"{",
"if",
"(",
"!",
"COMMAND_LIST",
")",
"{",
"COMMAND_LIST",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"z",
"in",
"this",
".",
"execs",
")",
"{",
"COMMAND_LIST",
".",
"push",
"(",
"this",
".",
"execs",
"[",
"z",
"]... | Helper to lazily build the command list. | [
"Helper",
"to",
"lazily",
"build",
"the",
"command",
"list",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/command.js#L18-L26 | train |
redisjs/jsr-server | lib/command/server/command.js | info | function info(req, res) {
var list = []
, i
, exec;
for(i = 0;i < req.args.length;i++) {
exec = this.execs[req.args[i]];
list.push(exec ? exec.definition.getDefinition() : null);
}
res.send(null, list);
} | javascript | function info(req, res) {
var list = []
, i
, exec;
for(i = 0;i < req.args.length;i++) {
exec = this.execs[req.args[i]];
list.push(exec ? exec.definition.getDefinition() : null);
}
res.send(null, list);
} | [
"function",
"info",
"(",
"req",
",",
"res",
")",
"{",
"var",
"list",
"=",
"[",
"]",
",",
"i",
",",
"exec",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"req",
".",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"exec",
"=",
"this",
".... | Respond to the INFO subcommand. | [
"Respond",
"to",
"the",
"INFO",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/command.js#L31-L40 | train |
redisjs/jsr-server | lib/command/server/command.js | getkeys | function getkeys(req, res) {
var keys = []
// target command
, tcmd = req.args[0]
, def = Constants.MAP[tcmd];
if(def) {
keys = def.getKeys(req.args.slice(1));
}
res.send(null, keys);
} | javascript | function getkeys(req, res) {
var keys = []
// target command
, tcmd = req.args[0]
, def = Constants.MAP[tcmd];
if(def) {
keys = def.getKeys(req.args.slice(1));
}
res.send(null, keys);
} | [
"function",
"getkeys",
"(",
"req",
",",
"res",
")",
"{",
"var",
"keys",
"=",
"[",
"]",
"// target command",
",",
"tcmd",
"=",
"req",
".",
"args",
"[",
"0",
"]",
",",
"def",
"=",
"Constants",
".",
"MAP",
"[",
"tcmd",
"]",
";",
"if",
"(",
"def",
... | Respond to the GETKEYS subcommand.
Current version redis@2.8.19 does not actually appear to
implement this: `command getkeys get key` results in an error.
Therefore this implementation is a best guess as to the intended
behaviour.
This command cannot fail with an error so we just return an empty list
for target comm... | [
"Respond",
"to",
"the",
"GETKEYS",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/command.js#L60-L69 | train |
redisjs/jsr-server | lib/command/server/command.js | count | function count(req, res) {
var list = getList.call(this);
return res.send(null, list.length);
} | javascript | function count(req, res) {
var list = getList.call(this);
return res.send(null, list.length);
} | [
"function",
"count",
"(",
"req",
",",
"res",
")",
"{",
"var",
"list",
"=",
"getList",
".",
"call",
"(",
"this",
")",
";",
"return",
"res",
".",
"send",
"(",
"null",
",",
"list",
".",
"length",
")",
";",
"}"
] | Respond to the COUNT subcommand. | [
"Respond",
"to",
"the",
"COUNT",
"subcommand",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/command.js#L74-L77 | train |
redisjs/jsr-server | lib/command/server/command.js | execute | function execute(req, res) {
if(req.info.command.sub) {
this.delegate(req, res);
// no subcommand return command list
}else{
var list = getList.call(this);
return res.send(null, list);
}
} | javascript | function execute(req, res) {
if(req.info.command.sub) {
this.delegate(req, res);
// no subcommand return command list
}else{
var list = getList.call(this);
return res.send(null, list);
}
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"req",
".",
"info",
".",
"command",
".",
"sub",
")",
"{",
"this",
".",
"delegate",
"(",
"req",
",",
"res",
")",
";",
"// no subcommand return command list",
"}",
"else",
"{",
"var",
... | Respond to the COMMAND command. | [
"Respond",
"to",
"the",
"COMMAND",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/command.js#L82-L90 | train |
logashoff/grunt-uglify-amd | tasks/uglifyAMD.js | buildPaths | function buildPaths(file, arr) {
if (!grunt.file.exists(file)) {
grunt.log.warn('File "' + file + '" not found');
return null;
}
arr.unshift(file);
var namespaces = pathTable[file];
if (namespaces && namespaces.length) {
for (var i = namespaces.length, ns; i-- > 0;) {
ns = ... | javascript | function buildPaths(file, arr) {
if (!grunt.file.exists(file)) {
grunt.log.warn('File "' + file + '" not found');
return null;
}
arr.unshift(file);
var namespaces = pathTable[file];
if (namespaces && namespaces.length) {
for (var i = namespaces.length, ns; i-- > 0;) {
ns = ... | [
"function",
"buildPaths",
"(",
"file",
",",
"arr",
")",
"{",
"if",
"(",
"!",
"grunt",
".",
"file",
".",
"exists",
"(",
"file",
")",
")",
"{",
"grunt",
".",
"log",
".",
"warn",
"(",
"'File \"'",
"+",
"file",
"+",
"'\" not found'",
")",
";",
"return"... | Recursively builds file paths array from specified file and assigns them to
array parameter. Uses pathTable to look up namespace dependencies.
@param {string} file File path.
@param {Array} arr Array to store file paths.
@returns {Array|null} Array of file paths. | [
"Recursively",
"builds",
"file",
"paths",
"array",
"from",
"specified",
"file",
"and",
"assigns",
"them",
"to",
"array",
"parameter",
".",
"Uses",
"pathTable",
"to",
"look",
"up",
"namespace",
"dependencies",
"."
] | 0bc68c42f7a555b6ac71b0e02ea5cda4860d0361 | https://github.com/logashoff/grunt-uglify-amd/blob/0bc68c42f7a555b6ac71b0e02ea5cda4860d0361/tasks/uglifyAMD.js#L46-L64 | train |
vlad-zhukov/redux-status | src/promiseState.js | create | function create({
pending = false, // eslint-disable-line no-shadow
refreshing = false, // eslint-disable-line no-shadow
fulfilled = false, // eslint-disable-line no-shadow
rejected = false, // eslint-disable-line no-shadow
value = null,
reason = null,
}) {
return {
pending,
... | javascript | function create({
pending = false, // eslint-disable-line no-shadow
refreshing = false, // eslint-disable-line no-shadow
fulfilled = false, // eslint-disable-line no-shadow
rejected = false, // eslint-disable-line no-shadow
value = null,
reason = null,
}) {
return {
pending,
... | [
"function",
"create",
"(",
"{",
"pending",
"=",
"false",
",",
"// eslint-disable-line no-shadow",
"refreshing",
"=",
"false",
",",
"// eslint-disable-line no-shadow",
"fulfilled",
"=",
"false",
",",
"// eslint-disable-line no-shadow",
"rejected",
"=",
"false",
",",
"// ... | Constructor for creating a new promiseState.
@param [pending] {Boolean}
@param [refreshing] {Boolean}
@param [fulfilled] {Boolean}
@param [rejected] {Boolean}
@param [value] {*}
@param [reason] {*}
@returns {Object} | [
"Constructor",
"for",
"creating",
"a",
"new",
"promiseState",
"."
] | 1f2108949b71f25d1c592501ed089a52a9fc61ec | https://github.com/vlad-zhukov/redux-status/blob/1f2108949b71f25d1c592501ed089a52a9fc61ec/src/promiseState.js#L13-L29 | train |
MostlyJS/mostly-feathers-mongoose | src/helpers/set-field.js | cloneById | function cloneById (v, k) {
if (Array.isArray(v)) {
let match = find(v, it => String(it[options.idField]) === String(k));
return match? cloneDeep(match) : (options.keepOrig? k : null);
} else {
return String(v[options.idField]) === String(k)? cloneDeep(v) : (options.keepOrig? k : null);
}
... | javascript | function cloneById (v, k) {
if (Array.isArray(v)) {
let match = find(v, it => String(it[options.idField]) === String(k));
return match? cloneDeep(match) : (options.keepOrig? k : null);
} else {
return String(v[options.idField]) === String(k)? cloneDeep(v) : (options.keepOrig? k : null);
}
... | [
"function",
"cloneById",
"(",
"v",
",",
"k",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"v",
")",
")",
"{",
"let",
"match",
"=",
"find",
"(",
"v",
",",
"it",
"=>",
"String",
"(",
"it",
"[",
"options",
".",
"idField",
"]",
")",
"===",
... | avoid duplicate setField | [
"avoid",
"duplicate",
"setField"
] | d20e150e054c784cc7db7c2487399e4f4eb730de | https://github.com/MostlyJS/mostly-feathers-mongoose/blob/d20e150e054c784cc7db7c2487399e4f4eb730de/src/helpers/set-field.js#L43-L50 | train |
ENOW-IJI/ENOW-console | start.js | function(req, topic, messages){
payloads[0]['topic'] = topic
payloads[0]['messages']= JSON.stringify(messages);
console.log(payloads[0]['messages']);
setTimeout(function () {
producer.send(payloads, function (err, data) {
if(err){
console.log(err);
}
... | javascript | function(req, topic, messages){
payloads[0]['topic'] = topic
payloads[0]['messages']= JSON.stringify(messages);
console.log(payloads[0]['messages']);
setTimeout(function () {
producer.send(payloads, function (err, data) {
if(err){
console.log(err);
}
... | [
"function",
"(",
"req",
",",
"topic",
",",
"messages",
")",
"{",
"payloads",
"[",
"0",
"]",
"[",
"'topic'",
"]",
"=",
"topic",
"payloads",
"[",
"0",
"]",
"[",
"'messages'",
"]",
"=",
"JSON",
".",
"stringify",
"(",
"messages",
")",
";",
"console",
"... | publish message to kafka. | [
"publish",
"message",
"to",
"kafka",
"."
] | f241ed4e645a7da0cd1a6ca86e896a5b73be53e5 | https://github.com/ENOW-IJI/ENOW-console/blob/f241ed4e645a7da0cd1a6ca86e896a5b73be53e5/start.js#L71-L85 | train | |
ENOW-IJI/ENOW-console | start.js | function(callback){
if(source['brokerId']!='null'){
db.db(dbName).collection(collectionName).find({brokerId:source['brokerId']}).toArray(function(err,result){
mqttHost = result[0]['ipAddress'];
mqttPort = result[0]['port'];
console.log(result);
... | javascript | function(callback){
if(source['brokerId']!='null'){
db.db(dbName).collection(collectionName).find({brokerId:source['brokerId']}).toArray(function(err,result){
mqttHost = result[0]['ipAddress'];
mqttPort = result[0]['port'];
console.log(result);
... | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"source",
"[",
"'brokerId'",
"]",
"!=",
"'null'",
")",
"{",
"db",
".",
"db",
"(",
"dbName",
")",
".",
"collection",
"(",
"collectionName",
")",
".",
"find",
"(",
"{",
"brokerId",
":",
"source",
"[",
... | find broker for get mqtt url. | [
"find",
"broker",
"for",
"get",
"mqtt",
"url",
"."
] | f241ed4e645a7da0cd1a6ca86e896a5b73be53e5 | https://github.com/ENOW-IJI/ENOW-console/blob/f241ed4e645a7da0cd1a6ca86e896a5b73be53e5/start.js#L353-L363 | train | |
ENOW-IJI/ENOW-console | start.js | function(callback){
var o_id = BSON.ObjectID.createFromHexString(source['_id']);
db.db(dbName).collection(collectionName).find({_id:o_id}).toArray(function(err,result){
response.send(result);
o_id = null;
});
} | javascript | function(callback){
var o_id = BSON.ObjectID.createFromHexString(source['_id']);
db.db(dbName).collection(collectionName).find({_id:o_id}).toArray(function(err,result){
response.send(result);
o_id = null;
});
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"o_id",
"=",
"BSON",
".",
"ObjectID",
".",
"createFromHexString",
"(",
"source",
"[",
"'_id'",
"]",
")",
";",
"db",
".",
"db",
"(",
"dbName",
")",
".",
"collection",
"(",
"collectionName",
")",
".",
"find",... | find roadmap. | [
"find",
"roadmap",
"."
] | f241ed4e645a7da0cd1a6ca86e896a5b73be53e5 | https://github.com/ENOW-IJI/ENOW-console/blob/f241ed4e645a7da0cd1a6ca86e896a5b73be53e5/start.js#L377-L383 | train | |
ENOW-IJI/ENOW-console | start.js | function(callback){
var cursor = db.db(dbName).collection(collectionName).find({}).toArray(function(err,result){
if(result.length!=0){
roadmapNum = roadMapIdTemp = parseInt(result[result.length-1]['roadMapId'])+1;
}
else{
roadmapNum = roadMapId... | javascript | function(callback){
var cursor = db.db(dbName).collection(collectionName).find({}).toArray(function(err,result){
if(result.length!=0){
roadmapNum = roadMapIdTemp = parseInt(result[result.length-1]['roadMapId'])+1;
}
else{
roadmapNum = roadMapId... | [
"function",
"(",
"callback",
")",
"{",
"var",
"cursor",
"=",
"db",
".",
"db",
"(",
"dbName",
")",
".",
"collection",
"(",
"collectionName",
")",
".",
"find",
"(",
"{",
"}",
")",
".",
"toArray",
"(",
"function",
"(",
"err",
",",
"result",
")",
"{",
... | run roadmap of save it to mongodb. | [
"run",
"roadmap",
"of",
"save",
"it",
"to",
"mongodb",
"."
] | f241ed4e645a7da0cd1a6ca86e896a5b73be53e5 | https://github.com/ENOW-IJI/ENOW-console/blob/f241ed4e645a7da0cd1a6ca86e896a5b73be53e5/start.js#L397-L421 | train | |
redisjs/jsr-store | lib/type/list.js | lset | function lset(index, value) {
if(index < 0) index = this._data.length + index;
// command should validate the index
if(index < 0 || index >= this._data.length) return null;
this._data[index] = value;
} | javascript | function lset(index, value) {
if(index < 0) index = this._data.length + index;
// command should validate the index
if(index < 0 || index >= this._data.length) return null;
this._data[index] = value;
} | [
"function",
"lset",
"(",
"index",
",",
"value",
")",
"{",
"if",
"(",
"index",
"<",
"0",
")",
"index",
"=",
"this",
".",
"_data",
".",
"length",
"+",
"index",
";",
"// command should validate the index",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">="... | Sets the list element at index to value. | [
"Sets",
"the",
"list",
"element",
"at",
"index",
"to",
"value",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/list.js#L17-L22 | train |
redisjs/jsr-store | lib/type/list.js | linsert | function linsert(beforeAfter, pivot, value) {
//console.dir(pivot);
//console.dir(this._data);
var ind = this.indexOf(pivot);
if(ind === -1) return ind;
// note beforeAfter can be a buffer
ind = (('' + beforeAfter) === BEFORE) ? ind : ind + 1;
this._data.splice(ind, 0, value);
return this._data.length;
... | javascript | function linsert(beforeAfter, pivot, value) {
//console.dir(pivot);
//console.dir(this._data);
var ind = this.indexOf(pivot);
if(ind === -1) return ind;
// note beforeAfter can be a buffer
ind = (('' + beforeAfter) === BEFORE) ? ind : ind + 1;
this._data.splice(ind, 0, value);
return this._data.length;
... | [
"function",
"linsert",
"(",
"beforeAfter",
",",
"pivot",
",",
"value",
")",
"{",
"//console.dir(pivot);",
"//console.dir(this._data);",
"var",
"ind",
"=",
"this",
".",
"indexOf",
"(",
"pivot",
")",
";",
"if",
"(",
"ind",
"===",
"-",
"1",
")",
"return",
"in... | Inserts value in the list either before or after
the reference value pivot. | [
"Inserts",
"value",
"in",
"the",
"list",
"either",
"before",
"or",
"after",
"the",
"reference",
"value",
"pivot",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/list.js#L28-L37 | train |
redisjs/jsr-store | lib/type/list.js | lindex | function lindex(index) {
if(index < 0) index = this._data.length + index;
return this._data[index] || null;
} | javascript | function lindex(index) {
if(index < 0) index = this._data.length + index;
return this._data[index] || null;
} | [
"function",
"lindex",
"(",
"index",
")",
"{",
"if",
"(",
"index",
"<",
"0",
")",
"index",
"=",
"this",
".",
"_data",
".",
"length",
"+",
"index",
";",
"return",
"this",
".",
"_data",
"[",
"index",
"]",
"||",
"null",
";",
"}"
] | Returns the element at index `index` in the list. | [
"Returns",
"the",
"element",
"at",
"index",
"index",
"in",
"the",
"list",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/list.js#L42-L45 | train |
redisjs/jsr-store | lib/type/list.js | lrem | function lrem(count, value) {
var ind, deleted = 0;
if(count === 0) {
while((ind = this.indexOf(value)) !== -1) {
this._data.splice(ind, 1);
deleted++;
}
}else if(count > 0) {
while((ind = this.indexOf(value)) !== -1 && (deleted < count)) {
this._data.splice(ind, 1);
deleted++;... | javascript | function lrem(count, value) {
var ind, deleted = 0;
if(count === 0) {
while((ind = this.indexOf(value)) !== -1) {
this._data.splice(ind, 1);
deleted++;
}
}else if(count > 0) {
while((ind = this.indexOf(value)) !== -1 && (deleted < count)) {
this._data.splice(ind, 1);
deleted++;... | [
"function",
"lrem",
"(",
"count",
",",
"value",
")",
"{",
"var",
"ind",
",",
"deleted",
"=",
"0",
";",
"if",
"(",
"count",
"===",
"0",
")",
"{",
"while",
"(",
"(",
"ind",
"=",
"this",
".",
"indexOf",
"(",
"value",
")",
")",
"!==",
"-",
"1",
"... | Removes elements from the list. | [
"Removes",
"elements",
"from",
"the",
"list",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/list.js#L82-L102 | train |
redisjs/jsr-store | lib/type/list.js | lrange | function lrange(start, stop) {
if(start < 0) start = this._data.length + start;
if(stop < 0) stop = this._data.length + stop;
stop++;
return this._data.slice(start, stop);
} | javascript | function lrange(start, stop) {
if(start < 0) start = this._data.length + start;
if(stop < 0) stop = this._data.length + stop;
stop++;
return this._data.slice(start, stop);
} | [
"function",
"lrange",
"(",
"start",
",",
"stop",
")",
"{",
"if",
"(",
"start",
"<",
"0",
")",
"start",
"=",
"this",
".",
"_data",
".",
"length",
"+",
"start",
";",
"if",
"(",
"stop",
"<",
"0",
")",
"stop",
"=",
"this",
".",
"_data",
".",
"lengt... | Returns the specified elements of the list. | [
"Returns",
"the",
"specified",
"elements",
"of",
"the",
"list",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/type/list.js#L115-L120 | train |
redisjs/jsr-persistence | lib/save.js | iterateKeys | function iterateKeys() {
var obj = getKeyObject(db, j);
if(obj === null) return onKeysComplete();
encoder.write(obj, function onWrite() {
j++;
setImmediate(iterateKeys);
});
} | javascript | function iterateKeys() {
var obj = getKeyObject(db, j);
if(obj === null) return onKeysComplete();
encoder.write(obj, function onWrite() {
j++;
setImmediate(iterateKeys);
});
} | [
"function",
"iterateKeys",
"(",
")",
"{",
"var",
"obj",
"=",
"getKeyObject",
"(",
"db",
",",
"j",
")",
";",
"if",
"(",
"obj",
"===",
"null",
")",
"return",
"onKeysComplete",
"(",
")",
";",
"encoder",
".",
"write",
"(",
"obj",
",",
"function",
"onWrit... | iterate keys in a db | [
"iterate",
"keys",
"in",
"a",
"db"
] | 77f3fc84ea7cbdb9f41a4dfa7ee1d89be61f7510 | https://github.com/redisjs/jsr-persistence/blob/77f3fc84ea7cbdb9f41a4dfa7ee1d89be61f7510/lib/save.js#L163-L170 | train |
repetere/periodicjs.ext.login | controller/token_controller.js | function (user, req, cb) {
CoreController.getPluginViewDefaultTemplate({
viewname: 'email/user/forgot_password_link',
themefileext: appSettings.templatefileextension,
},
function (err, templatepath) {
if (err) {
cb(err);
} else {
// console.log('emailForgotPasswordLink templatepath', templat... | javascript | function (user, req, cb) {
CoreController.getPluginViewDefaultTemplate({
viewname: 'email/user/forgot_password_link',
themefileext: appSettings.templatefileextension,
},
function (err, templatepath) {
if (err) {
cb(err);
} else {
// console.log('emailForgotPasswordLink templatepath', templat... | [
"function",
"(",
"user",
",",
"req",
",",
"cb",
")",
"{",
"CoreController",
".",
"getPluginViewDefaultTemplate",
"(",
"{",
"viewname",
":",
"'email/user/forgot_password_link'",
",",
"themefileext",
":",
"appSettings",
".",
"templatefileextension",
",",
"}",
",",
"... | create a func for the mail options | [
"create",
"a",
"func",
"for",
"the",
"mail",
"options"
] | f0e83fc0224242a841c013435c0f75d5f4ae15cd | https://github.com/repetere/periodicjs.ext.login/blob/f0e83fc0224242a841c013435c0f75d5f4ae15cd/controller/token_controller.js#L196-L233 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.