id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
18,700 | trailsjs/sails-permissions | api/services/ModelService.js | function (req) {
// TODO there has to be a more sails-y way to do this without including
// external modules
if (_.isString(req.options.alias)) {
sails.log.silly('singularizing', req.options.alias, 'to use as target model');
return pluralize.singular(req.options.alias);
} else if (_.isString... | javascript | function (req) {
// TODO there has to be a more sails-y way to do this without including
// external modules
if (_.isString(req.options.alias)) {
sails.log.silly('singularizing', req.options.alias, 'to use as target model');
return pluralize.singular(req.options.alias);
} else if (_.isString... | [
"function",
"(",
"req",
")",
"{",
"// TODO there has to be a more sails-y way to do this without including",
"// external modules",
"if",
"(",
"_",
".",
"isString",
"(",
"req",
".",
"options",
".",
"alias",
")",
")",
"{",
"sails",
".",
"log",
".",
"silly",
"(",
... | Return the type of model acted upon by this request. | [
"Return",
"the",
"type",
"of",
"model",
"acted",
"upon",
"by",
"this",
"request",
"."
] | 826d504711662bf43a5c266667dd4487553a8a41 | https://github.com/trailsjs/sails-permissions/blob/826d504711662bf43a5c266667dd4487553a8a41/api/services/ModelService.js#L8-L19 | |
18,701 | ksc-fe/kpc | components/upload/index.spec.js | fixInputChange | function fixInputChange(input) {
let files;
Object.defineProperty(input, 'files', {
set(v) { files = v; dispatchEvent(input, 'change'); },
get(v) { return files }
});
} | javascript | function fixInputChange(input) {
let files;
Object.defineProperty(input, 'files', {
set(v) { files = v; dispatchEvent(input, 'change'); },
get(v) { return files }
});
} | [
"function",
"fixInputChange",
"(",
"input",
")",
"{",
"let",
"files",
";",
"Object",
".",
"defineProperty",
"(",
"input",
",",
"'files'",
",",
"{",
"set",
"(",
"v",
")",
"{",
"files",
"=",
"v",
";",
"dispatchEvent",
"(",
"input",
",",
"'change'",
")",
... | we should trigger change event manually in the newest ChromeHeadless | [
"we",
"should",
"trigger",
"change",
"event",
"manually",
"in",
"the",
"newest",
"ChromeHeadless"
] | 5e5dcdbf95562ce3ab24dd670677348be91988c3 | https://github.com/ksc-fe/kpc/blob/5e5dcdbf95562ce3ab24dd670677348be91988c3/components/upload/index.spec.js#L25-L31 |
18,702 | nathanhleung/install-peerdeps | src/install-peerdeps.js | getPackageData | function getPackageData({ encodedPackageName, registry, auth, proxy }) {
const requestHeaders = {};
if (auth) {
requestHeaders.Authorization = `Bearer ${auth}`;
}
const options = {
uri: `${registry}/${encodedPackageName}`,
resolveWithFullResponse: true,
// When simple is true, all non-200 statu... | javascript | function getPackageData({ encodedPackageName, registry, auth, proxy }) {
const requestHeaders = {};
if (auth) {
requestHeaders.Authorization = `Bearer ${auth}`;
}
const options = {
uri: `${registry}/${encodedPackageName}`,
resolveWithFullResponse: true,
// When simple is true, all non-200 statu... | [
"function",
"getPackageData",
"(",
"{",
"encodedPackageName",
",",
"registry",
",",
"auth",
",",
"proxy",
"}",
")",
"{",
"const",
"requestHeaders",
"=",
"{",
"}",
";",
"if",
"(",
"auth",
")",
"{",
"requestHeaders",
".",
"Authorization",
"=",
"`",
"${",
"... | Gets metadata about the package from the provided registry
@param {Object} requestInfo - information needed to make the request for the data
@param {string} requestInfo.encodedPackageName - the urlencoded name of the package
@param {string} requestInfo.registry - the URI of the registry on which the package is hosted
@... | [
"Gets",
"metadata",
"about",
"the",
"package",
"from",
"the",
"provided",
"registry"
] | 402b697996ab3e6dbda503282e7a00b1e409a41e | https://github.com/nathanhleung/install-peerdeps/blob/402b697996ab3e6dbda503282e7a00b1e409a41e/src/install-peerdeps.js#L34-L73 |
18,703 | nathanhleung/install-peerdeps | src/install-peerdeps.js | spawnInstall | function spawnInstall(command, args) {
return new Promise((resolve, reject) => {
// Spawn install process
const installProcess = spawn(command, args, {
cwd: process.cwd(),
// Something to do with this, progress bar only shows if stdio is inherit
// https://github.com/yarnpkg/yarn/issues/2200... | javascript | function spawnInstall(command, args) {
return new Promise((resolve, reject) => {
// Spawn install process
const installProcess = spawn(command, args, {
cwd: process.cwd(),
// Something to do with this, progress bar only shows if stdio is inherit
// https://github.com/yarnpkg/yarn/issues/2200... | [
"function",
"spawnInstall",
"(",
"command",
",",
"args",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"// Spawn install process",
"const",
"installProcess",
"=",
"spawn",
"(",
"command",
",",
"args",
",",
"{",
"... | Spawns the package manager
@param {string} command - the command to spawn
@returns {Promise} - a Promise which resolves when the install process is finished | [
"Spawns",
"the",
"package",
"manager"
] | 402b697996ab3e6dbda503282e7a00b1e409a41e | https://github.com/nathanhleung/install-peerdeps/blob/402b697996ab3e6dbda503282e7a00b1e409a41e/src/install-peerdeps.js#L80-L99 |
18,704 | nathanhleung/install-peerdeps | src/cli.js | printPackageFormatError | function printPackageFormatError() {
console.log(
`${
C.errorText
} Please specify the package to install with peerDeps in the form of \`package\` or \`[email protected]\``
);
console.log(
`${
C.errorText
} At this time you must provide the full semver version of the package.`
);
conso... | javascript | function printPackageFormatError() {
console.log(
`${
C.errorText
} Please specify the package to install with peerDeps in the form of \`package\` or \`[email protected]\``
);
console.log(
`${
C.errorText
} At this time you must provide the full semver version of the package.`
);
conso... | [
"function",
"printPackageFormatError",
"(",
")",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"C",
".",
"errorText",
"}",
"\\`",
"\\`",
"\\`",
"\\`",
"`",
")",
";",
"console",
".",
"log",
"(",
"`",
"${",
"C",
".",
"errorText",
"}",
"`",
")",
";",
... | Error message that is printed when the program can't
parse the package string. | [
"Error",
"message",
"that",
"is",
"printed",
"when",
"the",
"program",
"can",
"t",
"parse",
"the",
"package",
"string",
"."
] | 402b697996ab3e6dbda503282e7a00b1e409a41e | https://github.com/nathanhleung/install-peerdeps/blob/402b697996ab3e6dbda503282e7a00b1e409a41e/src/cli.js#L24-L40 |
18,705 | nathanhleung/install-peerdeps | src/cli.js | installCb | function installCb(err) {
if (err) {
console.log(`${C.errorText} ${err.message}`);
process.exit(1);
}
let successMessage = `${C.successText} ${packageName}
and its peerDeps were installed successfully.`;
if (program.onlyPeers) {
successMessage = `${
C.successText
} The peerDeps of ${pack... | javascript | function installCb(err) {
if (err) {
console.log(`${C.errorText} ${err.message}`);
process.exit(1);
}
let successMessage = `${C.successText} ${packageName}
and its peerDeps were installed successfully.`;
if (program.onlyPeers) {
successMessage = `${
C.successText
} The peerDeps of ${pack... | [
"function",
"installCb",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"C",
".",
"errorText",
"}",
"${",
"err",
".",
"message",
"}",
"`",
")",
";",
"process",
".",
"exit",
"(",
"1",
")",
";",
"}",
"l... | Callback which is called after the installation
process finishes
@callback
@param {Error} [err] - the error, if any, that occurred during installation | [
"Callback",
"which",
"is",
"called",
"after",
"the",
"installation",
"process",
"finishes"
] | 402b697996ab3e6dbda503282e7a00b1e409a41e | https://github.com/nathanhleung/install-peerdeps/blob/402b697996ab3e6dbda503282e7a00b1e409a41e/src/cli.js#L209-L223 |
18,706 | springmeyer/arc.js | example/bezier/polymaps.js | projection | function projection(c) {
var zoom = c.zoom,
max = zoom < 0 ? 1 : 1 << zoom,
column = c.column % max,
row = c.row;
if (column < 0) column += max;
return {
locationPoint: function(l) {
var c = po.map.locationCoordinate(l),
k = Math.pow(2, zoo... | javascript | function projection(c) {
var zoom = c.zoom,
max = zoom < 0 ? 1 : 1 << zoom,
column = c.column % max,
row = c.row;
if (column < 0) column += max;
return {
locationPoint: function(l) {
var c = po.map.locationCoordinate(l),
k = Math.pow(2, zoo... | [
"function",
"projection",
"(",
"c",
")",
"{",
"var",
"zoom",
"=",
"c",
".",
"zoom",
",",
"max",
"=",
"zoom",
"<",
"0",
"?",
"1",
":",
"1",
"<<",
"zoom",
",",
"column",
"=",
"c",
".",
"column",
"%",
"max",
",",
"row",
"=",
"c",
".",
"row",
"... | tile-specific projection | [
"tile",
"-",
"specific",
"projection"
] | 7ea51c89915604f6e691b28b6fbdeeb95e54e820 | https://github.com/springmeyer/arc.js/blob/7ea51c89915604f6e691b28b6fbdeeb95e54e820/example/bezier/polymaps.js#L832-L848 |
18,707 | springmeyer/arc.js | example/bezier/polymaps.js | cleanup | function cleanup(e) {
if (e.tile.proxyRefs) {
for (var proxyKey in e.tile.proxyRefs) {
var proxyTile = e.tile.proxyRefs[proxyKey];
if ((--proxyTile.proxyCount <= 0) && cache.unload(proxyKey)) {
proxyTile.element.parentNode.removeChild(proxyTile.element);
}
}
delet... | javascript | function cleanup(e) {
if (e.tile.proxyRefs) {
for (var proxyKey in e.tile.proxyRefs) {
var proxyTile = e.tile.proxyRefs[proxyKey];
if ((--proxyTile.proxyCount <= 0) && cache.unload(proxyKey)) {
proxyTile.element.parentNode.removeChild(proxyTile.element);
}
}
delet... | [
"function",
"cleanup",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"tile",
".",
"proxyRefs",
")",
"{",
"for",
"(",
"var",
"proxyKey",
"in",
"e",
".",
"tile",
".",
"proxyRefs",
")",
"{",
"var",
"proxyTile",
"=",
"e",
".",
"tile",
".",
"proxyRefs",
"[... | remove proxy tiles when tiles load | [
"remove",
"proxy",
"tiles",
"when",
"tiles",
"load"
] | 7ea51c89915604f6e691b28b6fbdeeb95e54e820 | https://github.com/springmeyer/arc.js/blob/7ea51c89915604f6e691b28b6fbdeeb95e54e820/example/bezier/polymaps.js#L964-L974 |
18,708 | springmeyer/arc.js | example/bezier/polymaps.js | touchstart | function touchstart(e) {
var i = -1,
n = e.touches.length,
t = Date.now();
// doubletap detection
if ((n == 1) && (t - last < 300)) {
var z = map.zoom();
map.zoomBy(1 - z + Math.floor(z), map.mouse(e.touches[0]));
e.preventDefault();
}
last = t;
// store origi... | javascript | function touchstart(e) {
var i = -1,
n = e.touches.length,
t = Date.now();
// doubletap detection
if ((n == 1) && (t - last < 300)) {
var z = map.zoom();
map.zoomBy(1 - z + Math.floor(z), map.mouse(e.touches[0]));
e.preventDefault();
}
last = t;
// store origi... | [
"function",
"touchstart",
"(",
"e",
")",
"{",
"var",
"i",
"=",
"-",
"1",
",",
"n",
"=",
"e",
".",
"touches",
".",
"length",
",",
"t",
"=",
"Date",
".",
"now",
"(",
")",
";",
"// doubletap detection",
"if",
"(",
"(",
"n",
"==",
"1",
")",
"&&",
... | touch identifier -> location | [
"touch",
"identifier",
"-",
">",
"location"
] | 7ea51c89915604f6e691b28b6fbdeeb95e54e820 | https://github.com/springmeyer/arc.js/blob/7ea51c89915604f6e691b28b6fbdeeb95e54e820/example/bezier/polymaps.js#L1874-L1894 |
18,709 | standard/eslint-plugin-standard | rules/array-bracket-even-spacing.js | isOptionSet | function isOptionSet (option) {
return context.options[1] != null ? context.options[1][option] === !spaced : false
} | javascript | function isOptionSet (option) {
return context.options[1] != null ? context.options[1][option] === !spaced : false
} | [
"function",
"isOptionSet",
"(",
"option",
")",
"{",
"return",
"context",
".",
"options",
"[",
"1",
"]",
"!=",
"null",
"?",
"context",
".",
"options",
"[",
"1",
"]",
"[",
"option",
"]",
"===",
"!",
"spaced",
":",
"false",
"}"
] | Determines whether an option is set, relative to the spacing option.
If spaced is "always", then check whether option is set to false.
If spaced is "never", then check whether option is set to true.
@param {Object} option - The option to exclude.
@returns {boolean} Whether or not the property is excluded. | [
"Determines",
"whether",
"an",
"option",
"is",
"set",
"relative",
"to",
"the",
"spacing",
"option",
".",
"If",
"spaced",
"is",
"always",
"then",
"check",
"whether",
"option",
"is",
"set",
"to",
"false",
".",
"If",
"spaced",
"is",
"never",
"then",
"check",
... | deb1a2a05d8ed5dd2126e340e9589d94db16b670 | https://github.com/standard/eslint-plugin-standard/blob/deb1a2a05d8ed5dd2126e340e9589d94db16b670/rules/array-bracket-even-spacing.js#L33-L35 |
18,710 | standard/eslint-plugin-standard | rules/array-bracket-even-spacing.js | isSameLine | function isSameLine (left, right) {
return left.loc.start.line === right.loc.start.line
} | javascript | function isSameLine (left, right) {
return left.loc.start.line === right.loc.start.line
} | [
"function",
"isSameLine",
"(",
"left",
",",
"right",
")",
"{",
"return",
"left",
".",
"loc",
".",
"start",
".",
"line",
"===",
"right",
".",
"loc",
".",
"start",
".",
"line",
"}"
] | Determines whether two adjacent tokens are on the same line.
@param {Object} left - The left token object.
@param {Object} right - The right token object.
@returns {boolean} Whether or not the tokens are on the same line. | [
"Determines",
"whether",
"two",
"adjacent",
"tokens",
"are",
"on",
"the",
"same",
"line",
"."
] | deb1a2a05d8ed5dd2126e340e9589d94db16b670 | https://github.com/standard/eslint-plugin-standard/blob/deb1a2a05d8ed5dd2126e340e9589d94db16b670/rules/array-bracket-even-spacing.js#L65-L67 |
18,711 | standard/eslint-plugin-standard | rules/array-bracket-even-spacing.js | reportNoBeginningSpace | function reportNoBeginningSpace (node, token) {
context.report(node, token.loc.start,
"There should be no space after '" + token.value + "'")
} | javascript | function reportNoBeginningSpace (node, token) {
context.report(node, token.loc.start,
"There should be no space after '" + token.value + "'")
} | [
"function",
"reportNoBeginningSpace",
"(",
"node",
",",
"token",
")",
"{",
"context",
".",
"report",
"(",
"node",
",",
"token",
".",
"loc",
".",
"start",
",",
"\"There should be no space after '\"",
"+",
"token",
".",
"value",
"+",
"\"'\"",
")",
"}"
] | Reports that there shouldn't be a space after the first token
@param {ASTNode} node - The node to report in the event of an error.
@param {Token} token - The token to use for the report.
@returns {void} | [
"Reports",
"that",
"there",
"shouldn",
"t",
"be",
"a",
"space",
"after",
"the",
"first",
"token"
] | deb1a2a05d8ed5dd2126e340e9589d94db16b670 | https://github.com/standard/eslint-plugin-standard/blob/deb1a2a05d8ed5dd2126e340e9589d94db16b670/rules/array-bracket-even-spacing.js#L75-L78 |
18,712 | standard/eslint-plugin-standard | rules/array-bracket-even-spacing.js | validateArraySpacing | function validateArraySpacing (node) {
if (node.elements.length === 0) {
return
}
var first = context.getFirstToken(node)
var second = context.getFirstToken(node, 1)
var penultimate = context.getLastToken(node, 1)
var last = context.getLastToken(node)
var openingBrack... | javascript | function validateArraySpacing (node) {
if (node.elements.length === 0) {
return
}
var first = context.getFirstToken(node)
var second = context.getFirstToken(node, 1)
var penultimate = context.getLastToken(node, 1)
var last = context.getLastToken(node)
var openingBrack... | [
"function",
"validateArraySpacing",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"elements",
".",
"length",
"===",
"0",
")",
"{",
"return",
"}",
"var",
"first",
"=",
"context",
".",
"getFirstToken",
"(",
"node",
")",
"var",
"second",
"=",
"context",
... | Validates the spacing around array brackets
@param {ASTNode} node - The node we're checking for spacing
@returns {void} | [
"Validates",
"the",
"spacing",
"around",
"array",
"brackets"
] | deb1a2a05d8ed5dd2126e340e9589d94db16b670 | https://github.com/standard/eslint-plugin-standard/blob/deb1a2a05d8ed5dd2126e340e9589d94db16b670/rules/array-bracket-even-spacing.js#L132-L186 |
18,713 | standard/eslint-plugin-standard | rules/computed-property-even-spacing.js | checkSpacing | function checkSpacing (propertyName) {
return function (node) {
if (!node.computed) {
return
}
var property = node[propertyName]
var before = context.getTokenBefore(property)
var first = context.getFirstToken(property)
var last = context.getLastToken(pro... | javascript | function checkSpacing (propertyName) {
return function (node) {
if (!node.computed) {
return
}
var property = node[propertyName]
var before = context.getTokenBefore(property)
var first = context.getFirstToken(property)
var last = context.getLastToken(pro... | [
"function",
"checkSpacing",
"(",
"propertyName",
")",
"{",
"return",
"function",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
".",
"computed",
")",
"{",
"return",
"}",
"var",
"property",
"=",
"node",
"[",
"propertyName",
"]",
"var",
"before",
"=",
"c... | Returns a function that checks the spacing of a node on the property name
that was passed in.
@param {String} propertyName The property on the node to check for spacing
@returns {Function} A function that will check spacing on a node | [
"Returns",
"a",
"function",
"that",
"checks",
"the",
"spacing",
"of",
"a",
"node",
"on",
"the",
"property",
"name",
"that",
"was",
"passed",
"in",
"."
] | deb1a2a05d8ed5dd2126e340e9589d94db16b670 | https://github.com/standard/eslint-plugin-standard/blob/deb1a2a05d8ed5dd2126e340e9589d94db16b670/rules/computed-property-even-spacing.js#L97-L150 |
18,714 | standard/eslint-plugin-standard | rules/object-curly-even-spacing.js | validateBraceSpacing | function validateBraceSpacing (node, first, second, penultimate, last) {
var closingCurlyBraceMustBeSpaced =
(options.arraysInObjectsException && penultimate.value === ']') ||
(options.objectsInObjectsException && penultimate.value === '}')
? !options.spaced : options.spaced
// we only ... | javascript | function validateBraceSpacing (node, first, second, penultimate, last) {
var closingCurlyBraceMustBeSpaced =
(options.arraysInObjectsException && penultimate.value === ']') ||
(options.objectsInObjectsException && penultimate.value === '}')
? !options.spaced : options.spaced
// we only ... | [
"function",
"validateBraceSpacing",
"(",
"node",
",",
"first",
",",
"second",
",",
"penultimate",
",",
"last",
")",
"{",
"var",
"closingCurlyBraceMustBeSpaced",
"=",
"(",
"options",
".",
"arraysInObjectsException",
"&&",
"penultimate",
".",
"value",
"===",
"']'",
... | Determines if spacing in curly braces is valid.
@param {ASTNode} node The AST node to check.
@param {Token} first The first token to check (should be the opening brace)
@param {Token} second The second token to check (should be first after the opening brace)
@param {Token} penultimate The penultimate token to check (sh... | [
"Determines",
"if",
"spacing",
"in",
"curly",
"braces",
"is",
"valid",
"."
] | deb1a2a05d8ed5dd2126e340e9589d94db16b670 | https://github.com/standard/eslint-plugin-standard/blob/deb1a2a05d8ed5dd2126e340e9589d94db16b670/rules/object-curly-even-spacing.js#L135-L175 |
18,715 | prey/prey-node-client | lib/agent/triggers/auto-connect/mac.js | function() {
var cmd = `networksetup -setairportnetwork ${net_interface} "${ssid}"`;
run_as_user(cmd, [], function(err, out) {
return cb(err, out);
});
} | javascript | function() {
var cmd = `networksetup -setairportnetwork ${net_interface} "${ssid}"`;
run_as_user(cmd, [], function(err, out) {
return cb(err, out);
});
} | [
"function",
"(",
")",
"{",
"var",
"cmd",
"=",
"`",
"${",
"net_interface",
"}",
"${",
"ssid",
"}",
"`",
";",
"run_as_user",
"(",
"cmd",
",",
"[",
"]",
",",
"function",
"(",
"err",
",",
"out",
")",
"{",
"return",
"cb",
"(",
"err",
",",
"out",
")"... | revisar cb si va | [
"revisar",
"cb",
"si",
"va"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/agent/triggers/auto-connect/mac.js#L59-L64 | |
18,716 | prey/prey-node-client | lib/conf/account.js | function(key, cb) {
// ensure the plugin is loaded if registration succeeds
var success = function() {
shared.plugin_manager.force_enable('control-panel', function(err) {
cb();
});
}
// set API key and clear Device key
shared.keys.set_api_key(key, function(err) {
if (err) return cb(err);
... | javascript | function(key, cb) {
// ensure the plugin is loaded if registration succeeds
var success = function() {
shared.plugin_manager.force_enable('control-panel', function(err) {
cb();
});
}
// set API key and clear Device key
shared.keys.set_api_key(key, function(err) {
if (err) return cb(err);
... | [
"function",
"(",
"key",
",",
"cb",
")",
"{",
"// ensure the plugin is loaded if registration succeeds",
"var",
"success",
"=",
"function",
"(",
")",
"{",
"shared",
".",
"plugin_manager",
".",
"force_enable",
"(",
"'control-panel'",
",",
"function",
"(",
"err",
")"... | set api key and call setup so device gets linked called from cli.js after signing up or signing in | [
"set",
"api",
"key",
"and",
"call",
"setup",
"so",
"device",
"gets",
"linked",
"called",
"from",
"cli",
".",
"js",
"after",
"signing",
"up",
"or",
"signing",
"in"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/conf/account.js#L20-L44 | |
18,717 | prey/prey-node-client | lib/agent/actions/wipe/index.js | function(error, method) {
queued++;
if (typeof wipe[method] == 'function') {
wipe[method](function(err, removed) {
if (err) last_err = err;
removed += removed;
--queued || finished(last_err);
})
} else return finished(error);
} | javascript | function(error, method) {
queued++;
if (typeof wipe[method] == 'function') {
wipe[method](function(err, removed) {
if (err) last_err = err;
removed += removed;
--queued || finished(last_err);
})
} else return finished(error);
} | [
"function",
"(",
"error",
",",
"method",
")",
"{",
"queued",
"++",
";",
"if",
"(",
"typeof",
"wipe",
"[",
"method",
"]",
"==",
"'function'",
")",
"{",
"wipe",
"[",
"method",
"]",
"(",
"function",
"(",
"err",
",",
"removed",
")",
"{",
"if",
"(",
"... | runs it within this context, unlike the spawn option | [
"runs",
"it",
"within",
"this",
"context",
"unlike",
"the",
"spawn",
"option"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/agent/actions/wipe/index.js#L74-L84 | |
18,718 | prey/prey-node-client | lib/package.js | function(file, cb) {
var error,
hash = createHash('sha1'),
stream = fs.ReadStream(file);
stream.on('data', function(chunk) {
hash.update(chunk);
});
stream.on('error', function(e) {
if (!error) cb(e);
error = e;
})
stream.on('end', function() {
if (!error) cb(null, hash.dige... | javascript | function(file, cb) {
var error,
hash = createHash('sha1'),
stream = fs.ReadStream(file);
stream.on('data', function(chunk) {
hash.update(chunk);
});
stream.on('error', function(e) {
if (!error) cb(e);
error = e;
})
stream.on('end', function() {
if (!error) cb(null, hash.dige... | [
"function",
"(",
"file",
",",
"cb",
")",
"{",
"var",
"error",
",",
"hash",
"=",
"createHash",
"(",
"'sha1'",
")",
",",
"stream",
"=",
"fs",
".",
"ReadStream",
"(",
"file",
")",
";",
"stream",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"chunk",... | returns sha1 checksum for file | [
"returns",
"sha1",
"checksum",
"for",
"file"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/package.js#L36-L53 | |
18,719 | prey/prey-node-client | lib/package.js | like_a_boss | function like_a_boss(attempt) {
fs.rename(from, to, function(err) {
if (err) log('Error when moving directory: ' + err.message);
// if no error, or err is not EPERM/EACCES, we're done
if (!err || (err.code != 'EPERM' && err.code != 'EACCES'))
cb();
else if (attempt >= 30) // max att... | javascript | function like_a_boss(attempt) {
fs.rename(from, to, function(err) {
if (err) log('Error when moving directory: ' + err.message);
// if no error, or err is not EPERM/EACCES, we're done
if (!err || (err.code != 'EPERM' && err.code != 'EACCES'))
cb();
else if (attempt >= 30) // max att... | [
"function",
"like_a_boss",
"(",
"attempt",
")",
"{",
"fs",
".",
"rename",
"(",
"from",
",",
"to",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"log",
"(",
"'Error when moving directory: '",
"+",
"err",
".",
"message",
")",
";",
"// if ... | on windows, antivirus softwares lock new folders until all files are scanned which causes a EPERM error when doing a fs.rename. to prevent this from ruining the process, we'll retry the fs.rename 10 times every one second if we do get a EPERM error. | [
"on",
"windows",
"antivirus",
"softwares",
"lock",
"new",
"folders",
"until",
"all",
"files",
"are",
"scanned",
"which",
"causes",
"a",
"EPERM",
"error",
"when",
"doing",
"a",
"fs",
".",
"rename",
".",
"to",
"prevent",
"this",
"from",
"ruining",
"the",
"pr... | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/package.js#L73-L86 |
18,720 | prey/prey-node-client | lib/agent/providers/lan/windows.js | function(hostname, callback) {
get_nodes(function(err,nodes) {
if (err) return callback(err);
var n = nodes.filter(function(node) {
return node.name === hostname;
});
callback(null,(n.length === 1) ? n[0].ip_address : null);
});
} | javascript | function(hostname, callback) {
get_nodes(function(err,nodes) {
if (err) return callback(err);
var n = nodes.filter(function(node) {
return node.name === hostname;
});
callback(null,(n.length === 1) ? n[0].ip_address : null);
});
} | [
"function",
"(",
"hostname",
",",
"callback",
")",
"{",
"get_nodes",
"(",
"function",
"(",
"err",
",",
"nodes",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"var",
"n",
"=",
"nodes",
".",
"filter",
"(",
"function",
"... | Callsback an ip address or null if can't find the hostname | [
"Callsback",
"an",
"ip",
"address",
"or",
"null",
"if",
"can",
"t",
"find",
"the",
"hostname"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/agent/providers/lan/windows.js#L37-L47 | |
18,721 | prey/prey-node-client | lib/conf/install.js | function(version, cb) {
var version_path = join(paths.versions, version),
opts = { env: process.env, cwd: version_path },
args = ['config', 'activate'];
opts.env.UPGRADING_FROM = common.version;
if (process.platform == 'win32') {
var bin = join(version_path, 'bin', 'node.exe');
... | javascript | function(version, cb) {
var version_path = join(paths.versions, version),
opts = { env: process.env, cwd: version_path },
args = ['config', 'activate'];
opts.env.UPGRADING_FROM = common.version;
if (process.platform == 'win32') {
var bin = join(version_path, 'bin', 'node.exe');
... | [
"function",
"(",
"version",
",",
"cb",
")",
"{",
"var",
"version_path",
"=",
"join",
"(",
"paths",
".",
"versions",
",",
"version",
")",
",",
"opts",
"=",
"{",
"env",
":",
"process",
".",
"env",
",",
"cwd",
":",
"version_path",
"}",
",",
"args",
"=... | calls 'prey config activate' on the new installation, so that it performs the activation using its own paths and logic. if it fails, roll back by removing it | [
"calls",
"prey",
"config",
"activate",
"on",
"the",
"new",
"installation",
"so",
"that",
"it",
"performs",
"the",
"activation",
"using",
"its",
"own",
"paths",
"and",
"logic",
".",
"if",
"it",
"fails",
"roll",
"back",
"by",
"removing",
"it"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/conf/install.js#L14-L39 | |
18,722 | prey/prey-node-client | lib/agent/actions.js | function(type, action, name, opts, emitter) {
logger.info('Running: ' + name)
running[name] = action;
emitter.once('end', function(err, out) {
if (err) hooks.trigger('error', err);
logger.info('Stopped: ' + name);
action_stopped(name);
setTimeout(function() {
hooks.trigger(type, 'stopped'... | javascript | function(type, action, name, opts, emitter) {
logger.info('Running: ' + name)
running[name] = action;
emitter.once('end', function(err, out) {
if (err) hooks.trigger('error', err);
logger.info('Stopped: ' + name);
action_stopped(name);
setTimeout(function() {
hooks.trigger(type, 'stopped'... | [
"function",
"(",
"type",
",",
"action",
",",
"name",
",",
"opts",
",",
"emitter",
")",
"{",
"logger",
".",
"info",
"(",
"'Running: '",
"+",
"name",
")",
"running",
"[",
"name",
"]",
"=",
"action",
";",
"emitter",
".",
"once",
"(",
"'end'",
",",
"fu... | type can be 'action' or 'trigger' | [
"type",
"can",
"be",
"action",
"or",
"trigger"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/agent/actions.js#L20-L40 | |
18,723 | prey/prey-node-client | lib/agent/plugins/retry-failed-reports/index.js | store | function store(err, resp, data) {
if (err && (err.code == 'EADDRINFO' || err.code == 'ENOTFOUND'))
failed.push(data);
} | javascript | function store(err, resp, data) {
if (err && (err.code == 'EADDRINFO' || err.code == 'ENOTFOUND'))
failed.push(data);
} | [
"function",
"store",
"(",
"err",
",",
"resp",
",",
"data",
")",
"{",
"if",
"(",
"err",
"&&",
"(",
"err",
".",
"code",
"==",
"'EADDRINFO'",
"||",
"err",
".",
"code",
"==",
"'ENOTFOUND'",
")",
")",
"failed",
".",
"push",
"(",
"data",
")",
";",
"}"
... | wait 20 seconds before requeing each one | [
"wait",
"20",
"seconds",
"before",
"requeing",
"each",
"one"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/agent/plugins/retry-failed-reports/index.js#L5-L8 |
18,724 | prey/prey-node-client | lib/agent/cli.js | warn | function warn(str, code) {
if (process.stdout.writable)
process.stdout.write(str + '\n');
if (typeof code != 'undefined')
process.exit(code);
} | javascript | function warn(str, code) {
if (process.stdout.writable)
process.stdout.write(str + '\n');
if (typeof code != 'undefined')
process.exit(code);
} | [
"function",
"warn",
"(",
"str",
",",
"code",
")",
"{",
"if",
"(",
"process",
".",
"stdout",
".",
"writable",
")",
"process",
".",
"stdout",
".",
"write",
"(",
"str",
"+",
"'\\n'",
")",
";",
"if",
"(",
"typeof",
"code",
"!=",
"'undefined'",
")",
"pr... | null unless we do set one. | [
"null",
"unless",
"we",
"do",
"set",
"one",
"."
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/agent/cli.js#L40-L46 |
18,725 | prey/prey-node-client | lib/agent/plugin.js | visible | function visible(plugin_name) {
var obj = get_base_object();
obj.config = scoped_config(plugin_name);
obj.logger = scoped_logger(plugin_name);
return obj;
} | javascript | function visible(plugin_name) {
var obj = get_base_object();
obj.config = scoped_config(plugin_name);
obj.logger = scoped_logger(plugin_name);
return obj;
} | [
"function",
"visible",
"(",
"plugin_name",
")",
"{",
"var",
"obj",
"=",
"get_base_object",
"(",
")",
";",
"obj",
".",
"config",
"=",
"scoped_config",
"(",
"plugin_name",
")",
";",
"obj",
".",
"logger",
"=",
"scoped_logger",
"(",
"plugin_name",
")",
";",
... | returns the visible object that is passed over to plugin basically base + scoped_config + scoped_logger | [
"returns",
"the",
"visible",
"object",
"that",
"is",
"passed",
"over",
"to",
"plugin",
"basically",
"base",
"+",
"scoped_config",
"+",
"scoped_logger"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/agent/plugin.js#L26-L31 |
18,726 | prey/prey-node-client | lib/agent/commands.js | function(type, name, opts) {
if (!watching) return;
var storable = ['start', 'watch', 'report'];
if (type == 'cancel') // report cancelled
remove('report', name);
else if (storable.indexOf(type) !== -1) // ok for launch
store(type, name, opts);
} | javascript | function(type, name, opts) {
if (!watching) return;
var storable = ['start', 'watch', 'report'];
if (type == 'cancel') // report cancelled
remove('report', name);
else if (storable.indexOf(type) !== -1) // ok for launch
store(type, name, opts);
} | [
"function",
"(",
"type",
",",
"name",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"watching",
")",
"return",
";",
"var",
"storable",
"=",
"[",
"'start'",
",",
"'watch'",
",",
"'report'",
"]",
";",
"if",
"(",
"type",
"==",
"'cancel'",
")",
"// report cance... | record when actions, triggers and reports are started | [
"record",
"when",
"actions",
"triggers",
"and",
"reports",
"are",
"started"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/agent/commands.js#L163-L172 | |
18,727 | prey/prey-node-client | lib/agent/commands.js | function() {
if (!watching) return;
hooks.on('action', function(event, name) {
if (event == 'stopped' || event == 'failed')
remove('start', name);
});
hooks.on('trigger', function(event, name) {
if (event == 'stopped')
remove('watch', name);
});
} | javascript | function() {
if (!watching) return;
hooks.on('action', function(event, name) {
if (event == 'stopped' || event == 'failed')
remove('start', name);
});
hooks.on('trigger', function(event, name) {
if (event == 'stopped')
remove('watch', name);
});
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"watching",
")",
"return",
";",
"hooks",
".",
"on",
"(",
"'action'",
",",
"function",
"(",
"event",
",",
"name",
")",
"{",
"if",
"(",
"event",
"==",
"'stopped'",
"||",
"event",
"==",
"'failed'",
")",
"remo... | listen for new commands and add them to storage, in case the app crashes | [
"listen",
"for",
"new",
"commands",
"and",
"add",
"them",
"to",
"storage",
"in",
"case",
"the",
"app",
"crashes"
] | ade20bd28502a4126cdafbe00fe79043dff4e977 | https://github.com/prey/prey-node-client/blob/ade20bd28502a4126cdafbe00fe79043dff4e977/lib/agent/commands.js#L175-L187 | |
18,728 | OfficeDev/office-js-helpers | demo/app.js | prettify | function prettify(data) {
let json = JSON.stringify(data);
json = json.replace(/{/g, "{\n\n\t");
json = json.replace(/,/g, ",\n\t");
json = json.replace(/}/g, ",\n\n}");
return json;
} | javascript | function prettify(data) {
let json = JSON.stringify(data);
json = json.replace(/{/g, "{\n\n\t");
json = json.replace(/,/g, ",\n\t");
json = json.replace(/}/g, ",\n\n}");
return json;
} | [
"function",
"prettify",
"(",
"data",
")",
"{",
"let",
"json",
"=",
"JSON",
".",
"stringify",
"(",
"data",
")",
";",
"json",
"=",
"json",
".",
"replace",
"(",
"/",
"{",
"/",
"g",
",",
"\"{\\n\\n\\t\"",
")",
";",
"json",
"=",
"json",
".",
"replace",
... | Just a random helper to prettify json | [
"Just",
"a",
"random",
"helper",
"to",
"prettify",
"json"
] | 9bc0682bb16e60430278bf7814353aec0410352e | https://github.com/OfficeDev/office-js-helpers/blob/9bc0682bb16e60430278bf7814353aec0410352e/demo/app.js#L5-L11 |
18,729 | cwjohan/markdown-to-html | web-demo/routes/index.js | setOptions | function setOptions(options) {
exports.options = options;
home.options = options;
renderMarkdown.options = options;
renderGithubMarkdown.options = options;
} | javascript | function setOptions(options) {
exports.options = options;
home.options = options;
renderMarkdown.options = options;
renderGithubMarkdown.options = options;
} | [
"function",
"setOptions",
"(",
"options",
")",
"{",
"exports",
".",
"options",
"=",
"options",
";",
"home",
".",
"options",
"=",
"options",
";",
"renderMarkdown",
".",
"options",
"=",
"options",
";",
"renderGithubMarkdown",
".",
"options",
"=",
"options",
";... | options shared to all routing modules | [
"options",
"shared",
"to",
"all",
"routing",
"modules"
] | 15162bde7993220a141ec0dbe9ae7037bbbc3d00 | https://github.com/cwjohan/markdown-to-html/blob/15162bde7993220a141ec0dbe9ae7037bbbc3d00/web-demo/routes/index.js#L7-L12 |
18,730 | cwjohan/markdown-to-html | web-demo/routes/renderMarkdown.js | RenderMarkdown | function RenderMarkdown() {
this.options = {}; // Default value only.
this.routeMe = function(req, res) {
var md = new Markdown();
var debug = req.param('debug', false);
md.debug = debug;
md.bufmax = 2048;
var fileName = path.join(viewsDir, req.params.filename);
if (debug) console.error('>>... | javascript | function RenderMarkdown() {
this.options = {}; // Default value only.
this.routeMe = function(req, res) {
var md = new Markdown();
var debug = req.param('debug', false);
md.debug = debug;
md.bufmax = 2048;
var fileName = path.join(viewsDir, req.params.filename);
if (debug) console.error('>>... | [
"function",
"RenderMarkdown",
"(",
")",
"{",
"this",
".",
"options",
"=",
"{",
"}",
";",
"// Default value only.",
"this",
".",
"routeMe",
"=",
"function",
"(",
"req",
",",
"res",
")",
"{",
"var",
"md",
"=",
"new",
"Markdown",
"(",
")",
";",
"var",
"... | Class RenderMarkdown. | [
"Class",
"RenderMarkdown",
"."
] | 15162bde7993220a141ec0dbe9ae7037bbbc3d00 | https://github.com/cwjohan/markdown-to-html/blob/15162bde7993220a141ec0dbe9ae7037bbbc3d00/web-demo/routes/renderMarkdown.js#L16-L39 |
18,731 | pzavolinsky/elmx | cheatsheet/elm.js | fromListPush | function fromListPush(toPush, nodes)
{
var h = toPush.height;
// Maybe the node on this height does not exist.
if (nodes.length === h)
{
var node = {
ctor: '_Array',
height: h + 1,
table: [],
lengths: []
};
nodes.push(node);
}
nodes[h].table.push(toPush);
var len = length(toPush);
if (nodes[... | javascript | function fromListPush(toPush, nodes)
{
var h = toPush.height;
// Maybe the node on this height does not exist.
if (nodes.length === h)
{
var node = {
ctor: '_Array',
height: h + 1,
table: [],
lengths: []
};
nodes.push(node);
}
nodes[h].table.push(toPush);
var len = length(toPush);
if (nodes[... | [
"function",
"fromListPush",
"(",
"toPush",
",",
"nodes",
")",
"{",
"var",
"h",
"=",
"toPush",
".",
"height",
";",
"// Maybe the node on this height does not exist.",
"if",
"(",
"nodes",
".",
"length",
"===",
"h",
")",
"{",
"var",
"node",
"=",
"{",
"ctor",
... | Push a node into a higher node as a child. | [
"Push",
"a",
"node",
"into",
"a",
"higher",
"node",
"as",
"a",
"child",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L334-L368 |
18,732 | pzavolinsky/elmx | cheatsheet/elm.js | push | function push(item, a)
{
var pushed = push_(item, a);
if (pushed !== null)
{
return pushed;
}
var newTree = create(item, a.height);
return siblise(a, newTree);
} | javascript | function push(item, a)
{
var pushed = push_(item, a);
if (pushed !== null)
{
return pushed;
}
var newTree = create(item, a.height);
return siblise(a, newTree);
} | [
"function",
"push",
"(",
"item",
",",
"a",
")",
"{",
"var",
"pushed",
"=",
"push_",
"(",
"item",
",",
"a",
")",
";",
"if",
"(",
"pushed",
"!==",
"null",
")",
"{",
"return",
"pushed",
";",
"}",
"var",
"newTree",
"=",
"create",
"(",
"item",
",",
... | Pushes an item via push_ to the bottom right of a tree. | [
"Pushes",
"an",
"item",
"via",
"push_",
"to",
"the",
"bottom",
"right",
"of",
"a",
"tree",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L371-L381 |
18,733 | pzavolinsky/elmx | cheatsheet/elm.js | push_ | function push_(item, a)
{
// Handle resursion stop at leaf level.
if (a.height === 0)
{
if (a.table.length < M)
{
var newA = {
ctor: '_Array',
height: 0,
table: a.table.slice()
};
newA.table.push(item);
return newA;
}
else
{
return null;
}
}
// Recursively push
var pushed ... | javascript | function push_(item, a)
{
// Handle resursion stop at leaf level.
if (a.height === 0)
{
if (a.table.length < M)
{
var newA = {
ctor: '_Array',
height: 0,
table: a.table.slice()
};
newA.table.push(item);
return newA;
}
else
{
return null;
}
}
// Recursively push
var pushed ... | [
"function",
"push_",
"(",
"item",
",",
"a",
")",
"{",
"// Handle resursion stop at leaf level.",
"if",
"(",
"a",
".",
"height",
"===",
"0",
")",
"{",
"if",
"(",
"a",
".",
"table",
".",
"length",
"<",
"M",
")",
"{",
"var",
"newA",
"=",
"{",
"ctor",
... | Recursively tries to push an item to the bottom-right most tree possible. If there is no space left for the item, null will be returned. | [
"Recursively",
"tries",
"to",
"push",
"an",
"item",
"to",
"the",
"bottom",
"-",
"right",
"most",
"tree",
"possible",
".",
"If",
"there",
"is",
"no",
"space",
"left",
"for",
"the",
"item",
"null",
"will",
"be",
"returned",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L386-L435 |
18,734 | pzavolinsky/elmx | cheatsheet/elm.js | map | function map(f, a)
{
var newA = {
ctor: '_Array',
height: a.height,
table: new Array(a.table.length)
};
if (a.height > 0)
{
newA.lengths = a.lengths;
}
for (var i = 0; i < a.table.length; i++)
{
newA.table[i] =
a.height === 0
? f(a.table[i])
: map(f, a.table[i]);
}
return newA;
} | javascript | function map(f, a)
{
var newA = {
ctor: '_Array',
height: a.height,
table: new Array(a.table.length)
};
if (a.height > 0)
{
newA.lengths = a.lengths;
}
for (var i = 0; i < a.table.length; i++)
{
newA.table[i] =
a.height === 0
? f(a.table[i])
: map(f, a.table[i]);
}
return newA;
} | [
"function",
"map",
"(",
"f",
",",
"a",
")",
"{",
"var",
"newA",
"=",
"{",
"ctor",
":",
"'_Array'",
",",
"height",
":",
"a",
".",
"height",
",",
"table",
":",
"new",
"Array",
"(",
"a",
".",
"table",
".",
"length",
")",
"}",
";",
"if",
"(",
"a"... | Maps a function over the elements of an array. | [
"Maps",
"a",
"function",
"over",
"the",
"elements",
"of",
"an",
"array",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L456-L475 |
18,735 | pzavolinsky/elmx | cheatsheet/elm.js | append | function append(a,b)
{
if (a.table.length === 0)
{
return b;
}
if (b.table.length === 0)
{
return a;
}
var c = append_(a, b);
// Check if both nodes can be crunshed together.
if (c[0].table.length + c[1].table.length <= M)
{
if (c[0].table.length === 0)
{
return c[1];
}
if (c[1].table.length ... | javascript | function append(a,b)
{
if (a.table.length === 0)
{
return b;
}
if (b.table.length === 0)
{
return a;
}
var c = append_(a, b);
// Check if both nodes can be crunshed together.
if (c[0].table.length + c[1].table.length <= M)
{
if (c[0].table.length === 0)
{
return c[1];
}
if (c[1].table.length ... | [
"function",
"append",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
".",
"table",
".",
"length",
"===",
"0",
")",
"{",
"return",
"b",
";",
"}",
"if",
"(",
"b",
".",
"table",
".",
"length",
"===",
"0",
")",
"{",
"return",
"a",
";",
"}",
"var... | Appends two trees. | [
"Appends",
"two",
"trees",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L641-L691 |
18,736 | pzavolinsky/elmx | cheatsheet/elm.js | insertRight | function insertRight(parent, node)
{
var index = parent.table.length - 1;
parent.table[index] = node;
parent.lengths[index] = length(node);
parent.lengths[index] += index > 0 ? parent.lengths[index - 1] : 0;
} | javascript | function insertRight(parent, node)
{
var index = parent.table.length - 1;
parent.table[index] = node;
parent.lengths[index] = length(node);
parent.lengths[index] += index > 0 ? parent.lengths[index - 1] : 0;
} | [
"function",
"insertRight",
"(",
"parent",
",",
"node",
")",
"{",
"var",
"index",
"=",
"parent",
".",
"table",
".",
"length",
"-",
"1",
";",
"parent",
".",
"table",
"[",
"index",
"]",
"=",
"node",
";",
"parent",
".",
"lengths",
"[",
"index",
"]",
"=... | Helperfunctions for append_. Replaces a child node at the side of the parent. | [
"Helperfunctions",
"for",
"append_",
".",
"Replaces",
"a",
"child",
"node",
"at",
"the",
"side",
"of",
"the",
"parent",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L747-L753 |
18,737 | pzavolinsky/elmx | cheatsheet/elm.js | get2 | function get2(a, b, index)
{
return index < a.length
? a[index]
: b[index - a.length];
} | javascript | function get2(a, b, index)
{
return index < a.length
? a[index]
: b[index - a.length];
} | [
"function",
"get2",
"(",
"a",
",",
"b",
",",
"index",
")",
"{",
"return",
"index",
"<",
"a",
".",
"length",
"?",
"a",
"[",
"index",
"]",
":",
"b",
"[",
"index",
"-",
"a",
".",
"length",
"]",
";",
"}"
] | get2, set2 and saveSlot are helpers for accessing elements over two arrays. | [
"get2",
"set2",
"and",
"saveSlot",
"are",
"helpers",
"for",
"accessing",
"elements",
"over",
"two",
"arrays",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L798-L803 |
18,738 | pzavolinsky/elmx | cheatsheet/elm.js | createNode | function createNode(h, length)
{
if (length < 0)
{
length = 0;
}
var a = {
ctor: '_Array',
height: h,
table: new Array(length)
};
if (h > 0)
{
a.lengths = new Array(length);
}
return a;
} | javascript | function createNode(h, length)
{
if (length < 0)
{
length = 0;
}
var a = {
ctor: '_Array',
height: h,
table: new Array(length)
};
if (h > 0)
{
a.lengths = new Array(length);
}
return a;
} | [
"function",
"createNode",
"(",
"h",
",",
"length",
")",
"{",
"if",
"(",
"length",
"<",
"0",
")",
"{",
"length",
"=",
"0",
";",
"}",
"var",
"a",
"=",
"{",
"ctor",
":",
"'_Array'",
",",
"height",
":",
"h",
",",
"table",
":",
"new",
"Array",
"(",
... | Creates a node or leaf with a given length at their arrays for perfomance. Is only used by shuffle. | [
"Creates",
"a",
"node",
"or",
"leaf",
"with",
"a",
"given",
"length",
"at",
"their",
"arrays",
"for",
"perfomance",
".",
"Is",
"only",
"used",
"by",
"shuffle",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L830-L846 |
18,739 | pzavolinsky/elmx | cheatsheet/elm.js | nodeCopy | function nodeCopy(a)
{
var newA = {
ctor: '_Array',
height: a.height,
table: a.table.slice()
};
if (a.height > 0)
{
newA.lengths = a.lengths.slice();
}
return newA;
} | javascript | function nodeCopy(a)
{
var newA = {
ctor: '_Array',
height: a.height,
table: a.table.slice()
};
if (a.height > 0)
{
newA.lengths = a.lengths.slice();
}
return newA;
} | [
"function",
"nodeCopy",
"(",
"a",
")",
"{",
"var",
"newA",
"=",
"{",
"ctor",
":",
"'_Array'",
",",
"height",
":",
"a",
".",
"height",
",",
"table",
":",
"a",
".",
"table",
".",
"slice",
"(",
")",
"}",
";",
"if",
"(",
"a",
".",
"height",
">",
... | Copies a node for updating. Note that you should not use this if only updating only one of "table" or "lengths" for performance reasons. | [
"Copies",
"a",
"node",
"for",
"updating",
".",
"Note",
"that",
"you",
"should",
"not",
"use",
"this",
"if",
"only",
"updating",
"only",
"one",
"of",
"table",
"or",
"lengths",
"for",
"performance",
"reasons",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L938-L950 |
18,740 | pzavolinsky/elmx | cheatsheet/elm.js | length | function length(array)
{
if (array.height === 0)
{
return array.table.length;
}
else
{
return array.lengths[array.lengths.length - 1];
}
} | javascript | function length(array)
{
if (array.height === 0)
{
return array.table.length;
}
else
{
return array.lengths[array.lengths.length - 1];
}
} | [
"function",
"length",
"(",
"array",
")",
"{",
"if",
"(",
"array",
".",
"height",
"===",
"0",
")",
"{",
"return",
"array",
".",
"table",
".",
"length",
";",
"}",
"else",
"{",
"return",
"array",
".",
"lengths",
"[",
"array",
".",
"lengths",
".",
"len... | Returns how many items are in the tree. | [
"Returns",
"how",
"many",
"items",
"are",
"in",
"the",
"tree",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L953-L963 |
18,741 | pzavolinsky/elmx | cheatsheet/elm.js | getSlot | function getSlot(i, a)
{
var slot = i >> (5 * a.height);
while (a.lengths[slot] <= i)
{
slot++;
}
return slot;
} | javascript | function getSlot(i, a)
{
var slot = i >> (5 * a.height);
while (a.lengths[slot] <= i)
{
slot++;
}
return slot;
} | [
"function",
"getSlot",
"(",
"i",
",",
"a",
")",
"{",
"var",
"slot",
"=",
"i",
">>",
"(",
"5",
"*",
"a",
".",
"height",
")",
";",
"while",
"(",
"a",
".",
"lengths",
"[",
"slot",
"]",
"<=",
"i",
")",
"{",
"slot",
"++",
";",
"}",
"return",
"sl... | Calculates in which slot of "table" the item probably is, then find the exact slot via forward searching in "lengths". Returns the index. | [
"Calculates",
"in",
"which",
"slot",
"of",
"table",
"the",
"item",
"probably",
"is",
"then",
"find",
"the",
"exact",
"slot",
"via",
"forward",
"searching",
"in",
"lengths",
".",
"Returns",
"the",
"index",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L967-L975 |
18,742 | pzavolinsky/elmx | cheatsheet/elm.js | create | function create(item, h)
{
if (h === 0)
{
return {
ctor: '_Array',
height: 0,
table: [item]
};
}
return {
ctor: '_Array',
height: h,
table: [create(item, h - 1)],
lengths: [1]
};
} | javascript | function create(item, h)
{
if (h === 0)
{
return {
ctor: '_Array',
height: 0,
table: [item]
};
}
return {
ctor: '_Array',
height: h,
table: [create(item, h - 1)],
lengths: [1]
};
} | [
"function",
"create",
"(",
"item",
",",
"h",
")",
"{",
"if",
"(",
"h",
"===",
"0",
")",
"{",
"return",
"{",
"ctor",
":",
"'_Array'",
",",
"height",
":",
"0",
",",
"table",
":",
"[",
"item",
"]",
"}",
";",
"}",
"return",
"{",
"ctor",
":",
"'_A... | Recursively creates a tree with a given height containing only the given item. | [
"Recursively",
"creates",
"a",
"tree",
"with",
"a",
"given",
"height",
"containing",
"only",
"the",
"given",
"item",
"."
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L979-L995 |
18,743 | pzavolinsky/elmx | cheatsheet/elm.js | mainToProgram | function mainToProgram(moduleName, wrappedMain)
{
var main = wrappedMain.main;
if (typeof main.init === 'undefined')
{
var emptyBag = batch(_elm_lang$core$Native_List.Nil);
var noChange = _elm_lang$core$Native_Utils.Tuple2(
_elm_lang$core$Native_Utils.Tuple0,
emptyBag
);
return _elm_lang$virtual_dom$... | javascript | function mainToProgram(moduleName, wrappedMain)
{
var main = wrappedMain.main;
if (typeof main.init === 'undefined')
{
var emptyBag = batch(_elm_lang$core$Native_List.Nil);
var noChange = _elm_lang$core$Native_Utils.Tuple2(
_elm_lang$core$Native_Utils.Tuple0,
emptyBag
);
return _elm_lang$virtual_dom$... | [
"function",
"mainToProgram",
"(",
"moduleName",
",",
"wrappedMain",
")",
"{",
"var",
"main",
"=",
"wrappedMain",
".",
"main",
";",
"if",
"(",
"typeof",
"main",
".",
"init",
"===",
"'undefined'",
")",
"{",
"var",
"emptyBag",
"=",
"batch",
"(",
"_elm_lang$co... | MAIN TO PROGRAM | [
"MAIN",
"TO",
"PROGRAM"
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L2903-L2934 |
18,744 | pzavolinsky/elmx | cheatsheet/elm.js | makeEmbedHelp | function makeEmbedHelp(moduleName, program, rootDomNode, flags)
{
var init = program.init;
var update = program.update;
var subscriptions = program.subscriptions;
var view = program.view;
var makeRenderer = program.renderer;
// ambient state
var managers = {};
var renderer;
// init and update state in main p... | javascript | function makeEmbedHelp(moduleName, program, rootDomNode, flags)
{
var init = program.init;
var update = program.update;
var subscriptions = program.subscriptions;
var view = program.view;
var makeRenderer = program.renderer;
// ambient state
var managers = {};
var renderer;
// init and update state in main p... | [
"function",
"makeEmbedHelp",
"(",
"moduleName",
",",
"program",
",",
"rootDomNode",
",",
"flags",
")",
"{",
"var",
"init",
"=",
"program",
".",
"init",
";",
"var",
"update",
"=",
"program",
".",
"update",
";",
"var",
"subscriptions",
"=",
"program",
".",
... | SETUP RUNTIME SYSTEM | [
"SETUP",
"RUNTIME",
"SYSTEM"
] | ae125fa9a749273a65d224bc87bbecbf06f253d8 | https://github.com/pzavolinsky/elmx/blob/ae125fa9a749273a65d224bc87bbecbf06f253d8/cheatsheet/elm.js#L2972-L3018 |
18,745 | aurelia-ui-toolkits/aurelia-materialize-bridge | dist/commonjs/common/events.js | fireEvent | function fireEvent(element, name, data) {
if (data === void 0) { data = {}; }
var event = new CustomEvent(name, {
detail: data,
bubbles: true
});
element.dispatchEvent(event);
return event;
} | javascript | function fireEvent(element, name, data) {
if (data === void 0) { data = {}; }
var event = new CustomEvent(name, {
detail: data,
bubbles: true
});
element.dispatchEvent(event);
return event;
} | [
"function",
"fireEvent",
"(",
"element",
",",
"name",
",",
"data",
")",
"{",
"if",
"(",
"data",
"===",
"void",
"0",
")",
"{",
"data",
"=",
"{",
"}",
";",
"}",
"var",
"event",
"=",
"new",
"CustomEvent",
"(",
"name",
",",
"{",
"detail",
":",
"data"... | Fire DOM event on an element
@param element The Element which the DOM event will be fired on
@param name The Event's name
@param data Addition data to attach to an event | [
"Fire",
"DOM",
"event",
"on",
"an",
"element"
] | a25f1131465d19e8139c99dc5022df1cda5001c1 | https://github.com/aurelia-ui-toolkits/aurelia-materialize-bridge/blob/a25f1131465d19e8139c99dc5022df1cda5001c1/dist/commonjs/common/events.js#L10-L18 |
18,746 | aurelia-ui-toolkits/aurelia-materialize-bridge | dist/commonjs/common/events.js | fireMaterializeEvent | function fireMaterializeEvent(element, name, data) {
if (data === void 0) { data = {}; }
return fireEvent(element, "" + constants_1.constants.eventPrefix + name, data);
} | javascript | function fireMaterializeEvent(element, name, data) {
if (data === void 0) { data = {}; }
return fireEvent(element, "" + constants_1.constants.eventPrefix + name, data);
} | [
"function",
"fireMaterializeEvent",
"(",
"element",
",",
"name",
",",
"data",
")",
"{",
"if",
"(",
"data",
"===",
"void",
"0",
")",
"{",
"data",
"=",
"{",
"}",
";",
"}",
"return",
"fireEvent",
"(",
"element",
",",
"\"\"",
"+",
"constants_1",
".",
"co... | Fire DOM event on an element with the md-on prefix
@param element The Element which the DOM event will be fired on
@param name The Event's name, without md-on prefix
@param data Addition data to attach to an event | [
"Fire",
"DOM",
"event",
"on",
"an",
"element",
"with",
"the",
"md",
"-",
"on",
"prefix"
] | a25f1131465d19e8139c99dc5022df1cda5001c1 | https://github.com/aurelia-ui-toolkits/aurelia-materialize-bridge/blob/a25f1131465d19e8139c99dc5022df1cda5001c1/dist/commonjs/common/events.js#L26-L29 |
18,747 | aurelia-ui-toolkits/aurelia-materialize-bridge | dist/system/common/util.js | cleanOptions | function cleanOptions(options) {
Object.keys(options).filter(function (key) { return options[key] === undefined; }).forEach(function (key) { return delete options[key]; });
} | javascript | function cleanOptions(options) {
Object.keys(options).filter(function (key) { return options[key] === undefined; }).forEach(function (key) { return delete options[key]; });
} | [
"function",
"cleanOptions",
"(",
"options",
")",
"{",
"Object",
".",
"keys",
"(",
"options",
")",
".",
"filter",
"(",
"function",
"(",
"key",
")",
"{",
"return",
"options",
"[",
"key",
"]",
"===",
"undefined",
";",
"}",
")",
".",
"forEach",
"(",
"fun... | Remove undefined fields from an object
@param options An object to clean | [
"Remove",
"undefined",
"fields",
"from",
"an",
"object"
] | a25f1131465d19e8139c99dc5022df1cda5001c1 | https://github.com/aurelia-ui-toolkits/aurelia-materialize-bridge/blob/a25f1131465d19e8139c99dc5022df1cda5001c1/dist/system/common/util.js#L26-L28 |
18,748 | jonschlinkert/to-regex | index.js | makeRe | function makeRe(pattern, options) {
if (pattern instanceof RegExp) {
return pattern;
}
if (typeof pattern !== 'string') {
throw new TypeError('expected a string');
}
if (pattern.length > MAX_LENGTH) {
throw new Error('expected pattern to be less than ' + MAX_LENGTH + ' characters');
}
var k... | javascript | function makeRe(pattern, options) {
if (pattern instanceof RegExp) {
return pattern;
}
if (typeof pattern !== 'string') {
throw new TypeError('expected a string');
}
if (pattern.length > MAX_LENGTH) {
throw new Error('expected pattern to be less than ' + MAX_LENGTH + ' characters');
}
var k... | [
"function",
"makeRe",
"(",
"pattern",
",",
"options",
")",
"{",
"if",
"(",
"pattern",
"instanceof",
"RegExp",
")",
"{",
"return",
"pattern",
";",
"}",
"if",
"(",
"typeof",
"pattern",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'expect... | Create a regular expression from the given `pattern` string.
@param {String|RegExp} `pattern` Pattern can be a string or regular expression.
@param {Object} `options`
@return {RegExp}
@api public | [
"Create",
"a",
"regular",
"expression",
"from",
"the",
"given",
"pattern",
"string",
"."
] | cc5735f98f62c8e9cfb98ae5b309abea1c8a2432 | https://github.com/jonschlinkert/to-regex/blob/cc5735f98f62c8e9cfb98ae5b309abea1c8a2432/index.js#L40-L118 |
18,749 | jonschlinkert/to-regex | index.js | memoize | function memoize(regex, key, pattern, options) {
define(regex, 'cached', true);
define(regex, 'pattern', pattern);
define(regex, 'options', options);
define(regex, 'key', key);
cache[key] = regex;
} | javascript | function memoize(regex, key, pattern, options) {
define(regex, 'cached', true);
define(regex, 'pattern', pattern);
define(regex, 'options', options);
define(regex, 'key', key);
cache[key] = regex;
} | [
"function",
"memoize",
"(",
"regex",
",",
"key",
",",
"pattern",
",",
"options",
")",
"{",
"define",
"(",
"regex",
",",
"'cached'",
",",
"true",
")",
";",
"define",
"(",
"regex",
",",
"'pattern'",
",",
"pattern",
")",
";",
"define",
"(",
"regex",
","... | Memoize generated regex. This can result in dramatic speed improvements
and simplify debugging by adding options and pattern to the regex. It can be
disabled by passing setting `options.cache` to false. | [
"Memoize",
"generated",
"regex",
".",
"This",
"can",
"result",
"in",
"dramatic",
"speed",
"improvements",
"and",
"simplify",
"debugging",
"by",
"adding",
"options",
"and",
"pattern",
"to",
"the",
"regex",
".",
"It",
"can",
"be",
"disabled",
"by",
"passing",
... | cc5735f98f62c8e9cfb98ae5b309abea1c8a2432 | https://github.com/jonschlinkert/to-regex/blob/cc5735f98f62c8e9cfb98ae5b309abea1c8a2432/index.js#L126-L132 |
18,750 | tj/react-enroute | example/index.js | Link | function Link({ to, children }) {
function click(e) {
e.preventDefault()
navigate(to)
}
return <a href={to} onClick={click}>
{children}
</a>
} | javascript | function Link({ to, children }) {
function click(e) {
e.preventDefault()
navigate(to)
}
return <a href={to} onClick={click}>
{children}
</a>
} | [
"function",
"Link",
"(",
"{",
"to",
",",
"children",
"}",
")",
"{",
"function",
"click",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
"navigate",
"(",
"to",
")",
"}",
"return",
"<",
"a",
"href",
"=",
"{",
"to",
"}",
"onClick",
"=",
... | note this is just an example, this package does not provide a Link equivalent found in react-router, nor does it provide bindings for tools like Redux. You'll need to wire these up as desired. | [
"note",
"this",
"is",
"just",
"an",
"example",
"this",
"package",
"does",
"not",
"provide",
"a",
"Link",
"equivalent",
"found",
"in",
"react",
"-",
"router",
"nor",
"does",
"it",
"provide",
"bindings",
"for",
"tools",
"like",
"Redux",
".",
"You",
"ll",
"... | 9b3f99a01f13da69990553ac83e3e42932b7b59b | https://github.com/tj/react-enroute/blob/9b3f99a01f13da69990553ac83e3e42932b7b59b/example/index.js#L10-L19 |
18,751 | rambler-digital-solutions/rambler-ui | src/utils/colors.js | clamp | function clamp(value, min, max) {
if (value < min) return min
if (value > max) return max
return value
} | javascript | function clamp(value, min, max) {
if (value < min) return min
if (value > max) return max
return value
} | [
"function",
"clamp",
"(",
"value",
",",
"min",
",",
"max",
")",
"{",
"if",
"(",
"value",
"<",
"min",
")",
"return",
"min",
"if",
"(",
"value",
">",
"max",
")",
"return",
"max",
"return",
"value",
"}"
] | Returns a number whose value is limited to the given range.
@param {number} value The value to be clamped
@param {number} min The lower boundary of the output range
@param {number} max The upper boundary of the output range
@returns {number} A number in the range [min, max] | [
"Returns",
"a",
"number",
"whose",
"value",
"is",
"limited",
"to",
"the",
"given",
"range",
"."
] | 5c503a4e900efca11a1f318a329fa9d99cba0fb8 | https://github.com/rambler-digital-solutions/rambler-ui/blob/5c503a4e900efca11a1f318a329fa9d99cba0fb8/src/utils/colors.js#L9-L13 |
18,752 | rambler-digital-solutions/rambler-ui | src/utils/colors.js | convertHexToRGB | function convertHexToRGB(color) {
if (color.length === 4) {
let extendedColor = '#'
for (let i = 1; i < color.length; i++)
extendedColor += color.charAt(i) + color.charAt(i)
color = extendedColor
}
const values = {
r: parseInt(color.substr(1, 2), 16),
g: parseInt(color.substr(3, 2), 16)... | javascript | function convertHexToRGB(color) {
if (color.length === 4) {
let extendedColor = '#'
for (let i = 1; i < color.length; i++)
extendedColor += color.charAt(i) + color.charAt(i)
color = extendedColor
}
const values = {
r: parseInt(color.substr(1, 2), 16),
g: parseInt(color.substr(3, 2), 16)... | [
"function",
"convertHexToRGB",
"(",
"color",
")",
"{",
"if",
"(",
"color",
".",
"length",
"===",
"4",
")",
"{",
"let",
"extendedColor",
"=",
"'#'",
"for",
"(",
"let",
"i",
"=",
"1",
";",
"i",
"<",
"color",
".",
"length",
";",
"i",
"++",
")",
"ext... | Converts a color from CSS hex format to CSS rgb format.
@param {string} color - Hex color, i.e. #nnn or #nnnnnn
@returns {string} A CSS rgb color string | [
"Converts",
"a",
"color",
"from",
"CSS",
"hex",
"format",
"to",
"CSS",
"rgb",
"format",
"."
] | 5c503a4e900efca11a1f318a329fa9d99cba0fb8 | https://github.com/rambler-digital-solutions/rambler-ui/blob/5c503a4e900efca11a1f318a329fa9d99cba0fb8/src/utils/colors.js#L21-L36 |
18,753 | rambler-digital-solutions/rambler-ui | src/utils/colors.js | decomposeColor | function decomposeColor(color) {
if (color.charAt(0) === '#') return decomposeColor(convertHexToRGB(color))
color = color.replace(/\s/g, '')
const marker = color.indexOf('(')
if (marker === -1)
throw new Error(`Rambler UI: The ${color} color was not parsed correctly,
because it has an unsupported for... | javascript | function decomposeColor(color) {
if (color.charAt(0) === '#') return decomposeColor(convertHexToRGB(color))
color = color.replace(/\s/g, '')
const marker = color.indexOf('(')
if (marker === -1)
throw new Error(`Rambler UI: The ${color} color was not parsed correctly,
because it has an unsupported for... | [
"function",
"decomposeColor",
"(",
"color",
")",
"{",
"if",
"(",
"color",
".",
"charAt",
"(",
"0",
")",
"===",
"'#'",
")",
"return",
"decomposeColor",
"(",
"convertHexToRGB",
"(",
"color",
")",
")",
"color",
"=",
"color",
".",
"replace",
"(",
"/",
"\\s... | Returns an object with the type and values of a color.
Note: Does not support rgb % values and color names.
@param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
@returns {{type: string, values: number[]}} A MUI color object | [
"Returns",
"an",
"object",
"with",
"the",
"type",
"and",
"values",
"of",
"a",
"color",
"."
] | 5c503a4e900efca11a1f318a329fa9d99cba0fb8 | https://github.com/rambler-digital-solutions/rambler-ui/blob/5c503a4e900efca11a1f318a329fa9d99cba0fb8/src/utils/colors.js#L46-L60 |
18,754 | rambler-digital-solutions/rambler-ui | src/utils/colors.js | getLuminance | function getLuminance(color) {
color = decomposeColor(color)
if (color.type.indexOf('rgb') > -1) {
const rgb = color.values.map(val => {
val /= 255 // normalized
return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4)
})
return Number(
(0.2126 * rgb[0] + 0.7152 * rg... | javascript | function getLuminance(color) {
color = decomposeColor(color)
if (color.type.indexOf('rgb') > -1) {
const rgb = color.values.map(val => {
val /= 255 // normalized
return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4)
})
return Number(
(0.2126 * rgb[0] + 0.7152 * rg... | [
"function",
"getLuminance",
"(",
"color",
")",
"{",
"color",
"=",
"decomposeColor",
"(",
"color",
")",
"if",
"(",
"color",
".",
"type",
".",
"indexOf",
"(",
"'rgb'",
")",
">",
"-",
"1",
")",
"{",
"const",
"rgb",
"=",
"color",
".",
"values",
".",
"m... | The relative brightness of any point in a color space,
normalized to 0 for darkest black and 1 for lightest white.
Formula: https://www.w3.org/WAI/GL/wiki/Relative_luminance
@param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
@returns {number} The relative brightness of the col... | [
"The",
"relative",
"brightness",
"of",
"any",
"point",
"in",
"a",
"color",
"space",
"normalized",
"to",
"0",
"for",
"darkest",
"black",
"and",
"1",
"for",
"lightest",
"white",
"."
] | 5c503a4e900efca11a1f318a329fa9d99cba0fb8 | https://github.com/rambler-digital-solutions/rambler-ui/blob/5c503a4e900efca11a1f318a329fa9d99cba0fb8/src/utils/colors.js#L71-L85 |
18,755 | rambler-digital-solutions/rambler-ui | src/utils/colors.js | convertColorToString | function convertColorToString(color) {
const {type, values} = color
// Only convert the first 3 values to int (i.e. not alpha)
if (type.indexOf('rgb') > -1)
for (let i = 0; i < 3; i++) values[i] = parseInt(values[i])
let colorString
if (type.indexOf('hsl') > -1)
colorString = `${color.type}(${value... | javascript | function convertColorToString(color) {
const {type, values} = color
// Only convert the first 3 values to int (i.e. not alpha)
if (type.indexOf('rgb') > -1)
for (let i = 0; i < 3; i++) values[i] = parseInt(values[i])
let colorString
if (type.indexOf('hsl') > -1)
colorString = `${color.type}(${value... | [
"function",
"convertColorToString",
"(",
"color",
")",
"{",
"const",
"{",
"type",
",",
"values",
"}",
"=",
"color",
"// Only convert the first 3 values to int (i.e. not alpha)",
"if",
"(",
"type",
".",
"indexOf",
"(",
"'rgb'",
")",
">",
"-",
"1",
")",
"for",
"... | Converts a color object with type and values to a string.
@param {object} color - Decomposed color
@param {string} color.type - One of, 'rgb', 'rgba', 'hsl', 'hsla'
@param {array} color.values - [n,n,n] or [n,n,n,n]
@returns {string} A CSS color string | [
"Converts",
"a",
"color",
"object",
"with",
"type",
"and",
"values",
"to",
"a",
"string",
"."
] | 5c503a4e900efca11a1f318a329fa9d99cba0fb8 | https://github.com/rambler-digital-solutions/rambler-ui/blob/5c503a4e900efca11a1f318a329fa9d99cba0fb8/src/utils/colors.js#L95-L112 |
18,756 | petrovich/petrovich-js | dist/petrovich.js | inflect | function inflect(gender, name, gcase, nametype) {
var nametype_rulesets = rules[nametype],
parts = name.split('-'),
result = [];
for (var i = 0; i < parts.length; i++) {
var part = parts[i], first_word = i === 0 && parts.size > 1,
rule = find_rule_glob... | javascript | function inflect(gender, name, gcase, nametype) {
var nametype_rulesets = rules[nametype],
parts = name.split('-'),
result = [];
for (var i = 0; i < parts.length; i++) {
var part = parts[i], first_word = i === 0 && parts.size > 1,
rule = find_rule_glob... | [
"function",
"inflect",
"(",
"gender",
",",
"name",
",",
"gcase",
",",
"nametype",
")",
"{",
"var",
"nametype_rulesets",
"=",
"rules",
"[",
"nametype",
"]",
",",
"parts",
"=",
"name",
".",
"split",
"(",
"'-'",
")",
",",
"result",
"=",
"[",
"]",
";",
... | Key private method, used by all public methods | [
"Key",
"private",
"method",
"used",
"by",
"all",
"public",
"methods"
] | 809d5f7bb0e3af9ab2dcd8f0efa22b0bdd4f80ec | https://github.com/petrovich/petrovich-js/blob/809d5f7bb0e3af9ab2dcd8f0efa22b0bdd4f80ec/dist/petrovich.js#L91-L103 |
18,757 | petrovich/petrovich-js | dist/petrovich.js | find_rule_global | function find_rule_global(gender, name, nametype_rulesets, features) {
if (!features) features = {};
var tags = [];
for (var key in features) {
if (features.hasOwnProperty(key)) tags.push(key);
}
if (nametype_rulesets.exceptions) {
var rule = find_rule_loc... | javascript | function find_rule_global(gender, name, nametype_rulesets, features) {
if (!features) features = {};
var tags = [];
for (var key in features) {
if (features.hasOwnProperty(key)) tags.push(key);
}
if (nametype_rulesets.exceptions) {
var rule = find_rule_loc... | [
"function",
"find_rule_global",
"(",
"gender",
",",
"name",
",",
"nametype_rulesets",
",",
"features",
")",
"{",
"if",
"(",
"!",
"features",
")",
"features",
"=",
"{",
"}",
";",
"var",
"tags",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"feat... | Find groups of rules in exceptions or suffixes of given nametype | [
"Find",
"groups",
"of",
"rules",
"in",
"exceptions",
"or",
"suffixes",
"of",
"given",
"nametype"
] | 809d5f7bb0e3af9ab2dcd8f0efa22b0bdd4f80ec | https://github.com/petrovich/petrovich-js/blob/809d5f7bb0e3af9ab2dcd8f0efa22b0bdd4f80ec/dist/petrovich.js#L107-L120 |
18,758 | petrovich/petrovich-js | dist/petrovich.js | find_rule_local | function find_rule_local(gender, name, ruleset, match_whole_word, tags) {
for (var i = 0; i < ruleset.length; i++) {
var rule = ruleset[i];
if (rule.tags) {
var common_tags = [];
for (var j = 0; j < rule.tags.length; j++) {
var tag = ru... | javascript | function find_rule_local(gender, name, ruleset, match_whole_word, tags) {
for (var i = 0; i < ruleset.length; i++) {
var rule = ruleset[i];
if (rule.tags) {
var common_tags = [];
for (var j = 0; j < rule.tags.length; j++) {
var tag = ru... | [
"function",
"find_rule_local",
"(",
"gender",
",",
"name",
",",
"ruleset",
",",
"match_whole_word",
",",
"tags",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"ruleset",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"rule",
"=",
"rul... | Local search in rulesets of exceptions or suffixes | [
"Local",
"search",
"in",
"rulesets",
"of",
"exceptions",
"or",
"suffixes"
] | 809d5f7bb0e3af9ab2dcd8f0efa22b0bdd4f80ec | https://github.com/petrovich/petrovich-js/blob/809d5f7bb0e3af9ab2dcd8f0efa22b0bdd4f80ec/dist/petrovich.js#L124-L147 |
18,759 | petrovich/petrovich-js | dist/petrovich.js | apply_rule | function apply_rule(name, gcase, rule) {
var mod;
if (gcase === 'nominative') mod = '.';
else {
for (var i = 0; i < predef.cases.length; i++) {
if (gcase === predef.cases[i]) {
mod = rule.mods[i - 1];
break;
}
... | javascript | function apply_rule(name, gcase, rule) {
var mod;
if (gcase === 'nominative') mod = '.';
else {
for (var i = 0; i < predef.cases.length; i++) {
if (gcase === predef.cases[i]) {
mod = rule.mods[i - 1];
break;
}
... | [
"function",
"apply_rule",
"(",
"name",
",",
"gcase",
",",
"rule",
")",
"{",
"var",
"mod",
";",
"if",
"(",
"gcase",
"===",
"'nominative'",
")",
"mod",
"=",
"'.'",
";",
"else",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"predef",
".",
... | Apply found rule to given name Move error throwing from this function to API method | [
"Apply",
"found",
"rule",
"to",
"given",
"name",
"Move",
"error",
"throwing",
"from",
"this",
"function",
"to",
"API",
"method"
] | 809d5f7bb0e3af9ab2dcd8f0efa22b0bdd4f80ec | https://github.com/petrovich/petrovich-js/blob/809d5f7bb0e3af9ab2dcd8f0efa22b0bdd4f80ec/dist/petrovich.js#L152-L178 |
18,760 | testdouble/teenytest | lib/run/results-store.js | function (metadata) {
var result = createResult(metadata)
var parentResult = current()
if (parentResult) {
parentResult.children.push(result)
}
currentNesting.push(result)
} | javascript | function (metadata) {
var result = createResult(metadata)
var parentResult = current()
if (parentResult) {
parentResult.children.push(result)
}
currentNesting.push(result)
} | [
"function",
"(",
"metadata",
")",
"{",
"var",
"result",
"=",
"createResult",
"(",
"metadata",
")",
"var",
"parentResult",
"=",
"current",
"(",
")",
"if",
"(",
"parentResult",
")",
"{",
"parentResult",
".",
"children",
".",
"push",
"(",
"result",
")",
"}"... | Mutate current context | [
"Mutate",
"current",
"context"
] | 51243f4f457fda21c55d81c347b675d0629de51d | https://github.com/testdouble/teenytest/blob/51243f4f457fda21c55d81c347b675d0629de51d/lib/run/results-store.js#L29-L36 | |
18,761 | tumblr/tumblr.js | lib/tumblr.js | createFunction | function createFunction(name, args, fn) {
if (isFunction(args)) {
fn = args;
args = [];
}
return new Function('body',
'return function ' + name + '(' + args.join(', ') + ') { return body.apply(this, arguments); };'
)(fn);
} | javascript | function createFunction(name, args, fn) {
if (isFunction(args)) {
fn = args;
args = [];
}
return new Function('body',
'return function ' + name + '(' + args.join(', ') + ') { return body.apply(this, arguments); };'
)(fn);
} | [
"function",
"createFunction",
"(",
"name",
",",
"args",
",",
"fn",
")",
"{",
"if",
"(",
"isFunction",
"(",
"args",
")",
")",
"{",
"fn",
"=",
"args",
";",
"args",
"=",
"[",
"]",
";",
"}",
"return",
"new",
"Function",
"(",
"'body'",
",",
"'return fun... | Creates a named function with the desired signature
@param {string} name - function name
@param {Array} [args] - array of argument names
@param {Function} fn - function that contains the logic that should run
@return {Function} a named function that takes the desired arguments
@private | [
"Creates",
"a",
"named",
"function",
"with",
"the",
"desired",
"signature"
] | 87301bbbc2f3f6e60c3270e0147454ac02f0acfb | https://github.com/tumblr/tumblr.js/blob/87301bbbc2f3f6e60c3270e0147454ac02f0acfb/lib/tumblr.js#L380-L389 |
18,762 | tumblr/tumblr.js | lib/tumblr.js | promisifyRequest | function promisifyRequest(requestMethod) {
return function(apiPath, params, callback) {
const promise = new Promise(function(resolve, reject) {
requestMethod.call(this, apiPath, params, function(err, resp) {
if (err) {
reject(err);
} else {
... | javascript | function promisifyRequest(requestMethod) {
return function(apiPath, params, callback) {
const promise = new Promise(function(resolve, reject) {
requestMethod.call(this, apiPath, params, function(err, resp) {
if (err) {
reject(err);
} else {
... | [
"function",
"promisifyRequest",
"(",
"requestMethod",
")",
"{",
"return",
"function",
"(",
"apiPath",
",",
"params",
",",
"callback",
")",
"{",
"const",
"promise",
"=",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"requestMetho... | Take a callback-based function and returns a Promise instead
@param {Function} requestMethod - callback-based method to promisify
@return {Function} function that returns a Promise that resolves with the response body or
rejects with the error message
@private | [
"Take",
"a",
"callback",
"-",
"based",
"function",
"and",
"returns",
"a",
"Promise",
"instead"
] | 87301bbbc2f3f6e60c3270e0147454ac02f0acfb | https://github.com/tumblr/tumblr.js/blob/87301bbbc2f3f6e60c3270e0147454ac02f0acfb/lib/tumblr.js#L401-L425 |
18,763 | tumblr/tumblr.js | lib/tumblr.js | getRequest | function getRequest(requestGet, credentials, baseUrl, apiPath, requestOptions, params, callback) {
params = params || {};
if (credentials.consumer_key) {
params.api_key = credentials.consumer_key;
}
return requestGet(extend({
url: baseUrl + apiPath + '?' + qs.stringify(params),
... | javascript | function getRequest(requestGet, credentials, baseUrl, apiPath, requestOptions, params, callback) {
params = params || {};
if (credentials.consumer_key) {
params.api_key = credentials.consumer_key;
}
return requestGet(extend({
url: baseUrl + apiPath + '?' + qs.stringify(params),
... | [
"function",
"getRequest",
"(",
"requestGet",
",",
"credentials",
",",
"baseUrl",
",",
"apiPath",
",",
"requestOptions",
",",
"params",
",",
"callback",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"if",
"(",
"credentials",
".",
"consumer_key",
"... | Make a get request
@param {Function} requestGet - function that performs a get request
@param {Object} credentials - OAuth credentials
@param {string} baseUrl - base URL for the request
@param {string} apiPath - URL path for the request
@param {Object} requestOptions - additional request options
@param {Object} ... | [
"Make",
"a",
"get",
"request"
] | 87301bbbc2f3f6e60c3270e0147454ac02f0acfb | https://github.com/tumblr/tumblr.js/blob/87301bbbc2f3f6e60c3270e0147454ac02f0acfb/lib/tumblr.js#L474-L486 |
18,764 | tumblr/tumblr.js | lib/tumblr.js | postRequest | function postRequest(requestPost, credentials, baseUrl, apiPath, requestOptions, params, callback) {
params = params || {};
// Sign without multipart data
const currentRequest = requestPost(extend({
url: baseUrl + apiPath,
oauth: credentials,
}, requestOptions), function(err, response, ... | javascript | function postRequest(requestPost, credentials, baseUrl, apiPath, requestOptions, params, callback) {
params = params || {};
// Sign without multipart data
const currentRequest = requestPost(extend({
url: baseUrl + apiPath,
oauth: credentials,
}, requestOptions), function(err, response, ... | [
"function",
"postRequest",
"(",
"requestPost",
",",
"credentials",
",",
"baseUrl",
",",
"apiPath",
",",
"requestOptions",
",",
"params",
",",
"callback",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"// Sign without multipart data",
"const",
"currentR... | Create a function to make POST requests to the Tumblr API
@param {Function} requestPost - function that performs a get request
@param {Object} credentials - OAuth credentials
@param {string} baseUrl - base URL for the request
@param {string} apiPath - URL path for the request
@param {Object} requestOptions - addi... | [
"Create",
"a",
"function",
"to",
"make",
"POST",
"requests",
"to",
"the",
"Tumblr",
"API"
] | 87301bbbc2f3f6e60c3270e0147454ac02f0acfb | https://github.com/tumblr/tumblr.js/blob/87301bbbc2f3f6e60c3270e0147454ac02f0acfb/lib/tumblr.js#L503-L548 |
18,765 | tumblr/tumblr.js | lib/tumblr.js | addMethod | function addMethod(client, methodName, apiPath, paramNames, requestType) {
const apiPathSplit = apiPath.split('/');
const apiPathParamsCount = apiPath.split(/\/:[^\/]+/).length - 1;
const buildApiPath = function(args) {
let pathParamIndex = 0;
return reduce(apiPathSplit, function(apiPath, a... | javascript | function addMethod(client, methodName, apiPath, paramNames, requestType) {
const apiPathSplit = apiPath.split('/');
const apiPathParamsCount = apiPath.split(/\/:[^\/]+/).length - 1;
const buildApiPath = function(args) {
let pathParamIndex = 0;
return reduce(apiPathSplit, function(apiPath, a... | [
"function",
"addMethod",
"(",
"client",
",",
"methodName",
",",
"apiPath",
",",
"paramNames",
",",
"requestType",
")",
"{",
"const",
"apiPathSplit",
"=",
"apiPath",
".",
"split",
"(",
"'/'",
")",
";",
"const",
"apiPathParamsCount",
"=",
"apiPath",
".",
"spli... | Adds a request method to the client
@param {Object} client - add the method to this object
@param {string} methodName - the name of the method
@param {string} apiPath - the API route, which uses any colon-prefixed segments as arguments
@param {Array} paramNames - ordered list of required request parameters used as... | [
"Adds",
"a",
"request",
"method",
"to",
"the",
"client"
] | 87301bbbc2f3f6e60c3270e0147454ac02f0acfb | https://github.com/tumblr/tumblr.js/blob/87301bbbc2f3f6e60c3270e0147454ac02f0acfb/lib/tumblr.js#L561-L620 |
18,766 | tumblr/tumblr.js | lib/tumblr.js | addMethods | function addMethods(client, methods, requestType) {
let apiPath, paramNames;
for (const methodName in methods) {
apiPath = methods[methodName];
if (isString(apiPath)) {
paramNames = [];
} else if (isPlainObject(apiPath)) {
paramNames = apiPath.paramNames || [];
... | javascript | function addMethods(client, methods, requestType) {
let apiPath, paramNames;
for (const methodName in methods) {
apiPath = methods[methodName];
if (isString(apiPath)) {
paramNames = [];
} else if (isPlainObject(apiPath)) {
paramNames = apiPath.paramNames || [];
... | [
"function",
"addMethods",
"(",
"client",
",",
"methods",
",",
"requestType",
")",
"{",
"let",
"apiPath",
",",
"paramNames",
";",
"for",
"(",
"const",
"methodName",
"in",
"methods",
")",
"{",
"apiPath",
"=",
"methods",
"[",
"methodName",
"]",
";",
"if",
"... | Adds methods to the client
@param {TumblrClient} client - an instance of the `tumblr.js` API client
@param {Object} methods - mapping of method names to endpoints. Endpoints can be a string or an
array of format `[apiPathString, requireParamsArray]`
@param {String|Function} requestType - the request type or a funct... | [
"Adds",
"methods",
"to",
"the",
"client"
] | 87301bbbc2f3f6e60c3270e0147454ac02f0acfb | https://github.com/tumblr/tumblr.js/blob/87301bbbc2f3f6e60c3270e0147454ac02f0acfb/lib/tumblr.js#L632-L647 |
18,767 | tumblr/tumblr.js | lib/tumblr.js | wrapCreatePost | function wrapCreatePost(type, validate) {
return function(blogIdentifier, params, callback) {
params = extend({type: type}, params);
if (isArray(validate)) {
validate = partial(function(params, requireKeys) {
if (requireKeys.length) {
const keyInterse... | javascript | function wrapCreatePost(type, validate) {
return function(blogIdentifier, params, callback) {
params = extend({type: type}, params);
if (isArray(validate)) {
validate = partial(function(params, requireKeys) {
if (requireKeys.length) {
const keyInterse... | [
"function",
"wrapCreatePost",
"(",
"type",
",",
"validate",
")",
"{",
"return",
"function",
"(",
"blogIdentifier",
",",
"params",
",",
"callback",
")",
"{",
"params",
"=",
"extend",
"(",
"{",
"type",
":",
"type",
"}",
",",
"params",
")",
";",
"if",
"("... | Wraps createPost to specify `type` and validate the parameters
@param {string} type - post type
@param {Function} [validate] - returns `true` if the parameters validate
@return {Function} wrapped function
@private | [
"Wraps",
"createPost",
"to",
"specify",
"type",
"and",
"validate",
"the",
"parameters"
] | 87301bbbc2f3f6e60c3270e0147454ac02f0acfb | https://github.com/tumblr/tumblr.js/blob/87301bbbc2f3f6e60c3270e0147454ac02f0acfb/lib/tumblr.js#L659-L691 |
18,768 | tumblr/tumblr.js | lib/tumblr.js | TumblrClient | function TumblrClient(options) {
// Support for `TumblrClient(credentials, baseUrl, requestLibrary)`
if (arguments.length > 1) {
options = {
credentials: arguments[0],
baseUrl: arguments[1],
request: arguments[2],
returnPromises: false,
};
}
... | javascript | function TumblrClient(options) {
// Support for `TumblrClient(credentials, baseUrl, requestLibrary)`
if (arguments.length > 1) {
options = {
credentials: arguments[0],
baseUrl: arguments[1],
request: arguments[2],
returnPromises: false,
};
}
... | [
"function",
"TumblrClient",
"(",
"options",
")",
"{",
"// Support for `TumblrClient(credentials, baseUrl, requestLibrary)`",
"if",
"(",
"arguments",
".",
"length",
">",
"1",
")",
"{",
"options",
"=",
"{",
"credentials",
":",
"arguments",
"[",
"0",
"]",
",",
"baseU... | Creates a Tumblr API client using the given options
@param {Object} [options] - client options
@param {Object} [options.credentials] - OAuth credentials
@param {string} [options.baseUrl] - API base URL
@param {Object} [options.request] - library to use for making requests
@constructor | [
"Creates",
"a",
"Tumblr",
"API",
"client",
"using",
"the",
"given",
"options"
] | 87301bbbc2f3f6e60c3270e0147454ac02f0acfb | https://github.com/tumblr/tumblr.js/blob/87301bbbc2f3f6e60c3270e0147454ac02f0acfb/lib/tumblr.js#L703-L875 |
18,769 | tumblr/tumblr.js | lib/tumblr.js | function(options) {
// Support for `TumblrClient(credentials, baseUrl, requestLibrary)`
if (arguments.length > 1) {
options = {
credentials: arguments[0],
baseUrl: arguments[1],
request: arguments[2],
returnPromises: false,
... | javascript | function(options) {
// Support for `TumblrClient(credentials, baseUrl, requestLibrary)`
if (arguments.length > 1) {
options = {
credentials: arguments[0],
baseUrl: arguments[1],
request: arguments[2],
returnPromises: false,
... | [
"function",
"(",
"options",
")",
"{",
"// Support for `TumblrClient(credentials, baseUrl, requestLibrary)`",
"if",
"(",
"arguments",
".",
"length",
">",
"1",
")",
"{",
"options",
"=",
"{",
"credentials",
":",
"arguments",
"[",
"0",
"]",
",",
"baseUrl",
":",
"arg... | Creates a Tumblr Client
@param {Object} [options] - client options
@param {Object} [options.credentials] - OAuth credentials
@param {string} [options.baseUrl] - API base URL
@param {Object} [options.request] - library to use for making requests
@return {TumblrClient} {@link TumblrClient} instance
@memberof tumbl... | [
"Creates",
"a",
"Tumblr",
"Client"
] | 87301bbbc2f3f6e60c3270e0147454ac02f0acfb | https://github.com/tumblr/tumblr.js/blob/87301bbbc2f3f6e60c3270e0147454ac02f0acfb/lib/tumblr.js#L972-L987 | |
18,770 | aheckmann/node-ses | lib/email.js | Email | function Email (options) {
this.action = options.action || SEND_EMAIL_ACTION;
this.key = options.key;
this.secret = options.secret;
this.amazon = options.amazon;
this.from = options.from;
this.subject = options.subject;
this.message = options.message;
this.altText = options.altText;
this.rawMessage = ... | javascript | function Email (options) {
this.action = options.action || SEND_EMAIL_ACTION;
this.key = options.key;
this.secret = options.secret;
this.amazon = options.amazon;
this.from = options.from;
this.subject = options.subject;
this.message = options.message;
this.altText = options.altText;
this.rawMessage = ... | [
"function",
"Email",
"(",
"options",
")",
"{",
"this",
".",
"action",
"=",
"options",
".",
"action",
"||",
"SEND_EMAIL_ACTION",
";",
"this",
".",
"key",
"=",
"options",
".",
"key",
";",
"this",
".",
"secret",
"=",
"options",
".",
"secret",
";",
"this",... | Email constructor.
@param {Object} options | [
"Email",
"constructor",
"."
] | 03230e8f5a6278de736f3fbe4f1f7f12dac7aa42 | https://github.com/aheckmann/node-ses/blob/03230e8f5a6278de736f3fbe4f1f7f12dac7aa42/lib/email.js#L22-L38 |
18,771 | thinkloop/memoizerific | src/memoizerific.js | moveToMostRecentLru | function moveToMostRecentLru(lru, lruPath) {
var lruLen = lru.length,
lruPathLen = lruPath.length,
isMatch,
i, ii;
for (i = 0; i < lruLen; i++) {
isMatch = true;
for (ii = 0; ii < lruPathLen; ii++) {
if (!isEqual(lru[i][ii].arg, lruPath[ii].arg)) {
isMatch = false;
break;
}
}
if (isMatch)... | javascript | function moveToMostRecentLru(lru, lruPath) {
var lruLen = lru.length,
lruPathLen = lruPath.length,
isMatch,
i, ii;
for (i = 0; i < lruLen; i++) {
isMatch = true;
for (ii = 0; ii < lruPathLen; ii++) {
if (!isEqual(lru[i][ii].arg, lruPath[ii].arg)) {
isMatch = false;
break;
}
}
if (isMatch)... | [
"function",
"moveToMostRecentLru",
"(",
"lru",
",",
"lruPath",
")",
"{",
"var",
"lruLen",
"=",
"lru",
".",
"length",
",",
"lruPathLen",
"=",
"lruPath",
".",
"length",
",",
"isMatch",
",",
"i",
",",
"ii",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<... | move current args to most recent position | [
"move",
"current",
"args",
"to",
"most",
"recent",
"position"
] | d13074d4ef0b02924871c9e3958aa76628056605 | https://github.com/thinkloop/memoizerific/blob/d13074d4ef0b02924871c9e3958aa76628056605/src/memoizerific.js#L94-L114 |
18,772 | thinkloop/memoizerific | src/memoizerific.js | removeCachedResult | function removeCachedResult(removedLru) {
var removedLruLen = removedLru.length,
currentLru = removedLru[removedLruLen - 1],
tmp,
i;
currentLru.cacheItem.delete(currentLru.arg);
// walk down the tree removing dead branches (size 0) along the way
for (i = removedLruLen - 2; i >= 0; i--) {
currentLru = remo... | javascript | function removeCachedResult(removedLru) {
var removedLruLen = removedLru.length,
currentLru = removedLru[removedLruLen - 1],
tmp,
i;
currentLru.cacheItem.delete(currentLru.arg);
// walk down the tree removing dead branches (size 0) along the way
for (i = removedLruLen - 2; i >= 0; i--) {
currentLru = remo... | [
"function",
"removeCachedResult",
"(",
"removedLru",
")",
"{",
"var",
"removedLruLen",
"=",
"removedLru",
".",
"length",
",",
"currentLru",
"=",
"removedLru",
"[",
"removedLruLen",
"-",
"1",
"]",
",",
"tmp",
",",
"i",
";",
"currentLru",
".",
"cacheItem",
"."... | remove least recently used cache item and all dead branches | [
"remove",
"least",
"recently",
"used",
"cache",
"item",
"and",
"all",
"dead",
"branches"
] | d13074d4ef0b02924871c9e3958aa76628056605 | https://github.com/thinkloop/memoizerific/blob/d13074d4ef0b02924871c9e3958aa76628056605/src/memoizerific.js#L117-L136 |
18,773 | workshopper/goingnative | lib/gyp.js | rebuild | function rebuild (dir, _callback) {
var cwd = process.cwd()
, gypInst = gyp()
var callback = function (err) {
_callback(err)
}
gypInst.parseArgv([ null, null, 'rebuild', '--loglevel', 'silent' ])
process.chdir(dir)
gypInst.commands.clean([], function (err) {
if (err)
return callback(... | javascript | function rebuild (dir, _callback) {
var cwd = process.cwd()
, gypInst = gyp()
var callback = function (err) {
_callback(err)
}
gypInst.parseArgv([ null, null, 'rebuild', '--loglevel', 'silent' ])
process.chdir(dir)
gypInst.commands.clean([], function (err) {
if (err)
return callback(... | [
"function",
"rebuild",
"(",
"dir",
",",
"_callback",
")",
"{",
"var",
"cwd",
"=",
"process",
".",
"cwd",
"(",
")",
",",
"gypInst",
"=",
"gyp",
"(",
")",
"var",
"callback",
"=",
"function",
"(",
"err",
")",
"{",
"_callback",
"(",
"err",
")",
"}",
... | invoke `node-gyp rebuild` programatically, runs clean;configure;build | [
"invoke",
"node",
"-",
"gyp",
"rebuild",
"programatically",
"runs",
"clean",
";",
"configure",
";",
"build"
] | bfdc437383df849f5f9aab6028933cb490eac272 | https://github.com/workshopper/goingnative/blob/bfdc437383df849f5f9aab6028933cb490eac272/lib/gyp.js#L9-L34 |
18,774 | workshopper/goingnative | lib/gyp.js | checkBinding | function checkBinding (mode, callback) {
var exercise = this
function fail (msg) {
exercise.emit('fail', msg)
return callback(null, false)
}
fs.readFile(path.join(exercise.submission, 'binding.gyp'), 'utf8', function (err, data) {
if (err)
return fail('Read binding.gyp (' + err.message + ')'... | javascript | function checkBinding (mode, callback) {
var exercise = this
function fail (msg) {
exercise.emit('fail', msg)
return callback(null, false)
}
fs.readFile(path.join(exercise.submission, 'binding.gyp'), 'utf8', function (err, data) {
if (err)
return fail('Read binding.gyp (' + err.message + ')'... | [
"function",
"checkBinding",
"(",
"mode",
",",
"callback",
")",
"{",
"var",
"exercise",
"=",
"this",
"function",
"fail",
"(",
"msg",
")",
"{",
"exercise",
".",
"emit",
"(",
"'fail'",
",",
"msg",
")",
"return",
"callback",
"(",
"null",
",",
"false",
")",... | check binding.gyp to see if it's parsable YAML and contains the basic structure that we need for this to work | [
"check",
"binding",
".",
"gyp",
"to",
"see",
"if",
"it",
"s",
"parsable",
"YAML",
"and",
"contains",
"the",
"basic",
"structure",
"that",
"we",
"need",
"for",
"this",
"to",
"work"
] | bfdc437383df849f5f9aab6028933cb490eac272 | https://github.com/workshopper/goingnative/blob/bfdc437383df849f5f9aab6028933cb490eac272/lib/gyp.js#L39-L94 |
18,775 | workshopper/goingnative | lib/check.js | checkSubmissionDir | function checkSubmissionDir (mode, callback) {
var exercise = this
exercise.submission = this.args[0] // submission first arg obviously
function failBadPath () {
exercise.emit('fail', 'Submitted a readable directory path (please supply a path to your solution)')
callback(null, false)
}
if (!exerci... | javascript | function checkSubmissionDir (mode, callback) {
var exercise = this
exercise.submission = this.args[0] // submission first arg obviously
function failBadPath () {
exercise.emit('fail', 'Submitted a readable directory path (please supply a path to your solution)')
callback(null, false)
}
if (!exerci... | [
"function",
"checkSubmissionDir",
"(",
"mode",
",",
"callback",
")",
"{",
"var",
"exercise",
"=",
"this",
"exercise",
".",
"submission",
"=",
"this",
".",
"args",
"[",
"0",
"]",
"// submission first arg obviously",
"function",
"failBadPath",
"(",
")",
"{",
"ex... | simple check to see they are running a verify or run with an actual directory | [
"simple",
"check",
"to",
"see",
"they",
"are",
"running",
"a",
"verify",
"or",
"run",
"with",
"an",
"actual",
"directory"
] | bfdc437383df849f5f9aab6028933cb490eac272 | https://github.com/workshopper/goingnative/blob/bfdc437383df849f5f9aab6028933cb490eac272/lib/check.js#L5-L28 |
18,776 | workshopper/goingnative | lib/compile.js | checkCompile | function checkCompile (dir) {
return function (mode, callback) {
var exercise = this
if (!exercise.passed)
return callback(null, true) // shortcut if we've already had a failure
gyp.rebuild(dir, function (err) {
if (err) {
exercise.emit('fail', err.message)
return callback(n... | javascript | function checkCompile (dir) {
return function (mode, callback) {
var exercise = this
if (!exercise.passed)
return callback(null, true) // shortcut if we've already had a failure
gyp.rebuild(dir, function (err) {
if (err) {
exercise.emit('fail', err.message)
return callback(n... | [
"function",
"checkCompile",
"(",
"dir",
")",
"{",
"return",
"function",
"(",
"mode",
",",
"callback",
")",
"{",
"var",
"exercise",
"=",
"this",
"if",
"(",
"!",
"exercise",
".",
"passed",
")",
"return",
"callback",
"(",
"null",
",",
"true",
")",
"// sho... | run a `node-gyp rebuild` on their unmolested code in our copy | [
"run",
"a",
"node",
"-",
"gyp",
"rebuild",
"on",
"their",
"unmolested",
"code",
"in",
"our",
"copy"
] | bfdc437383df849f5f9aab6028933cb490eac272 | https://github.com/workshopper/goingnative/blob/bfdc437383df849f5f9aab6028933cb490eac272/lib/compile.js#L5-L21 |
18,777 | workshopper/goingnative | lib/copy.js | cleanup | function cleanup (dirs) {
return function (mode, pass, callback) {
var done = after(dirs.length, callback)
dirs.forEach(function (dir) {
rimraf(dir, done)
})
}
} | javascript | function cleanup (dirs) {
return function (mode, pass, callback) {
var done = after(dirs.length, callback)
dirs.forEach(function (dir) {
rimraf(dir, done)
})
}
} | [
"function",
"cleanup",
"(",
"dirs",
")",
"{",
"return",
"function",
"(",
"mode",
",",
"pass",
",",
"callback",
")",
"{",
"var",
"done",
"=",
"after",
"(",
"dirs",
".",
"length",
",",
"callback",
")",
"dirs",
".",
"forEach",
"(",
"function",
"(",
"dir... | don't leave the tmp dirs | [
"don",
"t",
"leave",
"the",
"tmp",
"dirs"
] | bfdc437383df849f5f9aab6028933cb490eac272 | https://github.com/workshopper/goingnative/blob/bfdc437383df849f5f9aab6028933cb490eac272/lib/copy.js#L50-L58 |
18,778 | workshopper/goingnative | exercises/am_i_ready/exercise.js | setup | function setup (mode, callback) {
copy(testPackageSrc, testPackageRnd, { overwrite: true }, function (err) {
if (err)
return callback(err)
copy.copyDeps(testPackageRnd, callback)
})
} | javascript | function setup (mode, callback) {
copy(testPackageSrc, testPackageRnd, { overwrite: true }, function (err) {
if (err)
return callback(err)
copy.copyDeps(testPackageRnd, callback)
})
} | [
"function",
"setup",
"(",
"mode",
",",
"callback",
")",
"{",
"copy",
"(",
"testPackageSrc",
",",
"testPackageRnd",
",",
"{",
"overwrite",
":",
"true",
"}",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
... | copy test package to a temporary location, populate it with bindings and nan | [
"copy",
"test",
"package",
"to",
"a",
"temporary",
"location",
"populate",
"it",
"with",
"bindings",
"and",
"nan"
] | bfdc437383df849f5f9aab6028933cb490eac272 | https://github.com/workshopper/goingnative/blob/bfdc437383df849f5f9aab6028933cb490eac272/exercises/am_i_ready/exercise.js#L37-L44 |
18,779 | simsalabim/sisyphus | vendor/jasmine/jasmine-jquery.js | function(eventName, eventHandler) {
var stack = this.actual.data("events")[eventName];
var i;
for (i = 0; i < stack.length; i++) {
if (stack[i].handler == eventHandler) {
return true;
}
}
return false;
} | javascript | function(eventName, eventHandler) {
var stack = this.actual.data("events")[eventName];
var i;
for (i = 0; i < stack.length; i++) {
if (stack[i].handler == eventHandler) {
return true;
}
}
return false;
} | [
"function",
"(",
"eventName",
",",
"eventHandler",
")",
"{",
"var",
"stack",
"=",
"this",
".",
"actual",
".",
"data",
"(",
"\"events\"",
")",
"[",
"eventName",
"]",
";",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"stack",
".",
"le... | tests the existence of a specific event binding + handler | [
"tests",
"the",
"existence",
"of",
"a",
"specific",
"event",
"binding",
"+",
"handler"
] | 1878a0f51ffc3062ff3d1740b22a8c8c7f616262 | https://github.com/simsalabim/sisyphus/blob/1878a0f51ffc3062ff3d1740b22a8c8c7f616262/vendor/jasmine/jasmine-jquery.js#L228-L237 | |
18,780 | simsalabim/sisyphus | sisyphus.js | function ( options ) {
var defaults = {
excludeFields: [],
customKeySuffix: "",
locationBased: false,
timeout: 0,
autoRelease: true,
onBeforeSave: function() {},
onSave: function() {},
onBeforeRestore: function() {},
onRestore: function() {},
onRelease: f... | javascript | function ( options ) {
var defaults = {
excludeFields: [],
customKeySuffix: "",
locationBased: false,
timeout: 0,
autoRelease: true,
onBeforeSave: function() {},
onSave: function() {},
onBeforeRestore: function() {},
onRestore: function() {},
onRelease: f... | [
"function",
"(",
"options",
")",
"{",
"var",
"defaults",
"=",
"{",
"excludeFields",
":",
"[",
"]",
",",
"customKeySuffix",
":",
"\"\"",
",",
"locationBased",
":",
"false",
",",
"timeout",
":",
"0",
",",
"autoRelease",
":",
"true",
",",
"onBeforeSave",
":... | Set plugin initial options
@param [Object] options
@return void | [
"Set",
"plugin",
"initial",
"options"
] | 1878a0f51ffc3062ff3d1740b22a8c8c7f616262 | https://github.com/simsalabim/sisyphus/blob/1878a0f51ffc3062ff3d1740b22a8c8c7f616262/sisyphus.js#L121-L136 | |
18,781 | simsalabim/sisyphus | sisyphus.js | function( targets, options ) {
this.setOptions( options );
targets = targets || {};
var self = this;
this.targets = this.targets || [];
if ( self.options.name ) {
this.href = self.options.name;
} else {
this.href = location.hostname + location.pathname + location.search + locat... | javascript | function( targets, options ) {
this.setOptions( options );
targets = targets || {};
var self = this;
this.targets = this.targets || [];
if ( self.options.name ) {
this.href = self.options.name;
} else {
this.href = location.hostname + location.pathname + location.search + locat... | [
"function",
"(",
"targets",
",",
"options",
")",
"{",
"this",
".",
"setOptions",
"(",
"options",
")",
";",
"targets",
"=",
"targets",
"||",
"{",
"}",
";",
"var",
"self",
"=",
"this",
";",
"this",
".",
"targets",
"=",
"this",
".",
"targets",
"||",
"... | Protect specified forms, store it's fields data to local storage and restore them on page load
@param [Object] targets forms object(s), result of jQuery selector
@param Object options plugin options
@return void | [
"Protect",
"specified",
"forms",
"store",
"it",
"s",
"fields",
"data",
"to",
"local",
"storage",
"and",
"restore",
"them",
"on",
"page",
"load"
] | 1878a0f51ffc3062ff3d1740b22a8c8c7f616262 | https://github.com/simsalabim/sisyphus/blob/1878a0f51ffc3062ff3d1740b22a8c8c7f616262/sisyphus.js#L158-L198 | |
18,782 | simsalabim/sisyphus | sisyphus.js | function() {
var self = this;
if ( self.options.timeout ) {
self.saveDataByTimeout();
}
self.targets.each( function() {
var targetFormIdAndName = getElementIdentifier( $( this ) );
self.findFieldsToProtect( $( this ) ).each( function() {
if ( $.inArray( this, self.options.... | javascript | function() {
var self = this;
if ( self.options.timeout ) {
self.saveDataByTimeout();
}
self.targets.each( function() {
var targetFormIdAndName = getElementIdentifier( $( this ) );
self.findFieldsToProtect( $( this ) ).each( function() {
if ( $.inArray( this, self.options.... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"self",
".",
"options",
".",
"timeout",
")",
"{",
"self",
".",
"saveDataByTimeout",
"(",
")",
";",
"}",
"self",
".",
"targets",
".",
"each",
"(",
"function",
"(",
")",
"{",
"v... | Bind saving data
@return void | [
"Bind",
"saving",
"data"
] | 1878a0f51ffc3062ff3d1740b22a8c8c7f616262 | https://github.com/simsalabim/sisyphus/blob/1878a0f51ffc3062ff3d1740b22a8c8c7f616262/sisyphus.js#L225-L249 | |
18,783 | simsalabim/sisyphus | sisyphus.js | function() {
var self = this;
var restored = false;
self.targets.each( function() {
var target = $( this );
var targetFormIdAndName = getElementIdentifier( $( this ) );
self.findFieldsToProtect( target ).each( function() {
if ( $.inArray( this, self.options.excludeFields ) !== ... | javascript | function() {
var self = this;
var restored = false;
self.targets.each( function() {
var target = $( this );
var targetFormIdAndName = getElementIdentifier( $( this ) );
self.findFieldsToProtect( target ).each( function() {
if ( $.inArray( this, self.options.excludeFields ) !== ... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"restored",
"=",
"false",
";",
"self",
".",
"targets",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"target",
"=",
"$",
"(",
"this",
")",
";",
"var",
"targetFormIdAndName",
"... | Restore forms data from Local Storage
@return void | [
"Restore",
"forms",
"data",
"from",
"Local",
"Storage"
] | 1878a0f51ffc3062ff3d1740b22a8c8c7f616262 | https://github.com/simsalabim/sisyphus/blob/1878a0f51ffc3062ff3d1740b22a8c8c7f616262/sisyphus.js#L318-L344 | |
18,784 | simsalabim/sisyphus | sisyphus.js | function( field, resque ) {
if ( field.attr( "name" ) === undefined && field.attr( "id" ) === undefined ) {
return false;
}
var name = field.attr( "name" );
if ( field.is( ":checkbox" ) && resque !== "false" && ( name === undefined || name.indexOf( "[" ) === -1 ) ) {
// If we aren't name... | javascript | function( field, resque ) {
if ( field.attr( "name" ) === undefined && field.attr( "id" ) === undefined ) {
return false;
}
var name = field.attr( "name" );
if ( field.is( ":checkbox" ) && resque !== "false" && ( name === undefined || name.indexOf( "[" ) === -1 ) ) {
// If we aren't name... | [
"function",
"(",
"field",
",",
"resque",
")",
"{",
"if",
"(",
"field",
".",
"attr",
"(",
"\"name\"",
")",
"===",
"undefined",
"&&",
"field",
".",
"attr",
"(",
"\"id\"",
")",
"===",
"undefined",
")",
"{",
"return",
"false",
";",
"}",
"var",
"name",
... | Restore form field data from local storage
@param Object field jQuery form element object
@param String resque previously stored fields data
@return void | [
"Restore",
"form",
"field",
"data",
"from",
"local",
"storage"
] | 1878a0f51ffc3062ff3d1740b22a8c8c7f616262 | https://github.com/simsalabim/sisyphus/blob/1878a0f51ffc3062ff3d1740b22a8c8c7f616262/sisyphus.js#L354-L376 | |
18,785 | simsalabim/sisyphus | sisyphus.js | function( key, value, fireCallback ) {
var self = this;
var callback_result = self.options.onBeforeSave.call( self );
if ( callback_result !== undefined && callback_result === false ) {
return;
}
// if fireCallback is undefined it should be true
fireCallback = fireCallback ===... | javascript | function( key, value, fireCallback ) {
var self = this;
var callback_result = self.options.onBeforeSave.call( self );
if ( callback_result !== undefined && callback_result === false ) {
return;
}
// if fireCallback is undefined it should be true
fireCallback = fireCallback ===... | [
"function",
"(",
"key",
",",
"value",
",",
"fireCallback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"callback_result",
"=",
"self",
".",
"options",
".",
"onBeforeSave",
".",
"call",
"(",
"self",
")",
";",
"if",
"(",
"callback_result",
"!==",
"... | Save data to Local Storage and fire callback if defined
@param String key
@param String value
@param Boolean [true] fireCallback
@return void | [
"Save",
"data",
"to",
"Local",
"Storage",
"and",
"fire",
"callback",
"if",
"defined"
] | 1878a0f51ffc3062ff3d1740b22a8c8c7f616262 | https://github.com/simsalabim/sisyphus/blob/1878a0f51ffc3062ff3d1740b22a8c8c7f616262/sisyphus.js#L417-L431 | |
18,786 | simsalabim/sisyphus | sisyphus.js | function() {
var self = this;
self.targets.each( function() {
var target = $( this );
var formIdAndName = getElementIdentifier( target );
self.releaseData( formIdAndName, self.findFieldsToProtect( target ) );
} );
} | javascript | function() {
var self = this;
self.targets.each( function() {
var target = $( this );
var formIdAndName = getElementIdentifier( target );
self.releaseData( formIdAndName, self.findFieldsToProtect( target ) );
} );
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"targets",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"target",
"=",
"$",
"(",
"this",
")",
";",
"var",
"formIdAndName",
"=",
"getElementIdentifier",
"(",
"target",
")"... | Manually release form fields
@return void | [
"Manually",
"release",
"form",
"fields"
] | 1878a0f51ffc3062ff3d1740b22a8c8c7f616262 | https://github.com/simsalabim/sisyphus/blob/1878a0f51ffc3062ff3d1740b22a8c8c7f616262/sisyphus.js#L485-L492 | |
18,787 | jhiesey/stream-http | lib/request.js | statusValid | function statusValid (xhr) {
try {
var status = xhr.status
return (status !== null && status !== 0)
} catch (e) {
return false
}
} | javascript | function statusValid (xhr) {
try {
var status = xhr.status
return (status !== null && status !== 0)
} catch (e) {
return false
}
} | [
"function",
"statusValid",
"(",
"xhr",
")",
"{",
"try",
"{",
"var",
"status",
"=",
"xhr",
".",
"status",
"return",
"(",
"status",
"!==",
"null",
"&&",
"status",
"!==",
"0",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"false",
"}",
"}"
] | Checks if xhr.status is readable and non-zero, indicating no error.
Even though the spec says it should be available in readyState 3,
accessing it throws an exception in IE8 | [
"Checks",
"if",
"xhr",
".",
"status",
"is",
"readable",
"and",
"non",
"-",
"zero",
"indicating",
"no",
"error",
".",
"Even",
"though",
"the",
"spec",
"says",
"it",
"should",
"be",
"available",
"in",
"readyState",
"3",
"accessing",
"it",
"throws",
"an",
"... | e60ce5fb99d1c74e96120aa1086197c43fc100a8 | https://github.com/jhiesey/stream-http/blob/e60ce5fb99d1c74e96120aa1086197c43fc100a8/lib/request.js#L224-L231 |
18,788 | klei/gulp-inject | src/inject/index.js | handleVinylStream | function handleVinylStream(sources, opt) {
var collected = streamToArray(sources);
return through2.obj(function (target, enc, cb) {
if (target.isStream()) {
return cb(error('Streams not supported for target templates!'));
}
collected.then(function (collection) {
target.contents = getNewCont... | javascript | function handleVinylStream(sources, opt) {
var collected = streamToArray(sources);
return through2.obj(function (target, enc, cb) {
if (target.isStream()) {
return cb(error('Streams not supported for target templates!'));
}
collected.then(function (collection) {
target.contents = getNewCont... | [
"function",
"handleVinylStream",
"(",
"sources",
",",
"opt",
")",
"{",
"var",
"collected",
"=",
"streamToArray",
"(",
"sources",
")",
";",
"return",
"through2",
".",
"obj",
"(",
"function",
"(",
"target",
",",
"enc",
",",
"cb",
")",
"{",
"if",
"(",
"ta... | Handle injection when files to
inject comes from a Vinyl File Stream
@param {Stream} sources
@param {Object} opt
@returns {Stream} | [
"Handle",
"injection",
"when",
"files",
"to",
"inject",
"comes",
"from",
"a",
"Vinyl",
"File",
"Stream"
] | 59bf9c68e4fe8cd500d196669df3bbd6e29611a9 | https://github.com/klei/gulp-inject/blob/59bf9c68e4fe8cd500d196669df3bbd6e29611a9/src/inject/index.js#L80-L96 |
18,789 | klei/gulp-inject | src/inject/index.js | getNewContent | function getNewContent(target, collection, opt) {
var logger = opt.quiet ? noop : function (filesCount) {
if (filesCount) {
var pluralState = filesCount > 1 ? 's' : '';
log(cyan(filesCount) + ' file' + pluralState + ' into ' + magenta(target.relative) + '.');
} else {
log('Nothing to inject ... | javascript | function getNewContent(target, collection, opt) {
var logger = opt.quiet ? noop : function (filesCount) {
if (filesCount) {
var pluralState = filesCount > 1 ? 's' : '';
log(cyan(filesCount) + ' file' + pluralState + ' into ' + magenta(target.relative) + '.');
} else {
log('Nothing to inject ... | [
"function",
"getNewContent",
"(",
"target",
",",
"collection",
",",
"opt",
")",
"{",
"var",
"logger",
"=",
"opt",
".",
"quiet",
"?",
"noop",
":",
"function",
"(",
"filesCount",
")",
"{",
"if",
"(",
"filesCount",
")",
"{",
"var",
"pluralState",
"=",
"fi... | Get new content for template
with all injections made
@param {Object} target
@param {Array} collection
@param {Object} opt
@returns {Buffer} | [
"Get",
"new",
"content",
"for",
"template",
"with",
"all",
"injections",
"made"
] | 59bf9c68e4fe8cd500d196669df3bbd6e29611a9 | https://github.com/klei/gulp-inject/blob/59bf9c68e4fe8cd500d196669df3bbd6e29611a9/src/inject/index.js#L107-L164 |
18,790 | klei/gulp-inject | src/inject/index.js | inject | function inject(content, opt) {
var startTag = opt.startTag;
var endTag = opt.endTag;
var startMatch;
var endMatch;
/**
* The content consists of:
*
* <everything before startMatch>
* <startMatch>
* <previousInnerContent>
* <endMatch>
* <everything after endMatch>
*/
while ((startM... | javascript | function inject(content, opt) {
var startTag = opt.startTag;
var endTag = opt.endTag;
var startMatch;
var endMatch;
/**
* The content consists of:
*
* <everything before startMatch>
* <startMatch>
* <previousInnerContent>
* <endMatch>
* <everything after endMatch>
*/
while ((startM... | [
"function",
"inject",
"(",
"content",
",",
"opt",
")",
"{",
"var",
"startTag",
"=",
"opt",
".",
"startTag",
";",
"var",
"endTag",
"=",
"opt",
".",
"endTag",
";",
"var",
"startMatch",
";",
"var",
"endMatch",
";",
"/**\n * The content consists of:\n *\n * ... | Inject tags into content for given
start and end tags
@param {String} content
@param {Object} opt
@returns {String} | [
"Inject",
"tags",
"into",
"content",
"for",
"given",
"start",
"and",
"end",
"tags"
] | 59bf9c68e4fe8cd500d196669df3bbd6e29611a9 | https://github.com/klei/gulp-inject/blob/59bf9c68e4fe8cd500d196669df3bbd6e29611a9/src/inject/index.js#L174-L233 |
18,791 | brianleroux/lawnchair | src/adapters/chrome-storage.js | function () {
return !!storage && function() {
// in mobile safari if safe browsing is enabled, window.storage
// is defined but setItem calls throw exceptions.
var success = true
var value = Math.random()
value = "" + value + "... | javascript | function () {
return !!storage && function() {
// in mobile safari if safe browsing is enabled, window.storage
// is defined but setItem calls throw exceptions.
var success = true
var value = Math.random()
value = "" + value + "... | [
"function",
"(",
")",
"{",
"return",
"!",
"!",
"storage",
"&&",
"function",
"(",
")",
"{",
"// in mobile safari if safe browsing is enabled, window.storage",
"// is defined but setItem calls throw exceptions.",
"var",
"success",
"=",
"true",
"var",
"value",
"=",
"Math",
... | ensure we are in an env with chrome.storage | [
"ensure",
"we",
"are",
"in",
"an",
"env",
"with",
"chrome",
".",
"storage"
] | 4a20309b14cee3b6eb74b24c688c5a4a5a98f879 | https://github.com/brianleroux/lawnchair/blob/4a20309b14cee3b6eb74b24c688c5a4a5a98f879/src/adapters/chrome-storage.js#L97-L114 | |
18,792 | brianleroux/lawnchair | lib/lawnchair.js | function () {
return !!storage && function() {
// in mobile safari if safe browsing is enabled, window.storage
// is defined but setItem calls throw exceptions.
var success = true
var value = Math.random()
try {
storage.se... | javascript | function () {
return !!storage && function() {
// in mobile safari if safe browsing is enabled, window.storage
// is defined but setItem calls throw exceptions.
var success = true
var value = Math.random()
try {
storage.se... | [
"function",
"(",
")",
"{",
"return",
"!",
"!",
"storage",
"&&",
"function",
"(",
")",
"{",
"// in mobile safari if safe browsing is enabled, window.storage",
"// is defined but setItem calls throw exceptions.",
"var",
"success",
"=",
"true",
"var",
"value",
"=",
"Math",
... | ensure we are in an env with localStorage | [
"ensure",
"we",
"are",
"in",
"an",
"env",
"with",
"localStorage"
] | 4a20309b14cee3b6eb74b24c688c5a4a5a98f879 | https://github.com/brianleroux/lawnchair/blob/4a20309b14cee3b6eb74b24c688c5a4a5a98f879/lib/lawnchair.js#L358-L372 | |
18,793 | brianleroux/lawnchair | src/adapters/html5-filesystem.js | function( callback ) {
var me = this;
root( this, function( store ) {
ls( store.createReader(), function( entries ) {
if ( callback ) me.fn( 'keys', callback ).call( me, entries );
});
});
return this;
} | javascript | function( callback ) {
var me = this;
root( this, function( store ) {
ls( store.createReader(), function( entries ) {
if ( callback ) me.fn( 'keys', callback ).call( me, entries );
});
});
return this;
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"me",
"=",
"this",
";",
"root",
"(",
"this",
",",
"function",
"(",
"store",
")",
"{",
"ls",
"(",
"store",
".",
"createReader",
"(",
")",
",",
"function",
"(",
"entries",
")",
"{",
"if",
"(",
"callback",... | returns all the keys in the store | [
"returns",
"all",
"the",
"keys",
"in",
"the",
"store"
] | 4a20309b14cee3b6eb74b24c688c5a4a5a98f879 | https://github.com/brianleroux/lawnchair/blob/4a20309b14cee3b6eb74b24c688c5a4a5a98f879/src/adapters/html5-filesystem.js#L62-L70 | |
18,794 | brianleroux/lawnchair | src/adapters/html5-filesystem.js | function( objs, callback ) {
var me = this;
var saved = [];
for ( var i = 0, il = objs.length; i < il; i++ ) {
me.save( objs[i], function( obj ) {
saved.push( obj );
if ( saved.length === il && callback ) {
... | javascript | function( objs, callback ) {
var me = this;
var saved = [];
for ( var i = 0, il = objs.length; i < il; i++ ) {
me.save( objs[i], function( obj ) {
saved.push( obj );
if ( saved.length === il && callback ) {
... | [
"function",
"(",
"objs",
",",
"callback",
")",
"{",
"var",
"me",
"=",
"this",
";",
"var",
"saved",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"objs",
".",
"length",
";",
"i",
"<",
"il",
";",
"i",
"++",
")",
"{",
... | batch save array of objs | [
"batch",
"save",
"array",
"of",
"objs"
] | 4a20309b14cee3b6eb74b24c688c5a4a5a98f879 | https://github.com/brianleroux/lawnchair/blob/4a20309b14cee3b6eb74b24c688c5a4a5a98f879/src/adapters/html5-filesystem.js#L101-L113 | |
18,795 | brianleroux/lawnchair | src/plugins/callbacks.js | function () {
for (var i = 0, l = methods.length; i < l; i++) {
this.evented(methods[i])
}
} | javascript | function () {
for (var i = 0, l = methods.length; i < l; i++) {
this.evented(methods[i])
}
} | [
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"methods",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"this",
".",
"evented",
"(",
"methods",
"[",
"i",
"]",
")",
"}",
"}"
] | start of module roll thru each method we with to augment | [
"start",
"of",
"module",
"roll",
"thru",
"each",
"method",
"we",
"with",
"to",
"augment"
] | 4a20309b14cee3b6eb74b24c688c5a4a5a98f879 | https://github.com/brianleroux/lawnchair/blob/4a20309b14cee3b6eb74b24c688c5a4a5a98f879/src/plugins/callbacks.js#L18-L22 | |
18,796 | brianleroux/lawnchair | src/adapters/indexed-db.js | onupgradeneeded | function onupgradeneeded() {
self.db = request.result;
self.transaction = request.transaction;
// NB! in case of a version conflict, we don't try to migrate,
// instead just throw away the old store and create a new one.
// this happens if somebody changed th... | javascript | function onupgradeneeded() {
self.db = request.result;
self.transaction = request.transaction;
// NB! in case of a version conflict, we don't try to migrate,
// instead just throw away the old store and create a new one.
// this happens if somebody changed th... | [
"function",
"onupgradeneeded",
"(",
")",
"{",
"self",
".",
"db",
"=",
"request",
".",
"result",
";",
"self",
".",
"transaction",
"=",
"request",
".",
"transaction",
";",
"// NB! in case of a version conflict, we don't try to migrate,",
"// instead just throw away the old ... | first start or indexeddb needs a version upgrade | [
"first",
"start",
"or",
"indexeddb",
"needs",
"a",
"version",
"upgrade"
] | 4a20309b14cee3b6eb74b24c688c5a4a5a98f879 | https://github.com/brianleroux/lawnchair/blob/4a20309b14cee3b6eb74b24c688c5a4a5a98f879/src/adapters/indexed-db.js#L56-L75 |
18,797 | brianleroux/lawnchair | src/adapters/indexed-db.js | onsuccess | function onsuccess(event) {
// remember the db instance
self.db = event.target.result;
// storage is now possible
self.store = true;
// execute all pending operations
while (self.waiting.length) {
self.waiting.shift().call(self);
... | javascript | function onsuccess(event) {
// remember the db instance
self.db = event.target.result;
// storage is now possible
self.store = true;
// execute all pending operations
while (self.waiting.length) {
self.waiting.shift().call(self);
... | [
"function",
"onsuccess",
"(",
"event",
")",
"{",
"// remember the db instance",
"self",
".",
"db",
"=",
"event",
".",
"target",
".",
"result",
";",
"// storage is now possible",
"self",
".",
"store",
"=",
"true",
";",
"// execute all pending operations",
"while",
... | database is ready for use | [
"database",
"is",
"ready",
"for",
"use"
] | 4a20309b14cee3b6eb74b24c688c5a4a5a98f879 | https://github.com/brianleroux/lawnchair/blob/4a20309b14cee3b6eb74b24c688c5a4a5a98f879/src/adapters/indexed-db.js#L78-L94 |
18,798 | brianleroux/lawnchair | src/plugins/aggregation.js | function (property, callback) {
// if only one arg we count the collection
if ([].slice.call(arguments).length === 1) {
callback = property
property = 'key'
}
var c = 0
this.each(function(e){
if (e[property]) c++
})
this.fn('... | javascript | function (property, callback) {
// if only one arg we count the collection
if ([].slice.call(arguments).length === 1) {
callback = property
property = 'key'
}
var c = 0
this.each(function(e){
if (e[property]) c++
})
this.fn('... | [
"function",
"(",
"property",
",",
"callback",
")",
"{",
"// if only one arg we count the collection",
"if",
"(",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
".",
"length",
"===",
"1",
")",
"{",
"callback",
"=",
"property",
"property",
"=",
... | count of rows in the lawnchair collection with property | [
"count",
"of",
"rows",
"in",
"the",
"lawnchair",
"collection",
"with",
"property"
] | 4a20309b14cee3b6eb74b24c688c5a4a5a98f879 | https://github.com/brianleroux/lawnchair/blob/4a20309b14cee3b6eb74b24c688c5a4a5a98f879/src/plugins/aggregation.js#L4-L15 | |
18,799 | brianleroux/lawnchair | src/plugins/aggregation.js | function (property, callback) {
var sum = 0
this.each(function(e){
if (e[property]) sum += e[property]
})
this.fn('sum', callback).call(this, sum)
} | javascript | function (property, callback) {
var sum = 0
this.each(function(e){
if (e[property]) sum += e[property]
})
this.fn('sum', callback).call(this, sum)
} | [
"function",
"(",
"property",
",",
"callback",
")",
"{",
"var",
"sum",
"=",
"0",
"this",
".",
"each",
"(",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
"[",
"property",
"]",
")",
"sum",
"+=",
"e",
"[",
"property",
"]",
"}",
")",
"this",
".",
... | adds up property and returns sum | [
"adds",
"up",
"property",
"and",
"returns",
"sum"
] | 4a20309b14cee3b6eb74b24c688c5a4a5a98f879 | https://github.com/brianleroux/lawnchair/blob/4a20309b14cee3b6eb74b24c688c5a4a5a98f879/src/plugins/aggregation.js#L18-L24 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.