repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/scayt/plugin.js | function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder )
{
editor.addCommand( commandName, command );
// If the "menu" plugin is loaded, register the menu item.
editor.addMenuItem( commandName,
{
label : buttonLabel,
command : commandName,
group : menugroup... | javascript | function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder )
{
editor.addCommand( commandName, command );
// If the "menu" plugin is loaded, register the menu item.
editor.addMenuItem( commandName,
{
label : buttonLabel,
command : commandName,
group : menugroup... | [
"function",
"(",
"editor",
",",
"buttonName",
",",
"buttonLabel",
",",
"commandName",
",",
"command",
",",
"menugroup",
",",
"menuOrder",
")",
"{",
"editor",
".",
"addCommand",
"(",
"commandName",
",",
"command",
")",
";",
"// If the \"menu\" plugin is loaded, reg... | Context menu constructing. | [
"Context",
"menu",
"constructing",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/scayt/plugin.js#L447-L459 | train | |
saggiyogesh/nodeportal | plugins/managePlugin/client/js/managePlugin.js | handlePermissionUpdate | function handlePermissionUpdate() {
permissionArea.find("form").submit(function (e) {
e.preventDefault();
//console.log(e);
var form = e.currentTarget;
appendFormFields(form);
Rocket.Util.submitFormAsync(form, function (response... | javascript | function handlePermissionUpdate() {
permissionArea.find("form").submit(function (e) {
e.preventDefault();
//console.log(e);
var form = e.currentTarget;
appendFormFields(form);
Rocket.Util.submitFormAsync(form, function (response... | [
"function",
"handlePermissionUpdate",
"(",
")",
"{",
"permissionArea",
".",
"find",
"(",
"\"form\"",
")",
".",
"submit",
"(",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"//console.log(e);",
"var",
"form",
"=",
"e",
".",
"c... | open permissions on tab click | [
"open",
"permissions",
"on",
"tab",
"click"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/managePlugin/client/js/managePlugin.js#L51-L64 | train |
ForbesLindesay/stop | lib/manifest.js | addManifest | function addManifest(file, options) {
file = file || '/app.manifest';
var stream = new Transform({objectMode: true});
var domains = {};
var hostProtocols = {};
stream._transform = function (page, _, callback) {
if (!(options && options.justManifests)) {
if (page.statusCode !== 404 || url.resolve(pa... | javascript | function addManifest(file, options) {
file = file || '/app.manifest';
var stream = new Transform({objectMode: true});
var domains = {};
var hostProtocols = {};
stream._transform = function (page, _, callback) {
if (!(options && options.justManifests)) {
if (page.statusCode !== 404 || url.resolve(pa... | [
"function",
"addManifest",
"(",
"file",
",",
"options",
")",
"{",
"file",
"=",
"file",
"||",
"'/app.manifest'",
";",
"var",
"stream",
"=",
"new",
"Transform",
"(",
"{",
"objectMode",
":",
"true",
"}",
")",
";",
"var",
"domains",
"=",
"{",
"}",
";",
"... | Add cache manifest files to the stream.
Options:
- justManifests - set to `true` to only emit the manifest files.
- addLinks - set to `true` to add <link href="/app.manifest" rel="manifest"/> to each html page.
@param {String} file
@param {Ojbect} options
@returns {TransformStream} | [
"Add",
"cache",
"manifest",
"files",
"to",
"the",
"stream",
"."
] | 61db8899bdde604dc45cfc8f11fffa1beaa27abb | https://github.com/ForbesLindesay/stop/blob/61db8899bdde604dc45cfc8f11fffa1beaa27abb/lib/manifest.js#L24-L73 | train |
h0x91b/ESB-node-driver | examples/bench-requester.js | report | function report(){
if(responses < 1) return;
var dt = new Date - starttime;
console.log(
'%s invokes per second, avg request time: %s ms, worst: %s ms, best: %s ms, invokes without response in queue: %s',
(responses/dt*1000).toFixed(2),
(totaltime/responses).toFixed(2),
maxtime,
mintime,
Obje... | javascript | function report(){
if(responses < 1) return;
var dt = new Date - starttime;
console.log(
'%s invokes per second, avg request time: %s ms, worst: %s ms, best: %s ms, invokes without response in queue: %s',
(responses/dt*1000).toFixed(2),
(totaltime/responses).toFixed(2),
maxtime,
mintime,
Obje... | [
"function",
"report",
"(",
")",
"{",
"if",
"(",
"responses",
"<",
"1",
")",
"return",
";",
"var",
"dt",
"=",
"new",
"Date",
"-",
"starttime",
";",
"console",
".",
"log",
"(",
"'%s invokes per second, avg request time: %s ms, worst: %s ms, best: %s ms, invokes withou... | ,5); | [
"5",
")",
";"
] | df9bda67a65c9f9c92218091a238ef3a5d5e694a | https://github.com/h0x91b/ESB-node-driver/blob/df9bda67a65c9f9c92218091a238ef3a5d5e694a/examples/bench-requester.js#L56-L71 | train |
Pencroff/kea-config | src/config-manager.js | function (path) {
'use strict';
path = fs.realpathSync(path);
var config = require(path);
this.setData(config, false);
return this;
} | javascript | function (path) {
'use strict';
path = fs.realpathSync(path);
var config = require(path);
this.setData(config, false);
return this;
} | [
"function",
"(",
"path",
")",
"{",
"'use strict'",
";",
"path",
"=",
"fs",
".",
"realpathSync",
"(",
"path",
")",
";",
"var",
"config",
"=",
"require",
"(",
"path",
")",
";",
"this",
".",
"setData",
"(",
"config",
",",
"false",
")",
";",
"return",
... | ConfigManager initialization by data in file. Not save previous configuration.
@param {string} path - path to CommonJs module with configuration, from project root | [
"ConfigManager",
"initialization",
"by",
"data",
"in",
"file",
".",
"Not",
"save",
"previous",
"configuration",
"."
] | 0889d7b8a89ee8720ebc3493e2b102de079869b1 | https://github.com/Pencroff/kea-config/blob/0889d7b8a89ee8720ebc3493e2b102de079869b1/src/config-manager.js#L202-L208 | train | |
Pencroff/kea-config | src/config-manager.js | function (path) {
'use strict';
path = fs.realpathSync(path);
var updateConf = require(path);
this.setData(updateConf, true);
return this;
} | javascript | function (path) {
'use strict';
path = fs.realpathSync(path);
var updateConf = require(path);
this.setData(updateConf, true);
return this;
} | [
"function",
"(",
"path",
")",
"{",
"'use strict'",
";",
"path",
"=",
"fs",
".",
"realpathSync",
"(",
"path",
")",
";",
"var",
"updateConf",
"=",
"require",
"(",
"path",
")",
";",
"this",
".",
"setData",
"(",
"updateConf",
",",
"true",
")",
";",
"retu... | Update exist configuration. Merge new config to exist.
@param {string} path - path to CommonJs module with configuration, from project root | [
"Update",
"exist",
"configuration",
".",
"Merge",
"new",
"config",
"to",
"exist",
"."
] | 0889d7b8a89ee8720ebc3493e2b102de079869b1 | https://github.com/Pencroff/kea-config/blob/0889d7b8a89ee8720ebc3493e2b102de079869b1/src/config-manager.js#L213-L219 | train | |
Pencroff/kea-config | src/config-manager.js | function (key) {
'use strict';
var value = conf[key];
if (!isStr(key)) {
throw new Error(confKeyStrMsg, 'config-manager');
}
if (key.indexOf('.') !== -1) {
value = getNestedValue(conf, key);
}
if (isObj(value)) {
if (isExtension... | javascript | function (key) {
'use strict';
var value = conf[key];
if (!isStr(key)) {
throw new Error(confKeyStrMsg, 'config-manager');
}
if (key.indexOf('.') !== -1) {
value = getNestedValue(conf, key);
}
if (isObj(value)) {
if (isExtension... | [
"function",
"(",
"key",
")",
"{",
"'use strict'",
";",
"var",
"value",
"=",
"conf",
"[",
"key",
"]",
";",
"if",
"(",
"!",
"isStr",
"(",
"key",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"confKeyStrMsg",
",",
"'config-manager'",
")",
";",
"}",
"if... | Get 'value' of 'key'.
@param {string} key - key in configuration. Like 'simpleKey' or 'section.subsection.complex.key'. See config-managet-test.js
@returns {*} value - `value` of `key`. Can be `primitive` or `javascript object`. Objects not connected to original configuration.
If value contain reference (`{$ref: 'some.... | [
"Get",
"value",
"of",
"key",
"."
] | 0889d7b8a89ee8720ebc3493e2b102de079869b1 | https://github.com/Pencroff/kea-config/blob/0889d7b8a89ee8720ebc3493e2b102de079869b1/src/config-manager.js#L274-L292 | train | |
Pencroff/kea-config | src/config-manager.js | function (key, value) {
'use strict';
var obj;
if (!isStr(key)) {
throw new Error(confKeyStrMsg, 'config-manager');
}
if (key.indexOf('.') === -1) {
conf[key] = value;
} else {
obj = getLastNodeKey(key, conf);
obj.node[obj.k... | javascript | function (key, value) {
'use strict';
var obj;
if (!isStr(key)) {
throw new Error(confKeyStrMsg, 'config-manager');
}
if (key.indexOf('.') === -1) {
conf[key] = value;
} else {
obj = getLastNodeKey(key, conf);
obj.node[obj.k... | [
"function",
"(",
"key",
",",
"value",
")",
"{",
"'use strict'",
";",
"var",
"obj",
";",
"if",
"(",
"!",
"isStr",
"(",
"key",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"confKeyStrMsg",
",",
"'config-manager'",
")",
";",
"}",
"if",
"(",
"key",
"."... | Set 'value' for 'key'
@param {string} key - key in configuration. Like 'simpleKey' or 'section.subsection.complex.key'. See config-managet-test.js
@param {*} value | [
"Set",
"value",
"for",
"key"
] | 0889d7b8a89ee8720ebc3493e2b102de079869b1 | https://github.com/Pencroff/kea-config/blob/0889d7b8a89ee8720ebc3493e2b102de079869b1/src/config-manager.js#L298-L311 | train | |
mdreizin/webpack-config-stream | lib/formatStream.js | formatStream | function formatStream(options) {
if (!_.isObject(options)) {
options = {};
}
var statsOptions = options.verbose === true ? _.defaults(options, DEFAULT_VERBOSE_STATS_OPTIONS) : _.defaults(options, DEFAULT_STATS_OPTIONS);
if (!gutil.colors.supportsColor) {
statsOptions.colors = false;
... | javascript | function formatStream(options) {
if (!_.isObject(options)) {
options = {};
}
var statsOptions = options.verbose === true ? _.defaults(options, DEFAULT_VERBOSE_STATS_OPTIONS) : _.defaults(options, DEFAULT_STATS_OPTIONS);
if (!gutil.colors.supportsColor) {
statsOptions.colors = false;
... | [
"function",
"formatStream",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"options",
")",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"var",
"statsOptions",
"=",
"options",
".",
"verbose",
"===",
"true",
"?",
"_",
".",
"def... | Writes formatted string of `stats` object and displays related `webpack.config.js` file path. Can be piped.
@function
@alias formatStream
@param {Object=} options - Options to pass to {@link http://webpack.github.io/docs/node.js-api.html#stats-tostring `stats.toString()`}.
@param {Boolean} [options.verbose=false] - Wri... | [
"Writes",
"formatted",
"string",
"of",
"stats",
"object",
"and",
"displays",
"related",
"webpack",
".",
"config",
".",
"js",
"file",
"path",
".",
"Can",
"be",
"piped",
"."
] | f8424f97837a224bc07cc18a03ecf649d708e924 | https://github.com/mdreizin/webpack-config-stream/blob/f8424f97837a224bc07cc18a03ecf649d708e924/lib/formatStream.js#L27-L51 | train |
mattbasta/btype | src/parser.js | parseString | function parseString(input) {
var stripped = input.substring(1, input.length - 1);
return stripped.replace(/\\(\w|\\)/gi, function(_, b) {
switch (b) {
case '\\r': return '\r';
case '\\n': return '\n';
case '\\t': return '\t';
case '\\0': return '\0';
... | javascript | function parseString(input) {
var stripped = input.substring(1, input.length - 1);
return stripped.replace(/\\(\w|\\)/gi, function(_, b) {
switch (b) {
case '\\r': return '\r';
case '\\n': return '\n';
case '\\t': return '\t';
case '\\0': return '\0';
... | [
"function",
"parseString",
"(",
"input",
")",
"{",
"var",
"stripped",
"=",
"input",
".",
"substring",
"(",
"1",
",",
"input",
".",
"length",
"-",
"1",
")",
";",
"return",
"stripped",
".",
"replace",
"(",
"/",
"\\\\(\\w|\\\\)",
"/",
"gi",
",",
"function... | Turns an encoded string into its text content
@param {string} input
@return {string} | [
"Turns",
"an",
"encoded",
"string",
"into",
"its",
"text",
"content"
] | 7d28db96f3e14fd83d4a72f6008cb9a26208ab71 | https://github.com/mattbasta/btype/blob/7d28db96f3e14fd83d4a72f6008cb9a26208ab71/src/parser.js#L11-L25 | train |
mattbasta/btype | src/parser.js | parseSwitchType | function parseSwitchType(lex) {
var start = lex.accept('switchtype');
if (!start) {
return null;
}
var expr = parseExpression(lex);
lex.assert('{');
var cases = [];
var end;
do {
let c = parseSwitchTypeCase(lex);
cases.push(c);
} while (!(end = lex.accept('}... | javascript | function parseSwitchType(lex) {
var start = lex.accept('switchtype');
if (!start) {
return null;
}
var expr = parseExpression(lex);
lex.assert('{');
var cases = [];
var end;
do {
let c = parseSwitchTypeCase(lex);
cases.push(c);
} while (!(end = lex.accept('}... | [
"function",
"parseSwitchType",
"(",
"lex",
")",
"{",
"var",
"start",
"=",
"lex",
".",
"accept",
"(",
"'switchtype'",
")",
";",
"if",
"(",
"!",
"start",
")",
"{",
"return",
"null",
";",
"}",
"var",
"expr",
"=",
"parseExpression",
"(",
"lex",
")",
";",... | Parses a `switchtype` statement
@param {Lexer} lex
@return {SwitchType} | [
"Parses",
"a",
"switchtype",
"statement"
] | 7d28db96f3e14fd83d4a72f6008cb9a26208ab71 | https://github.com/mattbasta/btype/blob/7d28db96f3e14fd83d4a72f6008cb9a26208ab71/src/parser.js#L1035-L1052 | train |
mattbasta/btype | src/parser.js | parseSwitchTypeCase | function parseSwitchTypeCase(lex) {
var start = lex.assert('case');
var type = parseType(lex);
lex.assert('{');
var body = parseStatements(lex, '}', false);
var end = lex.assert('}');
return new nodes.SwitchTypeCaseNode(type, body, start.start, end.end);
} | javascript | function parseSwitchTypeCase(lex) {
var start = lex.assert('case');
var type = parseType(lex);
lex.assert('{');
var body = parseStatements(lex, '}', false);
var end = lex.assert('}');
return new nodes.SwitchTypeCaseNode(type, body, start.start, end.end);
} | [
"function",
"parseSwitchTypeCase",
"(",
"lex",
")",
"{",
"var",
"start",
"=",
"lex",
".",
"assert",
"(",
"'case'",
")",
";",
"var",
"type",
"=",
"parseType",
"(",
"lex",
")",
";",
"lex",
".",
"assert",
"(",
"'{'",
")",
";",
"var",
"body",
"=",
"par... | Parses a SwitchType's case statement
@param {Lexer}
@return {SwitchTypeCase} | [
"Parses",
"a",
"SwitchType",
"s",
"case",
"statement"
] | 7d28db96f3e14fd83d4a72f6008cb9a26208ab71 | https://github.com/mattbasta/btype/blob/7d28db96f3e14fd83d4a72f6008cb9a26208ab71/src/parser.js#L1059-L1068 | train |
mattbasta/btype | src/parser.js | parseStatement | function parseStatement(lex, isRoot = false) {
return parseFunctionDeclaration(lex) ||
isRoot && parseOperatorStatement(lex) ||
isRoot && parseObjectDeclaration(lex) ||
parseIf(lex) ||
parseReturn(lex) ||
isRoot && parseExport(lex) ||
isRoot && parse... | javascript | function parseStatement(lex, isRoot = false) {
return parseFunctionDeclaration(lex) ||
isRoot && parseOperatorStatement(lex) ||
isRoot && parseObjectDeclaration(lex) ||
parseIf(lex) ||
parseReturn(lex) ||
isRoot && parseExport(lex) ||
isRoot && parse... | [
"function",
"parseStatement",
"(",
"lex",
",",
"isRoot",
"=",
"false",
")",
"{",
"return",
"parseFunctionDeclaration",
"(",
"lex",
")",
"||",
"isRoot",
"&&",
"parseOperatorStatement",
"(",
"lex",
")",
"||",
"isRoot",
"&&",
"parseObjectDeclaration",
"(",
"lex",
... | Parses a single statement
@param {Lexer} lex
@param {bool}
@return {*} | [
"Parses",
"a",
"single",
"statement"
] | 7d28db96f3e14fd83d4a72f6008cb9a26208ab71 | https://github.com/mattbasta/btype/blob/7d28db96f3e14fd83d4a72f6008cb9a26208ab71/src/parser.js#L1076-L1091 | train |
mattbasta/btype | src/parser.js | parseStatements | function parseStatements(lex, endTokens, isRoot) {
endTokens = Array.isArray(endTokens) ? endTokens : [endTokens];
var statements = [];
var temp = lex.peek();
while (endTokens.indexOf(temp) === -1 &&
(temp.type && endTokens.indexOf(temp.type) === -1)) {
var statement = parseStatement(... | javascript | function parseStatements(lex, endTokens, isRoot) {
endTokens = Array.isArray(endTokens) ? endTokens : [endTokens];
var statements = [];
var temp = lex.peek();
while (endTokens.indexOf(temp) === -1 &&
(temp.type && endTokens.indexOf(temp.type) === -1)) {
var statement = parseStatement(... | [
"function",
"parseStatements",
"(",
"lex",
",",
"endTokens",
",",
"isRoot",
")",
"{",
"endTokens",
"=",
"Array",
".",
"isArray",
"(",
"endTokens",
")",
"?",
"endTokens",
":",
"[",
"endTokens",
"]",
";",
"var",
"statements",
"=",
"[",
"]",
";",
"var",
"... | Parses an array of statements
@param {Lexer} lex
@param {string|string[]} endTokens
@param {bool} isRoot
@return {array} | [
"Parses",
"an",
"array",
"of",
"statements"
] | 7d28db96f3e14fd83d4a72f6008cb9a26208ab71 | https://github.com/mattbasta/btype/blob/7d28db96f3e14fd83d4a72f6008cb9a26208ab71/src/parser.js#L1100-L1114 | train |
bezoerb/asset-resolver | lib/resolver.js | requestAsync | function requestAsync(resource, opts = {}) {
const settings = {
followRedirect: true,
encoding: null,
rejectUnauthorized: false
};
if (opts.user && opts.pass) {
settings.headers = {Authorization: 'Basic ' + token(opts.user, opts.pass)};
}
return new Bluebird((resolve, reject) => {
// Han... | javascript | function requestAsync(resource, opts = {}) {
const settings = {
followRedirect: true,
encoding: null,
rejectUnauthorized: false
};
if (opts.user && opts.pass) {
settings.headers = {Authorization: 'Basic ' + token(opts.user, opts.pass)};
}
return new Bluebird((resolve, reject) => {
// Han... | [
"function",
"requestAsync",
"(",
"resource",
",",
"opts",
"=",
"{",
"}",
")",
"{",
"const",
"settings",
"=",
"{",
"followRedirect",
":",
"true",
",",
"encoding",
":",
"null",
",",
"rejectUnauthorized",
":",
"false",
"}",
";",
"if",
"(",
"opts",
".",
"u... | Get external resource
@param {string} resource Ressource to be fetched
@param {object} opts Option hash
@returns {Promise} Promise | [
"Get",
"external",
"resource"
] | 031e634920d62d76e5766dfdfcd7b35b7ca84213 | https://github.com/bezoerb/asset-resolver/blob/031e634920d62d76e5766dfdfcd7b35b7ca84213/lib/resolver.js#L52-L88 | train |
bezoerb/asset-resolver | lib/resolver.js | readAsync | function readAsync(resource) {
return fs.readFile(resource).then(body => {
const mimeType = mime.getType(resource);
debug('Fetched:', resource);
return Bluebird.resolve({
contents: body,
path: resource,
mime: mimeType
});
});
} | javascript | function readAsync(resource) {
return fs.readFile(resource).then(body => {
const mimeType = mime.getType(resource);
debug('Fetched:', resource);
return Bluebird.resolve({
contents: body,
path: resource,
mime: mimeType
});
});
} | [
"function",
"readAsync",
"(",
"resource",
")",
"{",
"return",
"fs",
".",
"readFile",
"(",
"resource",
")",
".",
"then",
"(",
"body",
"=>",
"{",
"const",
"mimeType",
"=",
"mime",
".",
"getType",
"(",
"resource",
")",
";",
"debug",
"(",
"'Fetched:'",
","... | Get local resource
@param {string} resource Resource to be fetched
@returns {Promise} Promise | [
"Get",
"local",
"resource"
] | 031e634920d62d76e5766dfdfcd7b35b7ca84213 | https://github.com/bezoerb/asset-resolver/blob/031e634920d62d76e5766dfdfcd7b35b7ca84213/lib/resolver.js#L95-L107 | train |
dman777/gulp-newy | lib/newy.js | checkMissingDir | function checkMissingDir(destinationFile) {
var filePath = path.dirname(destinationFile);
var pathAbsolute = path.isAbsolute(filePath);
var directories = filePath.split(path.sep);
return transversePath(directories);
} | javascript | function checkMissingDir(destinationFile) {
var filePath = path.dirname(destinationFile);
var pathAbsolute = path.isAbsolute(filePath);
var directories = filePath.split(path.sep);
return transversePath(directories);
} | [
"function",
"checkMissingDir",
"(",
"destinationFile",
")",
"{",
"var",
"filePath",
"=",
"path",
".",
"dirname",
"(",
"destinationFile",
")",
";",
"var",
"pathAbsolute",
"=",
"path",
".",
"isAbsolute",
"(",
"filePath",
")",
";",
"var",
"directories",
"=",
"f... | check for missing directory | [
"check",
"for",
"missing",
"directory"
] | 12e5bb01b908e83c5e3d99d54630168770ec817d | https://github.com/dman777/gulp-newy/blob/12e5bb01b908e83c5e3d99d54630168770ec817d/lib/newy.js#L10-L15 | train |
saggiyogesh/nodeportal | lib/ServeClientFiles/ClientDirWatcher.js | generateCache | function generateCache(filePath) {
var id = generateIdFromFilePath(filePath);
Debug._l(id);
fs.readFile(filePath, 'utf8', function (err, data) {
if (err) {
Debug._l("err: " + err);
return;
}
fs.stat(filePath, function (err, stat) {
setCache(id, {mo... | javascript | function generateCache(filePath) {
var id = generateIdFromFilePath(filePath);
Debug._l(id);
fs.readFile(filePath, 'utf8', function (err, data) {
if (err) {
Debug._l("err: " + err);
return;
}
fs.stat(filePath, function (err, stat) {
setCache(id, {mo... | [
"function",
"generateCache",
"(",
"filePath",
")",
"{",
"var",
"id",
"=",
"generateIdFromFilePath",
"(",
"filePath",
")",
";",
"Debug",
".",
"_l",
"(",
"id",
")",
";",
"fs",
".",
"readFile",
"(",
"filePath",
",",
"'utf8'",
",",
"function",
"(",
"err",
... | Reads file and cache its data
@param id
@param filePath | [
"Reads",
"file",
"and",
"cache",
"its",
"data"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/ServeClientFiles/ClientDirWatcher.js#L26-L38 | train |
saggiyogesh/nodeportal | public/js/util.js | function (options) {
if (!options) {
throw Error("Ajax options missing");
}
var that = this, util = Rocket.Util;
options.success = util.ajaxResponse(options.callback);
util.ajax(options);
} | javascript | function (options) {
if (!options) {
throw Error("Ajax options missing");
}
var that = this, util = Rocket.Util;
options.success = util.ajaxResponse(options.callback);
util.ajax(options);
} | [
"function",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"throw",
"Error",
"(",
"\"Ajax options missing\"",
")",
";",
"}",
"var",
"that",
"=",
"this",
",",
"util",
"=",
"Rocket",
".",
"Util",
";",
"options",
".",
"success",
"=",
"ut... | Ajax io transport utility method
@param options | [
"Ajax",
"io",
"transport",
"utility",
"method"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/js/util.js#L57-L64 | train | |
saggiyogesh/nodeportal | public/js/util.js | function (msg, nodeId, ns, isShow) {
ns = ns || Rocket.Plugin.currentPlugin.namespace;
var node = $("#" + ns + "_" + nodeId),
msgSpan = node.find("span.message");
isShow ? node.removeClass("hide") && node.css("display", "block") : node.addClass("hide");
if... | javascript | function (msg, nodeId, ns, isShow) {
ns = ns || Rocket.Plugin.currentPlugin.namespace;
var node = $("#" + ns + "_" + nodeId),
msgSpan = node.find("span.message");
isShow ? node.removeClass("hide") && node.css("display", "block") : node.addClass("hide");
if... | [
"function",
"(",
"msg",
",",
"nodeId",
",",
"ns",
",",
"isShow",
")",
"{",
"ns",
"=",
"ns",
"||",
"Rocket",
".",
"Plugin",
".",
"currentPlugin",
".",
"namespace",
";",
"var",
"node",
"=",
"$",
"(",
"\"#\"",
"+",
"ns",
"+",
"\"_\"",
"+",
"nodeId",
... | Method to toggle show of a flash messages
Jade template should be as
for error flash
#<nodeId>.hide.alert.alert-error
button(class="close", data-dismiss="alert") x
span.message
for success flash
#<nodeId>.hide.alert.alert-success
button(class="close", data-dismiss="alert") x
span.message
@param msg - Message to ... | [
"Method",
"to",
"toggle",
"show",
"of",
"a",
"flash",
"messages"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/js/util.js#L208-L227 | train | |
saggiyogesh/nodeportal | public/js/util.js | function (msg, nodeId, ns) {
nodeId = nodeId || "errorFlash";
this.flashMessage(msg, nodeId, ns, true);
} | javascript | function (msg, nodeId, ns) {
nodeId = nodeId || "errorFlash";
this.flashMessage(msg, nodeId, ns, true);
} | [
"function",
"(",
"msg",
",",
"nodeId",
",",
"ns",
")",
"{",
"nodeId",
"=",
"nodeId",
"||",
"\"errorFlash\"",
";",
"this",
".",
"flashMessage",
"(",
"msg",
",",
"nodeId",
",",
"ns",
",",
"true",
")",
";",
"}"
] | Id for error flash is default "errorFlash", without namespace
@param msg
@param nodeId
@param ns | [
"Id",
"for",
"error",
"flash",
"is",
"default",
"errorFlash",
"without",
"namespace"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/js/util.js#L234-L237 | train | |
saggiyogesh/nodeportal | lib/Renderer/ErrorRenderer.js | ErrorRenderer | function ErrorRenderer(err, req, res) {
PageRenderer.call(this, req, res);
Object.defineProperties(this, {
err: {
value: err || new Error()
}
});
req.attrs.isErrorPage = true;
} | javascript | function ErrorRenderer(err, req, res) {
PageRenderer.call(this, req, res);
Object.defineProperties(this, {
err: {
value: err || new Error()
}
});
req.attrs.isErrorPage = true;
} | [
"function",
"ErrorRenderer",
"(",
"err",
",",
"req",
",",
"res",
")",
"{",
"PageRenderer",
".",
"call",
"(",
"this",
",",
"req",
",",
"res",
")",
";",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"err",
":",
"{",
"value",
":",
"err",
"... | Constructor to create ErrorRenderer
@param err
@param req
@param res
@constructor | [
"Constructor",
"to",
"create",
"ErrorRenderer"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/Renderer/ErrorRenderer.js#L21-L29 | train |
KTH/kth-node-api-key-strategy | index.js | Strategy | function Strategy (options, verify) {
if (typeof options === 'function') {
verify = options
options = {}
} else {
if (options && options.log) {
log = options.log
}
}
if (!verify) {
throw new Error('apikey authentication strategy requires a verify function')
}
passport.Strategy.cal... | javascript | function Strategy (options, verify) {
if (typeof options === 'function') {
verify = options
options = {}
} else {
if (options && options.log) {
log = options.log
}
}
if (!verify) {
throw new Error('apikey authentication strategy requires a verify function')
}
passport.Strategy.cal... | [
"function",
"Strategy",
"(",
"options",
",",
"verify",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"verify",
"=",
"options",
"options",
"=",
"{",
"}",
"}",
"else",
"{",
"if",
"(",
"options",
"&&",
"options",
".",
"log",
"... | Creates an instance of `Strategy` checking api keys. | [
"Creates",
"an",
"instance",
"of",
"Strategy",
"checking",
"api",
"keys",
"."
] | 617d28cee15661edd007e2567779df9a5a3e0264 | https://github.com/KTH/kth-node-api-key-strategy/blob/617d28cee15661edd007e2567779df9a5a3e0264/index.js#L19-L38 | train |
ticup/CloudTypes-paper | shared/CString.js | CString | function CString(value, written, cond) {
this.value = value || '';
this.written = written || false;
this.cond = cond || false;
} | javascript | function CString(value, written, cond) {
this.value = value || '';
this.written = written || false;
this.cond = cond || false;
} | [
"function",
"CString",
"(",
"value",
",",
"written",
",",
"cond",
")",
"{",
"this",
".",
"value",
"=",
"value",
"||",
"''",
";",
"this",
".",
"written",
"=",
"written",
"||",
"false",
";",
"this",
".",
"cond",
"=",
"cond",
"||",
"false",
";",
"}"
] | Actual CString object of which an instance represents a variable of which the property is defined with CStringDeclaration | [
"Actual",
"CString",
"object",
"of",
"which",
"an",
"instance",
"represents",
"a",
"variable",
"of",
"which",
"the",
"property",
"is",
"defined",
"with",
"CStringDeclaration"
] | f3b6adcd60bd66a28eb0e22edfcdcd9500ef7dda | https://github.com/ticup/CloudTypes-paper/blob/f3b6adcd60bd66a28eb0e22edfcdcd9500ef7dda/shared/CString.js#L26-L30 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/undo/plugin.js | function( event )
{
var keystroke = event && event.data.getKey(),
isModifierKey = keystroke in modifierKeyCodes,
isEditingKey = keystroke in editingKeyCodes,
wasEditingKey = this.lastKeystroke in editingKeyCodes,
sameAsLastEditingKey = isEditingKey && keystroke == this.lastKeystroke,
// ... | javascript | function( event )
{
var keystroke = event && event.data.getKey(),
isModifierKey = keystroke in modifierKeyCodes,
isEditingKey = keystroke in editingKeyCodes,
wasEditingKey = this.lastKeystroke in editingKeyCodes,
sameAsLastEditingKey = isEditingKey && keystroke == this.lastKeystroke,
// ... | [
"function",
"(",
"event",
")",
"{",
"var",
"keystroke",
"=",
"event",
"&&",
"event",
".",
"data",
".",
"getKey",
"(",
")",
",",
"isModifierKey",
"=",
"keystroke",
"in",
"modifierKeyCodes",
",",
"isEditingKey",
"=",
"keystroke",
"in",
"editingKeyCodes",
",",
... | Process undo system regard keystrikes.
@param {CKEDITOR.dom.event} event | [
"Process",
"undo",
"system",
"regard",
"keystrikes",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/undo/plugin.js#L238-L325 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/undo/plugin.js | function( onContentOnly, image, autoFireChange )
{
var snapshots = this.snapshots;
// Get a content image.
if ( !image )
image = new Image( this.editor );
// Do nothing if it was not possible to retrieve an image.
if ( image.contents === false )
return false;
// Check if this ... | javascript | function( onContentOnly, image, autoFireChange )
{
var snapshots = this.snapshots;
// Get a content image.
if ( !image )
image = new Image( this.editor );
// Do nothing if it was not possible to retrieve an image.
if ( image.contents === false )
return false;
// Check if this ... | [
"function",
"(",
"onContentOnly",
",",
"image",
",",
"autoFireChange",
")",
"{",
"var",
"snapshots",
"=",
"this",
".",
"snapshots",
";",
"// Get a content image.\r",
"if",
"(",
"!",
"image",
")",
"image",
"=",
"new",
"Image",
"(",
"this",
".",
"editor",
")... | Save a snapshot of document image for later retrieve. | [
"Save",
"a",
"snapshot",
"of",
"document",
"image",
"for",
"later",
"retrieve",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/undo/plugin.js#L378-L409 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/undo/plugin.js | function( isUndo )
{
var snapshots = this.snapshots,
currentImage = this.currentImage,
image, i;
if ( currentImage )
{
if ( isUndo )
{
for ( i = this.index - 1 ; i >= 0 ; i-- )
{
image = snapshots[ i ];
if ( !currentImage.equals( image, true ) )
{
... | javascript | function( isUndo )
{
var snapshots = this.snapshots,
currentImage = this.currentImage,
image, i;
if ( currentImage )
{
if ( isUndo )
{
for ( i = this.index - 1 ; i >= 0 ; i-- )
{
image = snapshots[ i ];
if ( !currentImage.equals( image, true ) )
{
... | [
"function",
"(",
"isUndo",
")",
"{",
"var",
"snapshots",
"=",
"this",
".",
"snapshots",
",",
"currentImage",
"=",
"this",
".",
"currentImage",
",",
"image",
",",
"i",
";",
"if",
"(",
"currentImage",
")",
"{",
"if",
"(",
"isUndo",
")",
"{",
"for",
"("... | Get the closest available image. | [
"Get",
"the",
"closest",
"available",
"image",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/undo/plugin.js#L437-L472 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/undo/plugin.js | function()
{
if ( this.undoable() )
{
this.save( true );
var image = this.getNextImage( true );
if ( image )
return this.restoreImage( image ), true;
}
return false;
} | javascript | function()
{
if ( this.undoable() )
{
this.save( true );
var image = this.getNextImage( true );
if ( image )
return this.restoreImage( image ), true;
}
return false;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"undoable",
"(",
")",
")",
"{",
"this",
".",
"save",
"(",
"true",
")",
";",
"var",
"image",
"=",
"this",
".",
"getNextImage",
"(",
"true",
")",
";",
"if",
"(",
"image",
")",
"return",
"this",
"... | Perform undo on current index. | [
"Perform",
"undo",
"on",
"current",
"index",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/undo/plugin.js#L496-L508 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/undo/plugin.js | function()
{
if ( this.redoable() )
{
// Try to save. If no changes have been made, the redo stack
// will not change, so it will still be redoable.
this.save( true );
// If instead we had changes, we can't redo anymore.
if ( this.redoable() )
{
var image = this.getNextI... | javascript | function()
{
if ( this.redoable() )
{
// Try to save. If no changes have been made, the redo stack
// will not change, so it will still be redoable.
this.save( true );
// If instead we had changes, we can't redo anymore.
if ( this.redoable() )
{
var image = this.getNextI... | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"redoable",
"(",
")",
")",
"{",
"// Try to save. If no changes have been made, the redo stack\r",
"// will not change, so it will still be redoable.\r",
"this",
".",
"save",
"(",
"true",
")",
";",
"// If instead we had ch... | Perform redo on current index. | [
"Perform",
"redo",
"on",
"current",
"index",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/undo/plugin.js#L513-L531 | train | |
vega/vega-projection | src/projections.js | create | function create(type, constructor) {
return function projection() {
var p = constructor();
p.type = type;
p.path = geoPath().projection(p);
p.copy = p.copy || function() {
var c = projection();
projectionProperties.forEach(function(prop) {
if (p.hasOwnProperty(prop)) c[prop](p[p... | javascript | function create(type, constructor) {
return function projection() {
var p = constructor();
p.type = type;
p.path = geoPath().projection(p);
p.copy = p.copy || function() {
var c = projection();
projectionProperties.forEach(function(prop) {
if (p.hasOwnProperty(prop)) c[prop](p[p... | [
"function",
"create",
"(",
"type",
",",
"constructor",
")",
"{",
"return",
"function",
"projection",
"(",
")",
"{",
"var",
"p",
"=",
"constructor",
"(",
")",
";",
"p",
".",
"type",
"=",
"type",
";",
"p",
".",
"path",
"=",
"geoPath",
"(",
")",
".",
... | Augment projections with their type and a copy method. | [
"Augment",
"projections",
"with",
"their",
"type",
"and",
"a",
"copy",
"method",
"."
] | 0d71d4ed52196373f92f369ed8cffb9233eaabd1 | https://github.com/vega/vega-projection/blob/0d71d4ed52196373f92f369ed8cffb9233eaabd1/src/projections.js#L50-L69 | train |
levilindsey/physx | src/collisions/src/collidable-factories.js | createObbFromRenderableShape | function createObbFromRenderableShape(params, physicsJob) {
const halfRangeX = params.scale[0] / 2;
const halfRangeY = params.scale[1] / 2;
const halfRangeZ = params.scale[2] / 2;
return new Obb(halfRangeX, halfRangeY, halfRangeZ, params.isStationary, physicsJob);
} | javascript | function createObbFromRenderableShape(params, physicsJob) {
const halfRangeX = params.scale[0] / 2;
const halfRangeY = params.scale[1] / 2;
const halfRangeZ = params.scale[2] / 2;
return new Obb(halfRangeX, halfRangeY, halfRangeZ, params.isStationary, physicsJob);
} | [
"function",
"createObbFromRenderableShape",
"(",
"params",
",",
"physicsJob",
")",
"{",
"const",
"halfRangeX",
"=",
"params",
".",
"scale",
"[",
"0",
"]",
"/",
"2",
";",
"const",
"halfRangeY",
"=",
"params",
".",
"scale",
"[",
"1",
"]",
"/",
"2",
";",
... | This assumes the base RenderableShape has a side length of one unit.
@param {CollidableShapeConfig} params
@param {CollidablePhysicsJob} [physicsJob]
@returns {Collidable} | [
"This",
"assumes",
"the",
"base",
"RenderableShape",
"has",
"a",
"side",
"length",
"of",
"one",
"unit",
"."
] | 62df9f6968082ed34aa784a23f3db6c8feca6f3a | https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collidable-factories.js#L28-L33 | train |
levilindsey/physx | src/collisions/src/collidable-factories.js | createSphereFromRenderableShape | function createSphereFromRenderableShape(params, physicsJob) {
const radius = params.radius || vec3.length(params.scale) / Math.sqrt(3);
return new Sphere(0, 0, 0, radius, params.isStationary, physicsJob);
} | javascript | function createSphereFromRenderableShape(params, physicsJob) {
const radius = params.radius || vec3.length(params.scale) / Math.sqrt(3);
return new Sphere(0, 0, 0, radius, params.isStationary, physicsJob);
} | [
"function",
"createSphereFromRenderableShape",
"(",
"params",
",",
"physicsJob",
")",
"{",
"const",
"radius",
"=",
"params",
".",
"radius",
"||",
"vec3",
".",
"length",
"(",
"params",
".",
"scale",
")",
"/",
"Math",
".",
"sqrt",
"(",
"3",
")",
";",
"retu... | This assumes the base RenderableShape has a "radius" of one unit.
@param {CollidableShapeConfig} params
@param {CollidablePhysicsJob} [physicsJob]
@returns {Collidable} | [
"This",
"assumes",
"the",
"base",
"RenderableShape",
"has",
"a",
"radius",
"of",
"one",
"unit",
"."
] | 62df9f6968082ed34aa784a23f3db6c8feca6f3a | https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collidable-factories.js#L42-L45 | train |
levilindsey/physx | src/collisions/src/collidable-factories.js | createCapsuleFromRenderableShape | function createCapsuleFromRenderableShape(params, physicsJob) {
const scale = params.scale;
const capsuleEndPointsDistance = params.capsuleEndPointsDistance;
const isStationary = params.isStationary;
let radius = params.radius;
let halfDistance;
// There are two modes: either we use scale, or we use radiu... | javascript | function createCapsuleFromRenderableShape(params, physicsJob) {
const scale = params.scale;
const capsuleEndPointsDistance = params.capsuleEndPointsDistance;
const isStationary = params.isStationary;
let radius = params.radius;
let halfDistance;
// There are two modes: either we use scale, or we use radiu... | [
"function",
"createCapsuleFromRenderableShape",
"(",
"params",
",",
"physicsJob",
")",
"{",
"const",
"scale",
"=",
"params",
".",
"scale",
";",
"const",
"capsuleEndPointsDistance",
"=",
"params",
".",
"capsuleEndPointsDistance",
";",
"const",
"isStationary",
"=",
"p... | The radius of the created capsule will be an average from the two shortest sides.
There are two modes: either we use scale, or we use radius and capsuleEndPointsDistance.
@param {CollidableShapeConfig} params
@param {CollidablePhysicsJob} [physicsJob]
@returns {Collidable} | [
"The",
"radius",
"of",
"the",
"created",
"capsule",
"will",
"be",
"an",
"average",
"from",
"the",
"two",
"shortest",
"sides",
"."
] | 62df9f6968082ed34aa784a23f3db6c8feca6f3a | https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collidable-factories.js#L56-L95 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/core/htmlparser/fragment.js | function( node, index )
{
isNaN( index ) && ( index = this.children.length );
var previous = index > 0 ? this.children[ index - 1 ] : null;
if ( previous )
{
// If the block to be appended is following text, trim spaces at
// the right of it.
if ( node._.isBlockLike && previous.type ... | javascript | function( node, index )
{
isNaN( index ) && ( index = this.children.length );
var previous = index > 0 ? this.children[ index - 1 ] : null;
if ( previous )
{
// If the block to be appended is following text, trim spaces at
// the right of it.
if ( node._.isBlockLike && previous.type ... | [
"function",
"(",
"node",
",",
"index",
")",
"{",
"isNaN",
"(",
"index",
")",
"&&",
"(",
"index",
"=",
"this",
".",
"children",
".",
"length",
")",
";",
"var",
"previous",
"=",
"index",
">",
"0",
"?",
"this",
".",
"children",
"[",
"index",
"-",
"1... | Adds a node to this fragment.
@param {Object} node The node to be added. It can be any of of the
following types: {@link CKEDITOR.htmlParser.element},
{@link CKEDITOR.htmlParser.text} and
{@link CKEDITOR.htmlParser.comment}.
@param {Number} [index] From where the insertion happens.
@example | [
"Adds",
"a",
"node",
"to",
"this",
"fragment",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/htmlparser/fragment.js#L451-L483 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/htmlparser/fragment.js | function( writer, filter )
{
var isChildrenFiltered;
this.filterChildren = function()
{
var writer = new CKEDITOR.htmlParser.basicWriter();
this.writeChildrenHtml.call( this, writer, filter, true );
var html = writer.getHtml();
this.children = new CKEDITOR.htmlParser.fragment.fromHtml... | javascript | function( writer, filter )
{
var isChildrenFiltered;
this.filterChildren = function()
{
var writer = new CKEDITOR.htmlParser.basicWriter();
this.writeChildrenHtml.call( this, writer, filter, true );
var html = writer.getHtml();
this.children = new CKEDITOR.htmlParser.fragment.fromHtml... | [
"function",
"(",
"writer",
",",
"filter",
")",
"{",
"var",
"isChildrenFiltered",
";",
"this",
".",
"filterChildren",
"=",
"function",
"(",
")",
"{",
"var",
"writer",
"=",
"new",
"CKEDITOR",
".",
"htmlParser",
".",
"basicWriter",
"(",
")",
";",
"this",
".... | Writes the fragment HTML to a CKEDITOR.htmlWriter.
@param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
@example
var writer = new CKEDITOR.htmlWriter();
var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<P><B>Example' );
fragment.writeHtml( writer )
alert( writer.getHtml() ); "<p... | [
"Writes",
"the",
"fragment",
"HTML",
"to",
"a",
"CKEDITOR",
".",
"htmlWriter",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/htmlparser/fragment.js#L494-L510 | train | |
philmander/inverted | src/inverted/ProtoFactory.js | function(constructorFn, args) {
var newConstructorFn = function () {
constructorFn.apply(this, args);
};
newConstructorFn.prototype = constructorFn.prototype;
return new newConstructorFn();
} | javascript | function(constructorFn, args) {
var newConstructorFn = function () {
constructorFn.apply(this, args);
};
newConstructorFn.prototype = constructorFn.prototype;
return new newConstructorFn();
} | [
"function",
"(",
"constructorFn",
",",
"args",
")",
"{",
"var",
"newConstructorFn",
"=",
"function",
"(",
")",
"{",
"constructorFn",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"}",
";",
"newConstructorFn",
".",
"prototype",
"=",
"constructorFn",
"."... | magic constructor fn | [
"magic",
"constructor",
"fn"
] | af49a1ab2f501a19c457a8b41a40306e12103bf4 | https://github.com/philmander/inverted/blob/af49a1ab2f501a19c457a8b41a40306e12103bf4/src/inverted/ProtoFactory.js#L126-L133 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/tableresize/plugin.js | getMasterPillarRow | function getMasterPillarRow( table )
{
var $rows = table.$.rows,
maxCells = 0, cellsCount,
$elected, $tr;
for ( var i = 0, len = $rows.length ; i < len; i++ )
{
$tr = $rows[ i ];
cellsCount = $tr.cells.length;
if ( cellsCount > maxCells )
{
maxCells = cellsCount;
$electe... | javascript | function getMasterPillarRow( table )
{
var $rows = table.$.rows,
maxCells = 0, cellsCount,
$elected, $tr;
for ( var i = 0, len = $rows.length ; i < len; i++ )
{
$tr = $rows[ i ];
cellsCount = $tr.cells.length;
if ( cellsCount > maxCells )
{
maxCells = cellsCount;
$electe... | [
"function",
"getMasterPillarRow",
"(",
"table",
")",
"{",
"var",
"$rows",
"=",
"table",
".",
"$",
".",
"rows",
",",
"maxCells",
"=",
"0",
",",
"cellsCount",
",",
"$elected",
",",
"$tr",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"$rows... | Gets the table row that contains the most columns. | [
"Gets",
"the",
"table",
"row",
"that",
"contains",
"the",
"most",
"columns",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/tableresize/plugin.js#L39-L58 | train |
fvsch/gulp-task-maker | tools.js | catchErrors | function catchErrors() {
// don't use an arrow function, we need the `this` instance!
return plumber(function(err) {
if (!err.plugin) {
err.plugin = 'gulp-task-maker'
}
showError(err)
// keep watch tasks running
if (this && typeof this.emit === 'function') {
this.emit('end')
}
... | javascript | function catchErrors() {
// don't use an arrow function, we need the `this` instance!
return plumber(function(err) {
if (!err.plugin) {
err.plugin = 'gulp-task-maker'
}
showError(err)
// keep watch tasks running
if (this && typeof this.emit === 'function') {
this.emit('end')
}
... | [
"function",
"catchErrors",
"(",
")",
"{",
"// don't use an arrow function, we need the `this` instance!",
"return",
"plumber",
"(",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"err",
".",
"plugin",
")",
"{",
"err",
".",
"plugin",
"=",
"'gulp-task-maker'",
... | gulp-plumber with our custom error handler
@return {*} | [
"gulp",
"-",
"plumber",
"with",
"our",
"custom",
"error",
"handler"
] | 20ab4245f2d75174786ad140793e9438c025d546 | https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/tools.js#L19-L31 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/list/plugin.js | dirToListItems | function dirToListItems( list )
{
var dir = list.getDirection();
if ( dir )
{
for ( var i = 0, children = list.getChildren(), child; child = children.getItem( i ), i < children.count(); i++ )
{
if ( child.type == CKEDITOR.NODE_ELEMENT && child.is( 'li' ) && !child.getDirection() )
child.se... | javascript | function dirToListItems( list )
{
var dir = list.getDirection();
if ( dir )
{
for ( var i = 0, children = list.getChildren(), child; child = children.getItem( i ), i < children.count(); i++ )
{
if ( child.type == CKEDITOR.NODE_ELEMENT && child.is( 'li' ) && !child.getDirection() )
child.se... | [
"function",
"dirToListItems",
"(",
"list",
")",
"{",
"var",
"dir",
"=",
"list",
".",
"getDirection",
"(",
")",
";",
"if",
"(",
"dir",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"children",
"=",
"list",
".",
"getChildren",
"(",
")",
",",
"ch... | Move direction attribute from root to list items. | [
"Move",
"direction",
"attribute",
"from",
"root",
"to",
"list",
"items",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/list/plugin.js#L487-L500 | train |
slideme/rorschach | index.js | Rorschach | function Rorschach(connectionString, options) {
EventEmitter.call(this);
options = options || {};
var retryPolicy = options.retryPolicy;
if (retryPolicy instanceof RetryPolicy) {
this.retryPolicy = retryPolicy;
}
else {
this.retryPolicy = new RetryPolicy(retryPolicy);
}
// Initial state
thi... | javascript | function Rorschach(connectionString, options) {
EventEmitter.call(this);
options = options || {};
var retryPolicy = options.retryPolicy;
if (retryPolicy instanceof RetryPolicy) {
this.retryPolicy = retryPolicy;
}
else {
this.retryPolicy = new RetryPolicy(retryPolicy);
}
// Initial state
thi... | [
"function",
"Rorschach",
"(",
"connectionString",
",",
"options",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"retryPolicy",
"=",
"options",
".",
"retryPolicy",
";",
"if",
"(",
"ret... | Create instance and connect to ZooKeeper.
@constructor
@extends {events.EventEmitter}
@param {String} connectionString ZooKeeper connection string
@param {Object} [options] Options:
@param {Object|RetryPolicy} [options.retryPolicy] RetryPolicy instance or options
@param {Object} [options.zookeeper] ZooKeeper client op... | [
"Create",
"instance",
"and",
"connect",
"to",
"ZooKeeper",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/index.js#L48-L65 | train |
slideme/rorschach | index.js | initZooKeeper | function initZooKeeper(rorschach, connectionString, options) {
var error;
var zk = zookeeper.createClient(connectionString, options);
rorschach.zk = zk;
zk.connect();
zk.on('connected', onconnected);
zk.on('expired', setError);
zk.on('authenticationFailed', setError);
zk.on('disconnected', ondisconnec... | javascript | function initZooKeeper(rorschach, connectionString, options) {
var error;
var zk = zookeeper.createClient(connectionString, options);
rorschach.zk = zk;
zk.connect();
zk.on('connected', onconnected);
zk.on('expired', setError);
zk.on('authenticationFailed', setError);
zk.on('disconnected', ondisconnec... | [
"function",
"initZooKeeper",
"(",
"rorschach",
",",
"connectionString",
",",
"options",
")",
"{",
"var",
"error",
";",
"var",
"zk",
"=",
"zookeeper",
".",
"createClient",
"(",
"connectionString",
",",
"options",
")",
";",
"rorschach",
".",
"zk",
"=",
"zk",
... | Initialize connection with ZooKeeper.
@param {Rorschach} rorschach Rorschach instance
@param {String} connectionString Connection string
@param {Object} options ZooKeeper options. | [
"Initialize",
"connection",
"with",
"ZooKeeper",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/index.js#L183-L251 | train |
zakandrewking/tinier | src/tinier.js | updateComponents | function updateComponents (address, node, state, diff, bindings, renderResult,
relativeAddress, stateCallers, opts) {
// TODO pull these out to top level
const updateRecurse = ([ d, s ], k) => {
// TODO in updateRecurse functions where k can be null, there must be a
// nicer way t... | javascript | function updateComponents (address, node, state, diff, bindings, renderResult,
relativeAddress, stateCallers, opts) {
// TODO pull these out to top level
const updateRecurse = ([ d, s ], k) => {
// TODO in updateRecurse functions where k can be null, there must be a
// nicer way t... | [
"function",
"updateComponents",
"(",
"address",
",",
"node",
",",
"state",
",",
"diff",
",",
"bindings",
",",
"renderResult",
",",
"relativeAddress",
",",
"stateCallers",
",",
"opts",
")",
"{",
"// TODO pull these out to top level",
"const",
"updateRecurse",
"=",
... | Run create, update, and destroy for component.
@param {Array} address - The location of the component in the state.
@param {Object} node - A model or a node within a model.
@param {Object} diff - The diff object for this component.
@param {Object|null} bindings -
@param {Object|null} renderResult -
@param {Object} stat... | [
"Run",
"create",
"update",
"and",
"destroy",
"for",
"component",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L444-L486 | train |
zakandrewking/tinier | src/tinier.js | treeGet | function treeGet (address, tree) {
return address.reduce((accum, val) => {
return checkType(NODE, accum) ? accum.children[val] : accum[val]
}, tree)
} | javascript | function treeGet (address, tree) {
return address.reduce((accum, val) => {
return checkType(NODE, accum) ? accum.children[val] : accum[val]
}, tree)
} | [
"function",
"treeGet",
"(",
"address",
",",
"tree",
")",
"{",
"return",
"address",
".",
"reduce",
"(",
"(",
"accum",
",",
"val",
")",
"=>",
"{",
"return",
"checkType",
"(",
"NODE",
",",
"accum",
")",
"?",
"accum",
".",
"children",
"[",
"val",
"]",
... | Get the value in a tree.
@param {Array} address -
@param {Object} tree -
@return {*} - The value at the given address. | [
"Get",
"the",
"value",
"in",
"a",
"tree",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L513-L517 | train |
zakandrewking/tinier | src/tinier.js | treeSet | function treeSet (address, tree, value) {
if (address.length === 0) {
return value
} else {
const [ k, rest ] = head(address)
return (typeof k === 'string' ?
{ ...tree, [k]: treeSet(rest, treeGet([ k ], tree), value) } :
[ ...tree.slice(0, k), treeSet(rest, treeGet([ k ], tree), ... | javascript | function treeSet (address, tree, value) {
if (address.length === 0) {
return value
} else {
const [ k, rest ] = head(address)
return (typeof k === 'string' ?
{ ...tree, [k]: treeSet(rest, treeGet([ k ], tree), value) } :
[ ...tree.slice(0, k), treeSet(rest, treeGet([ k ], tree), ... | [
"function",
"treeSet",
"(",
"address",
",",
"tree",
",",
"value",
")",
"{",
"if",
"(",
"address",
".",
"length",
"===",
"0",
")",
"{",
"return",
"value",
"}",
"else",
"{",
"const",
"[",
"k",
",",
"rest",
"]",
"=",
"head",
"(",
"address",
")",
"re... | Set the value in a tree; immutable.
@param {Array} address -
@param {Object} tree -
@param {*} value - The new value to set at address.
@return (*) The new tree. | [
"Set",
"the",
"value",
"in",
"a",
"tree",
";",
"immutable",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L526-L536 | train |
zakandrewking/tinier | src/tinier.js | treeSetMutable | function treeSetMutable (address, tree, value) {
if (address.length === 0) {
return value
} else {
const [ rest, last ] = tail(address)
const parent = treeGet(rest, tree)
if (checkType(NODE, parent)) {
parent.children[last] = value
} else {
parent[last] = value
}
return tree
... | javascript | function treeSetMutable (address, tree, value) {
if (address.length === 0) {
return value
} else {
const [ rest, last ] = tail(address)
const parent = treeGet(rest, tree)
if (checkType(NODE, parent)) {
parent.children[last] = value
} else {
parent[last] = value
}
return tree
... | [
"function",
"treeSetMutable",
"(",
"address",
",",
"tree",
",",
"value",
")",
"{",
"if",
"(",
"address",
".",
"length",
"===",
"0",
")",
"{",
"return",
"value",
"}",
"else",
"{",
"const",
"[",
"rest",
",",
"last",
"]",
"=",
"tail",
"(",
"address",
... | Set the value in a tree; mutable.
@param {Array} address -
@param {Object} tree -
@param {*} value - The new value to set at address.
@return (*) The tree. | [
"Set",
"the",
"value",
"in",
"a",
"tree",
";",
"mutable",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L545-L558 | train |
zakandrewking/tinier | src/tinier.js | diffWithModel | function diffWithModel (modelNode, state, lastState, address,
triggeringAddress) {
return match(modelNode, match_diffWithModel, null, modelNode, state,
lastState, address, triggeringAddress)
} | javascript | function diffWithModel (modelNode, state, lastState, address,
triggeringAddress) {
return match(modelNode, match_diffWithModel, null, modelNode, state,
lastState, address, triggeringAddress)
} | [
"function",
"diffWithModel",
"(",
"modelNode",
",",
"state",
",",
"lastState",
",",
"address",
",",
"triggeringAddress",
")",
"{",
"return",
"match",
"(",
"modelNode",
",",
"match_diffWithModel",
",",
"null",
",",
"modelNode",
",",
"state",
",",
"lastState",
"... | Compute the full diff tree for the model node. Calls shouldUpdate. | [
"Compute",
"the",
"full",
"diff",
"tree",
"for",
"the",
"model",
"node",
".",
"Calls",
"shouldUpdate",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L711-L715 | train |
zakandrewking/tinier | src/tinier.js | singleOrAll | function singleOrAll (modelNode, address, minTreeAr) {
const getMin = indices => {
if (indices.length === 0) {
// If all elements in the array are null, return null.
return null
} else if (nonNullIndices.signals.length === 1) {
// If there is a single value, return that tree, with an updated... | javascript | function singleOrAll (modelNode, address, minTreeAr) {
const getMin = indices => {
if (indices.length === 0) {
// If all elements in the array are null, return null.
return null
} else if (nonNullIndices.signals.length === 1) {
// If there is a single value, return that tree, with an updated... | [
"function",
"singleOrAll",
"(",
"modelNode",
",",
"address",
",",
"minTreeAr",
")",
"{",
"const",
"getMin",
"=",
"indices",
"=>",
"{",
"if",
"(",
"indices",
".",
"length",
"===",
"0",
")",
"{",
"// If all elements in the array are null, return null.",
"return",
... | For an array of minSignals and minUpdate trees, return the minimal trees that
represent the whole array. | [
"For",
"an",
"array",
"of",
"minSignals",
"and",
"minUpdate",
"trees",
"return",
"the",
"minimal",
"trees",
"that",
"represent",
"the",
"whole",
"array",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L721-L768 | train |
zakandrewking/tinier | src/tinier.js | makeSignalsAPI | function makeSignalsAPI (signalNames, isCollection) {
return fromPairs(signalNames.map(name => {
return [ name, makeOneSignalAPI(isCollection) ]
}))
} | javascript | function makeSignalsAPI (signalNames, isCollection) {
return fromPairs(signalNames.map(name => {
return [ name, makeOneSignalAPI(isCollection) ]
}))
} | [
"function",
"makeSignalsAPI",
"(",
"signalNames",
",",
"isCollection",
")",
"{",
"return",
"fromPairs",
"(",
"signalNames",
".",
"map",
"(",
"name",
"=>",
"{",
"return",
"[",
"name",
",",
"makeOneSignalAPI",
"(",
"isCollection",
")",
"]",
"}",
")",
")",
"}... | Implement the signals API. | [
"Implement",
"the",
"signals",
"API",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L867-L871 | train |
zakandrewking/tinier | src/tinier.js | runSignalSetup | function runSignalSetup (component, address, stateCallers) {
const signalsAPI = makeSignalsAPI(component.signalNames, false)
const childSignalsAPI = makeChildSignalsAPI(component.model)
const reducers = patchReducersWithState(address, component, stateCallers.callReducer)
const signals = patchSignals(address, co... | javascript | function runSignalSetup (component, address, stateCallers) {
const signalsAPI = makeSignalsAPI(component.signalNames, false)
const childSignalsAPI = makeChildSignalsAPI(component.model)
const reducers = patchReducersWithState(address, component, stateCallers.callReducer)
const signals = patchSignals(address, co... | [
"function",
"runSignalSetup",
"(",
"component",
",",
"address",
",",
"stateCallers",
")",
"{",
"const",
"signalsAPI",
"=",
"makeSignalsAPI",
"(",
"component",
".",
"signalNames",
",",
"false",
")",
"const",
"childSignalsAPI",
"=",
"makeChildSignalsAPI",
"(",
"comp... | Run signalSetup with the component.
@param {Object} component -
@param {Array} address -
@param {Object} stateCallers -
@return {Object} Object with keys signalsAPI and childSignalsAPI. | [
"Run",
"signalSetup",
"with",
"the",
"component",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L921-L937 | train |
zakandrewking/tinier | src/tinier.js | makeCallSignal | function makeCallSignal (signals, opts) {
return (address, signalName, arg) => {
if (opts.verbose) {
console.log('Called signal ' + signalName + ' at [' + address.join(', ') +
'].')
}
signals.get(address).data.signals[signalName].call(arg)
}
} | javascript | function makeCallSignal (signals, opts) {
return (address, signalName, arg) => {
if (opts.verbose) {
console.log('Called signal ' + signalName + ' at [' + address.join(', ') +
'].')
}
signals.get(address).data.signals[signalName].call(arg)
}
} | [
"function",
"makeCallSignal",
"(",
"signals",
",",
"opts",
")",
"{",
"return",
"(",
"address",
",",
"signalName",
",",
"arg",
")",
"=>",
"{",
"if",
"(",
"opts",
".",
"verbose",
")",
"{",
"console",
".",
"log",
"(",
"'Called signal '",
"+",
"signalName",
... | Return a callSignal function. | [
"Return",
"a",
"callSignal",
"function",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L1269-L1277 | train |
zakandrewking/tinier | src/tinier.js | keyBy | function keyBy (arr, key) {
var obj = {}
arr.map(x => obj[x[key]] = x)
return obj
} | javascript | function keyBy (arr, key) {
var obj = {}
arr.map(x => obj[x[key]] = x)
return obj
} | [
"function",
"keyBy",
"(",
"arr",
",",
"key",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
"arr",
".",
"map",
"(",
"x",
"=>",
"obj",
"[",
"x",
"[",
"key",
"]",
"]",
"=",
"x",
")",
"return",
"obj",
"}"
] | Turn an array of objects into a new object of objects where the keys are
given by the value of `key` in each child object.
@param {[Object]} arr - The array of objects.
@param {String} key - The key to look for. | [
"Turn",
"an",
"array",
"of",
"objects",
"into",
"a",
"new",
"object",
"of",
"objects",
"where",
"the",
"keys",
"are",
"given",
"by",
"the",
"value",
"of",
"key",
"in",
"each",
"child",
"object",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L1470-L1474 | train |
zakandrewking/tinier | src/tinier.js | isText | function isText (o) {
return (o && typeof o === 'object' && o !== null &&
o.nodeType === 3 && typeof o.nodeName === 'string')
} | javascript | function isText (o) {
return (o && typeof o === 'object' && o !== null &&
o.nodeType === 3 && typeof o.nodeName === 'string')
} | [
"function",
"isText",
"(",
"o",
")",
"{",
"return",
"(",
"o",
"&&",
"typeof",
"o",
"===",
"'object'",
"&&",
"o",
"!==",
"null",
"&&",
"o",
".",
"nodeType",
"===",
"3",
"&&",
"typeof",
"o",
".",
"nodeName",
"===",
"'string'",
")",
"}"
] | Returns true if it is a DOM text element. | [
"Returns",
"true",
"if",
"it",
"is",
"a",
"DOM",
"text",
"element",
"."
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L1492-L1495 | train |
zakandrewking/tinier | src/tinier.js | flattenElementsAr | function flattenElementsAr (ar) {
return ar.reduce((acc, el) => {
return isArray(el) ? [ ...acc, ...el ] : [ ...acc, el ]
}, []).filter(notNull) // null means ignore
} | javascript | function flattenElementsAr (ar) {
return ar.reduce((acc, el) => {
return isArray(el) ? [ ...acc, ...el ] : [ ...acc, el ]
}, []).filter(notNull) // null means ignore
} | [
"function",
"flattenElementsAr",
"(",
"ar",
")",
"{",
"return",
"ar",
".",
"reduce",
"(",
"(",
"acc",
",",
"el",
")",
"=>",
"{",
"return",
"isArray",
"(",
"el",
")",
"?",
"[",
"...",
"acc",
",",
"...",
"el",
"]",
":",
"[",
"...",
"acc",
",",
"e... | flatten the elements array | [
"flatten",
"the",
"elements",
"array"
] | 05ee87bc6a52d9f411b45d145e0a62f543039a07 | https://github.com/zakandrewking/tinier/blob/05ee87bc6a52d9f411b45d145e0a62f543039a07/src/tinier.js#L1689-L1693 | train |
nodejitsu/npm-search-pagelet | client.js | redirect | function redirect(e) {
if (e && e.preventDefault) e.preventDefault();
//
// Assume that the value in the $control_input is uptodate. If not get the
// value directly through the constructor. When the selectize is still
// loading results the `getValue()` will return an empty value. This is why
... | javascript | function redirect(e) {
if (e && e.preventDefault) e.preventDefault();
//
// Assume that the value in the $control_input is uptodate. If not get the
// value directly through the constructor. When the selectize is still
// loading results the `getValue()` will return an empty value. This is why
... | [
"function",
"redirect",
"(",
"e",
")",
"{",
"if",
"(",
"e",
"&&",
"e",
".",
"preventDefault",
")",
"e",
".",
"preventDefault",
"(",
")",
";",
"//",
"// Assume that the value in the $control_input is uptodate. If not get the",
"// value directly through the constructor. Wh... | Bypass the submit functionality and just redirect manually so we don't have
to do a server callback.
@param {Event} e Optional event
@api private | [
"Bypass",
"the",
"submit",
"functionality",
"and",
"just",
"redirect",
"manually",
"so",
"we",
"don",
"t",
"have",
"to",
"do",
"a",
"server",
"callback",
"."
] | a6086c627b69c36c0cf638dc994c25f3d9d5df72 | https://github.com/nodejitsu/npm-search-pagelet/blob/a6086c627b69c36c0cf638dc994c25f3d9d5df72/client.js#L13-L28 | train |
nodejitsu/npm-search-pagelet | client.js | load | function load(query, callback) {
if (!query.length) return callback();
pagelet.complete(query, function complete(err, results) {
if (err) return callback();
callback(results);
});
} | javascript | function load(query, callback) {
if (!query.length) return callback();
pagelet.complete(query, function complete(err, results) {
if (err) return callback();
callback(results);
});
} | [
"function",
"load",
"(",
"query",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"query",
".",
"length",
")",
"return",
"callback",
"(",
")",
";",
"pagelet",
".",
"complete",
"(",
"query",
",",
"function",
"complete",
"(",
"err",
",",
"results",
")",
"{"... | Load the autocomplete results through the Pagelet's RPC methods.
@param {String} query Thing that we search for
@param {Function} callback Callback
@api private | [
"Load",
"the",
"autocomplete",
"results",
"through",
"the",
"Pagelet",
"s",
"RPC",
"methods",
"."
] | a6086c627b69c36c0cf638dc994c25f3d9d5df72 | https://github.com/nodejitsu/npm-search-pagelet/blob/a6086c627b69c36c0cf638dc994c25f3d9d5df72/client.js#L46-L54 | train |
nodejitsu/npm-search-pagelet | client.js | render | function render(item, escape) {
return [
'<div class="completed">',
'<strong class="name">'+ escape(item.name) +'</strong>',
'string' === typeof item.desc ? '<span class="description">'+ escape(item.desc) +'</span>' : '',
'</div>'
].join('');
} | javascript | function render(item, escape) {
return [
'<div class="completed">',
'<strong class="name">'+ escape(item.name) +'</strong>',
'string' === typeof item.desc ? '<span class="description">'+ escape(item.desc) +'</span>' : '',
'</div>'
].join('');
} | [
"function",
"render",
"(",
"item",
",",
"escape",
")",
"{",
"return",
"[",
"'<div class=\"completed\">'",
",",
"'<strong class=\"name\">'",
"+",
"escape",
"(",
"item",
".",
"name",
")",
"+",
"'</strong>'",
",",
"'string'",
"===",
"typeof",
"item",
".",
"desc",... | Custom layout renderer for items.
@param {Object} item The thing returned from the server.
@param {Function} escape Custom HTML escaper.
@returns {String}
@api private | [
"Custom",
"layout",
"renderer",
"for",
"items",
"."
] | a6086c627b69c36c0cf638dc994c25f3d9d5df72 | https://github.com/nodejitsu/npm-search-pagelet/blob/a6086c627b69c36c0cf638dc994c25f3d9d5df72/client.js#L65-L72 | train |
fvsch/gulp-task-maker | helpers.js | customLog | function customLog(message) {
const trimmed = message.trim()
const limit = trimmed.indexOf('\n')
if (limit === -1) {
fancyLog(trimmed)
} else {
const title = trimmed.slice(0, limit).trim()
const details = trimmed.slice(limit).trim()
fancyLog(`${title}${('\n' + details).replace(/\n/g, '\n ')}`)
... | javascript | function customLog(message) {
const trimmed = message.trim()
const limit = trimmed.indexOf('\n')
if (limit === -1) {
fancyLog(trimmed)
} else {
const title = trimmed.slice(0, limit).trim()
const details = trimmed.slice(limit).trim()
fancyLog(`${title}${('\n' + details).replace(/\n/g, '\n ')}`)
... | [
"function",
"customLog",
"(",
"message",
")",
"{",
"const",
"trimmed",
"=",
"message",
".",
"trim",
"(",
")",
"const",
"limit",
"=",
"trimmed",
".",
"indexOf",
"(",
"'\\n'",
")",
"if",
"(",
"limit",
"===",
"-",
"1",
")",
"{",
"fancyLog",
"(",
"trimme... | Custom long log format using fancy-log
@param {string} message | [
"Custom",
"long",
"log",
"format",
"using",
"fancy",
"-",
"log"
] | 20ab4245f2d75174786ad140793e9438c025d546 | https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/helpers.js#L7-L17 | train |
fvsch/gulp-task-maker | helpers.js | toUniqueStrings | function toUniqueStrings(input) {
const list = (Array.isArray(input) ? input : [input])
.map(el => (typeof el === 'string' ? el.trim() : null))
.filter(Boolean)
return list.length > 1 ? Array.from(new Set(list)) : list
} | javascript | function toUniqueStrings(input) {
const list = (Array.isArray(input) ? input : [input])
.map(el => (typeof el === 'string' ? el.trim() : null))
.filter(Boolean)
return list.length > 1 ? Array.from(new Set(list)) : list
} | [
"function",
"toUniqueStrings",
"(",
"input",
")",
"{",
"const",
"list",
"=",
"(",
"Array",
".",
"isArray",
"(",
"input",
")",
"?",
"input",
":",
"[",
"input",
"]",
")",
".",
"map",
"(",
"el",
"=>",
"(",
"typeof",
"el",
"===",
"'string'",
"?",
"el",... | Return an array of unique trimmed strings,
from input which can be a string or an array of strings
@param {Array|string} input
@return {string[]} | [
"Return",
"an",
"array",
"of",
"unique",
"trimmed",
"strings",
"from",
"input",
"which",
"can",
"be",
"a",
"string",
"or",
"an",
"array",
"of",
"strings"
] | 20ab4245f2d75174786ad140793e9438c025d546 | https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/helpers.js#L74-L79 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/forms/dialogs/select.js | removeSelectedOptions | function removeSelectedOptions( combo )
{
combo = getSelect( combo );
// Save the selected index
var iSelectedIndex = getSelectedIndex( combo );
// Remove all selected options.
for ( var i = combo.getChildren().count() - 1 ; i >= 0 ; i-- )
{
if ( combo.getChild( i ).$.selected )
combo.g... | javascript | function removeSelectedOptions( combo )
{
combo = getSelect( combo );
// Save the selected index
var iSelectedIndex = getSelectedIndex( combo );
// Remove all selected options.
for ( var i = combo.getChildren().count() - 1 ; i >= 0 ; i-- )
{
if ( combo.getChild( i ).$.selected )
combo.g... | [
"function",
"removeSelectedOptions",
"(",
"combo",
")",
"{",
"combo",
"=",
"getSelect",
"(",
"combo",
")",
";",
"// Save the selected index\r",
"var",
"iSelectedIndex",
"=",
"getSelectedIndex",
"(",
"combo",
")",
";",
"// Remove all selected options.\r",
"for",
"(",
... | Remove all selected options from a SELECT object. | [
"Remove",
"all",
"selected",
"options",
"from",
"a",
"SELECT",
"object",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/forms/dialogs/select.js#L45-L61 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/forms/dialogs/select.js | modifyOption | function modifyOption( combo, index, title, value )
{
combo = getSelect( combo );
if ( index < 0 )
return false;
var child = combo.getChild( index );
child.setText( title );
child.setValue( value );
return child;
} | javascript | function modifyOption( combo, index, title, value )
{
combo = getSelect( combo );
if ( index < 0 )
return false;
var child = combo.getChild( index );
child.setText( title );
child.setValue( value );
return child;
} | [
"function",
"modifyOption",
"(",
"combo",
",",
"index",
",",
"title",
",",
"value",
")",
"{",
"combo",
"=",
"getSelect",
"(",
"combo",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"return",
"false",
";",
"var",
"child",
"=",
"combo",
".",
"getChild",... | Modify option from a SELECT object. | [
"Modify",
"option",
"from",
"a",
"SELECT",
"object",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/forms/dialogs/select.js#L63-L72 | train |
Froguard/json-toy | bin/main.js | dir2TreeStr | function dir2TreeStr(){
argD = Type.isBoolean(argD) ? "./" : trimAndDelQuotes(argD);
let dirJson,djOpt;
try{
djOpt = {
// preChars:{
// directory: ":open_file_folder: ",
// file:":page_facing_up: "
// },
exclude:{
ou... | javascript | function dir2TreeStr(){
argD = Type.isBoolean(argD) ? "./" : trimAndDelQuotes(argD);
let dirJson,djOpt;
try{
djOpt = {
// preChars:{
// directory: ":open_file_folder: ",
// file:":page_facing_up: "
// },
exclude:{
ou... | [
"function",
"dir2TreeStr",
"(",
")",
"{",
"argD",
"=",
"Type",
".",
"isBoolean",
"(",
"argD",
")",
"?",
"\"./\"",
":",
"trimAndDelQuotes",
"(",
"argD",
")",
";",
"let",
"dirJson",
",",
"djOpt",
";",
"try",
"{",
"djOpt",
"=",
"{",
"// preChars:{",
"// ... | convert directory to tree-string | [
"convert",
"directory",
"to",
"tree",
"-",
"string"
] | cc0549794c2200adfa2c5adce4050b8ba2012000 | https://github.com/Froguard/json-toy/blob/cc0549794c2200adfa2c5adce4050b8ba2012000/bin/main.js#L120-L156 | train |
anvaka/ngraph.shremlin | lib/iterators/vertexIterator.js | VertexIterator | function VertexIterator(graph, startFrom) {
if (graph === undefined) {
throw new Error('Graph is required by VertexIterator');
}
this._graph = graph;
this._startFrom = startFrom;
this._currentIndex = 0;
this._allNodes = [];
this._initialized = false;
this._current = undefined;
} | javascript | function VertexIterator(graph, startFrom) {
if (graph === undefined) {
throw new Error('Graph is required by VertexIterator');
}
this._graph = graph;
this._startFrom = startFrom;
this._currentIndex = 0;
this._allNodes = [];
this._initialized = false;
this._current = undefined;
} | [
"function",
"VertexIterator",
"(",
"graph",
",",
"startFrom",
")",
"{",
"if",
"(",
"graph",
"===",
"undefined",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Graph is required by VertexIterator'",
")",
";",
"}",
"this",
".",
"_graph",
"=",
"graph",
";",
"this",
... | Vertex Iterator provides a simple wrapper over `graph.forEachNode`
to perform lazy iteration.
`startFrom` argument is optional and has the following meaning:
_Not passed_ - Iterate over all vertices of a `graph`:
```
var iterator = new VertexIterator(graph);
while (iterator.moveNext()) {
// prints all vertices:
cons... | [
"Vertex",
"Iterator",
"provides",
"a",
"simple",
"wrapper",
"over",
"graph",
".",
"forEachNode",
"to",
"perform",
"lazy",
"iteration",
"."
] | 98f1f7892e0b1ccc4511cf664b74e7c0276f2ce7 | https://github.com/anvaka/ngraph.shremlin/blob/98f1f7892e0b1ccc4511cf664b74e7c0276f2ce7/lib/iterators/vertexIterator.js#L58-L69 | train |
saggiyogesh/nodeportal | lib/CacheStore/index.js | CacheStore | function CacheStore(options) {
if (!options.id) {
throw new IdNotDefinedError();
}
var storeType, _cache;
function parseKey(key) {
return key.replace(/[^a-z0-9]/gi, '_').replace(/^-+/, '').replace(/-+$/, '').toLowerCase();
}
/**
* Returns Cache Store object
* @returns... | javascript | function CacheStore(options) {
if (!options.id) {
throw new IdNotDefinedError();
}
var storeType, _cache;
function parseKey(key) {
return key.replace(/[^a-z0-9]/gi, '_').replace(/^-+/, '').replace(/-+$/, '').toLowerCase();
}
/**
* Returns Cache Store object
* @returns... | [
"function",
"CacheStore",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"options",
".",
"id",
")",
"{",
"throw",
"new",
"IdNotDefinedError",
"(",
")",
";",
"}",
"var",
"storeType",
",",
"_cache",
";",
"function",
"parseKey",
"(",
"key",
")",
"{",
"return",... | Abstract function to create cache store
@param [options]
@constructor | [
"Abstract",
"function",
"to",
"create",
"cache",
"store"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/CacheStore/index.js#L41-L154 | train |
kchapelier/node-glitch | index.js | function(options) {
"use strict";
stream.Transform.call(this, options);
options = options || {};
this.probability = options.probability || 0;
this.deviation = Math.abs(options.deviation || 0);
this.whiteList = options.whiteList || [];
this.blackList = options.blackList || [];
this.func = options.func... | javascript | function(options) {
"use strict";
stream.Transform.call(this, options);
options = options || {};
this.probability = options.probability || 0;
this.deviation = Math.abs(options.deviation || 0);
this.whiteList = options.whiteList || [];
this.blackList = options.blackList || [];
this.func = options.func... | [
"function",
"(",
"options",
")",
"{",
"\"use strict\"",
";",
"stream",
".",
"Transform",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"probability",
"=",
"options",
".",
"probability",
... | GlitchedStream, a Transform stream to intentionally corrupt data
@param {Object} options
@constructor | [
"GlitchedStream",
"a",
"Transform",
"stream",
"to",
"intentionally",
"corrupt",
"data"
] | 28681c573df3864d32177252523e7ca0d59c5992 | https://github.com/kchapelier/node-glitch/blob/28681c573df3864d32177252523e7ca0d59c5992/index.js#L11-L23 | train | |
kchapelier/node-glitch | index.js | function(fileSrc, fileDst, probability, deviation, mode) {
"use strict";
var rstream = fs.createReadStream(fileSrc);
var woptions = mode ? { 'mode' : mode } : {};
var wstream = fs.createWriteStream(fileDst, woptions);
var gstream = new GlitchedStream({
'probability' : probability,
'deviation' : deviat... | javascript | function(fileSrc, fileDst, probability, deviation, mode) {
"use strict";
var rstream = fs.createReadStream(fileSrc);
var woptions = mode ? { 'mode' : mode } : {};
var wstream = fs.createWriteStream(fileDst, woptions);
var gstream = new GlitchedStream({
'probability' : probability,
'deviation' : deviat... | [
"function",
"(",
"fileSrc",
",",
"fileDst",
",",
"probability",
",",
"deviation",
",",
"mode",
")",
"{",
"\"use strict\"",
";",
"var",
"rstream",
"=",
"fs",
".",
"createReadStream",
"(",
"fileSrc",
")",
";",
"var",
"woptions",
"=",
"mode",
"?",
"{",
"'mo... | Read the content of a file, corrupt it and write it into another file
@param {String} fileSrc - Path of the source file
@param {String} fileDst - Path of the destination file
@param {Number} probability - Probability of deviation per byte (between 0 and 1)
@param {Number} deviation - Maximum value difference between ea... | [
"Read",
"the",
"content",
"of",
"a",
"file",
"corrupt",
"it",
"and",
"write",
"it",
"into",
"another",
"file"
] | 28681c573df3864d32177252523e7ca0d59c5992 | https://github.com/kchapelier/node-glitch/blob/28681c573df3864d32177252523e7ca0d59c5992/index.js#L87-L98 | train | |
ticup/CloudTypes-paper | shared/CInt.js | CInt | function CInt(base, offset, isSet) {
this.base = base || 0;
this.offset = offset || 0;
this.isSet = isSet || false;
} | javascript | function CInt(base, offset, isSet) {
this.base = base || 0;
this.offset = offset || 0;
this.isSet = isSet || false;
} | [
"function",
"CInt",
"(",
"base",
",",
"offset",
",",
"isSet",
")",
"{",
"this",
".",
"base",
"=",
"base",
"||",
"0",
";",
"this",
".",
"offset",
"=",
"offset",
"||",
"0",
";",
"this",
".",
"isSet",
"=",
"isSet",
"||",
"false",
";",
"}"
] | Actual CInt object of which an instance represents a variable of which the property is defined with CIntDeclaration | [
"Actual",
"CInt",
"object",
"of",
"which",
"an",
"instance",
"represents",
"a",
"variable",
"of",
"which",
"the",
"property",
"is",
"defined",
"with",
"CIntDeclaration"
] | f3b6adcd60bd66a28eb0e22edfcdcd9500ef7dda | https://github.com/ticup/CloudTypes-paper/blob/f3b6adcd60bd66a28eb0e22edfcdcd9500ef7dda/shared/CInt.js#L26-L30 | train |
jchook/virtual-dom-handlebars | lib/VText.js | VText | function VText(text, config) {
this.virtual = true;
extend(this, config);
// Non-overridable
this.text = [].concat(text);
this.textOnly = true;
this.simple = true;
} | javascript | function VText(text, config) {
this.virtual = true;
extend(this, config);
// Non-overridable
this.text = [].concat(text);
this.textOnly = true;
this.simple = true;
} | [
"function",
"VText",
"(",
"text",
",",
"config",
")",
"{",
"this",
".",
"virtual",
"=",
"true",
";",
"extend",
"(",
"this",
",",
"config",
")",
";",
"// Non-overridable",
"this",
".",
"text",
"=",
"[",
"]",
".",
"concat",
"(",
"text",
")",
";",
"th... | Simplest node, only text | [
"Simplest",
"node",
"only",
"text"
] | d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/VText.js#L6-L14 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/colordialog/dialogs/colordialog.js | appendColorRow | function appendColorRow( rangeA, rangeB )
{
for ( var i = rangeA ; i < rangeA + 3 ; i++ )
{
var row = table.$.insertRow( -1 );
for ( var j = rangeB ; j < rangeB + 3 ; j++ )
{
for ( var n = 0 ; n < 6 ; n++ )
{
appendColorCell( row, '#' + aColors[j] + aColors[n] + a... | javascript | function appendColorRow( rangeA, rangeB )
{
for ( var i = rangeA ; i < rangeA + 3 ; i++ )
{
var row = table.$.insertRow( -1 );
for ( var j = rangeB ; j < rangeB + 3 ; j++ )
{
for ( var n = 0 ; n < 6 ; n++ )
{
appendColorCell( row, '#' + aColors[j] + aColors[n] + a... | [
"function",
"appendColorRow",
"(",
"rangeA",
",",
"rangeB",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"rangeA",
";",
"i",
"<",
"rangeA",
"+",
"3",
";",
"i",
"++",
")",
"{",
"var",
"row",
"=",
"table",
".",
"$",
".",
"insertRow",
"(",
"-",
"1",
")"... | This function combines two ranges of three values from the color array into a row. | [
"This",
"function",
"combines",
"two",
"ranges",
"of",
"three",
"values",
"from",
"the",
"color",
"array",
"into",
"a",
"row",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/colordialog/dialogs/colordialog.js#L179-L193 | train |
ticup/CloudTypes-paper | shared/CEntity.js | CEntity | function CEntity(indexes, properties, states) {
CArray.call(this, indexes, properties);
this.states = {} || states;
this.uid = 0;
} | javascript | function CEntity(indexes, properties, states) {
CArray.call(this, indexes, properties);
this.states = {} || states;
this.uid = 0;
} | [
"function",
"CEntity",
"(",
"indexes",
",",
"properties",
",",
"states",
")",
"{",
"CArray",
".",
"call",
"(",
"this",
",",
"indexes",
",",
"properties",
")",
";",
"this",
".",
"states",
"=",
"{",
"}",
"||",
"states",
";",
"this",
".",
"uid",
"=",
... | when declared in a State, the state will add itself and the declared name for this CArray as properties to the CEntity object. | [
"when",
"declared",
"in",
"a",
"State",
"the",
"state",
"will",
"add",
"itself",
"and",
"the",
"declared",
"name",
"for",
"this",
"CArray",
"as",
"properties",
"to",
"the",
"CEntity",
"object",
"."
] | f3b6adcd60bd66a28eb0e22edfcdcd9500ef7dda | https://github.com/ticup/CloudTypes-paper/blob/f3b6adcd60bd66a28eb0e22edfcdcd9500ef7dda/shared/CEntity.js#L15-L19 | train |
saggiyogesh/nodeportal | plugins/manageResource/client/manageResource.js | attachMenu | function attachMenu(item) {
var menuType = item.find('a').hasClass(FOLDER_TYPE) ? "folderMenu" : "itemMenu";
item.contextMenu({
menu:menuType
},
function (action, el, pos) {
switch (action) {
case ADD_SUBFOLDER_MENU_COMMAND:
... | javascript | function attachMenu(item) {
var menuType = item.find('a').hasClass(FOLDER_TYPE) ? "folderMenu" : "itemMenu";
item.contextMenu({
menu:menuType
},
function (action, el, pos) {
switch (action) {
case ADD_SUBFOLDER_MENU_COMMAND:
... | [
"function",
"attachMenu",
"(",
"item",
")",
"{",
"var",
"menuType",
"=",
"item",
".",
"find",
"(",
"'a'",
")",
".",
"hasClass",
"(",
"FOLDER_TYPE",
")",
"?",
"\"folderMenu\"",
":",
"\"itemMenu\"",
";",
"item",
".",
"contextMenu",
"(",
"{",
"menu",
":",
... | attach menu as per type | [
"attach",
"menu",
"as",
"per",
"type"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/manageResource/client/manageResource.js#L272-L298 | train |
gummesson/inject-inline-style | index.js | injectStyle | function injectStyle(obj) {
if (!obj) return ''
var selectors = Object.keys(obj)
var styles = selectors.map(function(key) {
var selector = obj[key]
var style = inlineStyle(selector)
var inline = key.concat('{').concat(style).concat('}')
return inline
})
var results = styles.join('')
inser... | javascript | function injectStyle(obj) {
if (!obj) return ''
var selectors = Object.keys(obj)
var styles = selectors.map(function(key) {
var selector = obj[key]
var style = inlineStyle(selector)
var inline = key.concat('{').concat(style).concat('}')
return inline
})
var results = styles.join('')
inser... | [
"function",
"injectStyle",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"return",
"''",
"var",
"selectors",
"=",
"Object",
".",
"keys",
"(",
"obj",
")",
"var",
"styles",
"=",
"selectors",
".",
"map",
"(",
"function",
"(",
"key",
")",
"{",
"var... | Inject `obj` as an inline CSS string.
@param {Object} obj
@return {String} | [
"Inject",
"obj",
"as",
"an",
"inline",
"CSS",
"string",
"."
] | 9e8aa759ac240390b3404c0b508d02d52e699e6b | https://github.com/gummesson/inject-inline-style/blob/9e8aa759ac240390b3404c0b508d02d52e699e6b/index.js#L21-L37 | train |
BadgeUp/badgeup-browser-client | dist/src/http.js | fetchWithRetry | function fetchWithRetry(url, options) {
async function fetchWrapper() {
const response = await fetch(url, options);
// don't retry if status is 4xx
if (response.status >= 400 && response.status < 500) {
const contentType = response.headers.get('content-type');
if (con... | javascript | function fetchWithRetry(url, options) {
async function fetchWrapper() {
const response = await fetch(url, options);
// don't retry if status is 4xx
if (response.status >= 400 && response.status < 500) {
const contentType = response.headers.get('content-type');
if (con... | [
"function",
"fetchWithRetry",
"(",
"url",
",",
"options",
")",
"{",
"async",
"function",
"fetchWrapper",
"(",
")",
"{",
"const",
"response",
"=",
"await",
"fetch",
"(",
"url",
",",
"options",
")",
";",
"// don't retry if status is 4xx",
"if",
"(",
"response",
... | Performs fetch with retries in case of HTTP errors
@param url request url
@param options request options
@returns Returns a Promise that resolves with the response object | [
"Performs",
"fetch",
"with",
"retries",
"in",
"case",
"of",
"HTTP",
"errors"
] | a9ab5051b445f139a83c6ac1499e7a31c85a79f4 | https://github.com/BadgeUp/badgeup-browser-client/blob/a9ab5051b445f139a83c6ac1499e7a31c85a79f4/dist/src/http.js#L78-L95 | train |
BadgeUp/badgeup-browser-client | dist/src/http.js | hydrateDates | function hydrateDates(body) {
/**
* Hydrates a string date to a Date object. Mutates input.
* @param item object potentially containing a meta object
*/
function hydrateMeta(item) {
const meta = item.meta;
if (meta && meta.created) {
// parse ISO-8601 string to Date
... | javascript | function hydrateDates(body) {
/**
* Hydrates a string date to a Date object. Mutates input.
* @param item object potentially containing a meta object
*/
function hydrateMeta(item) {
const meta = item.meta;
if (meta && meta.created) {
// parse ISO-8601 string to Date
... | [
"function",
"hydrateDates",
"(",
"body",
")",
"{",
"/**\n * Hydrates a string date to a Date object. Mutates input.\n * @param item object potentially containing a meta object\n */",
"function",
"hydrateMeta",
"(",
"item",
")",
"{",
"const",
"meta",
"=",
"item",
".",
... | Hydrates dates in response bodies. Handles paginated responses and object responses.
Mutates input.
@param body HTTP response body | [
"Hydrates",
"dates",
"in",
"response",
"bodies",
".",
"Handles",
"paginated",
"responses",
"and",
"object",
"responses",
".",
"Mutates",
"input",
"."
] | a9ab5051b445f139a83c6ac1499e7a31c85a79f4 | https://github.com/BadgeUp/badgeup-browser-client/blob/a9ab5051b445f139a83c6ac1499e7a31c85a79f4/dist/src/http.js#L101-L124 | train |
BadgeUp/badgeup-browser-client | dist/src/http.js | hydrateMeta | function hydrateMeta(item) {
const meta = item.meta;
if (meta && meta.created) {
// parse ISO-8601 string to Date
meta.created = new Date(meta.created);
}
} | javascript | function hydrateMeta(item) {
const meta = item.meta;
if (meta && meta.created) {
// parse ISO-8601 string to Date
meta.created = new Date(meta.created);
}
} | [
"function",
"hydrateMeta",
"(",
"item",
")",
"{",
"const",
"meta",
"=",
"item",
".",
"meta",
";",
"if",
"(",
"meta",
"&&",
"meta",
".",
"created",
")",
"{",
"// parse ISO-8601 string to Date",
"meta",
".",
"created",
"=",
"new",
"Date",
"(",
"meta",
".",... | Hydrates a string date to a Date object. Mutates input.
@param item object potentially containing a meta object | [
"Hydrates",
"a",
"string",
"date",
"to",
"a",
"Date",
"object",
".",
"Mutates",
"input",
"."
] | a9ab5051b445f139a83c6ac1499e7a31c85a79f4 | https://github.com/BadgeUp/badgeup-browser-client/blob/a9ab5051b445f139a83c6ac1499e7a31c85a79f4/dist/src/http.js#L106-L112 | train |
slideme/rorschach | lib/LeaderElection.js | LeaderElection | function LeaderElection(client, path, id) {
EventEmitter.call(this);
/**
* Ref. to client.
*
* @type {Rorschach}
*/
this.client = client;
/**
* ZooKeeper path where participants' nodes exist.
*
* @type {String}
*/
this.path = path;
/**
* Id of participant. It's kept in node.
... | javascript | function LeaderElection(client, path, id) {
EventEmitter.call(this);
/**
* Ref. to client.
*
* @type {Rorschach}
*/
this.client = client;
/**
* ZooKeeper path where participants' nodes exist.
*
* @type {String}
*/
this.path = path;
/**
* Id of participant. It's kept in node.
... | [
"function",
"LeaderElection",
"(",
"client",
",",
"path",
",",
"id",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"/**\n * Ref. to client.\n *\n * @type {Rorschach}\n */",
"this",
".",
"client",
"=",
"client",
";",
"/**\n * ZooKeeper path wh... | Leader election participant.
@constructor
@extends {EventEmitter}
@param {Rorschach} client Rorschach instance
@param {String} path Election path
@param {String} id Participant id | [
"Leader",
"election",
"participant",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/LeaderElection.js#L44-L85 | train |
slideme/rorschach | lib/LeaderElection.js | handleStateChange | function handleStateChange(election, state) {
if (state === ConnectionState.RECONNECTED) {
reset(election, afterReset);
}
else if (state === ConnectionState.SUSPENDED ||
state === ConnectionState.LOST) {
setLeadership(election, false);
}
function afterReset(err) {
if (err) {
election.em... | javascript | function handleStateChange(election, state) {
if (state === ConnectionState.RECONNECTED) {
reset(election, afterReset);
}
else if (state === ConnectionState.SUSPENDED ||
state === ConnectionState.LOST) {
setLeadership(election, false);
}
function afterReset(err) {
if (err) {
election.em... | [
"function",
"handleStateChange",
"(",
"election",
",",
"state",
")",
"{",
"if",
"(",
"state",
"===",
"ConnectionState",
".",
"RECONNECTED",
")",
"{",
"reset",
"(",
"election",
",",
"afterReset",
")",
";",
"}",
"else",
"if",
"(",
"state",
"===",
"Connection... | Handle connection state change.
@param {LeaderElection} election
@param {ConnectionState} state | [
"Handle",
"connection",
"state",
"change",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/LeaderElection.js#L154-L169 | train |
UsabilityDynamics/node-wordpress-client | examples/upload.js | fileUploaded | function fileUploaded( error, response ) {
this.debug( 'File Uploaded' );
console.log( require( 'util' ).inspect( error || response, { showHidden: false, colors: true, depth: 4 } ) );
} | javascript | function fileUploaded( error, response ) {
this.debug( 'File Uploaded' );
console.log( require( 'util' ).inspect( error || response, { showHidden: false, colors: true, depth: 4 } ) );
} | [
"function",
"fileUploaded",
"(",
"error",
",",
"response",
")",
"{",
"this",
".",
"debug",
"(",
"'File Uploaded'",
")",
";",
"console",
".",
"log",
"(",
"require",
"(",
"'util'",
")",
".",
"inspect",
"(",
"error",
"||",
"response",
",",
"{",
"showHidden"... | File Uploaded Callback
@param error
@param response | [
"File",
"Uploaded",
"Callback"
] | 2b47a7c5cadd3d8f2cfd255f997f36af14a5d843 | https://github.com/UsabilityDynamics/node-wordpress-client/blob/2b47a7c5cadd3d8f2cfd255f997f36af14a5d843/examples/upload.js#L22-L25 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/core/htmlparser/text.js | function( writer, filter )
{
var text = this.value;
if ( filter && !( text = filter.onText( text, this ) ) )
return;
writer.text( text );
} | javascript | function( writer, filter )
{
var text = this.value;
if ( filter && !( text = filter.onText( text, this ) ) )
return;
writer.text( text );
} | [
"function",
"(",
"writer",
",",
"filter",
")",
"{",
"var",
"text",
"=",
"this",
".",
"value",
";",
"if",
"(",
"filter",
"&&",
"!",
"(",
"text",
"=",
"filter",
".",
"onText",
"(",
"text",
",",
"this",
")",
")",
")",
"return",
";",
"writer",
".",
... | Writes the HTML representation of this text to a CKEDITOR.htmlWriter.
@param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
@example | [
"Writes",
"the",
"HTML",
"representation",
"of",
"this",
"text",
"to",
"a",
"CKEDITOR",
".",
"htmlWriter",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/htmlparser/text.js#L43-L51 | train | |
Froguard/json-toy | lib/json-check-circular.js | checkCircular | function checkCircular(obj){
let isCcl = false;
let cclKeysArr = [];
travelJson(obj,function(k,v,kp,ts,cpl,cd,isCircular){
if(isCircular){
isCcl = true;
cclKeysArr.push({
keyPath: kp,
circularTo: v.slice(11,-1),
key: k,
... | javascript | function checkCircular(obj){
let isCcl = false;
let cclKeysArr = [];
travelJson(obj,function(k,v,kp,ts,cpl,cd,isCircular){
if(isCircular){
isCcl = true;
cclKeysArr.push({
keyPath: kp,
circularTo: v.slice(11,-1),
key: k,
... | [
"function",
"checkCircular",
"(",
"obj",
")",
"{",
"let",
"isCcl",
"=",
"false",
";",
"let",
"cclKeysArr",
"=",
"[",
"]",
";",
"travelJson",
"(",
"obj",
",",
"function",
"(",
"k",
",",
"v",
",",
"kp",
",",
"ts",
",",
"cpl",
",",
"cd",
",",
"isCir... | check circular obj
@param obj
@returns {{isCircular: boolean, circularProps: Array}} | [
"check",
"circular",
"obj"
] | cc0549794c2200adfa2c5adce4050b8ba2012000 | https://github.com/Froguard/json-toy/blob/cc0549794c2200adfa2c5adce4050b8ba2012000/lib/json-check-circular.js#L7-L25 | train |
dcodeIO/node-BufferView | index.js | BufferView | function BufferView(buffer, byteOffset, byteLength) {
if (typeof byteOffset === "undefined") byteOffset = 0;
if (typeof byteLength === "undefined") byteLength = buffer.length;
this._buffer = byteOffset === 0 && byteLength === buffer.length
? buffer
: buffer.slice(byteOffset, byteLength);
} | javascript | function BufferView(buffer, byteOffset, byteLength) {
if (typeof byteOffset === "undefined") byteOffset = 0;
if (typeof byteLength === "undefined") byteLength = buffer.length;
this._buffer = byteOffset === 0 && byteLength === buffer.length
? buffer
: buffer.slice(byteOffset, byteLength);
} | [
"function",
"BufferView",
"(",
"buffer",
",",
"byteOffset",
",",
"byteLength",
")",
"{",
"if",
"(",
"typeof",
"byteOffset",
"===",
"\"undefined\"",
")",
"byteOffset",
"=",
"0",
";",
"if",
"(",
"typeof",
"byteLength",
"===",
"\"undefined\"",
")",
"byteLength",
... | Constructs a new BufferView.
@exports BufferView
@class An optimized DataView-compatible BufferView for node Buffers.
@param {!Buffer} buffer An existing Buffer to use as the storage for the new BufferView object.
@param {number=} byteOffset The offset, in bytes, to the first byte in the specified buffer for the new vi... | [
"Constructs",
"a",
"new",
"BufferView",
"."
] | 4e025d6f0ebd089f0408d3c1d3f47684aac8c965 | https://github.com/dcodeIO/node-BufferView/blob/4e025d6f0ebd089f0408d3c1d3f47684aac8c965/index.js#L16-L22 | train |
Havvy/mock-net-socket | socket.js | function (message, data) {
var datastr = data === undefined ? "no-data" : inspect(data);
logfn(format(" [EMIT] %s %s", pad(message), datastr));
EEProto.emit.apply(this, arguments);
} | javascript | function (message, data) {
var datastr = data === undefined ? "no-data" : inspect(data);
logfn(format(" [EMIT] %s %s", pad(message), datastr));
EEProto.emit.apply(this, arguments);
} | [
"function",
"(",
"message",
",",
"data",
")",
"{",
"var",
"datastr",
"=",
"data",
"===",
"undefined",
"?",
"\"no-data\"",
":",
"inspect",
"(",
"data",
")",
";",
"logfn",
"(",
"format",
"(",
"\" [EMIT] %s %s\"",
",",
"pad",
"(",
"message",
")",
",",
"da... | Spying on Event Emitter methods. | [
"Spying",
"on",
"Event",
"Emitter",
"methods",
"."
] | b27404b2be835536829f1391fcd6cba4f0de3d9e | https://github.com/Havvy/mock-net-socket/blob/b27404b2be835536829f1391fcd6cba4f0de3d9e/socket.js#L86-L90 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/node.js | function( evaluator )
{
var next = this.$, retval;
do
{
next = next.nextSibling;
retval = next && new CKEDITOR.dom.node( next );
}
while ( retval && evaluator && !evaluator( retval ) )
return retval;
} | javascript | function( evaluator )
{
var next = this.$, retval;
do
{
next = next.nextSibling;
retval = next && new CKEDITOR.dom.node( next );
}
while ( retval && evaluator && !evaluator( retval ) )
return retval;
} | [
"function",
"(",
"evaluator",
")",
"{",
"var",
"next",
"=",
"this",
".",
"$",
",",
"retval",
";",
"do",
"{",
"next",
"=",
"next",
".",
"nextSibling",
";",
"retval",
"=",
"next",
"&&",
"new",
"CKEDITOR",
".",
"dom",
".",
"node",
"(",
"next",
")",
... | Gets the node that follows this element in its parent's child list.
@param {Function} evaluator Filtering the result node.
@returns {CKEDITOR.dom.node} The next node or null if not available.
@example
var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b> <i>next</i></d... | [
"Gets",
"the",
"node",
"that",
"follows",
"this",
"element",
"in",
"its",
"parent",
"s",
"child",
"list",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/node.js#L370-L380 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/node.js | function( reference, includeSelf )
{
var $ = this.$,
name;
if ( !includeSelf )
$ = $.parentNode;
while ( $ )
{
if ( $.nodeName && ( name = $.nodeName.toLowerCase(), ( typeof reference == 'string' ? name == reference : name in reference ) ) )
return new CKEDITOR.dom.node( $ );... | javascript | function( reference, includeSelf )
{
var $ = this.$,
name;
if ( !includeSelf )
$ = $.parentNode;
while ( $ )
{
if ( $.nodeName && ( name = $.nodeName.toLowerCase(), ( typeof reference == 'string' ? name == reference : name in reference ) ) )
return new CKEDITOR.dom.node( $ );... | [
"function",
"(",
"reference",
",",
"includeSelf",
")",
"{",
"var",
"$",
"=",
"this",
".",
"$",
",",
"name",
";",
"if",
"(",
"!",
"includeSelf",
")",
"$",
"=",
"$",
".",
"parentNode",
";",
"while",
"(",
"$",
")",
"{",
"if",
"(",
"$",
".",
"nodeN... | Gets the closest ancestor node of this node, specified by its name.
@param {String} reference The name of the ancestor node to search or
an object with the node names to search for.
@param {Boolean} [includeSelf] Whether to include the current
node in the search.
@returns {CKEDITOR.dom.node} The located ancestor node o... | [
"Gets",
"the",
"closest",
"ancestor",
"node",
"of",
"this",
"node",
"specified",
"by",
"its",
"name",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/node.js#L507-L523 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/node.js | function( preserveChildren )
{
var $ = this.$;
var parent = $.parentNode;
if ( parent )
{
if ( preserveChildren )
{
// Move all children before the node.
for ( var child ; ( child = $.firstChild ) ; )
{
parent.insertBefore( $.removeChild( child ), $ );
}
... | javascript | function( preserveChildren )
{
var $ = this.$;
var parent = $.parentNode;
if ( parent )
{
if ( preserveChildren )
{
// Move all children before the node.
for ( var child ; ( child = $.firstChild ) ; )
{
parent.insertBefore( $.removeChild( child ), $ );
}
... | [
"function",
"(",
"preserveChildren",
")",
"{",
"var",
"$",
"=",
"this",
".",
"$",
";",
"var",
"parent",
"=",
"$",
".",
"parentNode",
";",
"if",
"(",
"parent",
")",
"{",
"if",
"(",
"preserveChildren",
")",
"{",
"// Move all children before the node.\r",
"fo... | Removes this node from the document DOM.
@param {Boolean} [preserveChildren] Indicates that the children
elements must remain in the document, removing only the outer
tags.
@example
var element = CKEDITOR.dom.element.getById( 'MyElement' );
<strong>element.remove()</strong>; | [
"Removes",
"this",
"node",
"from",
"the",
"document",
"DOM",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/node.js#L556-L576 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/skins.js | function()
{
if ( cssIsLoaded && jsIsLoaded )
{
// Mark the part as loaded.
part._isLoaded = 1;
// Call all pending callbacks.
for ( var i = 0 ; i < pending.length ; i++ )
{
if ( pending[ i ] )
pending[ i ]();
}
}
} | javascript | function()
{
if ( cssIsLoaded && jsIsLoaded )
{
// Mark the part as loaded.
part._isLoaded = 1;
// Call all pending callbacks.
for ( var i = 0 ; i < pending.length ; i++ )
{
if ( pending[ i ] )
pending[ i ]();
}
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"cssIsLoaded",
"&&",
"jsIsLoaded",
")",
"{",
"// Mark the part as loaded.\r",
"part",
".",
"_isLoaded",
"=",
"1",
";",
"// Call all pending callbacks.\r",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"pending",
".",
... | This is the function that will trigger the callback calls on load. | [
"This",
"is",
"the",
"function",
"that",
"will",
"trigger",
"the",
"callback",
"calls",
"on",
"load",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/skins.js#L81-L95 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/skins.js | function( skinName, skinDefinition )
{
loaded[ skinName ] = skinDefinition;
skinDefinition.skinPath = paths[ skinName ]
|| ( paths[ skinName ] =
CKEDITOR.getUrl(
'_source/' + // @Packager.RemoveLine
'skins/' + skinName + '/' ) );
} | javascript | function( skinName, skinDefinition )
{
loaded[ skinName ] = skinDefinition;
skinDefinition.skinPath = paths[ skinName ]
|| ( paths[ skinName ] =
CKEDITOR.getUrl(
'_source/' + // @Packager.RemoveLine
'skins/' + skinName + '/' ) );
} | [
"function",
"(",
"skinName",
",",
"skinDefinition",
")",
"{",
"loaded",
"[",
"skinName",
"]",
"=",
"skinDefinition",
";",
"skinDefinition",
".",
"skinPath",
"=",
"paths",
"[",
"skinName",
"]",
"||",
"(",
"paths",
"[",
"skinName",
"]",
"=",
"CKEDITOR",
".",... | Registers a skin definition.
@param {String} skinName The skin name.
@param {Object} skinDefinition The skin definition.
@example | [
"Registers",
"a",
"skin",
"definition",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/skins.js#L145-L154 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/skins.js | function( editor, skinPart, callback )
{
var skinName = editor.skinName,
skinPath = editor.skinPath;
if ( loaded[ skinName ] )
loadPart( editor, skinName, skinPart, callback );
else
{
paths[ skinName ] = skinPath;
CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( skinPath + 'skin.js'... | javascript | function( editor, skinPart, callback )
{
var skinName = editor.skinName,
skinPath = editor.skinPath;
if ( loaded[ skinName ] )
loadPart( editor, skinName, skinPart, callback );
else
{
paths[ skinName ] = skinPath;
CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( skinPath + 'skin.js'... | [
"function",
"(",
"editor",
",",
"skinPart",
",",
"callback",
")",
"{",
"var",
"skinName",
"=",
"editor",
".",
"skinName",
",",
"skinPath",
"=",
"editor",
".",
"skinPath",
";",
"if",
"(",
"loaded",
"[",
"skinName",
"]",
")",
"loadPart",
"(",
"editor",
"... | Loads a skin part. Skins are defined in parts, which are basically
separated CSS files. This function is mainly used by the core code and
should not have much use out of it.
@param {String} skinName The name of the skin to be loaded.
@param {String} skinPart The skin part to be loaded. Common skin parts
are "editor" an... | [
"Loads",
"a",
"skin",
"part",
".",
"Skins",
"are",
"defined",
"in",
"parts",
"which",
"are",
"basically",
"separated",
"CSS",
"files",
".",
"This",
"function",
"is",
"mainly",
"used",
"by",
"the",
"core",
"code",
"and",
"should",
"not",
"have",
"much",
"... | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/skins.js#L167-L182 | train | |
Testlio/lambda-foundation | lib/util.js | forOwnDeep | function forOwnDeep(object, callback, prefix) {
prefix = prefix ? prefix + '.' : '';
_.forOwn(object, function(value, key) {
if (_.isString(value)) {
callback(value, prefix + key);
} else {
forOwnDeep(value, callback, prefix + key);
}
});
} | javascript | function forOwnDeep(object, callback, prefix) {
prefix = prefix ? prefix + '.' : '';
_.forOwn(object, function(value, key) {
if (_.isString(value)) {
callback(value, prefix + key);
} else {
forOwnDeep(value, callback, prefix + key);
}
});
} | [
"function",
"forOwnDeep",
"(",
"object",
",",
"callback",
",",
"prefix",
")",
"{",
"prefix",
"=",
"prefix",
"?",
"prefix",
"+",
"'.'",
":",
"''",
";",
"_",
".",
"forOwn",
"(",
"object",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"if",
"("... | Utility function for looping deeply over an object's properties
@param object - object to loop over
@param callback - callback to call for every key-value pair found
@param prefix - prefix to use for the keys that are returned in the callback | [
"Utility",
"function",
"for",
"looping",
"deeply",
"over",
"an",
"object",
"s",
"properties"
] | d6db22ab7974b9279f17466f36f77af4d53fde01 | https://github.com/Testlio/lambda-foundation/blob/d6db22ab7974b9279f17466f36f77af4d53fde01/lib/util.js#L14-L24 | train |
slideme/rorschach | lib/Lock.js | Lock | function Lock(client, basePath, lockName, lockDriver) {
if (lockName instanceof LockDriver) {
lockDriver = lockName;
lockName = null;
}
if (!lockName) {
lockName = Lock.LOCK_NAME;
}
if (!lockDriver) {
lockDriver = new LockDriver();
}
/**
* Keep ref to client as all the low-level opera... | javascript | function Lock(client, basePath, lockName, lockDriver) {
if (lockName instanceof LockDriver) {
lockDriver = lockName;
lockName = null;
}
if (!lockName) {
lockName = Lock.LOCK_NAME;
}
if (!lockDriver) {
lockDriver = new LockDriver();
}
/**
* Keep ref to client as all the low-level opera... | [
"function",
"Lock",
"(",
"client",
",",
"basePath",
",",
"lockName",
",",
"lockDriver",
")",
"{",
"if",
"(",
"lockName",
"instanceof",
"LockDriver",
")",
"{",
"lockDriver",
"=",
"lockName",
";",
"lockName",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"lockNam... | Distributed lock implementation
@constructor
@param {Rorschach} client Rorschach instance
@param {String} basePath Base lock path
@param {String} [lockName] Ephemeral node name
@param {LockDriver} [lockDriver=new LockDriver()] Lock utilities | [
"Distributed",
"lock",
"implementation"
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/Lock.js#L29-L96 | train |
slideme/rorschach | lib/Lock.js | attemptLock | function attemptLock(lock, timeout, callback) {
var lockPath;
var sequenceNodeName;
var timerId = null;
var start = Date.now();
createNode(lock, afterCreate);
function afterCreate(err, nodePath) {
if (err) {
return exit(err);
}
lockPath = nodePath;
sequenceNodeName = nodePath.subst... | javascript | function attemptLock(lock, timeout, callback) {
var lockPath;
var sequenceNodeName;
var timerId = null;
var start = Date.now();
createNode(lock, afterCreate);
function afterCreate(err, nodePath) {
if (err) {
return exit(err);
}
lockPath = nodePath;
sequenceNodeName = nodePath.subst... | [
"function",
"attemptLock",
"(",
"lock",
",",
"timeout",
",",
"callback",
")",
"{",
"var",
"lockPath",
";",
"var",
"sequenceNodeName",
";",
"var",
"timerId",
"=",
"null",
";",
"var",
"start",
"=",
"Date",
".",
"now",
"(",
")",
";",
"createNode",
"(",
"l... | Attempt to acquire a lock.
@private
@param {Lock} lock Instance
@param {Number} timeout Timeout
@param {Function} callback Callback function: <code>(err, lockPath)</code> | [
"Attempt",
"to",
"acquire",
"a",
"lock",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/Lock.js#L158-L277 | train |
slideme/rorschach | lib/Lock.js | createNode | function createNode(lock, callback) {
var nodePath = utils.join(lock.basePath, lock.lockName);
var client = lock.client;
client
.create()
.creatingParentsIfNeeded()
.withMode(CreateMode.EPHEMERAL_SEQUENTIAL)
.forPath(nodePath, callback);
} | javascript | function createNode(lock, callback) {
var nodePath = utils.join(lock.basePath, lock.lockName);
var client = lock.client;
client
.create()
.creatingParentsIfNeeded()
.withMode(CreateMode.EPHEMERAL_SEQUENTIAL)
.forPath(nodePath, callback);
} | [
"function",
"createNode",
"(",
"lock",
",",
"callback",
")",
"{",
"var",
"nodePath",
"=",
"utils",
".",
"join",
"(",
"lock",
".",
"basePath",
",",
"lock",
".",
"lockName",
")",
";",
"var",
"client",
"=",
"lock",
".",
"client",
";",
"client",
".",
"cr... | Create lock node.
@private
@param {Lock} lock Lock instance
@param {Function} callback Callback function: `(err, nodePath)` | [
"Create",
"lock",
"node",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/Lock.js#L289-L298 | train |
slideme/rorschach | lib/Lock.js | deleteNode | function deleteNode(lock, lockPath, callback) {
lock.client
.delete()
.guaranteed()
.forPath(lockPath, callback);
} | javascript | function deleteNode(lock, lockPath, callback) {
lock.client
.delete()
.guaranteed()
.forPath(lockPath, callback);
} | [
"function",
"deleteNode",
"(",
"lock",
",",
"lockPath",
",",
"callback",
")",
"{",
"lock",
".",
"client",
".",
"delete",
"(",
")",
".",
"guaranteed",
"(",
")",
".",
"forPath",
"(",
"lockPath",
",",
"callback",
")",
";",
"}"
] | Guaranteed node deletion.
@private
@param {Lock} lock Lock instance
@param {String} lockPath
@param {Function} [callback] Callback function: `(err)` | [
"Guaranteed",
"node",
"deletion",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/Lock.js#L311-L316 | train |
lucastan/node-buffer-utils | lib/utils.js | dupBuffer | function dupBuffer(buf){
var cloned = new Buffer(buf.length);
buf.copy(cloned);
return cloned;
} | javascript | function dupBuffer(buf){
var cloned = new Buffer(buf.length);
buf.copy(cloned);
return cloned;
} | [
"function",
"dupBuffer",
"(",
"buf",
")",
"{",
"var",
"cloned",
"=",
"new",
"Buffer",
"(",
"buf",
".",
"length",
")",
";",
"buf",
".",
"copy",
"(",
"cloned",
")",
";",
"return",
"cloned",
";",
"}"
] | Duplicates a buffer.
@param {Buffer} buf To be duplicated.
@return {Buffer} A new buffer with the exact same size and contents.
Modifying this will NOT modify the original instance. | [
"Duplicates",
"a",
"buffer",
"."
] | 8c7d7c498c2c9ada3c217f1faf08874c3e1644ed | https://github.com/lucastan/node-buffer-utils/blob/8c7d7c498c2c9ada3c217f1faf08874c3e1644ed/lib/utils.js#L9-L13 | train |
lucastan/node-buffer-utils | lib/utils.js | compare | function compare(buf1, buf2){
if (buf1.length !== buf2.length)
return buf1.length - buf2.length;
for (var i = 0; i < buf1.length; i++)
if (buf1[i] !== buf2[i])
return buf1[i] - buf2[i];
return 0;
} | javascript | function compare(buf1, buf2){
if (buf1.length !== buf2.length)
return buf1.length - buf2.length;
for (var i = 0; i < buf1.length; i++)
if (buf1[i] !== buf2[i])
return buf1[i] - buf2[i];
return 0;
} | [
"function",
"compare",
"(",
"buf1",
",",
"buf2",
")",
"{",
"if",
"(",
"buf1",
".",
"length",
"!==",
"buf2",
".",
"length",
")",
"return",
"buf1",
".",
"length",
"-",
"buf2",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"... | Compares 2 buffers, works like C's memcmp.
@return {integer} -1 if buf1 is "smaller", 0 if both are equal,
1 if buf1 is "greater". | [
"Compares",
"2",
"buffers",
"works",
"like",
"C",
"s",
"memcmp",
"."
] | 8c7d7c498c2c9ada3c217f1faf08874c3e1644ed | https://github.com/lucastan/node-buffer-utils/blob/8c7d7c498c2c9ada3c217f1faf08874c3e1644ed/lib/utils.js#L20-L29 | train |
xpepermint/koa-strong-params | lib/index.js | strongify | function strongify(o) {
/**
* Cloning object.
*/
var params = _.clone(o);
/**
* Returns all object data.
*
* @return {object}
* @api public
*/
params.all = function() {
return params = _.omit(params, ['all', 'only', 'except', 'require', 'merge']);
}
/**
* Returns only listed... | javascript | function strongify(o) {
/**
* Cloning object.
*/
var params = _.clone(o);
/**
* Returns all object data.
*
* @return {object}
* @api public
*/
params.all = function() {
return params = _.omit(params, ['all', 'only', 'except', 'require', 'merge']);
}
/**
* Returns only listed... | [
"function",
"strongify",
"(",
"o",
")",
"{",
"/**\n * Cloning object.\n */",
"var",
"params",
"=",
"_",
".",
"clone",
"(",
"o",
")",
";",
"/**\n * Returns all object data.\n *\n * @return {object}\n * @api public\n */",
"params",
".",
"all",
"=",
"function",... | Returns cloned object with extends functionality.
@param {object}
@return {object}
@api private | [
"Returns",
"cloned",
"object",
"with",
"extends",
"functionality",
"."
] | 2a81065064b2a5096dc57545fc611607f122f047 | https://github.com/xpepermint/koa-strong-params/blob/2a81065064b2a5096dc57545fc611607f122f047/lib/index.js#L17-L89 | train |
saggiyogesh/nodeportal | plugins/themeBuilder/client/themeBuilder.js | saveFileChanges | function saveFileChanges(themeId, folderName, fileName, text) {
io({
url:getURL("save") + "/" + themeId + "/" + folderName + "/" + fileName,
data:{
content:encodeURI(text)
},
callback:function (isSuccess, message, response) {
if (!i... | javascript | function saveFileChanges(themeId, folderName, fileName, text) {
io({
url:getURL("save") + "/" + themeId + "/" + folderName + "/" + fileName,
data:{
content:encodeURI(text)
},
callback:function (isSuccess, message, response) {
if (!i... | [
"function",
"saveFileChanges",
"(",
"themeId",
",",
"folderName",
",",
"fileName",
",",
"text",
")",
"{",
"io",
"(",
"{",
"url",
":",
"getURL",
"(",
"\"save\"",
")",
"+",
"\"/\"",
"+",
"themeId",
"+",
"\"/\"",
"+",
"folderName",
"+",
"\"/\"",
"+",
"fil... | Handler for save file changes
@param {String} themeId
@param {String} folderName
@param {String} fileName
@param {String} text | [
"Handler",
"for",
"save",
"file",
"changes"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/themeBuilder/client/themeBuilder.js#L55-L67 | train |
saggiyogesh/nodeportal | plugins/themeBuilder/client/themeBuilder.js | initAceEditor | function initAceEditor(themeId, folderName, fileName, text, mode) {
hideImageHolder();
$("#" + editorId).show();
var doc = new Document(text);
var session = new EditSession(doc, "ace/mode/" + mode);
session.setUndoManager(new UndoManager());
editor.setSession(session);
... | javascript | function initAceEditor(themeId, folderName, fileName, text, mode) {
hideImageHolder();
$("#" + editorId).show();
var doc = new Document(text);
var session = new EditSession(doc, "ace/mode/" + mode);
session.setUndoManager(new UndoManager());
editor.setSession(session);
... | [
"function",
"initAceEditor",
"(",
"themeId",
",",
"folderName",
",",
"fileName",
",",
"text",
",",
"mode",
")",
"{",
"hideImageHolder",
"(",
")",
";",
"$",
"(",
"\"#\"",
"+",
"editorId",
")",
".",
"show",
"(",
")",
";",
"var",
"doc",
"=",
"new",
"Doc... | Initialize editor for each file opened
@param {String} themeId
@param {String} folderName
@param {String} fileName
@param {String} text
@param {String} mode | [
"Initialize",
"editor",
"for",
"each",
"file",
"opened"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/themeBuilder/client/themeBuilder.js#L77-L91 | train |
saggiyogesh/nodeportal | plugins/themeBuilder/client/themeBuilder.js | openFile | function openFile(themeId, folderName, fileName) {
if (themeId && folderName && fileName) {
//if image then display it
if (folderName === "images") {
showImage(themeId, folderName, fileName);
return;
}
var options = {
... | javascript | function openFile(themeId, folderName, fileName) {
if (themeId && folderName && fileName) {
//if image then display it
if (folderName === "images") {
showImage(themeId, folderName, fileName);
return;
}
var options = {
... | [
"function",
"openFile",
"(",
"themeId",
",",
"folderName",
",",
"fileName",
")",
"{",
"if",
"(",
"themeId",
"&&",
"folderName",
"&&",
"fileName",
")",
"{",
"//if image then display it",
"if",
"(",
"folderName",
"===",
"\"images\"",
")",
"{",
"showImage",
"(",
... | Handler when theme file is activated in tree, calls io to show file content
@param {Number} themeId
@param {String} folderName
@param {String} fileName | [
"Handler",
"when",
"theme",
"file",
"is",
"activated",
"in",
"tree",
"calls",
"io",
"to",
"show",
"file",
"content"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/themeBuilder/client/themeBuilder.js#L100-L130 | train |
saggiyogesh/nodeportal | plugins/themeBuilder/client/themeBuilder.js | renderThemeTree | function renderThemeTree(themeId, fileList, themeName) {
var getTreeNodes = function (arr) {
var ret = [];
_.each(arr, function (fileName) {
ret.push({title:fileName});
});
return ret;
};
var css = {title:validTitleName[0], isFolder... | javascript | function renderThemeTree(themeId, fileList, themeName) {
var getTreeNodes = function (arr) {
var ret = [];
_.each(arr, function (fileName) {
ret.push({title:fileName});
});
return ret;
};
var css = {title:validTitleName[0], isFolder... | [
"function",
"renderThemeTree",
"(",
"themeId",
",",
"fileList",
",",
"themeName",
")",
"{",
"var",
"getTreeNodes",
"=",
"function",
"(",
"arr",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"_",
".",
"each",
"(",
"arr",
",",
"function",
"(",
"fileName",
... | Renders theme's folders as tree in left side and attach handlers on each file
@param {String} themeId
@param {Object} fileList | [
"Renders",
"theme",
"s",
"folders",
"as",
"tree",
"in",
"left",
"side",
"and",
"attach",
"handlers",
"on",
"each",
"file"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/themeBuilder/client/themeBuilder.js#L137-L165 | train |
jlewczyk/git-hooks-js-win | lib/git-hooks-debug.js | function (workingDirectory) {
var gitPath = getClosestGitPath(workingDirectory);
if (!gitPath) {
throw new Error('git-hooks must be run inside a git repository');
}
var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
var pathToGitHooks = path.join(path.relative(ho... | javascript | function (workingDirectory) {
var gitPath = getClosestGitPath(workingDirectory);
if (!gitPath) {
throw new Error('git-hooks must be run inside a git repository');
}
var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
var pathToGitHooks = path.join(path.relative(ho... | [
"function",
"(",
"workingDirectory",
")",
"{",
"var",
"gitPath",
"=",
"getClosestGitPath",
"(",
"workingDirectory",
")",
";",
"if",
"(",
"!",
"gitPath",
")",
"{",
"throw",
"new",
"Error",
"(",
"'git-hooks must be run inside a git repository'",
")",
";",
"}",
"va... | Installs git hooks.
@param {String} [workingDirectory]
@throws {Error} | [
"Installs",
"git",
"hooks",
"."
] | e156f88ad7aec76c9180c70656c5568ad89f9de7 | https://github.com/jlewczyk/git-hooks-js-win/blob/e156f88ad7aec76c9180c70656c5568ad89f9de7/lib/git-hooks-debug.js#L51-L90 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.