id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
56,700 | AndreasMadsen/immortal | lib/executables/daemon.js | function (emit) {
ipc.send({
cmd : 'setup',
emit: emit,
daemon: process.pid,
message: errorBuffer === "" ? null : errorBuffer
});
} | javascript | function (emit) {
ipc.send({
cmd : 'setup',
emit: emit,
daemon: process.pid,
message: errorBuffer === "" ? null : errorBuffer
});
} | [
"function",
"(",
"emit",
")",
"{",
"ipc",
".",
"send",
"(",
"{",
"cmd",
":",
"'setup'",
",",
"emit",
":",
"emit",
",",
"daemon",
":",
"process",
".",
"pid",
",",
"message",
":",
"errorBuffer",
"===",
"\"\"",
"?",
"null",
":",
"errorBuffer",
"}",
")... | this function will setup a new pump as a daemon | [
"this",
"function",
"will",
"setup",
"a",
"new",
"pump",
"as",
"a",
"daemon"
] | c1ab5a4287a543fdfd980604a9e9927d663a9ef2 | https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/executables/daemon.js#L43-L50 | |
56,701 | overlookmotel/ejs-extra | lib/index.js | resolveObjectName | function resolveObjectName(view){
return cache[view] || (cache[view] = view
.split('/')
.slice(-1)[0]
.split('.')[0]
.replace(/^_/, '')
.replace(/[^a-zA-Z0-9 ]+/g, ' ')
.split(/ +/).map(function(word, i){
return i ? word[0].toUpperCase() + word.substr(1) : word;
}).join(''));
} | javascript | function resolveObjectName(view){
return cache[view] || (cache[view] = view
.split('/')
.slice(-1)[0]
.split('.')[0]
.replace(/^_/, '')
.replace(/[^a-zA-Z0-9 ]+/g, ' ')
.split(/ +/).map(function(word, i){
return i ? word[0].toUpperCase() + word.substr(1) : word;
}).join(''));
} | [
"function",
"resolveObjectName",
"(",
"view",
")",
"{",
"return",
"cache",
"[",
"view",
"]",
"||",
"(",
"cache",
"[",
"view",
"]",
"=",
"view",
".",
"split",
"(",
"'/'",
")",
".",
"slice",
"(",
"-",
"1",
")",
"[",
"0",
"]",
".",
"split",
"(",
"... | Resolve partial object name from the view path.
Examples:
"user.ejs" becomes "user"
"forum thread.ejs" becomes "forumThread"
"forum/thread/post.ejs" becomes "post"
"blog-post.ejs" becomes "blogPost"
@return {String}
@api private | [
"Resolve",
"partial",
"object",
"name",
"from",
"the",
"view",
"path",
"."
] | 0bda55152b174f1a990f4a04787a41676b1430d1 | https://github.com/overlookmotel/ejs-extra/blob/0bda55152b174f1a990f4a04787a41676b1430d1/lib/index.js#L160-L170 |
56,702 | overlookmotel/ejs-extra | lib/index.js | block | function block(name, html) {
// bound to the blocks object in renderFile
var blk = this[name];
if (!blk) {
// always create, so if we request a
// non-existent block we'll get a new one
blk = this[name] = new Block();
}
if (html) {
blk.append(html);
}
return blk;
} | javascript | function block(name, html) {
// bound to the blocks object in renderFile
var blk = this[name];
if (!blk) {
// always create, so if we request a
// non-existent block we'll get a new one
blk = this[name] = new Block();
}
if (html) {
blk.append(html);
}
return blk;
} | [
"function",
"block",
"(",
"name",
",",
"html",
")",
"{",
"// bound to the blocks object in renderFile",
"var",
"blk",
"=",
"this",
"[",
"name",
"]",
";",
"if",
"(",
"!",
"blk",
")",
"{",
"// always create, so if we request a",
"// non-existent block we'll get a new on... | Return the block with the given name, create it if necessary.
Optionally append the given html to the block.
The returned Block can append, prepend or replace the block,
as well as render it when included in a parent template.
@param {String} name
@param {String} html
@return {Block}
@api private | [
"Return",
"the",
"block",
"with",
"the",
"given",
"name",
"create",
"it",
"if",
"necessary",
".",
"Optionally",
"append",
"the",
"given",
"html",
"to",
"the",
"block",
"."
] | 0bda55152b174f1a990f4a04787a41676b1430d1 | https://github.com/overlookmotel/ejs-extra/blob/0bda55152b174f1a990f4a04787a41676b1430d1/lib/index.js#L427-L439 |
56,703 | overlookmotel/ejs-extra | lib/index.js | script | function script(path, type) {
if (path) {
var html = '<script src="'+path+'"'+(type ? 'type="'+type+'"' : '')+'></script>';
if (this.html.indexOf(html) == -1) this.append(html);
}
return this;
} | javascript | function script(path, type) {
if (path) {
var html = '<script src="'+path+'"'+(type ? 'type="'+type+'"' : '')+'></script>';
if (this.html.indexOf(html) == -1) this.append(html);
}
return this;
} | [
"function",
"script",
"(",
"path",
",",
"type",
")",
"{",
"if",
"(",
"path",
")",
"{",
"var",
"html",
"=",
"'<script src=\"'",
"+",
"path",
"+",
"'\"'",
"+",
"(",
"type",
"?",
"'type=\"'",
"+",
"type",
"+",
"'\"'",
":",
"''",
")",
"+",
"'></script>... | bound to scripts Block in renderFile | [
"bound",
"to",
"scripts",
"Block",
"in",
"renderFile"
] | 0bda55152b174f1a990f4a04787a41676b1430d1 | https://github.com/overlookmotel/ejs-extra/blob/0bda55152b174f1a990f4a04787a41676b1430d1/lib/index.js#L442-L448 |
56,704 | overlookmotel/ejs-extra | lib/index.js | stylesheet | function stylesheet(path, media) {
if (path) {
var html = '<link rel="stylesheet" href="'+path+'"'+(media ? 'media="'+media+'"' : '')+' />';
if (this.html.indexOf(html) == -1) this.append(html);
}
return this;
} | javascript | function stylesheet(path, media) {
if (path) {
var html = '<link rel="stylesheet" href="'+path+'"'+(media ? 'media="'+media+'"' : '')+' />';
if (this.html.indexOf(html) == -1) this.append(html);
}
return this;
} | [
"function",
"stylesheet",
"(",
"path",
",",
"media",
")",
"{",
"if",
"(",
"path",
")",
"{",
"var",
"html",
"=",
"'<link rel=\"stylesheet\" href=\"'",
"+",
"path",
"+",
"'\"'",
"+",
"(",
"media",
"?",
"'media=\"'",
"+",
"media",
"+",
"'\"'",
":",
"''",
... | bound to stylesheets Block in renderFile | [
"bound",
"to",
"stylesheets",
"Block",
"in",
"renderFile"
] | 0bda55152b174f1a990f4a04787a41676b1430d1 | https://github.com/overlookmotel/ejs-extra/blob/0bda55152b174f1a990f4a04787a41676b1430d1/lib/index.js#L451-L457 |
56,705 | Pocketbrain/native-ads-web-ad-library | src/ads/insertAds.js | insertAds | function insertAds(adUnit, ads, adLoadedCallback) {
var adContainers = page.getAdContainers(adUnit);
if (!adContainers.length) {
logger.error("No ad containers could be found. stopping insertion for adUnit " + adUnit.name);
return []; //Ad can't be inserted
}
var adBuilder = new Ad... | javascript | function insertAds(adUnit, ads, adLoadedCallback) {
var adContainers = page.getAdContainers(adUnit);
if (!adContainers.length) {
logger.error("No ad containers could be found. stopping insertion for adUnit " + adUnit.name);
return []; //Ad can't be inserted
}
var adBuilder = new Ad... | [
"function",
"insertAds",
"(",
"adUnit",
",",
"ads",
",",
"adLoadedCallback",
")",
"{",
"var",
"adContainers",
"=",
"page",
".",
"getAdContainers",
"(",
"adUnit",
")",
";",
"if",
"(",
"!",
"adContainers",
".",
"length",
")",
"{",
"logger",
".",
"error",
"... | Insert advertisements for the given ad unit on the page
@param adUnit - The ad unit to insert advertisements for
@param ads - Array of ads retrieved from OfferEngine
@param adLoadedCallback - Callback to execute when the ads are fully loaded
@returns {Array} | [
"Insert",
"advertisements",
"for",
"the",
"given",
"ad",
"unit",
"on",
"the",
"page"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/ads/insertAds.js#L17-L50 |
56,706 | Pocketbrain/native-ads-web-ad-library | src/ads/insertAds.js | handleImageLoad | function handleImageLoad(adElement, adLoadedCallback) {
var adImage = adElement.querySelector("img");
if (adImage) {
(function (adToInsert, adImage) {
adImage.onload = function () {
adLoadedCallback(adToInsert, true);
};
})(adElement, adImage);
} else ... | javascript | function handleImageLoad(adElement, adLoadedCallback) {
var adImage = adElement.querySelector("img");
if (adImage) {
(function (adToInsert, adImage) {
adImage.onload = function () {
adLoadedCallback(adToInsert, true);
};
})(adElement, adImage);
} else ... | [
"function",
"handleImageLoad",
"(",
"adElement",
",",
"adLoadedCallback",
")",
"{",
"var",
"adImage",
"=",
"adElement",
".",
"querySelector",
"(",
"\"img\"",
")",
";",
"if",
"(",
"adImage",
")",
"{",
"(",
"function",
"(",
"adToInsert",
",",
"adImage",
")",
... | Add an event handler to the onload of ad images.
@param adElement - The HTML element of the advertisement
@param adLoadedCallback - Callback to execute when ads are loaded | [
"Add",
"an",
"event",
"handler",
"to",
"the",
"onload",
"of",
"ad",
"images",
"."
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/ads/insertAds.js#L57-L68 |
56,707 | shkuznetsov/machinegun | index.js | function (powder) {
var callback = function (err) {
shooting--;
if (err) {
// Only emit error if a listener exists
// This is mainly to prevent silent errors in promises
if (machinegun.listenerCount('error')) machinegun.emit('error', err);
if (opt.giveUpOnError) machinegun.giveUp(err);
... | javascript | function (powder) {
var callback = function (err) {
shooting--;
if (err) {
// Only emit error if a listener exists
// This is mainly to prevent silent errors in promises
if (machinegun.listenerCount('error')) machinegun.emit('error', err);
if (opt.giveUpOnError) machinegun.giveUp(err);
... | [
"function",
"(",
"powder",
")",
"{",
"var",
"callback",
"=",
"function",
"(",
"err",
")",
"{",
"shooting",
"--",
";",
"if",
"(",
"err",
")",
"{",
"// Only emit error if a listener exists\r",
"// This is mainly to prevent silent errors in promises\r",
"if",
"(",
"mac... | Primer function wrapper class Used mainly to contextualise callback | [
"Primer",
"function",
"wrapper",
"class",
"Used",
"mainly",
"to",
"contextualise",
"callback"
] | a9d342300dca7a7701a7f3954fe63bf88e206634 | https://github.com/shkuznetsov/machinegun/blob/a9d342300dca7a7701a7f3954fe63bf88e206634/index.js#L21-L42 | |
56,708 | hakovala/node-fse-promise | index.js | callPromise | function callPromise(fn, args) {
return new Promise((resolve, reject) => {
// promisified callback
function callback(err,other) {
// check if the 'err' is boolean, if so then this is a 'exists' callback special case
if (err && (typeof err !== 'boolean')) return reject(err);
// convert arguments to proper ... | javascript | function callPromise(fn, args) {
return new Promise((resolve, reject) => {
// promisified callback
function callback(err,other) {
// check if the 'err' is boolean, if so then this is a 'exists' callback special case
if (err && (typeof err !== 'boolean')) return reject(err);
// convert arguments to proper ... | [
"function",
"callPromise",
"(",
"fn",
",",
"args",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"// promisified callback",
"function",
"callback",
"(",
"err",
",",
"other",
")",
"{",
"// check if the 'err' is boolea... | Call method with promises | [
"Call",
"method",
"with",
"promises"
] | 0171cd2927f4daad8c33ed99e1e46b53a7e24b90 | https://github.com/hakovala/node-fse-promise/blob/0171cd2927f4daad8c33ed99e1e46b53a7e24b90/index.js#L82-L96 |
56,709 | hakovala/node-fse-promise | index.js | makePromise | function makePromise(fn) {
return function() {
var args = Array.prototype.slice.call(arguments);
if (hasCallback(args)) {
// argument list has callback, so call method with callback
return callCallback(fn, args);
} else {
// no callback, call method with promises
return callPromise(fn, args);
}
}
... | javascript | function makePromise(fn) {
return function() {
var args = Array.prototype.slice.call(arguments);
if (hasCallback(args)) {
// argument list has callback, so call method with callback
return callCallback(fn, args);
} else {
// no callback, call method with promises
return callPromise(fn, args);
}
}
... | [
"function",
"makePromise",
"(",
"fn",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"if",
"(",
"hasCallback",
"(",
"args",
")",
")",
"{",
"// argum... | Wrap method to handle both callbacks and promises | [
"Wrap",
"method",
"to",
"handle",
"both",
"callbacks",
"and",
"promises"
] | 0171cd2927f4daad8c33ed99e1e46b53a7e24b90 | https://github.com/hakovala/node-fse-promise/blob/0171cd2927f4daad8c33ed99e1e46b53a7e24b90/index.js#L101-L112 |
56,710 | mheadd/phl-property | index.js | standardizeAddress | function standardizeAddress(address, callback) {
var url = address_url + encodeURIComponent(address) + '?format=json';
request(url, function(err, resp, body) {
var error = resp.statusCode != 200 ? new Error('Unable to standardize address') : err;
callback(error, body);
});
} | javascript | function standardizeAddress(address, callback) {
var url = address_url + encodeURIComponent(address) + '?format=json';
request(url, function(err, resp, body) {
var error = resp.statusCode != 200 ? new Error('Unable to standardize address') : err;
callback(error, body);
});
} | [
"function",
"standardizeAddress",
"(",
"address",
",",
"callback",
")",
"{",
"var",
"url",
"=",
"address_url",
"+",
"encodeURIComponent",
"(",
"address",
")",
"+",
"'?format=json'",
";",
"request",
"(",
"url",
",",
"function",
"(",
"err",
",",
"resp",
",",
... | Standardize address and location information for a property. | [
"Standardize",
"address",
"and",
"location",
"information",
"for",
"a",
"property",
"."
] | d94abe26cd9ec11a94320ccee42a6abb2e08d49e | https://github.com/mheadd/phl-property/blob/d94abe26cd9ec11a94320ccee42a6abb2e08d49e/index.js#L30-L36 |
56,711 | mheadd/phl-property | index.js | getAddressDetails | function getAddressDetails(body, callback) {
var addresses = JSON.parse(body).addresses
if(addresses.length == 0) {
callback(new Error('No property information for that address'), null);
}
else {
var url = property_url + encodeURIComponent(addresses[0].standardizedAddress);
request(url, function(err, resp, bo... | javascript | function getAddressDetails(body, callback) {
var addresses = JSON.parse(body).addresses
if(addresses.length == 0) {
callback(new Error('No property information for that address'), null);
}
else {
var url = property_url + encodeURIComponent(addresses[0].standardizedAddress);
request(url, function(err, resp, bo... | [
"function",
"getAddressDetails",
"(",
"body",
",",
"callback",
")",
"{",
"var",
"addresses",
"=",
"JSON",
".",
"parse",
"(",
"body",
")",
".",
"addresses",
"if",
"(",
"addresses",
".",
"length",
"==",
"0",
")",
"{",
"callback",
"(",
"new",
"Error",
"("... | Get property details for an address. | [
"Get",
"property",
"details",
"for",
"an",
"address",
"."
] | d94abe26cd9ec11a94320ccee42a6abb2e08d49e | https://github.com/mheadd/phl-property/blob/d94abe26cd9ec11a94320ccee42a6abb2e08d49e/index.js#L39-L50 |
56,712 | verbose/verb-reflinks | index.js | isValidPackageName | function isValidPackageName(name) {
const stats = validateName(name);
return stats.validForNewPackages === true
&& stats.validForOldPackages === true;
} | javascript | function isValidPackageName(name) {
const stats = validateName(name);
return stats.validForNewPackages === true
&& stats.validForOldPackages === true;
} | [
"function",
"isValidPackageName",
"(",
"name",
")",
"{",
"const",
"stats",
"=",
"validateName",
"(",
"name",
")",
";",
"return",
"stats",
".",
"validForNewPackages",
"===",
"true",
"&&",
"stats",
".",
"validForOldPackages",
"===",
"true",
";",
"}"
] | Returns true if the given name is a valid npm package name | [
"Returns",
"true",
"if",
"the",
"given",
"name",
"is",
"a",
"valid",
"npm",
"package",
"name"
] | 89ee1e55a1385d6de03af9af97c28042de4e3b37 | https://github.com/verbose/verb-reflinks/blob/89ee1e55a1385d6de03af9af97c28042de4e3b37/index.js#L124-L128 |
56,713 | Pocketbrain/native-ads-web-ad-library | src/device/deviceDetector.js | isValidPlatform | function isValidPlatform() {
if (appSettings.overrides && appSettings.overrides.platform) {
return true; //If a platform override is set, it's always valid
}
return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
} | javascript | function isValidPlatform() {
if (appSettings.overrides && appSettings.overrides.platform) {
return true; //If a platform override is set, it's always valid
}
return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
} | [
"function",
"isValidPlatform",
"(",
")",
"{",
"if",
"(",
"appSettings",
".",
"overrides",
"&&",
"appSettings",
".",
"overrides",
".",
"platform",
")",
"{",
"return",
"true",
";",
"//If a platform override is set, it's always valid",
"}",
"return",
"/",
"iPhone|iPad|... | Check if the platform the user is currently visiting the page with is valid for
the ad library to run
@returns {boolean} | [
"Check",
"if",
"the",
"platform",
"the",
"user",
"is",
"currently",
"visiting",
"the",
"page",
"with",
"is",
"valid",
"for",
"the",
"ad",
"library",
"to",
"run"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/device/deviceDetector.js#L14-L19 |
56,714 | Pocketbrain/native-ads-web-ad-library | src/device/deviceDetector.js | detectFormFactor | function detectFormFactor() {
var viewPortWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var displaySettings = appSettings.displaySettings; //convenience variable
var formFactor;
if (viewPortWidth >= displaySettings.mobile.minWidth && viewPortWidth <= displaySettings.m... | javascript | function detectFormFactor() {
var viewPortWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var displaySettings = appSettings.displaySettings; //convenience variable
var formFactor;
if (viewPortWidth >= displaySettings.mobile.minWidth && viewPortWidth <= displaySettings.m... | [
"function",
"detectFormFactor",
"(",
")",
"{",
"var",
"viewPortWidth",
"=",
"Math",
".",
"max",
"(",
"document",
".",
"documentElement",
".",
"clientWidth",
",",
"window",
".",
"innerWidth",
"||",
"0",
")",
";",
"var",
"displaySettings",
"=",
"appSettings",
... | Detects the device form factor based on the ViewPort and the deviceWidths in AppSettings
The test_old is done based on the viewport, because it is already validated that a device is Android or iOS
@returns {*} the form factor of the device
@private | [
"Detects",
"the",
"device",
"form",
"factor",
"based",
"on",
"the",
"ViewPort",
"and",
"the",
"deviceWidths",
"in",
"AppSettings",
"The",
"test_old",
"is",
"done",
"based",
"on",
"the",
"viewport",
"because",
"it",
"is",
"already",
"validated",
"that",
"a",
... | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/device/deviceDetector.js#L27-L42 |
56,715 | smallhadroncollider/grunt-jspm | tasks/jspm.js | function () {
var pkgJson = grunt.file.readJSON("package.json");
if (pkgJson.jspm && pkgJson.jspm.directories && pkgJson.jspm.directories.baseURL) {
return pkgJson.jspm.directories.baseURL;
}
return "";
} | javascript | function () {
var pkgJson = grunt.file.readJSON("package.json");
if (pkgJson.jspm && pkgJson.jspm.directories && pkgJson.jspm.directories.baseURL) {
return pkgJson.jspm.directories.baseURL;
}
return "";
} | [
"function",
"(",
")",
"{",
"var",
"pkgJson",
"=",
"grunt",
".",
"file",
".",
"readJSON",
"(",
"\"package.json\"",
")",
";",
"if",
"(",
"pkgJson",
".",
"jspm",
"&&",
"pkgJson",
".",
"jspm",
".",
"directories",
"&&",
"pkgJson",
".",
"jspm",
".",
"directo... | Geth the JSPM baseURL from package.json | [
"Geth",
"the",
"JSPM",
"baseURL",
"from",
"package",
".",
"json"
] | 45c02eedef0f1a578a379631891e0ef13406786e | https://github.com/smallhadroncollider/grunt-jspm/blob/45c02eedef0f1a578a379631891e0ef13406786e/tasks/jspm.js#L11-L19 | |
56,716 | apflieger/grunt-csstree | lib/csstree.js | function(treeRoot) {
var stat = fs.statSync(treeRoot);
if (stat.isDirectory()) {
return buildTree(treeRoot);
} else {
throw new Error("path: " + treeRoot + " is not a directory");
}
} | javascript | function(treeRoot) {
var stat = fs.statSync(treeRoot);
if (stat.isDirectory()) {
return buildTree(treeRoot);
} else {
throw new Error("path: " + treeRoot + " is not a directory");
}
} | [
"function",
"(",
"treeRoot",
")",
"{",
"var",
"stat",
"=",
"fs",
".",
"statSync",
"(",
"treeRoot",
")",
";",
"if",
"(",
"stat",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"buildTree",
"(",
"treeRoot",
")",
";",
"}",
"else",
"{",
"throw",
"ne... | Crawl the given directory and build the tree object model for further use | [
"Crawl",
"the",
"given",
"directory",
"and",
"build",
"the",
"tree",
"object",
"model",
"for",
"further",
"use"
] | a1844eb22acc7359116ab1fa9bf1004a6512a2b2 | https://github.com/apflieger/grunt-csstree/blob/a1844eb22acc7359116ab1fa9bf1004a6512a2b2/lib/csstree.js#L76-L83 | |
56,717 | apflieger/grunt-csstree | lib/csstree.js | function(tree, options) {
if (!options) {
options = {
ext: '.css',
importFormat: null, // to be initialized just bellow
encoding: 'utf-8'
};
}
if (!options.ext) {
options.ext = '.css';
}
if (!options.importFormat) {
if (option... | javascript | function(tree, options) {
if (!options) {
options = {
ext: '.css',
importFormat: null, // to be initialized just bellow
encoding: 'utf-8'
};
}
if (!options.ext) {
options.ext = '.css';
}
if (!options.importFormat) {
if (option... | [
"function",
"(",
"tree",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"ext",
":",
"'.css'",
",",
"importFormat",
":",
"null",
",",
"// to be initialized just bellow",
"encoding",
":",
"'utf-8'",
"}",
";",
"}",
"if",... | Generate the files that contains @import rules on the given tree | [
"Generate",
"the",
"files",
"that",
"contains"
] | a1844eb22acc7359116ab1fa9bf1004a6512a2b2 | https://github.com/apflieger/grunt-csstree/blob/a1844eb22acc7359116ab1fa9bf1004a6512a2b2/lib/csstree.js#L85-L115 | |
56,718 | intervolga/bemjson-loader | lib/validate-bemdecl.js | validateBemDecl | function validateBemDecl(bemDecl, fileName) {
let errors = [];
bemDecl.forEach((decl) => {
errors = errors.concat(validateBemDeclItem(decl, fileName));
});
return errors;
} | javascript | function validateBemDecl(bemDecl, fileName) {
let errors = [];
bemDecl.forEach((decl) => {
errors = errors.concat(validateBemDeclItem(decl, fileName));
});
return errors;
} | [
"function",
"validateBemDecl",
"(",
"bemDecl",
",",
"fileName",
")",
"{",
"let",
"errors",
"=",
"[",
"]",
";",
"bemDecl",
".",
"forEach",
"(",
"(",
"decl",
")",
"=>",
"{",
"errors",
"=",
"errors",
".",
"concat",
"(",
"validateBemDeclItem",
"(",
"decl",
... | Validate BEM declarations
@param {Array} bemDecl
@param {String} fileName
@return {Array} of validation errors | [
"Validate",
"BEM",
"declarations"
] | c4ff680ee07ab939d400f241859fe608411fd8de | https://github.com/intervolga/bemjson-loader/blob/c4ff680ee07ab939d400f241859fe608411fd8de/lib/validate-bemdecl.js#L8-L16 |
56,719 | intervolga/bemjson-loader | lib/validate-bemdecl.js | validateBemDeclItem | function validateBemDeclItem(decl, fileName) {
let errors = [];
Object.keys(decl).forEach((key) => {
const val = decl[key];
if (val === '[object Object]') {
errors.push(new Error('Error in BemJson ' + fileName +
' produced wrong BemDecl ' + JSON.stringify(decl, null, 2)));
}
});
retu... | javascript | function validateBemDeclItem(decl, fileName) {
let errors = [];
Object.keys(decl).forEach((key) => {
const val = decl[key];
if (val === '[object Object]') {
errors.push(new Error('Error in BemJson ' + fileName +
' produced wrong BemDecl ' + JSON.stringify(decl, null, 2)));
}
});
retu... | [
"function",
"validateBemDeclItem",
"(",
"decl",
",",
"fileName",
")",
"{",
"let",
"errors",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"decl",
")",
".",
"forEach",
"(",
"(",
"key",
")",
"=>",
"{",
"const",
"val",
"=",
"decl",
"[",
"key",
"]",
... | Validate single BEM declaration
@param {Object} decl
@param {String} fileName
@return {Array} of validation errors | [
"Validate",
"single",
"BEM",
"declaration"
] | c4ff680ee07ab939d400f241859fe608411fd8de | https://github.com/intervolga/bemjson-loader/blob/c4ff680ee07ab939d400f241859fe608411fd8de/lib/validate-bemdecl.js#L25-L37 |
56,720 | royriojas/simplessy | compile-less.js | _getToken | function _getToken( /*klass, klass1, klass2*/ ) {
if ( !tokens ) {
throw new Error( 'no tokens found' );
}
var _args = [ ].slice.call( arguments ).join( ' ' ).split( ' ' );
var _result = _args.map( function ( klass ) {
var token = tokens[ klass ];
... | javascript | function _getToken( /*klass, klass1, klass2*/ ) {
if ( !tokens ) {
throw new Error( 'no tokens found' );
}
var _args = [ ].slice.call( arguments ).join( ' ' ).split( ' ' );
var _result = _args.map( function ( klass ) {
var token = tokens[ klass ];
... | [
"function",
"_getToken",
"(",
"/*klass, klass1, klass2*/",
")",
"{",
"if",
"(",
"!",
"tokens",
")",
"{",
"throw",
"new",
"Error",
"(",
"'no tokens found'",
")",
";",
"}",
"var",
"_args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
... | be careful here, this function is defined like this for ease of use, but this is going to actually be serialized inside the output of the transform so tokens inside this function, refer to the tokens variable declared in the transformed code | [
"be",
"careful",
"here",
"this",
"function",
"is",
"defined",
"like",
"this",
"for",
"ease",
"of",
"use",
"but",
"this",
"is",
"going",
"to",
"actually",
"be",
"serialized",
"inside",
"the",
"output",
"of",
"the",
"transform",
"so",
"tokens",
"inside",
"th... | ac6c7af664c846bcfb23099ca5f6841335f833ae | https://github.com/royriojas/simplessy/blob/ac6c7af664c846bcfb23099ca5f6841335f833ae/compile-less.js#L58-L76 |
56,721 | Chapabu/gulp-holograph | src/index.js | handleBuffer | function handleBuffer (file, encoding, cb) {
const config = configParser(String(file.contents));
holograph.holograph(config);
return cb(null, file);
} | javascript | function handleBuffer (file, encoding, cb) {
const config = configParser(String(file.contents));
holograph.holograph(config);
return cb(null, file);
} | [
"function",
"handleBuffer",
"(",
"file",
",",
"encoding",
",",
"cb",
")",
"{",
"const",
"config",
"=",
"configParser",
"(",
"String",
"(",
"file",
".",
"contents",
")",
")",
";",
"holograph",
".",
"holograph",
"(",
"config",
")",
";",
"return",
"cb",
"... | Run Hologram when given a buffer.
@param {Object} file A Vinyl file.
@param {String} encoding The file encoding.
@param {Function} cb Called after hologram has run.
@returns {Function} Executed callback. | [
"Run",
"Hologram",
"when",
"given",
"a",
"buffer",
"."
] | 182dc177efd593956abf31d3a402f2d02daa95a5 | https://github.com/Chapabu/gulp-holograph/blob/182dc177efd593956abf31d3a402f2d02daa95a5/src/index.js#L20-L24 |
56,722 | Chapabu/gulp-holograph | src/index.js | handleStream | function handleStream (file, encoding, cb) {
let config = '';
file.contents.on('data', chunk => {
config += chunk;
});
file.contents.on('end', () => {
config = configParser(config);
holograph.holograph(config);
return cb(null, file);
});
} | javascript | function handleStream (file, encoding, cb) {
let config = '';
file.contents.on('data', chunk => {
config += chunk;
});
file.contents.on('end', () => {
config = configParser(config);
holograph.holograph(config);
return cb(null, file);
});
} | [
"function",
"handleStream",
"(",
"file",
",",
"encoding",
",",
"cb",
")",
"{",
"let",
"config",
"=",
"''",
";",
"file",
".",
"contents",
".",
"on",
"(",
"'data'",
",",
"chunk",
"=>",
"{",
"config",
"+=",
"chunk",
";",
"}",
")",
";",
"file",
".",
... | Run Hologram when given a stream.
@param {Object} file A Vinyl file.
@param {String} encoding The file encoding.
@param {Function} cb Called after hologram has run.
@returns {Function} Executed callback. | [
"Run",
"Hologram",
"when",
"given",
"a",
"stream",
"."
] | 182dc177efd593956abf31d3a402f2d02daa95a5 | https://github.com/Chapabu/gulp-holograph/blob/182dc177efd593956abf31d3a402f2d02daa95a5/src/index.js#L34-L48 |
56,723 | Chapabu/gulp-holograph | src/index.js | gulpHolograph | function gulpHolograph () {
return through.obj(function (file, encoding, cb) {
// Handle any non-supported types.
// This covers directories and symlinks as well, as they have to be null.
if (file.isNull()) {
this.emit('error', new PluginError(PLUGIN_NAME, 'No file contents.'));
}
// Hand... | javascript | function gulpHolograph () {
return through.obj(function (file, encoding, cb) {
// Handle any non-supported types.
// This covers directories and symlinks as well, as they have to be null.
if (file.isNull()) {
this.emit('error', new PluginError(PLUGIN_NAME, 'No file contents.'));
}
// Hand... | [
"function",
"gulpHolograph",
"(",
")",
"{",
"return",
"through",
".",
"obj",
"(",
"function",
"(",
"file",
",",
"encoding",
",",
"cb",
")",
"{",
"// Handle any non-supported types.",
"// This covers directories and symlinks as well, as they have to be null.",
"if",
"(",
... | The actual plugin. Runs Holograph with a provided config file.
@returns {Object} A through2 stream. | [
"The",
"actual",
"plugin",
".",
"Runs",
"Holograph",
"with",
"a",
"provided",
"config",
"file",
"."
] | 182dc177efd593956abf31d3a402f2d02daa95a5 | https://github.com/Chapabu/gulp-holograph/blob/182dc177efd593956abf31d3a402f2d02daa95a5/src/index.js#L55-L77 |
56,724 | ianmuninio/jmodel | lib/error.js | JModelError | function JModelError(obj) {
this.message = obj['message'];
this.propertyName = obj['propertyName'];
Error.call(this);
Error.captureStackTrace(this, this.constructor);
} | javascript | function JModelError(obj) {
this.message = obj['message'];
this.propertyName = obj['propertyName'];
Error.call(this);
Error.captureStackTrace(this, this.constructor);
} | [
"function",
"JModelError",
"(",
"obj",
")",
"{",
"this",
".",
"message",
"=",
"obj",
"[",
"'message'",
"]",
";",
"this",
".",
"propertyName",
"=",
"obj",
"[",
"'propertyName'",
"]",
";",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"cap... | JModel Error Class
@param {Object} obj
@returns {JModelError} | [
"JModel",
"Error",
"Class"
] | c118bfc46596f59445604acc43b01ad2b04c31ef | https://github.com/ianmuninio/jmodel/blob/c118bfc46596f59445604acc43b01ad2b04c31ef/lib/error.js#L14-L20 |
56,725 | weisjohn/jsonload | index.js | normalize | function normalize(filepath) {
// resolve to an absolute ppath
if (!path.isAbsolute || !path.isAbsolute(filepath))
filepath = path.resolve(path.dirname(module.parent.filename), filepath);
// tack .json on the end if need be
if (!/\.json$/.test(filepath))
filepath = filepath + '.json';
... | javascript | function normalize(filepath) {
// resolve to an absolute ppath
if (!path.isAbsolute || !path.isAbsolute(filepath))
filepath = path.resolve(path.dirname(module.parent.filename), filepath);
// tack .json on the end if need be
if (!/\.json$/.test(filepath))
filepath = filepath + '.json';
... | [
"function",
"normalize",
"(",
"filepath",
")",
"{",
"// resolve to an absolute ppath",
"if",
"(",
"!",
"path",
".",
"isAbsolute",
"||",
"!",
"path",
".",
"isAbsolute",
"(",
"filepath",
")",
")",
"filepath",
"=",
"path",
".",
"resolve",
"(",
"path",
".",
"d... | clean up paths for convenient loading | [
"clean",
"up",
"paths",
"for",
"convenient",
"loading"
] | 53ad101bc32c766c75bf93616a805ab67edaa9ef | https://github.com/weisjohn/jsonload/blob/53ad101bc32c766c75bf93616a805ab67edaa9ef/index.js#L6-L17 |
56,726 | weisjohn/jsonload | index.js | parse | function parse(contents, retained, parser) {
var errors = [], data = [], lines = 0;
// optional parser
if (!parser) parser = JSON;
// process each line of the file
contents.toString().split('\n').forEach(function(line) {
if (!line) return;
lines++;
try {
data.pu... | javascript | function parse(contents, retained, parser) {
var errors = [], data = [], lines = 0;
// optional parser
if (!parser) parser = JSON;
// process each line of the file
contents.toString().split('\n').forEach(function(line) {
if (!line) return;
lines++;
try {
data.pu... | [
"function",
"parse",
"(",
"contents",
",",
"retained",
",",
"parser",
")",
"{",
"var",
"errors",
"=",
"[",
"]",
",",
"data",
"=",
"[",
"]",
",",
"lines",
"=",
"0",
";",
"// optional parser",
"if",
"(",
"!",
"parser",
")",
"parser",
"=",
"JSON",
";"... | process line-delimited files | [
"process",
"line",
"-",
"delimited",
"files"
] | 53ad101bc32c766c75bf93616a805ab67edaa9ef | https://github.com/weisjohn/jsonload/blob/53ad101bc32c766c75bf93616a805ab67edaa9ef/index.js#L20-L47 |
56,727 | AgronKabashi/trastpiler | lib/trastpiler.js | createTranspiler | function createTranspiler ({ mappers = {}, initialScopeData } = {}) {
const config = {
scope: createScope(initialScopeData),
mappers
};
return (config.decoratedTranspile = transpile.bind(null, config));
} | javascript | function createTranspiler ({ mappers = {}, initialScopeData } = {}) {
const config = {
scope: createScope(initialScopeData),
mappers
};
return (config.decoratedTranspile = transpile.bind(null, config));
} | [
"function",
"createTranspiler",
"(",
"{",
"mappers",
"=",
"{",
"}",
",",
"initialScopeData",
"}",
"=",
"{",
"}",
")",
"{",
"const",
"config",
"=",
"{",
"scope",
":",
"createScope",
"(",
"initialScopeData",
")",
",",
"mappers",
"}",
";",
"return",
"(",
... | eslint-disable-line no-use-before-define | [
"eslint",
"-",
"disable",
"-",
"line",
"no",
"-",
"use",
"-",
"before",
"-",
"define"
] | 6bbebda1290aa2aaf9dfe6c286777aa20bfe56c5 | https://github.com/AgronKabashi/trastpiler/blob/6bbebda1290aa2aaf9dfe6c286777aa20bfe56c5/lib/trastpiler.js#L53-L60 |
56,728 | ltoussaint/node-bootstrap-core | routers/matchPath.js | MatchPath | function MatchPath() {
var defaultAction = 'welcome',
defaultMethod = 'index';
/**
* Resolve uri
* @param request
* @returns {*}
*/
this.resolve = function (request) {
var action = defaultAction;
var method = defaultMethod;
if ('/' != request.url) {
var uriComponents = request... | javascript | function MatchPath() {
var defaultAction = 'welcome',
defaultMethod = 'index';
/**
* Resolve uri
* @param request
* @returns {*}
*/
this.resolve = function (request) {
var action = defaultAction;
var method = defaultMethod;
if ('/' != request.url) {
var uriComponents = request... | [
"function",
"MatchPath",
"(",
")",
"{",
"var",
"defaultAction",
"=",
"'welcome'",
",",
"defaultMethod",
"=",
"'index'",
";",
"/**\n * Resolve uri\n * @param request\n * @returns {*}\n */",
"this",
".",
"resolve",
"=",
"function",
"(",
"request",
")",
"{",
"var... | Simple router which will match url pathname with an action
@returns {MatchPath}
@constructor | [
"Simple",
"router",
"which",
"will",
"match",
"url",
"pathname",
"with",
"an",
"action"
] | b083b320900ed068007e58af2249825b8da24c79 | https://github.com/ltoussaint/node-bootstrap-core/blob/b083b320900ed068007e58af2249825b8da24c79/routers/matchPath.js#L8-L60 |
56,729 | twolfson/grunt-init-init | src/init/resolveTemplateFiles.js | resolveTemplateFiles | function resolveTemplateFiles(name) {
// Create paths for resolving
var customFile = customDir + '/' + name + '.js',
customTemplateDir = customDir + '/' + name + '/**/*',
stdFile = stdDir + '/' + name + '.js',
stdTemplateDir = stdDir + '/' + name + '/**/*';
// Grab any and all files... | javascript | function resolveTemplateFiles(name) {
// Create paths for resolving
var customFile = customDir + '/' + name + '.js',
customTemplateDir = customDir + '/' + name + '/**/*',
stdFile = stdDir + '/' + name + '.js',
stdTemplateDir = stdDir + '/' + name + '/**/*';
// Grab any and all files... | [
"function",
"resolveTemplateFiles",
"(",
"name",
")",
"{",
"// Create paths for resolving",
"var",
"customFile",
"=",
"customDir",
"+",
"'/'",
"+",
"name",
"+",
"'.js'",
",",
"customTemplateDir",
"=",
"customDir",
"+",
"'/'",
"+",
"name",
"+",
"'/**/*'",
",",
... | Define a helper to find custom and standard template files | [
"Define",
"a",
"helper",
"to",
"find",
"custom",
"and",
"standard",
"template",
"files"
] | 2dd3d063f06213c4ca086ec5b220759067ecd567 | https://github.com/twolfson/grunt-init-init/blob/2dd3d063f06213c4ca086ec5b220759067ecd567/src/init/resolveTemplateFiles.js#L9-L46 |
56,730 | pinyin/outline | vendor/transformation-matrix/rotate.js | rotate | function rotate(angle, cx, cy) {
var cosAngle = cos(angle);
var sinAngle = sin(angle);
var rotationMatrix = {
a: cosAngle, c: -sinAngle, e: 0,
b: sinAngle, d: cosAngle, f: 0
};
if ((0, _utils.isUndefined)(cx) || (0, _utils.isUndefined)(cy)) {
return rotationMatrix;
}
... | javascript | function rotate(angle, cx, cy) {
var cosAngle = cos(angle);
var sinAngle = sin(angle);
var rotationMatrix = {
a: cosAngle, c: -sinAngle, e: 0,
b: sinAngle, d: cosAngle, f: 0
};
if ((0, _utils.isUndefined)(cx) || (0, _utils.isUndefined)(cy)) {
return rotationMatrix;
}
... | [
"function",
"rotate",
"(",
"angle",
",",
"cx",
",",
"cy",
")",
"{",
"var",
"cosAngle",
"=",
"cos",
"(",
"angle",
")",
";",
"var",
"sinAngle",
"=",
"sin",
"(",
"angle",
")",
";",
"var",
"rotationMatrix",
"=",
"{",
"a",
":",
"cosAngle",
",",
"c",
"... | Calculate a rotation matrix
@param angle Angle in radians
@param [cx] If (cx,cy) are supplied the rotate is about this point
@param [cy] If (cx,cy) are supplied the rotate is about this point
@returns {{a: number, b: number, c: number, e: number, d: number, f: number}} Affine matrix * | [
"Calculate",
"a",
"rotation",
"matrix"
] | e49f05d2f8ab384f5b1d71b2b10875cd48d41051 | https://github.com/pinyin/outline/blob/e49f05d2f8ab384f5b1d71b2b10875cd48d41051/vendor/transformation-matrix/rotate.js#L27-L39 |
56,731 | pinyin/outline | vendor/transformation-matrix/rotate.js | rotateDEG | function rotateDEG(angle) {
var cx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
var cy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
return rotate(angle * PI / 180, cx, cy);
} | javascript | function rotateDEG(angle) {
var cx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
var cy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
return rotate(angle * PI / 180, cx, cy);
} | [
"function",
"rotateDEG",
"(",
"angle",
")",
"{",
"var",
"cx",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"undefined",
";",
"var",
"cy",
"=",
"arguments",
".",... | Calculate a rotation matrix with a DEG angle
@param angle Angle in degree
@param [cx] If (cx,cy) are supplied the rotate is about this point
@param [cy] If (cx,cy) are supplied the rotate is about this point
@returns {{a: number, b: number, c: number, e: number, d: number, f: number}} Affine matrix | [
"Calculate",
"a",
"rotation",
"matrix",
"with",
"a",
"DEG",
"angle"
] | e49f05d2f8ab384f5b1d71b2b10875cd48d41051 | https://github.com/pinyin/outline/blob/e49f05d2f8ab384f5b1d71b2b10875cd48d41051/vendor/transformation-matrix/rotate.js#L48-L53 |
56,732 | vnykmshr/proc-utils | lib/proc.js | reload | function reload(args) {
if (args !== undefined) {
if (args.l !== undefined) {
fs.closeSync(1);
fs.openSync(args.l, 'a+');
}
if (args.e !== undefined) {
fs.closeSync(2);
fs.openSync(args.e, 'a+');
}
}
} | javascript | function reload(args) {
if (args !== undefined) {
if (args.l !== undefined) {
fs.closeSync(1);
fs.openSync(args.l, 'a+');
}
if (args.e !== undefined) {
fs.closeSync(2);
fs.openSync(args.e, 'a+');
}
}
} | [
"function",
"reload",
"(",
"args",
")",
"{",
"if",
"(",
"args",
"!==",
"undefined",
")",
"{",
"if",
"(",
"args",
".",
"l",
"!==",
"undefined",
")",
"{",
"fs",
".",
"closeSync",
"(",
"1",
")",
";",
"fs",
".",
"openSync",
"(",
"args",
".",
"l",
"... | Close the standard output and error descriptors
and redirect them to the specified files provided
in the argument | [
"Close",
"the",
"standard",
"output",
"and",
"error",
"descriptors",
"and",
"redirect",
"them",
"to",
"the",
"specified",
"files",
"provided",
"in",
"the",
"argument"
] | cae3b96a9cd6689a3e5cfedfefef3718c1e4839c | https://github.com/vnykmshr/proc-utils/blob/cae3b96a9cd6689a3e5cfedfefef3718c1e4839c/lib/proc.js#L17-L29 |
56,733 | vnykmshr/proc-utils | lib/proc.js | setupHandlers | function setupHandlers() {
function terminate(err) {
util.log('Uncaught Error: ' + err.message);
console.log(err.stack);
if (proc.shutdownHook) {
proc.shutdownHook(err, gracefulShutdown);
}
}
process.on('uncaughtException', terminate);
process.addListener('... | javascript | function setupHandlers() {
function terminate(err) {
util.log('Uncaught Error: ' + err.message);
console.log(err.stack);
if (proc.shutdownHook) {
proc.shutdownHook(err, gracefulShutdown);
}
}
process.on('uncaughtException', terminate);
process.addListener('... | [
"function",
"setupHandlers",
"(",
")",
"{",
"function",
"terminate",
"(",
"err",
")",
"{",
"util",
".",
"log",
"(",
"'Uncaught Error: '",
"+",
"err",
".",
"message",
")",
";",
"console",
".",
"log",
"(",
"err",
".",
"stack",
")",
";",
"if",
"(",
"pro... | Reopen logfiles on SIGHUP
Exit on uncaught exceptions | [
"Reopen",
"logfiles",
"on",
"SIGHUP",
"Exit",
"on",
"uncaught",
"exceptions"
] | cae3b96a9cd6689a3e5cfedfefef3718c1e4839c | https://github.com/vnykmshr/proc-utils/blob/cae3b96a9cd6689a3e5cfedfefef3718c1e4839c/lib/proc.js#L56-L75 |
56,734 | JohnnieFucker/dreamix-admin | lib/consoleService.js | enableCommand | function enableCommand(consoleService, moduleId, msg, cb) {
if (!moduleId) {
logger.error(`fail to enable admin module for ${moduleId}`);
cb('empty moduleId');
return;
}
const modules = consoleService.modules;
if (!modules[moduleId]) {
cb(null, protocol.PRO_FAIL);
... | javascript | function enableCommand(consoleService, moduleId, msg, cb) {
if (!moduleId) {
logger.error(`fail to enable admin module for ${moduleId}`);
cb('empty moduleId');
return;
}
const modules = consoleService.modules;
if (!modules[moduleId]) {
cb(null, protocol.PRO_FAIL);
... | [
"function",
"enableCommand",
"(",
"consoleService",
",",
"moduleId",
",",
"msg",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"moduleId",
")",
"{",
"logger",
".",
"error",
"(",
"`",
"${",
"moduleId",
"}",
"`",
")",
";",
"cb",
"(",
"'empty moduleId'",
")",
";... | enable module in current server | [
"enable",
"module",
"in",
"current",
"server"
] | fc169e2481d5a7456725fb33f7a7907e0776ef79 | https://github.com/JohnnieFucker/dreamix-admin/blob/fc169e2481d5a7456725fb33f7a7907e0776ef79/lib/consoleService.js#L35-L56 |
56,735 | JohnnieFucker/dreamix-admin | lib/consoleService.js | registerRecord | function registerRecord(service, moduleId, module) {
const record = {
moduleId: moduleId,
module: module,
enable: false
};
if (module.type && module.interval) {
if (!service.master && record.module.type === 'push' || service.master && record.module.type !== 'push') {// eslin... | javascript | function registerRecord(service, moduleId, module) {
const record = {
moduleId: moduleId,
module: module,
enable: false
};
if (module.type && module.interval) {
if (!service.master && record.module.type === 'push' || service.master && record.module.type !== 'push') {// eslin... | [
"function",
"registerRecord",
"(",
"service",
",",
"moduleId",
",",
"module",
")",
"{",
"const",
"record",
"=",
"{",
"moduleId",
":",
"moduleId",
",",
"module",
":",
"module",
",",
"enable",
":",
"false",
"}",
";",
"if",
"(",
"module",
".",
"type",
"&&... | register a module service
@param {Object} service consoleService object
@param {String} moduleId adminConsole id/name
@param {Object} module module object
@api private | [
"register",
"a",
"module",
"service"
] | fc169e2481d5a7456725fb33f7a7907e0776ef79 | https://github.com/JohnnieFucker/dreamix-admin/blob/fc169e2481d5a7456725fb33f7a7907e0776ef79/lib/consoleService.js#L93-L120 |
56,736 | JohnnieFucker/dreamix-admin | lib/consoleService.js | addToSchedule | function addToSchedule(service, record) {
if (record && record.schedule) {
record.jobId = schedule.scheduleJob({
start: Date.now() + record.delay,
period: record.interval
},
doScheduleJob, {
service: service,
record: record
});
}
} | javascript | function addToSchedule(service, record) {
if (record && record.schedule) {
record.jobId = schedule.scheduleJob({
start: Date.now() + record.delay,
period: record.interval
},
doScheduleJob, {
service: service,
record: record
});
}
} | [
"function",
"addToSchedule",
"(",
"service",
",",
"record",
")",
"{",
"if",
"(",
"record",
"&&",
"record",
".",
"schedule",
")",
"{",
"record",
".",
"jobId",
"=",
"schedule",
".",
"scheduleJob",
"(",
"{",
"start",
":",
"Date",
".",
"now",
"(",
")",
"... | schedule console module
@param {Object} service consoleService object
@param {Object} record module object
@api private | [
"schedule",
"console",
"module"
] | fc169e2481d5a7456725fb33f7a7907e0776ef79 | https://github.com/JohnnieFucker/dreamix-admin/blob/fc169e2481d5a7456725fb33f7a7907e0776ef79/lib/consoleService.js#L153-L164 |
56,737 | JohnnieFucker/dreamix-admin | lib/consoleService.js | exportEvent | function exportEvent(outer, inner, event) {
inner.on(event, (...args) => {
args.unshift(event);
outer.emit(...args);
});
} | javascript | function exportEvent(outer, inner, event) {
inner.on(event, (...args) => {
args.unshift(event);
outer.emit(...args);
});
} | [
"function",
"exportEvent",
"(",
"outer",
",",
"inner",
",",
"event",
")",
"{",
"inner",
".",
"on",
"(",
"event",
",",
"(",
"...",
"args",
")",
"=>",
"{",
"args",
".",
"unshift",
"(",
"event",
")",
";",
"outer",
".",
"emit",
"(",
"...",
"args",
")... | export closure function out
@param {Function} outer outer function
@param {Function} inner inner function
@param {object} event
@api private | [
"export",
"closure",
"function",
"out"
] | fc169e2481d5a7456725fb33f7a7907e0776ef79 | https://github.com/JohnnieFucker/dreamix-admin/blob/fc169e2481d5a7456725fb33f7a7907e0776ef79/lib/consoleService.js#L174-L179 |
56,738 | fladi/sails-generate-avahi | templates/hook.template.js | add_group | function add_group() {
server.EntryGroupNew(function(err, path) {
if (err) {
sails.log.error('DBus: Could not call org.freedesktop.Avahi.Server.EntryGroupNew');
return;
}
service.getInterface(
path,
avahi.DBUS_INTERFACE_ENTRY_GROUP.value,
function (
... | javascript | function add_group() {
server.EntryGroupNew(function(err, path) {
if (err) {
sails.log.error('DBus: Could not call org.freedesktop.Avahi.Server.EntryGroupNew');
return;
}
service.getInterface(
path,
avahi.DBUS_INTERFACE_ENTRY_GROUP.value,
function (
... | [
"function",
"add_group",
"(",
")",
"{",
"server",
".",
"EntryGroupNew",
"(",
"function",
"(",
"err",
",",
"path",
")",
"{",
"if",
"(",
"err",
")",
"{",
"sails",
".",
"log",
".",
"error",
"(",
"'DBus: Could not call org.freedesktop.Avahi.Server.EntryGroupNew'",
... | Add a new EntryGroup for our service. | [
"Add",
"a",
"new",
"EntryGroup",
"for",
"our",
"service",
"."
] | 09f66f30d9301ad7078a3b4e95f3b3c7f3b6d337 | https://github.com/fladi/sails-generate-avahi/blob/09f66f30d9301ad7078a3b4e95f3b3c7f3b6d337/templates/hook.template.js#L41-L59 |
56,739 | fladi/sails-generate-avahi | templates/hook.template.js | add_service | function add_service() {
// Default configuration. Overrides can be defined in `config/avahi.js`.
sails.log.info('Publishing service ' + config.name + ' (' + config.type + ') on port '+ config.port);
group.AddService(
avahi.IF_UNSPEC.value,
avahi.PROTO_INET.value,
0,
config.name,
... | javascript | function add_service() {
// Default configuration. Overrides can be defined in `config/avahi.js`.
sails.log.info('Publishing service ' + config.name + ' (' + config.type + ') on port '+ config.port);
group.AddService(
avahi.IF_UNSPEC.value,
avahi.PROTO_INET.value,
0,
config.name,
... | [
"function",
"add_service",
"(",
")",
"{",
"// Default configuration. Overrides can be defined in `config/avahi.js`.",
"sails",
".",
"log",
".",
"info",
"(",
"'Publishing service '",
"+",
"config",
".",
"name",
"+",
"' ('",
"+",
"config",
".",
"type",
"+",
"') on port ... | Add our service definition. | [
"Add",
"our",
"service",
"definition",
"."
] | 09f66f30d9301ad7078a3b4e95f3b3c7f3b6d337 | https://github.com/fladi/sails-generate-avahi/blob/09f66f30d9301ad7078a3b4e95f3b3c7f3b6d337/templates/hook.template.js#L62-L84 |
56,740 | vanjacosic/opbeat-js | src/opbeat.js | triggerEvent | function triggerEvent(eventType, options) {
var event, key;
options = options || {};
eventType = 'opbeat' + eventType.substr(0,1).toUpperCase() + eventType.substr(1);
if (document.createEvent) {
event = document.createEvent('HTMLEvents');
event.initEvent(eventType, true, true);
} ... | javascript | function triggerEvent(eventType, options) {
var event, key;
options = options || {};
eventType = 'opbeat' + eventType.substr(0,1).toUpperCase() + eventType.substr(1);
if (document.createEvent) {
event = document.createEvent('HTMLEvents');
event.initEvent(eventType, true, true);
} ... | [
"function",
"triggerEvent",
"(",
"eventType",
",",
"options",
")",
"{",
"var",
"event",
",",
"key",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"eventType",
"=",
"'opbeat'",
"+",
"eventType",
".",
"substr",
"(",
"0",
",",
"1",
")",
".",
"toU... | To be deprecated | [
"To",
"be",
"deprecated"
] | 136065ff2f6cda0097c783e43ca3773da6dff3ed | https://github.com/vanjacosic/opbeat-js/blob/136065ff2f6cda0097c783e43ca3773da6dff3ed/src/opbeat.js#L308-L337 |
56,741 | PrinceNebulon/github-api-promise | src/request-helpers.js | function(url, method = 'get', body = undefined) {
var deferred = Q.defer();
this.extendedRequest(url, method, body)
.then((res) => { deferred.resolve(res.body); })
.catch((err) => { deferred.reject(err); });
return deferred.promise;
} | javascript | function(url, method = 'get', body = undefined) {
var deferred = Q.defer();
this.extendedRequest(url, method, body)
.then((res) => { deferred.resolve(res.body); })
.catch((err) => { deferred.reject(err); });
return deferred.promise;
} | [
"function",
"(",
"url",
",",
"method",
"=",
"'get'",
",",
"body",
"=",
"undefined",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"this",
".",
"extendedRequest",
"(",
"url",
",",
"method",
",",
"body",
")",
".",
"then",
"(",
... | Returns only the response body | [
"Returns",
"only",
"the",
"response",
"body"
] | 990cb2cce19b53f54d9243002fde47428f24e7cc | https://github.com/PrinceNebulon/github-api-promise/blob/990cb2cce19b53f54d9243002fde47428f24e7cc/src/request-helpers.js#L37-L45 | |
56,742 | mjhasbach/bower-package-url | lib/bowerPackageURL.js | bowerPackageURL | function bowerPackageURL(packageName, cb) {
if (typeof cb !== 'function') {
throw new TypeError('cb must be a function');
}
if (typeof packageName !== 'string') {
cb(new TypeError('packageName must be a string'));
return;
}
http.get('https://bower.herokuapp.com/packages/' + ... | javascript | function bowerPackageURL(packageName, cb) {
if (typeof cb !== 'function') {
throw new TypeError('cb must be a function');
}
if (typeof packageName !== 'string') {
cb(new TypeError('packageName must be a string'));
return;
}
http.get('https://bower.herokuapp.com/packages/' + ... | [
"function",
"bowerPackageURL",
"(",
"packageName",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"cb",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'cb must be a function'",
")",
";",
"}",
"if",
"(",
"typeof",
"packageName",
"!==",
"'string'... | The bowerPackageURL callback
@callback bowerPackageURLCallback
@param {Object} err - An error object if an error occurred
@param {string} url - The repository URL associated with the provided bower package name
Get the repository URL associated with a bower package name
@alias module:bowerPackageURL
@param {string} p... | [
"The",
"bowerPackageURL",
"callback"
] | 5ed279cc7e685789ec73667ff6787ae85e368acc | https://github.com/mjhasbach/bower-package-url/blob/5ed279cc7e685789ec73667ff6787ae85e368acc/lib/bowerPackageURL.js#L26-L43 |
56,743 | crokita/functionite | examples/example3.js | addPoints | function addPoints (x1, y1, x2, y2, cb) {
var xFinal = x1 + x2;
var yFinal = y1 + y2;
cb(xFinal, yFinal);
} | javascript | function addPoints (x1, y1, x2, y2, cb) {
var xFinal = x1 + x2;
var yFinal = y1 + y2;
cb(xFinal, yFinal);
} | [
"function",
"addPoints",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"cb",
")",
"{",
"var",
"xFinal",
"=",
"x1",
"+",
"x2",
";",
"var",
"yFinal",
"=",
"y1",
"+",
"y2",
";",
"cb",
"(",
"xFinal",
",",
"yFinal",
")",
";",
"}"
] | this function takes the sum of two points, and returns the sum of x's and the sum of y's in a callback | [
"this",
"function",
"takes",
"the",
"sum",
"of",
"two",
"points",
"and",
"returns",
"the",
"sum",
"of",
"x",
"s",
"and",
"the",
"sum",
"of",
"y",
"s",
"in",
"a",
"callback"
] | e5d52b3bded8eac6b42413208e1dc61e0741ae34 | https://github.com/crokita/functionite/blob/e5d52b3bded8eac6b42413208e1dc61e0741ae34/examples/example3.js#L16-L20 |
56,744 | creationix/git-pack-codec | decode.js | emitObject | function emitObject() {
var item = {
type: types[type],
size: length,
body: bops.join(parts),
offset: start
};
if (ref) item.ref = ref;
parts.length = 0;
start = 0;
offset = 0;
type = 0;
length = 0;
ref = null;
emit(item);
} | javascript | function emitObject() {
var item = {
type: types[type],
size: length,
body: bops.join(parts),
offset: start
};
if (ref) item.ref = ref;
parts.length = 0;
start = 0;
offset = 0;
type = 0;
length = 0;
ref = null;
emit(item);
} | [
"function",
"emitObject",
"(",
")",
"{",
"var",
"item",
"=",
"{",
"type",
":",
"types",
"[",
"type",
"]",
",",
"size",
":",
"length",
",",
"body",
":",
"bops",
".",
"join",
"(",
"parts",
")",
",",
"offset",
":",
"start",
"}",
";",
"if",
"(",
"r... | Common helper for emitting all three object shapes | [
"Common",
"helper",
"for",
"emitting",
"all",
"three",
"object",
"shapes"
] | bf14e63755795dc5d15f7f68b68bbc312a114ef2 | https://github.com/creationix/git-pack-codec/blob/bf14e63755795dc5d15f7f68b68bbc312a114ef2/decode.js#L149-L164 |
56,745 | creationix/git-pack-codec | decode.js | $body | function $body(byte, i, chunk) {
if (inf.write(byte)) return $body;
var buf = inf.flush();
inf.recycle();
if (buf.length) {
parts.push(buf);
}
emitObject();
// If this was all the objects, start calculating the sha1sum
if (--num) return $header;
sha1sum.upda... | javascript | function $body(byte, i, chunk) {
if (inf.write(byte)) return $body;
var buf = inf.flush();
inf.recycle();
if (buf.length) {
parts.push(buf);
}
emitObject();
// If this was all the objects, start calculating the sha1sum
if (--num) return $header;
sha1sum.upda... | [
"function",
"$body",
"(",
"byte",
",",
"i",
",",
"chunk",
")",
"{",
"if",
"(",
"inf",
".",
"write",
"(",
"byte",
")",
")",
"return",
"$body",
";",
"var",
"buf",
"=",
"inf",
".",
"flush",
"(",
")",
";",
"inf",
".",
"recycle",
"(",
")",
";",
"i... | Feed the deflated code to the inflate engine | [
"Feed",
"the",
"deflated",
"code",
"to",
"the",
"inflate",
"engine"
] | bf14e63755795dc5d15f7f68b68bbc312a114ef2 | https://github.com/creationix/git-pack-codec/blob/bf14e63755795dc5d15f7f68b68bbc312a114ef2/decode.js#L167-L179 |
56,746 | pierrec/node-atok | lib/subrule.js | typeOf | function typeOf (rule) {
var ruleType = typeof rule
return ruleType === 'function'
? ruleType
: ruleType !== 'object'
? (rule.length === 0
? 'noop'
: (rule === 0
? 'zero'
: ruleType
)
)
: Buffer.isBuffer(rule)
? 'buff... | javascript | function typeOf (rule) {
var ruleType = typeof rule
return ruleType === 'function'
? ruleType
: ruleType !== 'object'
? (rule.length === 0
? 'noop'
: (rule === 0
? 'zero'
: ruleType
)
)
: Buffer.isBuffer(rule)
? 'buff... | [
"function",
"typeOf",
"(",
"rule",
")",
"{",
"var",
"ruleType",
"=",
"typeof",
"rule",
"return",
"ruleType",
"===",
"'function'",
"?",
"ruleType",
":",
"ruleType",
"!==",
"'object'",
"?",
"(",
"rule",
".",
"length",
"===",
"0",
"?",
"'noop'",
":",
"(",
... | Return the type of an item
@param {...} item to check
@return {String} type | [
"Return",
"the",
"type",
"of",
"an",
"item"
] | abe139e7fa8c092d87e528289b6abd9083df2323 | https://github.com/pierrec/node-atok/blob/abe139e7fa8c092d87e528289b6abd9083df2323/lib/subrule.js#L603-L645 |
56,747 | hillscottc/nostra | src/sentence_mgr.js | encounter | function encounter(mood) {
//Sentence 1: The meeting
const familiar_people = wordLib.getWords("familiar_people");
const strange_people = wordLib.getWords("strange_people");
const locations = wordLib.getWords("locations");
const person = nu.chooseFrom(familiar_people.concat(strange_people));
let location =... | javascript | function encounter(mood) {
//Sentence 1: The meeting
const familiar_people = wordLib.getWords("familiar_people");
const strange_people = wordLib.getWords("strange_people");
const locations = wordLib.getWords("locations");
const person = nu.chooseFrom(familiar_people.concat(strange_people));
let location =... | [
"function",
"encounter",
"(",
"mood",
")",
"{",
"//Sentence 1: The meeting",
"const",
"familiar_people",
"=",
"wordLib",
".",
"getWords",
"(",
"\"familiar_people\"",
")",
";",
"const",
"strange_people",
"=",
"wordLib",
".",
"getWords",
"(",
"\"strange_people\"",
")"... | Generate a few sentences about a meeting with another person.
@param mood | [
"Generate",
"a",
"few",
"sentences",
"about",
"a",
"meeting",
"with",
"another",
"person",
"."
] | 1801c8e19f7fab91dd29fea07195789d41624915 | https://github.com/hillscottc/nostra/blob/1801c8e19f7fab91dd29fea07195789d41624915/src/sentence_mgr.js#L38-L76 |
56,748 | hillscottc/nostra | src/sentence_mgr.js | feeling | function feeling(mood) {
const rnum = Math.floor(Math.random() * 10);
const adjectives = wordLib.getWords(mood + "_feeling_adjs");
//var degrees = getWords("neutral_degrees") + getWords(mood + "_degrees");
const degrees = wordLib.getWords("neutral_degrees").concat(wordLib.getWords(mood + "_degrees"));
const ... | javascript | function feeling(mood) {
const rnum = Math.floor(Math.random() * 10);
const adjectives = wordLib.getWords(mood + "_feeling_adjs");
//var degrees = getWords("neutral_degrees") + getWords(mood + "_degrees");
const degrees = wordLib.getWords("neutral_degrees").concat(wordLib.getWords(mood + "_degrees"));
const ... | [
"function",
"feeling",
"(",
"mood",
")",
"{",
"const",
"rnum",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"10",
")",
";",
"const",
"adjectives",
"=",
"wordLib",
".",
"getWords",
"(",
"mood",
"+",
"\"_feeling_adjs\"",
")",
"... | A mood-based feeling
@param mood
@returns {*} | [
"A",
"mood",
"-",
"based",
"feeling"
] | 1801c8e19f7fab91dd29fea07195789d41624915 | https://github.com/hillscottc/nostra/blob/1801c8e19f7fab91dd29fea07195789d41624915/src/sentence_mgr.js#L83-L101 |
56,749 | angeloocana/joj-core | dist-esnext/Move.js | getGameAfterMove | function getGameAfterMove(game, move, backMove = false) {
if (!backMove && canNotMove(game, move))
return game;
const board = getBoardAfterMove(game.board, move);
return {
players: game.players,
board,
score: Score.getScore(game.board),
moves: backMove ? game.moves : ... | javascript | function getGameAfterMove(game, move, backMove = false) {
if (!backMove && canNotMove(game, move))
return game;
const board = getBoardAfterMove(game.board, move);
return {
players: game.players,
board,
score: Score.getScore(game.board),
moves: backMove ? game.moves : ... | [
"function",
"getGameAfterMove",
"(",
"game",
",",
"move",
",",
"backMove",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"backMove",
"&&",
"canNotMove",
"(",
"game",
",",
"move",
")",
")",
"return",
"game",
";",
"const",
"board",
"=",
"getBoardAfterMove",
"(",... | Takes game and move then returns new game after move.
Updates:
- .board (It cleans board, set new positions and move breadcrumb)
- .score
- .moves (add new move if valid and it is not backMove) | [
"Takes",
"game",
"and",
"move",
"then",
"returns",
"new",
"game",
"after",
"move",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist-esnext/Move.js#L69-L79 |
56,750 | angeloocana/joj-core | dist-esnext/Move.js | getGameBeforeLastMove | function getGameBeforeLastMove(game) {
// $Fix I do NOT know if it is the best way to make game immutable.
game = Object.assign({}, game);
let lastMove = game.moves.pop();
if (lastMove)
game = getGameAfterMove(game, getBackMove(lastMove), true);
if (Game.getPlayerTurn(game).isAi) {
l... | javascript | function getGameBeforeLastMove(game) {
// $Fix I do NOT know if it is the best way to make game immutable.
game = Object.assign({}, game);
let lastMove = game.moves.pop();
if (lastMove)
game = getGameAfterMove(game, getBackMove(lastMove), true);
if (Game.getPlayerTurn(game).isAi) {
l... | [
"function",
"getGameBeforeLastMove",
"(",
"game",
")",
"{",
"// $Fix I do NOT know if it is the best way to make game immutable.",
"game",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"game",
")",
";",
"let",
"lastMove",
"=",
"game",
".",
"moves",
".",
"pop",... | Get game before last move,
if playing vs Ai rollback Ai move too. | [
"Get",
"game",
"before",
"last",
"move",
"if",
"playing",
"vs",
"Ai",
"rollback",
"Ai",
"move",
"too",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist-esnext/Move.js#L84-L97 |
56,751 | evaisse/wiresrc | lib/detect.js | function (config) {
/**
* The iterator function, which is called on each component.
*
* @param {string} version the version of the component
* @param {string} component the name of the component
* @return {undefined}
*/
return function (version, component) {
var dep =... | javascript | function (config) {
/**
* The iterator function, which is called on each component.
*
* @param {string} version the version of the component
* @param {string} component the name of the component
* @return {undefined}
*/
return function (version, component) {
var dep =... | [
"function",
"(",
"config",
")",
"{",
"/**\n * The iterator function, which is called on each component.\n *\n * @param {string} version the version of the component\n * @param {string} component the name of the component\n * @return {undefined}\n */",
"return",
"function"... | Store the information our prioritizer will need to determine rank.
@param {object} config the global configuration object
@return {function} the iterator function, called on every component | [
"Store",
"the",
"information",
"our",
"prioritizer",
"will",
"need",
"to",
"determine",
"rank",
"."
] | 73b6e8b25bca095d665bf85478429996613f88a3 | https://github.com/evaisse/wiresrc/blob/73b6e8b25bca095d665bf85478429996613f88a3/lib/detect.js#L78-L140 | |
56,752 | evaisse/wiresrc | lib/detect.js | function (a, b) {
var aNeedsB = false;
var bNeedsA = false;
aNeedsB = Object.
keys(a.dependencies).
some(function (dependency) {
return dependency === b.name;
});
if (aNeedsB) {
return 1;
}
bNeedsA = Object.
keys(b.dependencies).
some(function (dependency) ... | javascript | function (a, b) {
var aNeedsB = false;
var bNeedsA = false;
aNeedsB = Object.
keys(a.dependencies).
some(function (dependency) {
return dependency === b.name;
});
if (aNeedsB) {
return 1;
}
bNeedsA = Object.
keys(b.dependencies).
some(function (dependency) ... | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"aNeedsB",
"=",
"false",
";",
"var",
"bNeedsA",
"=",
"false",
";",
"aNeedsB",
"=",
"Object",
".",
"keys",
"(",
"a",
".",
"dependencies",
")",
".",
"some",
"(",
"function",
"(",
"dependency",
")",
"{"... | Compare two dependencies to determine priority.
@param {object} a dependency a
@param {object} b dependency b
@return {number} the priority of dependency a in comparison to dependency b | [
"Compare",
"two",
"dependencies",
"to",
"determine",
"priority",
"."
] | 73b6e8b25bca095d665bf85478429996613f88a3 | https://github.com/evaisse/wiresrc/blob/73b6e8b25bca095d665bf85478429996613f88a3/lib/detect.js#L150-L175 | |
56,753 | evaisse/wiresrc | lib/detect.js | function (left, right) {
var result = [];
var leftIndex = 0;
var rightIndex = 0;
while (leftIndex < left.length && rightIndex < right.length) {
if (dependencyComparator(left[leftIndex], right[rightIndex]) < 1) {
result.push(left[leftIndex++]);
} else {
result.pus... | javascript | function (left, right) {
var result = [];
var leftIndex = 0;
var rightIndex = 0;
while (leftIndex < left.length && rightIndex < right.length) {
if (dependencyComparator(left[leftIndex], right[rightIndex]) < 1) {
result.push(left[leftIndex++]);
} else {
result.pus... | [
"function",
"(",
"left",
",",
"right",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"leftIndex",
"=",
"0",
";",
"var",
"rightIndex",
"=",
"0",
";",
"while",
"(",
"leftIndex",
"<",
"left",
".",
"length",
"&&",
"rightIndex",
"<",
"right",
".... | Take two arrays, sort based on their dependency relationship, then merge them
together.
@param {array} left
@param {array} right
@return {array} the sorted, merged array | [
"Take",
"two",
"arrays",
"sort",
"based",
"on",
"their",
"dependency",
"relationship",
"then",
"merge",
"them",
"together",
"."
] | 73b6e8b25bca095d665bf85478429996613f88a3 | https://github.com/evaisse/wiresrc/blob/73b6e8b25bca095d665bf85478429996613f88a3/lib/detect.js#L186-L202 | |
56,754 | evaisse/wiresrc | lib/detect.js | function (items) {
if (items.length < 2) {
return items;
}
var middle = Math.floor(items.length / 2);
return merge(
mergeSort(items.slice(0, middle)),
mergeSort(items.slice(middle))
);
} | javascript | function (items) {
if (items.length < 2) {
return items;
}
var middle = Math.floor(items.length / 2);
return merge(
mergeSort(items.slice(0, middle)),
mergeSort(items.slice(middle))
);
} | [
"function",
"(",
"items",
")",
"{",
"if",
"(",
"items",
".",
"length",
"<",
"2",
")",
"{",
"return",
"items",
";",
"}",
"var",
"middle",
"=",
"Math",
".",
"floor",
"(",
"items",
".",
"length",
"/",
"2",
")",
";",
"return",
"merge",
"(",
"mergeSor... | Take an array and slice it in halves, sorting each half along the way.
@param {array} items
@return {array} the sorted array | [
"Take",
"an",
"array",
"and",
"slice",
"it",
"in",
"halves",
"sorting",
"each",
"half",
"along",
"the",
"way",
"."
] | 73b6e8b25bca095d665bf85478429996613f88a3 | https://github.com/evaisse/wiresrc/blob/73b6e8b25bca095d665bf85478429996613f88a3/lib/detect.js#L211-L222 | |
56,755 | evaisse/wiresrc | lib/detect.js | function (allDependencies, patterns) {
return _.transform(allDependencies, function (result, dependencies, fileType) {
result[fileType] = _.reject(dependencies, function (dependency) {
return _.find(patterns, function (pattern) {
return dependency.match(pattern);
});
... | javascript | function (allDependencies, patterns) {
return _.transform(allDependencies, function (result, dependencies, fileType) {
result[fileType] = _.reject(dependencies, function (dependency) {
return _.find(patterns, function (pattern) {
return dependency.match(pattern);
});
... | [
"function",
"(",
"allDependencies",
",",
"patterns",
")",
"{",
"return",
"_",
".",
"transform",
"(",
"allDependencies",
",",
"function",
"(",
"result",
",",
"dependencies",
",",
"fileType",
")",
"{",
"result",
"[",
"fileType",
"]",
"=",
"_",
".",
"reject",... | Excludes dependencies that match any of the patterns.
@param {array} allDependencies array of dependencies to filter
@param {array} patterns array of patterns to match against
@return {array} items that don't match any of the patterns | [
"Excludes",
"dependencies",
"that",
"match",
"any",
"of",
"the",
"patterns",
"."
] | 73b6e8b25bca095d665bf85478429996613f88a3 | https://github.com/evaisse/wiresrc/blob/73b6e8b25bca095d665bf85478429996613f88a3/lib/detect.js#L279-L287 | |
56,756 | tether/methodd | index.js | proxy | function proxy (original, routes) {
return new Proxy(original, {
get(target, key, receiver) {
const method = target[key]
if (method) return method
else return function (path, ...args) {
const cb = args[0]
if (typeof cb === 'function') {
original.add(key, path, cb)
... | javascript | function proxy (original, routes) {
return new Proxy(original, {
get(target, key, receiver) {
const method = target[key]
if (method) return method
else return function (path, ...args) {
const cb = args[0]
if (typeof cb === 'function') {
original.add(key, path, cb)
... | [
"function",
"proxy",
"(",
"original",
",",
"routes",
")",
"{",
"return",
"new",
"Proxy",
"(",
"original",
",",
"{",
"get",
"(",
"target",
",",
"key",
",",
"receiver",
")",
"{",
"const",
"method",
"=",
"target",
"[",
"key",
"]",
"if",
"(",
"method",
... | Proxy function with router.
@param {Function} original
@param {Object} routes
@api private | [
"Proxy",
"function",
"with",
"router",
"."
] | 1604ffb43e28742003ea74c080d936e5a4f203fd | https://github.com/tether/methodd/blob/1604ffb43e28742003ea74c080d936e5a4f203fd/index.js#L98-L114 |
56,757 | YusukeHirao/sceg | lib/fn/gen.js | gen | function gen(path) {
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var config = assignConfig_1.default(option, path);
return globElements_1.default(config).then(readElements_1.default(config)).then(optimize_1.default()).then(render_1.default(config));
} | javascript | function gen(path) {
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var config = assignConfig_1.default(option, path);
return globElements_1.default(config).then(readElements_1.default(config)).then(optimize_1.default()).then(render_1.default(config));
} | [
"function",
"gen",
"(",
"path",
")",
"{",
"var",
"option",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"{",
"}",
";",
"var",
"config",
"=",
"assignConfig_1",
... | Generate guide page from elements
@param path Paths of element files that glob pattern
@param option Optional configure
@return rendered HTML string | [
"Generate",
"guide",
"page",
"from",
"elements"
] | 4cde1e56d48dd3b604cc2ddff36b2e9de3348771 | https://github.com/YusukeHirao/sceg/blob/4cde1e56d48dd3b604cc2ddff36b2e9de3348771/lib/fn/gen.js#L16-L21 |
56,758 | oliversalzburg/strider-modern-extensions | lib/proxy.js | toStriderProxy | function toStriderProxy(instance) {
debug(`Proxying async plugin: ${instance.constructor.name}`);
const functionsInInstance = Object.getOwnPropertyNames(Object.getPrototypeOf(instance)).filter(propertyName => {
return typeof instance[propertyName] === 'function' && propertyName !== 'constructor';
});
func... | javascript | function toStriderProxy(instance) {
debug(`Proxying async plugin: ${instance.constructor.name}`);
const functionsInInstance = Object.getOwnPropertyNames(Object.getPrototypeOf(instance)).filter(propertyName => {
return typeof instance[propertyName] === 'function' && propertyName !== 'constructor';
});
func... | [
"function",
"toStriderProxy",
"(",
"instance",
")",
"{",
"debug",
"(",
"`",
"${",
"instance",
".",
"constructor",
".",
"name",
"}",
"`",
")",
";",
"const",
"functionsInInstance",
"=",
"Object",
".",
"getOwnPropertyNames",
"(",
"Object",
".",
"getPrototypeOf",
... | Given an input object, replaces all functions on that object with node-style callback equivalents.
The methods are expected to return promises. It's kind of like a reverse-promisifyAll.
The original methods are available by their old name with "Async" appended.
@param {Object} instance
@returns {Object} | [
"Given",
"an",
"input",
"object",
"replaces",
"all",
"functions",
"on",
"that",
"object",
"with",
"node",
"-",
"style",
"callback",
"equivalents",
".",
"The",
"methods",
"are",
"expected",
"to",
"return",
"promises",
".",
"It",
"s",
"kind",
"of",
"like",
"... | f8c37e49af1f05e34c66afff71d977e4b316289b | https://github.com/oliversalzburg/strider-modern-extensions/blob/f8c37e49af1f05e34c66afff71d977e4b316289b/lib/proxy.js#L15-L41 |
56,759 | phated/grunt-enyo | tasks/init/enyo/root/enyo/source/touch/Thumb.js | function(inShowing) {
if (inShowing && inShowing != this.showing) {
if (this.scrollBounds[this.sizeDimension] >= this.scrollBounds[this.dimension]) {
return;
}
}
if (this.hasNode()) {
this.cancelDelayHide();
}
if (inShowing != this.showing) {
var last = this.showing;
this.showing = inShowin... | javascript | function(inShowing) {
if (inShowing && inShowing != this.showing) {
if (this.scrollBounds[this.sizeDimension] >= this.scrollBounds[this.dimension]) {
return;
}
}
if (this.hasNode()) {
this.cancelDelayHide();
}
if (inShowing != this.showing) {
var last = this.showing;
this.showing = inShowin... | [
"function",
"(",
"inShowing",
")",
"{",
"if",
"(",
"inShowing",
"&&",
"inShowing",
"!=",
"this",
".",
"showing",
")",
"{",
"if",
"(",
"this",
".",
"scrollBounds",
"[",
"this",
".",
"sizeDimension",
"]",
">=",
"this",
".",
"scrollBounds",
"[",
"this",
"... | implement set because showing is not changed while we delayHide but we want to cancel the hide. | [
"implement",
"set",
"because",
"showing",
"is",
"not",
"changed",
"while",
"we",
"delayHide",
"but",
"we",
"want",
"to",
"cancel",
"the",
"hide",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/touch/Thumb.js#L88-L102 | |
56,760 | jharding/yapawapa | lib/utils.js | extend | function extend(obj) {
var slice = Array.prototype.slice;
slice.call(arguments, 1).forEach(function(source) {
var getter
, setter;
for (var key in source) {
getter = source.__lookupGetter__(key);
setter = source.__lookupSetter__(key);
if (getter || setter) {
getter && obj.... | javascript | function extend(obj) {
var slice = Array.prototype.slice;
slice.call(arguments, 1).forEach(function(source) {
var getter
, setter;
for (var key in source) {
getter = source.__lookupGetter__(key);
setter = source.__lookupSetter__(key);
if (getter || setter) {
getter && obj.... | [
"function",
"extend",
"(",
"obj",
")",
"{",
"var",
"slice",
"=",
"Array",
".",
"prototype",
".",
"slice",
";",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
".",
"forEach",
"(",
"function",
"(",
"source",
")",
"{",
"var",
"getter",
",",
"s... | roll custom extend since underscore's doesn't play nice with getters and setters | [
"roll",
"custom",
"extend",
"since",
"underscore",
"s",
"doesn",
"t",
"play",
"nice",
"with",
"getters",
"and",
"setters"
] | 18816447a9fcfbe744cadf2d6f0fdceca443c05f | https://github.com/jharding/yapawapa/blob/18816447a9fcfbe744cadf2d6f0fdceca443c05f/lib/utils.js#L12-L35 |
56,761 | Industryswarm/isnode-mod-data | lib/mongodb/mongodb-core/lib/sdam/cursor.js | setCursorDeadAndNotified | function setCursorDeadAndNotified(cursor, callback) {
cursor.s.dead = true;
setCursorNotified(cursor, callback);
} | javascript | function setCursorDeadAndNotified(cursor, callback) {
cursor.s.dead = true;
setCursorNotified(cursor, callback);
} | [
"function",
"setCursorDeadAndNotified",
"(",
"cursor",
",",
"callback",
")",
"{",
"cursor",
".",
"s",
".",
"dead",
"=",
"true",
";",
"setCursorNotified",
"(",
"cursor",
",",
"callback",
")",
";",
"}"
] | Mark cursor as being dead and notified | [
"Mark",
"cursor",
"as",
"being",
"dead",
"and",
"notified"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb-core/lib/sdam/cursor.js#L523-L526 |
56,762 | TribeMedia/tribemedia-kurento-client-core | lib/complexTypes/RTCOutboundRTPStreamStats.js | RTCOutboundRTPStreamStats | function RTCOutboundRTPStreamStats(rTCOutboundRTPStreamStatsDict){
if(!(this instanceof RTCOutboundRTPStreamStats))
return new RTCOutboundRTPStreamStats(rTCOutboundRTPStreamStatsDict)
// Check rTCOutboundRTPStreamStatsDict has the required fields
checkType('int', 'rTCOutboundRTPStreamStatsDict.packetsSent', ... | javascript | function RTCOutboundRTPStreamStats(rTCOutboundRTPStreamStatsDict){
if(!(this instanceof RTCOutboundRTPStreamStats))
return new RTCOutboundRTPStreamStats(rTCOutboundRTPStreamStatsDict)
// Check rTCOutboundRTPStreamStatsDict has the required fields
checkType('int', 'rTCOutboundRTPStreamStatsDict.packetsSent', ... | [
"function",
"RTCOutboundRTPStreamStats",
"(",
"rTCOutboundRTPStreamStatsDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"RTCOutboundRTPStreamStats",
")",
")",
"return",
"new",
"RTCOutboundRTPStreamStats",
"(",
"rTCOutboundRTPStreamStatsDict",
")",
"// Check rTCO... | Statistics that represents the measurement metrics for the outgoing media
stream.
@constructor module:core/complexTypes.RTCOutboundRTPStreamStats
@property {external:Integer} packetsSent
Total number of RTP packets sent for this SSRC.
@property {external:Integer} bytesSent
Total number of bytes sent for this SSRC.
@p... | [
"Statistics",
"that",
"represents",
"the",
"measurement",
"metrics",
"for",
"the",
"outgoing",
"media",
"stream",
"."
] | de4c0094644aae91320e330f9cea418a3ac55468 | https://github.com/TribeMedia/tribemedia-kurento-client-core/blob/de4c0094644aae91320e330f9cea418a3ac55468/lib/complexTypes/RTCOutboundRTPStreamStats.js#L45-L81 |
56,763 | pinyin/outline | vendor/transformation-matrix/inverse.js | inverse | function inverse(matrix) {
//http://www.wolframalpha.com/input/?i=Inverse+%5B%7B%7Ba,c,e%7D,%7Bb,d,f%7D,%7B0,0,1%7D%7D%5D
var a = matrix.a,
b = matrix.b,
c = matrix.c,
d = matrix.d,
e = matrix.e,
f = matrix.f;
var denom = a * d - b * c;
return {
a: d /... | javascript | function inverse(matrix) {
//http://www.wolframalpha.com/input/?i=Inverse+%5B%7B%7Ba,c,e%7D,%7Bb,d,f%7D,%7B0,0,1%7D%7D%5D
var a = matrix.a,
b = matrix.b,
c = matrix.c,
d = matrix.d,
e = matrix.e,
f = matrix.f;
var denom = a * d - b * c;
return {
a: d /... | [
"function",
"inverse",
"(",
"matrix",
")",
"{",
"//http://www.wolframalpha.com/input/?i=Inverse+%5B%7B%7Ba,c,e%7D,%7Bb,d,f%7D,%7B0,0,1%7D%7D%5D",
"var",
"a",
"=",
"matrix",
".",
"a",
",",
"b",
"=",
"matrix",
".",
"b",
",",
"c",
"=",
"matrix",
".",
"c",
",",
"d",
... | Calculate a matrix that is the inverse of the provided matrix
@param matrix Affine matrix
@returns {{a: number, b: number, c: number, e: number, d: number, f: number}} Affine matrix | [
"Calculate",
"a",
"matrix",
"that",
"is",
"the",
"inverse",
"of",
"the",
"provided",
"matrix"
] | e49f05d2f8ab384f5b1d71b2b10875cd48d41051 | https://github.com/pinyin/outline/blob/e49f05d2f8ab384f5b1d71b2b10875cd48d41051/vendor/transformation-matrix/inverse.js#L13-L34 |
56,764 | brianloveswords/gogo | lib/ext-underscore.js | curry | function curry(fn, obj) {
// create a local copy of the function. don't apply anything yet
// optionally bind an object to the `this` of the function.
var newFunction = _.bind(fn, (obj || null));
// curried functions always take one argument
return function () {
// create another copy of the function wit... | javascript | function curry(fn, obj) {
// create a local copy of the function. don't apply anything yet
// optionally bind an object to the `this` of the function.
var newFunction = _.bind(fn, (obj || null));
// curried functions always take one argument
return function () {
// create another copy of the function wit... | [
"function",
"curry",
"(",
"fn",
",",
"obj",
")",
"{",
"// create a local copy of the function. don't apply anything yet",
"// optionally bind an object to the `this` of the function.",
"var",
"newFunction",
"=",
"_",
".",
"bind",
"(",
"fn",
",",
"(",
"obj",
"||",
"null",
... | this takes advantage of ES5 bind's awesome ability to do partial application | [
"this",
"takes",
"advantage",
"of",
"ES5",
"bind",
"s",
"awesome",
"ability",
"to",
"do",
"partial",
"application"
] | f17ee794e0439ed961907f52b91bcb74dcca351a | https://github.com/brianloveswords/gogo/blob/f17ee794e0439ed961907f52b91bcb74dcca351a/lib/ext-underscore.js#L21-L38 |
56,765 | brianloveswords/gogo | lib/ext-underscore.js | function (o, path) {
function iterator(m, p) { return _.getv(p)(m); }
return _.reduce(path, iterator, o);
} | javascript | function (o, path) {
function iterator(m, p) { return _.getv(p)(m); }
return _.reduce(path, iterator, o);
} | [
"function",
"(",
"o",
",",
"path",
")",
"{",
"function",
"iterator",
"(",
"m",
",",
"p",
")",
"{",
"return",
"_",
".",
"getv",
"(",
"p",
")",
"(",
"m",
")",
";",
"}",
"return",
"_",
".",
"reduce",
"(",
"path",
",",
"iterator",
",",
"o",
")",
... | perform a root canal on an object. depends on getv | [
"perform",
"a",
"root",
"canal",
"on",
"an",
"object",
".",
"depends",
"on",
"getv"
] | f17ee794e0439ed961907f52b91bcb74dcca351a | https://github.com/brianloveswords/gogo/blob/f17ee794e0439ed961907f52b91bcb74dcca351a/lib/ext-underscore.js#L65-L68 | |
56,766 | brianloveswords/gogo | lib/ext-underscore.js | function (a) {
var elements = _.reject(_.rest(arguments), _.isMissing);
return a.push.apply(a, elements);
} | javascript | function (a) {
var elements = _.reject(_.rest(arguments), _.isMissing);
return a.push.apply(a, elements);
} | [
"function",
"(",
"a",
")",
"{",
"var",
"elements",
"=",
"_",
".",
"reject",
"(",
"_",
".",
"rest",
"(",
"arguments",
")",
",",
"_",
".",
"isMissing",
")",
";",
"return",
"a",
".",
"push",
".",
"apply",
"(",
"a",
",",
"elements",
")",
";",
"}"
] | push only defined elements to the array | [
"push",
"only",
"defined",
"elements",
"to",
"the",
"array"
] | f17ee794e0439ed961907f52b91bcb74dcca351a | https://github.com/brianloveswords/gogo/blob/f17ee794e0439ed961907f52b91bcb74dcca351a/lib/ext-underscore.js#L119-L122 | |
56,767 | inlight-media/gulp-asset | index.js | function(opts) {
var opts = opts || {};
var shouldHash = typeof opts.hash != 'undefined' ? opts.hash : defaults.hash;
var prefix = _.flatten([defaults.prefix]);
var shouldPrefix = typeof opts.shouldPrefix != 'undefined' ? opts.shouldPrefix : true;
return through.obj(function(file, enc, cb) {
var originalPath = f... | javascript | function(opts) {
var opts = opts || {};
var shouldHash = typeof opts.hash != 'undefined' ? opts.hash : defaults.hash;
var prefix = _.flatten([defaults.prefix]);
var shouldPrefix = typeof opts.shouldPrefix != 'undefined' ? opts.shouldPrefix : true;
return through.obj(function(file, enc, cb) {
var originalPath = f... | [
"function",
"(",
"opts",
")",
"{",
"var",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"shouldHash",
"=",
"typeof",
"opts",
".",
"hash",
"!=",
"'undefined'",
"?",
"opts",
".",
"hash",
":",
"defaults",
".",
"hash",
";",
"var",
"prefix",
"=",
"_"... | Gets md5 from file contents and writes new filename with hash included to destinations | [
"Gets",
"md5",
"from",
"file",
"contents",
"and",
"writes",
"new",
"filename",
"with",
"hash",
"included",
"to",
"destinations"
] | 13cbd41def828c9af1de50d44b753e1bf05c3916 | https://github.com/inlight-media/gulp-asset/blob/13cbd41def828c9af1de50d44b753e1bf05c3916/index.js#L85-L139 | |
56,768 | nil/options-config | src/index.js | validateValue | function validateValue(key, valObj, list) {
let type; let valid; let range; let regex;
const object = list[key];
const val = hasKey(valObj, key) ? valObj[key] : 'value_not_defined';
let defaultValue = object;
if (object) {
type = object.type;
valid = object.valid;
range = object.range;
regex... | javascript | function validateValue(key, valObj, list) {
let type; let valid; let range; let regex;
const object = list[key];
const val = hasKey(valObj, key) ? valObj[key] : 'value_not_defined';
let defaultValue = object;
if (object) {
type = object.type;
valid = object.valid;
range = object.range;
regex... | [
"function",
"validateValue",
"(",
"key",
",",
"valObj",
",",
"list",
")",
"{",
"let",
"type",
";",
"let",
"valid",
";",
"let",
"range",
";",
"let",
"regex",
";",
"const",
"object",
"=",
"list",
"[",
"key",
"]",
";",
"const",
"val",
"=",
"hasKey",
"... | Checks if a value fits the restrictions.
@param {string} key - The name of the option
@param {object} valObj - The value to check.
@param {object} list - The replacement restrictions.
@returns A value, whether it is the default or the given by the user. | [
"Checks",
"if",
"a",
"value",
"fits",
"the",
"restrictions",
"."
] | 40fb5011d3d931913318d7e852c029ab816885b8 | https://github.com/nil/options-config/blob/40fb5011d3d931913318d7e852c029ab816885b8/src/index.js#L19-L52 |
56,769 | dekujs/assert-element | index.js | classes | function classes(input) {
if (!input) return [];
assert.strictEqual(typeof input, 'string', 'expected a string for the class name');
if (!input.trim()) return [];
return input.trim().split(/\s+/g);
} | javascript | function classes(input) {
if (!input) return [];
assert.strictEqual(typeof input, 'string', 'expected a string for the class name');
if (!input.trim()) return [];
return input.trim().split(/\s+/g);
} | [
"function",
"classes",
"(",
"input",
")",
"{",
"if",
"(",
"!",
"input",
")",
"return",
"[",
"]",
";",
"assert",
".",
"strictEqual",
"(",
"typeof",
"input",
",",
"'string'",
",",
"'expected a string for the class name'",
")",
";",
"if",
"(",
"!",
"input",
... | private helpers
Parse the given `input` into an `Array` of class names. Will always return
an `Array`, even if it's empty.
@param {String} [input] The class attribute string.
@return {Array} | [
"private",
"helpers",
"Parse",
"the",
"given",
"input",
"into",
"an",
"Array",
"of",
"class",
"names",
".",
"Will",
"always",
"return",
"an",
"Array",
"even",
"if",
"it",
"s",
"empty",
"."
] | a275c98825249101f0e790635a1d33b300b16bc1 | https://github.com/dekujs/assert-element/blob/a275c98825249101f0e790635a1d33b300b16bc1/index.js#L162-L167 |
56,770 | dekujs/assert-element | index.js | deepChild | function deepChild(root, path) {
return path.reduce(function (node, index, x) {
assert(index in node.children, 'child does not exist at the given deep index ' + path.join('.'));
return node.children[index];
}, root);
} | javascript | function deepChild(root, path) {
return path.reduce(function (node, index, x) {
assert(index in node.children, 'child does not exist at the given deep index ' + path.join('.'));
return node.children[index];
}, root);
} | [
"function",
"deepChild",
"(",
"root",
",",
"path",
")",
"{",
"return",
"path",
".",
"reduce",
"(",
"function",
"(",
"node",
",",
"index",
",",
"x",
")",
"{",
"assert",
"(",
"index",
"in",
"node",
".",
"children",
",",
"'child does not exist at the given de... | Retrieve a deep child via an input array `index` of indices to traverse.
@param {Object} node The virtual node to traverse.
@param {Array:Number} path The path to traverse.
@return {Object} | [
"Retrieve",
"a",
"deep",
"child",
"via",
"an",
"input",
"array",
"index",
"of",
"indices",
"to",
"traverse",
"."
] | a275c98825249101f0e790635a1d33b300b16bc1 | https://github.com/dekujs/assert-element/blob/a275c98825249101f0e790635a1d33b300b16bc1/index.js#L177-L182 |
56,771 | mhelgeson/b9 | src/post/index.js | handler | function handler ( err, data ){
if ( callback != null ){
callback.apply( b9, arguments );
}
// only emit events when there is no error
if ( err == null ){
b9.emit.call( b9, method, data );
}
} | javascript | function handler ( err, data ){
if ( callback != null ){
callback.apply( b9, arguments );
}
// only emit events when there is no error
if ( err == null ){
b9.emit.call( b9, method, data );
}
} | [
"function",
"handler",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"callback",
".",
"apply",
"(",
"b9",
",",
"arguments",
")",
";",
"}",
"// only emit events when there is no error",
"if",
"(",
"err",
"==",
"null",
"... | wrap callback with an event emitter | [
"wrap",
"callback",
"with",
"an",
"event",
"emitter"
] | 5f7ad9ac7c3fa586b06f6460b70a42c50b34e6f1 | https://github.com/mhelgeson/b9/blob/5f7ad9ac7c3fa586b06f6460b70a42c50b34e6f1/src/post/index.js#L54-L62 |
56,772 | mgesmundo/port-manager | lib/service.js | Service | function Service(manager, name, port, heartbeat) {
var _name = name;
/**
* @property {String} name The name of the service
*/
Object.defineProperty(this, 'name', {
get: function get() {
return _name;
},
enumerable: true
});
var _port = port;
/**
* @property {Number} port The port ... | javascript | function Service(manager, name, port, heartbeat) {
var _name = name;
/**
* @property {String} name The name of the service
*/
Object.defineProperty(this, 'name', {
get: function get() {
return _name;
},
enumerable: true
});
var _port = port;
/**
* @property {Number} port The port ... | [
"function",
"Service",
"(",
"manager",
",",
"name",
",",
"port",
",",
"heartbeat",
")",
"{",
"var",
"_name",
"=",
"name",
";",
"/**\n * @property {String} name The name of the service\n */",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'name'",
",",
"{"... | The service to manage
@class node_modules.port_manager.Service
@param {Manager} manager The manager instance that store all services
@param {String} name The name of the service
@param {Number} port The port claimed by the service
@param {Number} [heartbeat] The heartbeat timer
@constructor | [
"The",
"service",
"to",
"manage"
] | a09356b9063c228616d0ffc56217b93c479f2604 | https://github.com/mgesmundo/port-manager/blob/a09356b9063c228616d0ffc56217b93c479f2604/lib/service.js#L29-L63 |
56,773 | rranauro/boxspringjs | workflows.js | function(docs, callback) {
remaining = docs;
console.log('[ remove ] info: ' + remaining +' to remove.');
async.eachLimit(_.range(0, docs, 10000), 1, handleOneBlock, callback);
} | javascript | function(docs, callback) {
remaining = docs;
console.log('[ remove ] info: ' + remaining +' to remove.');
async.eachLimit(_.range(0, docs, 10000), 1, handleOneBlock, callback);
} | [
"function",
"(",
"docs",
",",
"callback",
")",
"{",
"remaining",
"=",
"docs",
";",
"console",
".",
"log",
"(",
"'[ remove ] info: '",
"+",
"remaining",
"+",
"' to remove.'",
")",
";",
"async",
".",
"eachLimit",
"(",
"_",
".",
"range",
"(",
"0",
",",
"d... | fetch the 'removeView' list; returns array of objects marked "_deleted" | [
"fetch",
"the",
"removeView",
"list",
";",
"returns",
"array",
"of",
"objects",
"marked",
"_deleted"
] | 43fd13ae45ba5b16ba9144084b96748a1cd8c0ea | https://github.com/rranauro/boxspringjs/blob/43fd13ae45ba5b16ba9144084b96748a1cd8c0ea/workflows.js#L83-L87 | |
56,774 | CCISEL/connect-controller | example/lib/controllers/favorites.js | function(teamId, req) {
const favoritesList = req.app.locals.favoritesList
const index = favoritesList.findIndex(t => t.id == teamId)
if(index < 0) {
const err = new Error('Team is not parte of Favorites!!!')
err.status = 409
throw err
}
... | javascript | function(teamId, req) {
const favoritesList = req.app.locals.favoritesList
const index = favoritesList.findIndex(t => t.id == teamId)
if(index < 0) {
const err = new Error('Team is not parte of Favorites!!!')
err.status = 409
throw err
}
... | [
"function",
"(",
"teamId",
",",
"req",
")",
"{",
"const",
"favoritesList",
"=",
"req",
".",
"app",
".",
"locals",
".",
"favoritesList",
"const",
"index",
"=",
"favoritesList",
".",
"findIndex",
"(",
"t",
"=>",
"t",
".",
"id",
"==",
"teamId",
")",
"if",... | This is a synchronous action that does not do any IO.
Simply returning with NO exceptions just means success and
connect-controller will send a 200 response status. | [
"This",
"is",
"a",
"synchronous",
"action",
"that",
"does",
"not",
"do",
"any",
"IO",
".",
"Simply",
"returning",
"with",
"NO",
"exceptions",
"just",
"means",
"success",
"and",
"connect",
"-",
"controller",
"will",
"send",
"a",
"200",
"response",
"status",
... | c8e2587c5a31e3cb54e3668c4b98b7b7526d69b4 | https://github.com/CCISEL/connect-controller/blob/c8e2587c5a31e3cb54e3668c4b98b7b7526d69b4/example/lib/controllers/favorites.js#L34-L43 | |
56,775 | richRemer/twixt-click | click.js | click | function click(target, handler) {
target.addEventListener("click", function(evt) {
evt.stopPropagation();
evt.preventDefault();
handler.call(this);
});
} | javascript | function click(target, handler) {
target.addEventListener("click", function(evt) {
evt.stopPropagation();
evt.preventDefault();
handler.call(this);
});
} | [
"function",
"click",
"(",
"target",
",",
"handler",
")",
"{",
"target",
".",
"addEventListener",
"(",
"\"click\"",
",",
"function",
"(",
"evt",
")",
"{",
"evt",
".",
"stopPropagation",
"(",
")",
";",
"evt",
".",
"preventDefault",
"(",
")",
";",
"handler"... | Attach click event handler.
@param {EventTarget} target
@param {function} handler | [
"Attach",
"click",
"event",
"handler",
"."
] | e3b0574f148c8060b19b1fe4517ede460474e821 | https://github.com/richRemer/twixt-click/blob/e3b0574f148c8060b19b1fe4517ede460474e821/click.js#L6-L12 |
56,776 | fshost/api-chain | api-chain.js | function(name, method) {
API.prototype[name] = function() {
var api = this;
var args = Array.prototype.slice.call(arguments);
this.chain(function(next) {
var cargs = [].slice.call(arguments);
cargs = args.concat(cargs);
// arg... | javascript | function(name, method) {
API.prototype[name] = function() {
var api = this;
var args = Array.prototype.slice.call(arguments);
this.chain(function(next) {
var cargs = [].slice.call(arguments);
cargs = args.concat(cargs);
// arg... | [
"function",
"(",
"name",
",",
"method",
")",
"{",
"API",
".",
"prototype",
"[",
"name",
"]",
"=",
"function",
"(",
")",
"{",
"var",
"api",
"=",
"this",
";",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",... | add a method to the prototype | [
"add",
"a",
"method",
"to",
"the",
"prototype"
] | d98df82575b0a0afd20c10424c0c038389b32f80 | https://github.com/fshost/api-chain/blob/d98df82575b0a0afd20c10424c0c038389b32f80/api-chain.js#L67-L82 | |
56,777 | fshost/api-chain | api-chain.js | function(err) {
if (err) this._onError(err);
if (this._continueErrors || !err) {
var args = [].slice.call(arguments);
if (this._callbacks.length > 0) {
this._isQueueRunning = true;
var cb = this._callbacks.shift();
cb = cb.bind(this... | javascript | function(err) {
if (err) this._onError(err);
if (this._continueErrors || !err) {
var args = [].slice.call(arguments);
if (this._callbacks.length > 0) {
this._isQueueRunning = true;
var cb = this._callbacks.shift();
cb = cb.bind(this... | [
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"this",
".",
"_onError",
"(",
"err",
")",
";",
"if",
"(",
"this",
".",
"_continueErrors",
"||",
"!",
"err",
")",
"{",
"var",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"argume... | advance to next cb | [
"advance",
"to",
"next",
"cb"
] | d98df82575b0a0afd20c10424c0c038389b32f80 | https://github.com/fshost/api-chain/blob/d98df82575b0a0afd20c10424c0c038389b32f80/api-chain.js#L96-L118 | |
56,778 | fshost/api-chain | api-chain.js | function(name, value, immediate) {
if (immediate) {
this[name] = value;
} else this.chain(function() {
var args = Array.prototype.slice.call(arguments);
var next = args.pop();
this[name] = value;
args.unshift(null);
next.apply(this,... | javascript | function(name, value, immediate) {
if (immediate) {
this[name] = value;
} else this.chain(function() {
var args = Array.prototype.slice.call(arguments);
var next = args.pop();
this[name] = value;
args.unshift(null);
next.apply(this,... | [
"function",
"(",
"name",
",",
"value",
",",
"immediate",
")",
"{",
"if",
"(",
"immediate",
")",
"{",
"this",
"[",
"name",
"]",
"=",
"value",
";",
"}",
"else",
"this",
".",
"chain",
"(",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",... | set instance property | [
"set",
"instance",
"property"
] | d98df82575b0a0afd20c10424c0c038389b32f80 | https://github.com/fshost/api-chain/blob/d98df82575b0a0afd20c10424c0c038389b32f80/api-chain.js#L121-L132 | |
56,779 | fshost/api-chain | api-chain.js | function(cb) {
cb = this.wrap(cb);
this._callbacks.push(cb);
if (!this._isQueueRunning) {
if (this.start) {
this.start();
} else this.next();
// this.start();
}
return this;
} | javascript | function(cb) {
cb = this.wrap(cb);
this._callbacks.push(cb);
if (!this._isQueueRunning) {
if (this.start) {
this.start();
} else this.next();
// this.start();
}
return this;
} | [
"function",
"(",
"cb",
")",
"{",
"cb",
"=",
"this",
".",
"wrap",
"(",
"cb",
")",
";",
"this",
".",
"_callbacks",
".",
"push",
"(",
"cb",
")",
";",
"if",
"(",
"!",
"this",
".",
"_isQueueRunning",
")",
"{",
"if",
"(",
"this",
".",
"start",
")",
... | add a callback to the execution chain | [
"add",
"a",
"callback",
"to",
"the",
"execution",
"chain"
] | d98df82575b0a0afd20c10424c0c038389b32f80 | https://github.com/fshost/api-chain/blob/d98df82575b0a0afd20c10424c0c038389b32f80/api-chain.js#L151-L161 | |
56,780 | iolo/node-toybox | async.js | parallel | function parallel(promises, limit) {
var d = Q.defer();
var total = promises.length;
var results = new Array(total);
var firstErr;
var running = 0;
var finished = 0;
var next = 0;
limit = limit || total;
function sched() {
while (next < total && running < limit) {
... | javascript | function parallel(promises, limit) {
var d = Q.defer();
var total = promises.length;
var results = new Array(total);
var firstErr;
var running = 0;
var finished = 0;
var next = 0;
limit = limit || total;
function sched() {
while (next < total && running < limit) {
... | [
"function",
"parallel",
"(",
"promises",
",",
"limit",
")",
"{",
"var",
"d",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"var",
"total",
"=",
"promises",
".",
"length",
";",
"var",
"results",
"=",
"new",
"Array",
"(",
"total",
")",
";",
"var",
"firstErr... | !!debug.enabled;
@param {Array.<promise>} promises
@param {number} [limit]
@returns {promise} | [
"!!debug",
".",
"enabled",
";"
] | d03e48b5e4b3deb022688fee59dd33a2b71819d0 | https://github.com/iolo/node-toybox/blob/d03e48b5e4b3deb022688fee59dd33a2b71819d0/async.js#L15-L59 |
56,781 | Techniv/node-command-io | libs/commandio.js | addCommand | function addCommand(descriptor){
// Check descriptor type.
var err = {};
if( !checkDescriptor(descriptor, err) ){
logger.error(
'The command descriptor is invalid.',
new Error('[command.io] Invalid command descriptor ("'+err.key+'": expected "'+err.expect+'", have "'+err.type+'").')
);
logger.error('Plea... | javascript | function addCommand(descriptor){
// Check descriptor type.
var err = {};
if( !checkDescriptor(descriptor, err) ){
logger.error(
'The command descriptor is invalid.',
new Error('[command.io] Invalid command descriptor ("'+err.key+'": expected "'+err.expect+'", have "'+err.type+'").')
);
logger.error('Plea... | [
"function",
"addCommand",
"(",
"descriptor",
")",
"{",
"// Check descriptor type.",
"var",
"err",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"checkDescriptor",
"(",
"descriptor",
",",
"err",
")",
")",
"{",
"logger",
".",
"error",
"(",
"'The command descriptor is inva... | Add a command
@param name string
@param description string
@param action Function
@returns Object return Command.IO API. | [
"Add",
"a",
"command"
] | 3d3cdfac83b2e14e801a9fc94ced9024c757674f | https://github.com/Techniv/node-command-io/blob/3d3cdfac83b2e14e801a9fc94ced9024c757674f/libs/commandio.js#L122-L142 |
56,782 | Techniv/node-command-io | libs/commandio.js | addCommands | function addCommands(commands){
for(var i in commands){
var commandObj = commands[i];
addCommand(commandObj);
}
return module.exports;
} | javascript | function addCommands(commands){
for(var i in commands){
var commandObj = commands[i];
addCommand(commandObj);
}
return module.exports;
} | [
"function",
"addCommands",
"(",
"commands",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"commands",
")",
"{",
"var",
"commandObj",
"=",
"commands",
"[",
"i",
"]",
";",
"addCommand",
"(",
"commandObj",
")",
";",
"}",
"return",
"module",
".",
"exports",
";",... | Add commands recursively.
@param commands Object[] An array of command descriptor {name: string, description: string, :action: function}.
@return Object Return Command.IO API. | [
"Add",
"commands",
"recursively",
"."
] | 3d3cdfac83b2e14e801a9fc94ced9024c757674f | https://github.com/Techniv/node-command-io/blob/3d3cdfac83b2e14e801a9fc94ced9024c757674f/libs/commandio.js#L149-L156 |
56,783 | Techniv/node-command-io | libs/commandio.js | CommandController | function CommandController(descriptor){
Object.defineProperties(this, {
name: {
get: function(){
return descriptor.name;
}
},
description: {
get: function(){
return descriptor.description;
}
},
CommandError: {
get: function(){
return LocalCommandError;
}
},
RuntimeCommandEr... | javascript | function CommandController(descriptor){
Object.defineProperties(this, {
name: {
get: function(){
return descriptor.name;
}
},
description: {
get: function(){
return descriptor.description;
}
},
CommandError: {
get: function(){
return LocalCommandError;
}
},
RuntimeCommandEr... | [
"function",
"CommandController",
"(",
"descriptor",
")",
"{",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"name",
":",
"{",
"get",
":",
"function",
"(",
")",
"{",
"return",
"descriptor",
".",
"name",
";",
"}",
"}",
",",
"description",
":",
... | CommandIO API to command action.
@param descriptor The command descriptor. | [
"CommandIO",
"API",
"to",
"command",
"action",
"."
] | 3d3cdfac83b2e14e801a9fc94ced9024c757674f | https://github.com/Techniv/node-command-io/blob/3d3cdfac83b2e14e801a9fc94ced9024c757674f/libs/commandio.js#L222-L261 |
56,784 | Techniv/node-command-io | libs/commandio.js | checkDescriptor | function checkDescriptor(descriptor, err){
if(typeof descriptor != 'object') return false;
for(var key in CONST.descriptorType){
if(!checkType(descriptor[key], CONST.descriptorType[key])){
err.key = key;
err.expect = CONST.descriptorType[key];
err.type = typeof descriptor[key];
return false;
}
}
... | javascript | function checkDescriptor(descriptor, err){
if(typeof descriptor != 'object') return false;
for(var key in CONST.descriptorType){
if(!checkType(descriptor[key], CONST.descriptorType[key])){
err.key = key;
err.expect = CONST.descriptorType[key];
err.type = typeof descriptor[key];
return false;
}
}
... | [
"function",
"checkDescriptor",
"(",
"descriptor",
",",
"err",
")",
"{",
"if",
"(",
"typeof",
"descriptor",
"!=",
"'object'",
")",
"return",
"false",
";",
"for",
"(",
"var",
"key",
"in",
"CONST",
".",
"descriptorType",
")",
"{",
"if",
"(",
"!",
"checkType... | Check if the command descriptor is valid.
@return boolean | [
"Check",
"if",
"the",
"command",
"descriptor",
"is",
"valid",
"."
] | 3d3cdfac83b2e14e801a9fc94ced9024c757674f | https://github.com/Techniv/node-command-io/blob/3d3cdfac83b2e14e801a9fc94ced9024c757674f/libs/commandio.js#L306-L332 |
56,785 | Techniv/node-command-io | libs/commandio.js | CommandError | function CommandError(message, command, level){
var that = this, error;
// Set the default level.
if( isNaN(level) || level < 1 || level > 3) level = CONST.errorLvl.error;
// Format the message
if(typeof command == 'string') message = '{'+command+'} '+message;
message = '[command.io] '+message;
// Create the ... | javascript | function CommandError(message, command, level){
var that = this, error;
// Set the default level.
if( isNaN(level) || level < 1 || level > 3) level = CONST.errorLvl.error;
// Format the message
if(typeof command == 'string') message = '{'+command+'} '+message;
message = '[command.io] '+message;
// Create the ... | [
"function",
"CommandError",
"(",
"message",
",",
"command",
",",
"level",
")",
"{",
"var",
"that",
"=",
"this",
",",
"error",
";",
"// Set the default level.",
"if",
"(",
"isNaN",
"(",
"level",
")",
"||",
"level",
"<",
"1",
"||",
"level",
">",
"3",
")"... | ERRORS
Custom error object to manage exceptions on command's action.
@param string message The error message.
@param string command The command name what throw the error.
@param int level The severity level (1,2 or 3 to notice, error, critical).
@constructor | [
"ERRORS",
"Custom",
"error",
"object",
"to",
"manage",
"exceptions",
"on",
"command",
"s",
"action",
"."
] | 3d3cdfac83b2e14e801a9fc94ced9024c757674f | https://github.com/Techniv/node-command-io/blob/3d3cdfac83b2e14e801a9fc94ced9024c757674f/libs/commandio.js#L354-L390 |
56,786 | wigy/chronicles_of_grunt | lib/templates.js | substitute | function substitute(str, variables) {
// Based on Simple JavaScript Templating by
// John Resig - http://ejohn.org/blog/javascript-micro-templating/ - MIT Licensed
if (!cache[str]) {
// Figure out if we're getting a template, or if we need to
// load the template - and b... | javascript | function substitute(str, variables) {
// Based on Simple JavaScript Templating by
// John Resig - http://ejohn.org/blog/javascript-micro-templating/ - MIT Licensed
if (!cache[str]) {
// Figure out if we're getting a template, or if we need to
// load the template - and b... | [
"function",
"substitute",
"(",
"str",
",",
"variables",
")",
"{",
"// Based on Simple JavaScript Templating by",
"// John Resig - http://ejohn.org/blog/javascript-micro-templating/ - MIT Licensed",
"if",
"(",
"!",
"cache",
"[",
"str",
"]",
")",
"{",
"// Figure out if we're gett... | Perform variable substitutions in the template.
@param str Content of the template as a string.
@param variables An object containing variable values.
Note that templating does not support single quotes. It also removes line feeds. | [
"Perform",
"variable",
"substitutions",
"in",
"the",
"template",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/templates.js#L39-L70 |
56,787 | wigy/chronicles_of_grunt | lib/templates.js | generate | function generate(tmpl, src, variables) {
variables = variables || {};
variables.FILES = {};
for (var i = 0; i < src.length; i++) {
var content = JSON.stringify(grunt.file.read(src[i]));
variables.FILES[src[i]] = content;
}
var template = grunt.file.read(t... | javascript | function generate(tmpl, src, variables) {
variables = variables || {};
variables.FILES = {};
for (var i = 0; i < src.length; i++) {
var content = JSON.stringify(grunt.file.read(src[i]));
variables.FILES[src[i]] = content;
}
var template = grunt.file.read(t... | [
"function",
"generate",
"(",
"tmpl",
",",
"src",
",",
"variables",
")",
"{",
"variables",
"=",
"variables",
"||",
"{",
"}",
";",
"variables",
".",
"FILES",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"src",
".",
"length",... | Generate a file based on the template and source files.
@param tmpl Path to the template file.
@param src An array of source files.
@param variables Initial variables as an object.
@return A string with template substitutions made. | [
"Generate",
"a",
"file",
"based",
"on",
"the",
"template",
"and",
"source",
"files",
"."
] | c5f089a6f391a0ca625fcb81ef51907713471bb3 | https://github.com/wigy/chronicles_of_grunt/blob/c5f089a6f391a0ca625fcb81ef51907713471bb3/lib/templates.js#L80-L89 |
56,788 | melvincarvalho/rdf-shell | lib/util.js | putStorage | function putStorage(host, path, data, cert, callback) {
var protocol = 'https://'
var ldp = {
hostname: host,
rejectUnauthorized: false,
port: 443,
method: 'PUT',
headers: {'Content-Type': 'text/turtle'}
}
if (cert) {
ldp.key = fs.readFileSync(cert)
ldp.cert = fs.readFileSyn... | javascript | function putStorage(host, path, data, cert, callback) {
var protocol = 'https://'
var ldp = {
hostname: host,
rejectUnauthorized: false,
port: 443,
method: 'PUT',
headers: {'Content-Type': 'text/turtle'}
}
if (cert) {
ldp.key = fs.readFileSync(cert)
ldp.cert = fs.readFileSyn... | [
"function",
"putStorage",
"(",
"host",
",",
"path",
",",
"data",
",",
"cert",
",",
"callback",
")",
"{",
"var",
"protocol",
"=",
"'https://'",
"var",
"ldp",
"=",
"{",
"hostname",
":",
"host",
",",
"rejectUnauthorized",
":",
"false",
",",
"port",
":",
"... | putStorage Sends turtle data to remote storage via put request
@param {String} host The host to send to
@param {String} path The path relative to host
@param {String} data The turtle to send
@param {String} cert Certificate path used for auth
@param {Function} callback Callback with error o... | [
"putStorage",
"Sends",
"turtle",
"data",
"to",
"remote",
"storage",
"via",
"put",
"request"
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/lib/util.js#L72-L109 |
56,789 | melvincarvalho/rdf-shell | lib/util.js | is | function is(store, uri, type) {
var ret = false
var types = store.findTypeURIs($rdf.sym(uri))
if (types && types[type]) {
ret = true
}
return ret
} | javascript | function is(store, uri, type) {
var ret = false
var types = store.findTypeURIs($rdf.sym(uri))
if (types && types[type]) {
ret = true
}
return ret
} | [
"function",
"is",
"(",
"store",
",",
"uri",
",",
"type",
")",
"{",
"var",
"ret",
"=",
"false",
"var",
"types",
"=",
"store",
".",
"findTypeURIs",
"(",
"$rdf",
".",
"sym",
"(",
"uri",
")",
")",
"if",
"(",
"types",
"&&",
"types",
"[",
"type",
"]",
... | See if a URI is a certain type
@param {object} store the rdflib store
@param {string} uri the uri to check
@param {string} type the type to test
@return {Boolean} true if uri is that type | [
"See",
"if",
"a",
"URI",
"is",
"a",
"certain",
"type"
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/lib/util.js#L362-L372 |
56,790 | kaelzhang/typo-rgb | lib/rgb.js | to_rgb | function to_rgb(obj){
return [obj.R, obj.G, obj.B].map(format_number).join('');
} | javascript | function to_rgb(obj){
return [obj.R, obj.G, obj.B].map(format_number).join('');
} | [
"function",
"to_rgb",
"(",
"obj",
")",
"{",
"return",
"[",
"obj",
".",
"R",
",",
"obj",
".",
"G",
",",
"obj",
".",
"B",
"]",
".",
"map",
"(",
"format_number",
")",
".",
"join",
"(",
"''",
")",
";",
"}"
] | reversed method of `rgb_2_object` | [
"reversed",
"method",
"of",
"rgb_2_object"
] | 27a0498bb291fbda8c33e4c9568fc9ae5d539edb | https://github.com/kaelzhang/typo-rgb/blob/27a0498bb291fbda8c33e4c9568fc9ae5d539edb/lib/rgb.js#L313-L315 |
56,791 | benzhou1/iod | lib/iod.js | function(results) {
// Only do so if `callback` is specified
if (IODOpts.callback) {
var options = { url: IODOpts.callback.uri }
var res = JSON.stringify(results)
// Url-encode use `form` property
if (IODOpts.callback.method === 'encoded') {
options.form = { results: res }
}
var r =... | javascript | function(results) {
// Only do so if `callback` is specified
if (IODOpts.callback) {
var options = { url: IODOpts.callback.uri }
var res = JSON.stringify(results)
// Url-encode use `form` property
if (IODOpts.callback.method === 'encoded') {
options.form = { results: res }
}
var r =... | [
"function",
"(",
"results",
")",
"{",
"// Only do so if `callback` is specified",
"if",
"(",
"IODOpts",
".",
"callback",
")",
"{",
"var",
"options",
"=",
"{",
"url",
":",
"IODOpts",
".",
"callback",
".",
"uri",
"}",
"var",
"res",
"=",
"JSON",
".",
"stringi... | Sends results of request to specified callback.
@param {*} results - Results of request | [
"Sends",
"results",
"of",
"request",
"to",
"specified",
"callback",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/iod.js#L236-L265 | |
56,792 | benzhou1/iod | lib/iod.js | function(jobId) {
var isFinished = function(res) {
return res && res.status &&
(res.status === 'finished' || res.status === 'failed')
}
var poll = function() {
IOD.status({ jobId: jobId }, function(err, res) {
// Emits err as first argument
if (err) IOD.eventEmitter.emit(jobId, err)
... | javascript | function(jobId) {
var isFinished = function(res) {
return res && res.status &&
(res.status === 'finished' || res.status === 'failed')
}
var poll = function() {
IOD.status({ jobId: jobId }, function(err, res) {
// Emits err as first argument
if (err) IOD.eventEmitter.emit(jobId, err)
... | [
"function",
"(",
"jobId",
")",
"{",
"var",
"isFinished",
"=",
"function",
"(",
"res",
")",
"{",
"return",
"res",
"&&",
"res",
".",
"status",
"&&",
"(",
"res",
".",
"status",
"===",
"'finished'",
"||",
"res",
".",
"status",
"===",
"'failed'",
")",
"}"... | Periodically get status of a job with specified job id `jobId`.
Do so until job has finished or failed.
@param {String} jobId - Job id | [
"Periodically",
"get",
"status",
"of",
"a",
"job",
"with",
"specified",
"job",
"id",
"jobId",
".",
"Do",
"so",
"until",
"job",
"has",
"finished",
"or",
"failed",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/iod.js#L273-L292 | |
56,793 | benzhou1/iod | lib/iod.js | function(asyncRes, callback) {
var jobId = asyncRes.jobID
if (!jobId) return callback(null, asyncRes)
else if (IODOpts.getResults) {
IOD.result({
jobId: jobId,
majorVersion: IODOpts.majorVersion,
retries: 3
}, callback)
}
else {
callback(null, asyncRes)
pollUntilDone(jobId... | javascript | function(asyncRes, callback) {
var jobId = asyncRes.jobID
if (!jobId) return callback(null, asyncRes)
else if (IODOpts.getResults) {
IOD.result({
jobId: jobId,
majorVersion: IODOpts.majorVersion,
retries: 3
}, callback)
}
else {
callback(null, asyncRes)
pollUntilDone(jobId... | [
"function",
"(",
"asyncRes",
",",
"callback",
")",
"{",
"var",
"jobId",
"=",
"asyncRes",
".",
"jobID",
"if",
"(",
"!",
"jobId",
")",
"return",
"callback",
"(",
"null",
",",
"asyncRes",
")",
"else",
"if",
"(",
"IODOpts",
".",
"getResults",
")",
"{",
"... | If getResults is true and jobId is found, send IOD result request.
@param {Object} asyncRes - Async request response
@param {Function} callback - Callback(err, IOD response)) | [
"If",
"getResults",
"is",
"true",
"and",
"jobId",
"is",
"found",
"send",
"IOD",
"result",
"request",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/iod.js#L300-L316 | |
56,794 | JohnnieFucker/dreamix-admin | lib/modules/scripts.js | list | function list(scriptModule, agent, msg, cb) {
const servers = [];
const scripts = [];
const idMap = agent.idMap;
for (const sid in idMap) {
if (idMap.hasOwnProperty(sid)) {
servers.push(sid);
}
}
fs.readdir(scriptModule.root, (err, filenames) => {
if (err) {... | javascript | function list(scriptModule, agent, msg, cb) {
const servers = [];
const scripts = [];
const idMap = agent.idMap;
for (const sid in idMap) {
if (idMap.hasOwnProperty(sid)) {
servers.push(sid);
}
}
fs.readdir(scriptModule.root, (err, filenames) => {
if (err) {... | [
"function",
"list",
"(",
"scriptModule",
",",
"agent",
",",
"msg",
",",
"cb",
")",
"{",
"const",
"servers",
"=",
"[",
"]",
";",
"const",
"scripts",
"=",
"[",
"]",
";",
"const",
"idMap",
"=",
"agent",
".",
"idMap",
";",
"for",
"(",
"const",
"sid",
... | List server id and scripts file name | [
"List",
"server",
"id",
"and",
"scripts",
"file",
"name"
] | fc169e2481d5a7456725fb33f7a7907e0776ef79 | https://github.com/JohnnieFucker/dreamix-admin/blob/fc169e2481d5a7456725fb33f7a7907e0776ef79/lib/modules/scripts.js#L13-L37 |
56,795 | JohnnieFucker/dreamix-admin | lib/modules/scripts.js | get | function get(scriptModule, agent, msg, cb) {
const filename = msg.filename;
if (!filename) {
cb('empty filename');
return;
}
fs.readFile(path.join(scriptModule.root, filename), 'utf-8', (err, data) => {
if (err) {
logger.error(`fail to read script file:${filename}, $... | javascript | function get(scriptModule, agent, msg, cb) {
const filename = msg.filename;
if (!filename) {
cb('empty filename');
return;
}
fs.readFile(path.join(scriptModule.root, filename), 'utf-8', (err, data) => {
if (err) {
logger.error(`fail to read script file:${filename}, $... | [
"function",
"get",
"(",
"scriptModule",
",",
"agent",
",",
"msg",
",",
"cb",
")",
"{",
"const",
"filename",
"=",
"msg",
".",
"filename",
";",
"if",
"(",
"!",
"filename",
")",
"{",
"cb",
"(",
"'empty filename'",
")",
";",
"return",
";",
"}",
"fs",
"... | Get the content of the script file | [
"Get",
"the",
"content",
"of",
"the",
"script",
"file"
] | fc169e2481d5a7456725fb33f7a7907e0776ef79 | https://github.com/JohnnieFucker/dreamix-admin/blob/fc169e2481d5a7456725fb33f7a7907e0776ef79/lib/modules/scripts.js#L42-L57 |
56,796 | JohnnieFucker/dreamix-admin | lib/modules/scripts.js | save | function save(scriptModule, agent, msg, cb) {
const filepath = path.join(scriptModule.root, msg.filename);
fs.writeFile(filepath, msg.body, (err) => {
if (err) {
logger.error(`fail to write script file:${msg.filename}, ${err.stack}`);
cb(`fail to write script file:${msg.filename... | javascript | function save(scriptModule, agent, msg, cb) {
const filepath = path.join(scriptModule.root, msg.filename);
fs.writeFile(filepath, msg.body, (err) => {
if (err) {
logger.error(`fail to write script file:${msg.filename}, ${err.stack}`);
cb(`fail to write script file:${msg.filename... | [
"function",
"save",
"(",
"scriptModule",
",",
"agent",
",",
"msg",
",",
"cb",
")",
"{",
"const",
"filepath",
"=",
"path",
".",
"join",
"(",
"scriptModule",
".",
"root",
",",
"msg",
".",
"filename",
")",
";",
"fs",
".",
"writeFile",
"(",
"filepath",
"... | Save a script file that posted from admin console | [
"Save",
"a",
"script",
"file",
"that",
"posted",
"from",
"admin",
"console"
] | fc169e2481d5a7456725fb33f7a7907e0776ef79 | https://github.com/JohnnieFucker/dreamix-admin/blob/fc169e2481d5a7456725fb33f7a7907e0776ef79/lib/modules/scripts.js#L62-L74 |
56,797 | melvincarvalho/rdf-shell | bin/cat.js | bin | function bin(argv) {
if (!argv[2]) {
console.error("url is required")
console.error("Usage : cat <url>")
process.exit(-1)
}
shell.cat(argv[2], function(err, res, uri) {
if (err) {
console.error(err)
} else {
console.log(res)
}
})
} | javascript | function bin(argv) {
if (!argv[2]) {
console.error("url is required")
console.error("Usage : cat <url>")
process.exit(-1)
}
shell.cat(argv[2], function(err, res, uri) {
if (err) {
console.error(err)
} else {
console.log(res)
}
})
} | [
"function",
"bin",
"(",
"argv",
")",
"{",
"if",
"(",
"!",
"argv",
"[",
"2",
"]",
")",
"{",
"console",
".",
"error",
"(",
"\"url is required\"",
")",
"console",
".",
"error",
"(",
"\"Usage : cat <url>\"",
")",
"process",
".",
"exit",
"(",
"-",
"1",
")... | cat as a command
@param {Array} argv Args, argv[2] is the uri | [
"cat",
"as",
"a",
"command"
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/bin/cat.js#L9-L22 |
56,798 | oleics/node-xcouch | registry.js | connectUser | function connectUser(name, pass, cb) {
loginUser(name, pass, function(err, user) {
if(err) return cb(err)
var nano = NANO(_ci.protocol+'//'+encodeURIComponent(name)+':'+encodeURIComponent(pass)+'@'+_ci.host+'/')
, db = nano.use(name)
;
function getObject(type, id, rev) {
var ct... | javascript | function connectUser(name, pass, cb) {
loginUser(name, pass, function(err, user) {
if(err) return cb(err)
var nano = NANO(_ci.protocol+'//'+encodeURIComponent(name)+':'+encodeURIComponent(pass)+'@'+_ci.host+'/')
, db = nano.use(name)
;
function getObject(type, id, rev) {
var ct... | [
"function",
"connectUser",
"(",
"name",
",",
"pass",
",",
"cb",
")",
"{",
"loginUser",
"(",
"name",
",",
"pass",
",",
"function",
"(",
"err",
",",
"user",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
"var",
"nano",
"=",
"NANO... | Connects a user | [
"Connects",
"a",
"user"
] | 47e492235b8e6c7235c7f8807725a3bb51fb44ba | https://github.com/oleics/node-xcouch/blob/47e492235b8e6c7235c7f8807725a3bb51fb44ba/registry.js#L141-L164 |
56,799 | oleics/node-xcouch | registry.js | createDatabase | function createDatabase(name, cb) {
nano().db.create(name, function(err) {
if(err && err.status_code !== 412) return cb(err)
cb(null, err ? false : true)
})
} | javascript | function createDatabase(name, cb) {
nano().db.create(name, function(err) {
if(err && err.status_code !== 412) return cb(err)
cb(null, err ? false : true)
})
} | [
"function",
"createDatabase",
"(",
"name",
",",
"cb",
")",
"{",
"nano",
"(",
")",
".",
"db",
".",
"create",
"(",
"name",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
"&&",
"err",
".",
"status_code",
"!==",
"412",
")",
"return",
"cb",
... | Creates a database We assume that every database belongs to exactly one user. Both share the same name. | [
"Creates",
"a",
"database",
"We",
"assume",
"that",
"every",
"database",
"belongs",
"to",
"exactly",
"one",
"user",
".",
"Both",
"share",
"the",
"same",
"name",
"."
] | 47e492235b8e6c7235c7f8807725a3bb51fb44ba | https://github.com/oleics/node-xcouch/blob/47e492235b8e6c7235c7f8807725a3bb51fb44ba/registry.js#L209-L214 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.