repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ngReact/ngReact | ngReact.js | findAttribute | function findAttribute(attrs, propName) {
var index = Object.keys(attrs).filter(function (attr) {
return attr.toLowerCase() === propName.toLowerCase();
})[0];
return attrs[index];
} | javascript | function findAttribute(attrs, propName) {
var index = Object.keys(attrs).filter(function (attr) {
return attr.toLowerCase() === propName.toLowerCase();
})[0];
return attrs[index];
} | [
"function",
"findAttribute",
"(",
"attrs",
",",
"propName",
")",
"{",
"var",
"index",
"=",
"Object",
".",
"keys",
"(",
"attrs",
")",
".",
"filter",
"(",
"function",
"(",
"attr",
")",
"{",
"return",
"attr",
".",
"toLowerCase",
"(",
")",
"===",
"propName... | find the normalized attribute knowing that React props accept any type of capitalization | [
"find",
"the",
"normalized",
"attribute",
"knowing",
"that",
"React",
"props",
"accept",
"any",
"type",
"of",
"capitalization"
] | 5f91c2e6bc976eb1aca7517adb448e4f07ff5d98 | https://github.com/ngReact/ngReact/blob/5f91c2e6bc976eb1aca7517adb448e4f07ff5d98/ngReact.js#L162-L167 | train |
ngReact/ngReact | ngReact.js | function() {
var scopeProps = {}, config = {};
props.forEach(function(prop) {
var propName = getPropName(prop);
scopeProps[propName] = scope.$eval(findAttribute(attrs, propName));
config[propName] = getPropConfig(prop);
});
scopeP... | javascript | function() {
var scopeProps = {}, config = {};
props.forEach(function(prop) {
var propName = getPropName(prop);
scopeProps[propName] = scope.$eval(findAttribute(attrs, propName));
config[propName] = getPropConfig(prop);
});
scopeP... | [
"function",
"(",
")",
"{",
"var",
"scopeProps",
"=",
"{",
"}",
",",
"config",
"=",
"{",
"}",
";",
"props",
".",
"forEach",
"(",
"function",
"(",
"prop",
")",
"{",
"var",
"propName",
"=",
"getPropName",
"(",
"prop",
")",
";",
"scopeProps",
"[",
"pro... | for each of the properties, get their scope value and set it to scope.props | [
"for",
"each",
"of",
"the",
"properties",
"get",
"their",
"scope",
"value",
"and",
"set",
"it",
"to",
"scope",
".",
"props"
] | 5f91c2e6bc976eb1aca7517adb448e4f07ff5d98 | https://github.com/ngReact/ngReact/blob/5f91c2e6bc976eb1aca7517adb448e4f07ff5d98/ngReact.js#L275-L285 | train | |
marcelduran/webpagetest-api | lib/helper.js | netLogParser | function netLogParser(data) {
data = (data || '{}').toString();
if (data.slice(data.length - 3) === ',\r\n') {
data = data.slice(0, data.length - 3) + ']}';
}
return JSON.parse(data);
} | javascript | function netLogParser(data) {
data = (data || '{}').toString();
if (data.slice(data.length - 3) === ',\r\n') {
data = data.slice(0, data.length - 3) + ']}';
}
return JSON.parse(data);
} | [
"function",
"netLogParser",
"(",
"data",
")",
"{",
"data",
"=",
"(",
"data",
"||",
"'{}'",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"data",
".",
"slice",
"(",
"data",
".",
"length",
"-",
"3",
")",
"===",
"',\\r\\n'",
")",
"{",
"data",
"=",... | Net log has a buggy end of file, attempt to fix | [
"Net",
"log",
"has",
"a",
"buggy",
"end",
"of",
"file",
"attempt",
"to",
"fix"
] | 9c4d4d89aa9637319bdc4d170211e19abafafda7 | https://github.com/marcelduran/webpagetest-api/blob/9c4d4d89aa9637319bdc4d170211e19abafafda7/lib/helper.js#L121-L128 | train |
marcelduran/webpagetest-api | lib/helper.js | scriptToString | function scriptToString(data) {
var script = [];
data.forEach(function dataEach(step) {
var key, value;
if (typeof step === 'string') {
script.push(step);
} else if (typeof step === 'object') {
key = [Object.keys(step)[0]];
value = step[key];
if (value !== undefined && value !=... | javascript | function scriptToString(data) {
var script = [];
data.forEach(function dataEach(step) {
var key, value;
if (typeof step === 'string') {
script.push(step);
} else if (typeof step === 'object') {
key = [Object.keys(step)[0]];
value = step[key];
if (value !== undefined && value !=... | [
"function",
"scriptToString",
"(",
"data",
")",
"{",
"var",
"script",
"=",
"[",
"]",
";",
"data",
".",
"forEach",
"(",
"function",
"dataEach",
"(",
"step",
")",
"{",
"var",
"key",
",",
"value",
";",
"if",
"(",
"typeof",
"step",
"===",
"'string'",
")"... | Convert script objects into formatted string | [
"Convert",
"script",
"objects",
"into",
"formatted",
"string"
] | 9c4d4d89aa9637319bdc4d170211e19abafafda7 | https://github.com/marcelduran/webpagetest-api/blob/9c4d4d89aa9637319bdc4d170211e19abafafda7/lib/helper.js#L136-L155 | train |
marcelduran/webpagetest-api | lib/helper.js | dryRun | function dryRun(config, path) {
path = url.parse(path, true);
return {
url: url.format({
protocol: config.protocol,
hostname: config.hostname,
port: (config.port !== 80 && config.port !== 443 ?
config.port : undefined),
pathname: path.pathname,
query: path.query
})
}... | javascript | function dryRun(config, path) {
path = url.parse(path, true);
return {
url: url.format({
protocol: config.protocol,
hostname: config.hostname,
port: (config.port !== 80 && config.port !== 443 ?
config.port : undefined),
pathname: path.pathname,
query: path.query
})
}... | [
"function",
"dryRun",
"(",
"config",
",",
"path",
")",
"{",
"path",
"=",
"url",
".",
"parse",
"(",
"path",
",",
"true",
")",
";",
"return",
"{",
"url",
":",
"url",
".",
"format",
"(",
"{",
"protocol",
":",
"config",
".",
"protocol",
",",
"hostname"... | Build the RESTful API url call only | [
"Build",
"the",
"RESTful",
"API",
"url",
"call",
"only"
] | 9c4d4d89aa9637319bdc4d170211e19abafafda7 | https://github.com/marcelduran/webpagetest-api/blob/9c4d4d89aa9637319bdc4d170211e19abafafda7/lib/helper.js#L158-L171 | train |
marcelduran/webpagetest-api | lib/helper.js | normalizeServer | function normalizeServer(server) {
// normalize hostname
if (!reProtocol.test(server)) {
server = 'http://' + server;
}
server = url.parse(server);
return {
protocol: server.protocol,
hostname: server.hostname,
auth: server.auth,
pathname: server.pathname,
port: parseInt(server.port, ... | javascript | function normalizeServer(server) {
// normalize hostname
if (!reProtocol.test(server)) {
server = 'http://' + server;
}
server = url.parse(server);
return {
protocol: server.protocol,
hostname: server.hostname,
auth: server.auth,
pathname: server.pathname,
port: parseInt(server.port, ... | [
"function",
"normalizeServer",
"(",
"server",
")",
"{",
"// normalize hostname",
"if",
"(",
"!",
"reProtocol",
".",
"test",
"(",
"server",
")",
")",
"{",
"server",
"=",
"'http://'",
"+",
"server",
";",
"}",
"server",
"=",
"url",
".",
"parse",
"(",
"serve... | Normalize server config | [
"Normalize",
"server",
"config"
] | 9c4d4d89aa9637319bdc4d170211e19abafafda7 | https://github.com/marcelduran/webpagetest-api/blob/9c4d4d89aa9637319bdc4d170211e19abafafda7/lib/helper.js#L174-L188 | train |
marcelduran/webpagetest-api | lib/helper.js | localhost | function localhost(local, defaultPort) {
// edge case when hostname:port is not informed via cli
if (local === undefined || local === 'true') {
local = [defaultPort];
} else {
local = local.toString().split(':');
}
return {
hostname: reIp.test(local[0]) || isNaN(parseInt(local[0], 10)) &&
l... | javascript | function localhost(local, defaultPort) {
// edge case when hostname:port is not informed via cli
if (local === undefined || local === 'true') {
local = [defaultPort];
} else {
local = local.toString().split(':');
}
return {
hostname: reIp.test(local[0]) || isNaN(parseInt(local[0], 10)) &&
l... | [
"function",
"localhost",
"(",
"local",
",",
"defaultPort",
")",
"{",
"// edge case when hostname:port is not informed via cli",
"if",
"(",
"local",
"===",
"undefined",
"||",
"local",
"===",
"'true'",
")",
"{",
"local",
"=",
"[",
"defaultPort",
"]",
";",
"}",
"el... | Normalize localhost and port | [
"Normalize",
"localhost",
"and",
"port"
] | 9c4d4d89aa9637319bdc4d170211e19abafafda7 | https://github.com/marcelduran/webpagetest-api/blob/9c4d4d89aa9637319bdc4d170211e19abafafda7/lib/helper.js#L191-L205 | train |
marcelduran/webpagetest-api | lib/helper.js | setQuery | function setQuery(map, options, query) {
query = query || {};
options = options || {};
map.options.forEach(function eachOpts(opt) {
Object.keys(opt).forEach(function eachOpt(key) {
var param = opt[key],
name = param.name,
value = options[name] || options[key];
if (value !== u... | javascript | function setQuery(map, options, query) {
query = query || {};
options = options || {};
map.options.forEach(function eachOpts(opt) {
Object.keys(opt).forEach(function eachOpt(key) {
var param = opt[key],
name = param.name,
value = options[name] || options[key];
if (value !== u... | [
"function",
"setQuery",
"(",
"map",
",",
"options",
",",
"query",
")",
"{",
"query",
"=",
"query",
"||",
"{",
"}",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"map",
".",
"options",
".",
"forEach",
"(",
"function",
"eachOpts",
"(",
"opt",
... | Set valid parameter in query | [
"Set",
"valid",
"parameter",
"in",
"query"
] | 9c4d4d89aa9637319bdc4d170211e19abafafda7 | https://github.com/marcelduran/webpagetest-api/blob/9c4d4d89aa9637319bdc4d170211e19abafafda7/lib/helper.js#L217-L238 | train |
marcelduran/webpagetest-api | lib/mapping.js | setOptions | function setOptions(command, query) {
var count, opts;
command = commands[command];
if (!command) {
return;
}
opts = {};
count = Object.keys(query).length;
[options.common].concat(command.options).some(function someTypes(options) {
if (!options) {
return;
}
Object.keys(options).so... | javascript | function setOptions(command, query) {
var count, opts;
command = commands[command];
if (!command) {
return;
}
opts = {};
count = Object.keys(query).length;
[options.common].concat(command.options).some(function someTypes(options) {
if (!options) {
return;
}
Object.keys(options).so... | [
"function",
"setOptions",
"(",
"command",
",",
"query",
")",
"{",
"var",
"count",
",",
"opts",
";",
"command",
"=",
"commands",
"[",
"command",
"]",
";",
"if",
"(",
"!",
"command",
")",
"{",
"return",
";",
"}",
"opts",
"=",
"{",
"}",
";",
"count",
... | set valid options only per command | [
"set",
"valid",
"options",
"only",
"per",
"command"
] | 9c4d4d89aa9637319bdc4d170211e19abafafda7 | https://github.com/marcelduran/webpagetest-api/blob/9c4d4d89aa9637319bdc4d170211e19abafafda7/lib/mapping.js#L837-L871 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | baseDelay | function baseDelay(func, wait, args) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return setTimeout(function() { func.apply(undefined$1, args); }, wait);
} | javascript | function baseDelay(func, wait, args) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return setTimeout(function() { func.apply(undefined$1, args); }, wait);
} | [
"function",
"baseDelay",
"(",
"func",
",",
"wait",
",",
"args",
")",
"{",
"if",
"(",
"typeof",
"func",
"!=",
"'function'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"FUNC_ERROR_TEXT",
")",
";",
"}",
"return",
"setTimeout",
"(",
"function",
"(",
")",
... | The base implementation of `_.delay` and `_.defer` which accepts `args`
to provide to `func`.
@private
@param {Function} func The function to delay.
@param {number} wait The number of milliseconds to delay invocation.
@param {Array} args The arguments to provide to `func`.
@returns {number|Object} Returns the timer id... | [
"The",
"base",
"implementation",
"of",
"_",
".",
"delay",
"and",
"_",
".",
"defer",
"which",
"accepts",
"args",
"to",
"provide",
"to",
"func",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L2768-L2773 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | baseIntersection | function baseIntersection(arrays, iteratee, comparator) {
var includes = comparator ? arrayIncludesWith : arrayIncludes,
length = arrays[0].length,
othLength = arrays.length,
othIndex = othLength,
caches = Array(othLength),
maxLength = Infinity,
result =... | javascript | function baseIntersection(arrays, iteratee, comparator) {
var includes = comparator ? arrayIncludesWith : arrayIncludes,
length = arrays[0].length,
othLength = arrays.length,
othIndex = othLength,
caches = Array(othLength),
maxLength = Infinity,
result =... | [
"function",
"baseIntersection",
"(",
"arrays",
",",
"iteratee",
",",
"comparator",
")",
"{",
"var",
"includes",
"=",
"comparator",
"?",
"arrayIncludesWith",
":",
"arrayIncludes",
",",
"length",
"=",
"arrays",
"[",
"0",
"]",
".",
"length",
",",
"othLength",
"... | The base implementation of methods like `_.intersection`, without support
for iteratee shorthands, that accepts an array of arrays to inspect.
@private
@param {Array} arrays The arrays to inspect.
@param {Function} [iteratee] The iteratee invoked per element.
@param {Function} [comparator] The comparator invoked per e... | [
"The",
"base",
"implementation",
"of",
"methods",
"like",
"_",
".",
"intersection",
"without",
"support",
"for",
"iteratee",
"shorthands",
"that",
"accepts",
"an",
"array",
"of",
"arrays",
"to",
"inspect",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L3154-L3205 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | castSlice | function castSlice(array, start, end) {
var length = array.length;
end = end === undefined$1 ? length : end;
return (!start && end >= length) ? array : baseSlice(array, start, end);
} | javascript | function castSlice(array, start, end) {
var length = array.length;
end = end === undefined$1 ? length : end;
return (!start && end >= length) ? array : baseSlice(array, start, end);
} | [
"function",
"castSlice",
"(",
"array",
",",
"start",
",",
"end",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
";",
"end",
"=",
"end",
"===",
"undefined$1",
"?",
"length",
":",
"end",
";",
"return",
"(",
"!",
"start",
"&&",
"end",
">=",
"... | Casts `array` to a slice if it's needed.
@private
@param {Array} array The array to inspect.
@param {number} start The start position.
@param {number} [end=array.length] The end position.
@returns {Array} Returns the cast slice. | [
"Casts",
"array",
"to",
"a",
"slice",
"if",
"it",
"s",
"needed",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L4504-L4508 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | createCurry | function createCurry(func, bitmask, arity) {
var Ctor = createCtor(func);
function wrapper() {
var length = arguments.length,
args = Array(length),
index = length,
placeholder = getHolder(wrapper);
while (index--) {
args[index] = arguments[inde... | javascript | function createCurry(func, bitmask, arity) {
var Ctor = createCtor(func);
function wrapper() {
var length = arguments.length,
args = Array(length),
index = length,
placeholder = getHolder(wrapper);
while (index--) {
args[index] = arguments[inde... | [
"function",
"createCurry",
"(",
"func",
",",
"bitmask",
",",
"arity",
")",
"{",
"var",
"Ctor",
"=",
"createCtor",
"(",
"func",
")",
";",
"function",
"wrapper",
"(",
")",
"{",
"var",
"length",
"=",
"arguments",
".",
"length",
",",
"args",
"=",
"Array",
... | Creates a function that wraps `func` to enable currying.
@private
@param {Function} func The function to wrap.
@param {number} bitmask The bitmask flags. See `createWrap` for more details.
@param {number} arity The arity of `func`.
@returns {Function} Returns the new wrapped function. | [
"Creates",
"a",
"function",
"that",
"wraps",
"func",
"to",
"enable",
"currying",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L5038-L5064 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | createRecurry | function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & WRAP_CURRY_FLAG,
newHolders = isCurry ? holders : undefined$1,
newHoldersRight = isCurry ? undefined$1 : holders,
newPartials = isCurry ? partials : ... | javascript | function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & WRAP_CURRY_FLAG,
newHolders = isCurry ? holders : undefined$1,
newHoldersRight = isCurry ? undefined$1 : holders,
newPartials = isCurry ? partials : ... | [
"function",
"createRecurry",
"(",
"func",
",",
"bitmask",
",",
"wrapFunc",
",",
"placeholder",
",",
"thisArg",
",",
"partials",
",",
"holders",
",",
"argPos",
",",
"ary",
",",
"arity",
")",
"{",
"var",
"isCurry",
"=",
"bitmask",
"&",
"WRAP_CURRY_FLAG",
","... | Creates a function that wraps `func` to continue currying.
@private
@param {Function} func The function to wrap.
@param {number} bitmask The bitmask flags. See `createWrap` for more details.
@param {Function} wrapFunc The function to create the `func` wrapper.
@param {*} placeholder The placeholder value.
@param {*} [... | [
"Creates",
"a",
"function",
"that",
"wraps",
"func",
"to",
"continue",
"currying",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L5403-L5427 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | shuffleSelf | function shuffleSelf(array, size) {
var index = -1,
length = array.length,
lastIndex = length - 1;
size = size === undefined$1 ? length : size;
while (++index < size) {
var rand = baseRandom(index, lastIndex),
value = array[rand];
array[rand] = array[i... | javascript | function shuffleSelf(array, size) {
var index = -1,
length = array.length,
lastIndex = length - 1;
size = size === undefined$1 ? length : size;
while (++index < size) {
var rand = baseRandom(index, lastIndex),
value = array[rand];
array[rand] = array[i... | [
"function",
"shuffleSelf",
"(",
"array",
",",
"size",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"array",
".",
"length",
",",
"lastIndex",
"=",
"length",
"-",
"1",
";",
"size",
"=",
"size",
"===",
"undefined$1",
"?",
"length",
":",
... | A specialized version of `_.shuffle` which mutates and sets the size of `array`.
@private
@param {Array} array The array to shuffle.
@param {number} [size=array.length] The size of `array`.
@returns {Array} Returns `array`. | [
"A",
"specialized",
"version",
"of",
"_",
".",
"shuffle",
"which",
"mutates",
"and",
"sets",
"the",
"size",
"of",
"array",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L6729-L6744 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | last | function last(array) {
var length = array == null ? 0 : array.length;
return length ? array[length - 1] : undefined$1;
} | javascript | function last(array) {
var length = array == null ? 0 : array.length;
return length ? array[length - 1] : undefined$1;
} | [
"function",
"last",
"(",
"array",
")",
"{",
"var",
"length",
"=",
"array",
"==",
"null",
"?",
"0",
":",
"array",
".",
"length",
";",
"return",
"length",
"?",
"array",
"[",
"length",
"-",
"1",
"]",
":",
"undefined$1",
";",
"}"
] | Gets the last element of `array`.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to query.
@returns {*} Returns the last element of `array`.
@example
_.last([1, 2, 3]);
// => 3 | [
"Gets",
"the",
"last",
"element",
"of",
"array",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L7627-L7630 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | take | function take(array, n, guard) {
if (!(array && array.length)) {
return [];
}
n = (guard || n === undefined$1) ? 1 : toInteger(n);
return baseSlice(array, 0, n < 0 ? 0 : n);
} | javascript | function take(array, n, guard) {
if (!(array && array.length)) {
return [];
}
n = (guard || n === undefined$1) ? 1 : toInteger(n);
return baseSlice(array, 0, n < 0 ? 0 : n);
} | [
"function",
"take",
"(",
"array",
",",
"n",
",",
"guard",
")",
"{",
"if",
"(",
"!",
"(",
"array",
"&&",
"array",
".",
"length",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"n",
"=",
"(",
"guard",
"||",
"n",
"===",
"undefined$1",
")",
"?",
"1... | Creates a slice of `array` with `n` elements taken from the beginning.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to query.
@param {number} [n=1] The number of elements to take.
@param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
@returns {Array} Returns t... | [
"Creates",
"a",
"slice",
"of",
"array",
"with",
"n",
"elements",
"taken",
"from",
"the",
"beginning",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L8187-L8193 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | template | function template(string, options, guard) {
// Based on John Resig's `tmpl` implementation
// (http://ejohn.org/blog/javascript-micro-templating/)
// and Laura Doktorova's doT.js (https://github.com/olado/doT).
var settings = lodash.templateSettings;
if (guard && isIterateeCall(string, op... | javascript | function template(string, options, guard) {
// Based on John Resig's `tmpl` implementation
// (http://ejohn.org/blog/javascript-micro-templating/)
// and Laura Doktorova's doT.js (https://github.com/olado/doT).
var settings = lodash.templateSettings;
if (guard && isIterateeCall(string, op... | [
"function",
"template",
"(",
"string",
",",
"options",
",",
"guard",
")",
"{",
"// Based on John Resig's `tmpl` implementation",
"// (http://ejohn.org/blog/javascript-micro-templating/)",
"// and Laura Doktorova's doT.js (https://github.com/olado/doT).",
"var",
"settings",
"=",
"loda... | Creates a compiled template function that can interpolate data properties
in "interpolate" delimiters, HTML-escape interpolated data properties in
"escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
properties may be accessed as free variables in the template. If a setting
object is given, it tak... | [
"Creates",
"a",
"compiled",
"template",
"function",
"that",
"can",
"interpolate",
"data",
"properties",
"in",
"interpolate",
"delimiters",
"HTML",
"-",
"escape",
"interpolated",
"data",
"properties",
"in",
"escape",
"delimiters",
"and",
"execute",
"JavaScript",
"in"... | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L14787-L14893 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | baseKeys | function baseKeys(object) {
if (!_isPrototype(object)) {
return _nativeKeys(object);
}
var result = [];
for (var key in Object(object)) {
if (hasOwnProperty$7.call(object, key) && key != 'constructor') {
result.push(key);
}
}
return result;
} | javascript | function baseKeys(object) {
if (!_isPrototype(object)) {
return _nativeKeys(object);
}
var result = [];
for (var key in Object(object)) {
if (hasOwnProperty$7.call(object, key) && key != 'constructor') {
result.push(key);
}
}
return result;
} | [
"function",
"baseKeys",
"(",
"object",
")",
"{",
"if",
"(",
"!",
"_isPrototype",
"(",
"object",
")",
")",
"{",
"return",
"_nativeKeys",
"(",
"object",
")",
";",
"}",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"Object",
"("... | The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
@private
@param {Object} object The object to query.
@returns {Array} Returns the array of property names. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"keys",
"which",
"doesn",
"t",
"treat",
"sparse",
"arrays",
"as",
"dense",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L18793-L18804 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | baseFilter | function baseFilter(collection, predicate) {
var result = [];
_baseEach(collection, function(value, index, collection) {
if (predicate(value, index, collection)) {
result.push(value);
}
});
return result;
} | javascript | function baseFilter(collection, predicate) {
var result = [];
_baseEach(collection, function(value, index, collection) {
if (predicate(value, index, collection)) {
result.push(value);
}
});
return result;
} | [
"function",
"baseFilter",
"(",
"collection",
",",
"predicate",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"_baseEach",
"(",
"collection",
",",
"function",
"(",
"value",
",",
"index",
",",
"collection",
")",
"{",
"if",
"(",
"predicate",
"(",
"value",
... | The base implementation of `_.filter` without support for iteratee shorthands.
@private
@param {Array|Object} collection The collection to iterate over.
@param {Function} predicate The function invoked per iteration.
@returns {Array} Returns the new filtered array. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"filter",
"without",
"support",
"for",
"iteratee",
"shorthands",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L20009-L20017 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | baseIsEqual | function baseIsEqual(value, other, bitmask, customizer, stack) {
if (value === other) {
return true;
}
if (value == null || other == null || (!isObjectLike_1(value) && !isObjectLike_1(other))) {
return value !== value && other !== other;
}
return _baseIsEqualDeep(value, other, bitmask, customizer, bas... | javascript | function baseIsEqual(value, other, bitmask, customizer, stack) {
if (value === other) {
return true;
}
if (value == null || other == null || (!isObjectLike_1(value) && !isObjectLike_1(other))) {
return value !== value && other !== other;
}
return _baseIsEqualDeep(value, other, bitmask, customizer, bas... | [
"function",
"baseIsEqual",
"(",
"value",
",",
"other",
",",
"bitmask",
",",
"customizer",
",",
"stack",
")",
"{",
"if",
"(",
"value",
"===",
"other",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"value",
"==",
"null",
"||",
"other",
"==",
"null",... | The base implementation of `_.isEqual` which supports partial comparisons
and tracks traversed objects.
@private
@param {*} value The value to compare.
@param {*} other The other value to compare.
@param {boolean} bitmask The bitmask flags.
1 - Unordered comparison
2 - Partial comparison
@param {Function} [customizer]... | [
"The",
"base",
"implementation",
"of",
"_",
".",
"isEqual",
"which",
"supports",
"partial",
"comparisons",
"and",
"tracks",
"traversed",
"objects",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L20519-L20527 | train |
ezolenko/rollup-plugin-typescript2 | dist/rollup-plugin-typescript2.cjs.js | baseUniq | function baseUniq(array, iteratee, comparator) {
var index = -1,
includes = _arrayIncludes,
length = array.length,
isCommon = true,
result = [],
seen = result;
if (comparator) {
isCommon = false;
includes = _arrayIncludesWith;
}
else if (length >= LARGE_ARRAY_SIZE$1) {
... | javascript | function baseUniq(array, iteratee, comparator) {
var index = -1,
includes = _arrayIncludes,
length = array.length,
isCommon = true,
result = [],
seen = result;
if (comparator) {
isCommon = false;
includes = _arrayIncludesWith;
}
else if (length >= LARGE_ARRAY_SIZE$1) {
... | [
"function",
"baseUniq",
"(",
"array",
",",
"iteratee",
",",
"comparator",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"includes",
"=",
"_arrayIncludes",
",",
"length",
"=",
"array",
".",
"length",
",",
"isCommon",
"=",
"true",
",",
"result",
"=",
"["... | The base implementation of `_.uniqBy` without support for iteratee shorthands.
@private
@param {Array} array The array to inspect.
@param {Function} [iteratee] The iteratee invoked per element.
@param {Function} [comparator] The comparator invoked per element.
@returns {Array} Returns the new duplicate free array. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"uniqBy",
"without",
"support",
"for",
"iteratee",
"shorthands",
"."
] | 1fa02cd89ec3664a810342c4e4072496436e8a1d | https://github.com/ezolenko/rollup-plugin-typescript2/blob/1fa02cd89ec3664a810342c4e4072496436e8a1d/dist/rollup-plugin-typescript2.cjs.js#L22139-L22189 | train |
jansepar/node-jenkins-api | src/main.js | function (specificOptions, customParams, callback) {
// Options - Default values
const options = Object.assign({}, {
urlPattern: ['/'],
method: 'GET',
successStatusCodes: [HTTP_CODE_200],
failureStatusCodes: [],
bodyProp: null,
noparse: false,
request: {}
}, defaul... | javascript | function (specificOptions, customParams, callback) {
// Options - Default values
const options = Object.assign({}, {
urlPattern: ['/'],
method: 'GET',
successStatusCodes: [HTTP_CODE_200],
failureStatusCodes: [],
bodyProp: null,
noparse: false,
request: {}
}, defaul... | [
"function",
"(",
"specificOptions",
",",
"customParams",
",",
"callback",
")",
"{",
"// Options - Default values",
"const",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"{",
"urlPattern",
":",
"[",
"'/'",
"]",
",",
"method",
":",
"'GET'",
"... | Run the actual HTTP request.
@param {object} specificOptions - options object overriding the default options below.
@param {object} customParams - custom url params to be added to url.
@param {function} callback - the callback function to be called when request is finished. | [
"Run",
"the",
"actual",
"HTTP",
"request",
"."
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/src/main.js#L238-L298 | train | |
jansepar/node-jenkins-api | src/main.js | function (jobName, jobConfig, customParams, callback) {
[jobName, jobConfig, customParams, callback] = doArgs(arguments, ['string', 'string', ['object', {}], 'function']);
// Set the created job name!
customParams.name = jobName;
const self = this;
doRequest({
method: 'POST',
... | javascript | function (jobName, jobConfig, customParams, callback) {
[jobName, jobConfig, customParams, callback] = doArgs(arguments, ['string', 'string', ['object', {}], 'function']);
// Set the created job name!
customParams.name = jobName;
const self = this;
doRequest({
method: 'POST',
... | [
"function",
"(",
"jobName",
",",
"jobConfig",
",",
"customParams",
",",
"callback",
")",
"{",
"[",
"jobName",
",",
"jobConfig",
",",
"customParams",
",",
"callback",
"]",
"=",
"doArgs",
"(",
"arguments",
",",
"[",
"'string'",
",",
"'string'",
",",
"[",
"... | Create a new job based on a jobConfig string
@param {string} jobName
@param {string} jobConfig
@param {object|undefined} customParams is optional
@param {function} callback | [
"Create",
"a",
"new",
"job",
"based",
"on",
"a",
"jobConfig",
"string"
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/src/main.js#L652-L675 | train | |
jansepar/node-jenkins-api | src/main.js | function (viewName, viewConfig, customParams, callback) {
[viewName, viewConfig, customParams, callback] = doArgs(arguments, ['string', 'object', ['object', {}], 'function']);
viewConfig.json = JSON.stringify(viewConfig);
const self = this;
doRequest({
method: 'POST',
urlPatte... | javascript | function (viewName, viewConfig, customParams, callback) {
[viewName, viewConfig, customParams, callback] = doArgs(arguments, ['string', 'object', ['object', {}], 'function']);
viewConfig.json = JSON.stringify(viewConfig);
const self = this;
doRequest({
method: 'POST',
urlPatte... | [
"function",
"(",
"viewName",
",",
"viewConfig",
",",
"customParams",
",",
"callback",
")",
"{",
"[",
"viewName",
",",
"viewConfig",
",",
"customParams",
",",
"callback",
"]",
"=",
"doArgs",
"(",
"arguments",
",",
"[",
"'string'",
",",
"'object'",
",",
"[",... | Update a view based on a viewConfig object
@param {string} viewName
@param {object} viewConfig
@param {object|undefined} customParams is optional
@param {function} callback | [
"Update",
"a",
"view",
"based",
"on",
"a",
"viewConfig",
"object"
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/src/main.js#L959-L981 | train | |
jansepar/node-jenkins-api | src/main.js | function (viewName, customParams, callback) {
[viewName, customParams, callback] = doArgs(arguments, ['string', ['object', {}], 'function']);
doRequest({
urlPattern: [VIEW_INFO, viewName],
bodyProp: 'jobs'
}, customParams, callback);
} | javascript | function (viewName, customParams, callback) {
[viewName, customParams, callback] = doArgs(arguments, ['string', ['object', {}], 'function']);
doRequest({
urlPattern: [VIEW_INFO, viewName],
bodyProp: 'jobs'
}, customParams, callback);
} | [
"function",
"(",
"viewName",
",",
"customParams",
",",
"callback",
")",
"{",
"[",
"viewName",
",",
"customParams",
",",
"callback",
"]",
"=",
"doArgs",
"(",
"arguments",
",",
"[",
"'string'",
",",
"[",
"'object'",
",",
"{",
"}",
"]",
",",
"'function'",
... | Return a list of objet literals containing the name and color of all the jobs for a view on the Jenkins server
@param {string} viewName
@param {object|undefined} customParams is optional
@param {function} callback | [
"Return",
"a",
"list",
"of",
"objet",
"literals",
"containing",
"the",
"name",
"and",
"color",
"of",
"all",
"the",
"jobs",
"for",
"a",
"view",
"on",
"the",
"Jenkins",
"server"
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/src/main.js#L1047-L1054 | train | |
jansepar/node-jenkins-api | src/main.js | function (pluginName, customParams, callback) {
[pluginName, customParams, callback] = doArgs(arguments, ['string', ['object', {}], 'function']);
const body = `<jenkins><install plugin="${pluginName}" /></jenkins>`;
doRequest({
method: 'POST',
urlPattern: [INSTALL_PLUGIN],
re... | javascript | function (pluginName, customParams, callback) {
[pluginName, customParams, callback] = doArgs(arguments, ['string', ['object', {}], 'function']);
const body = `<jenkins><install plugin="${pluginName}" /></jenkins>`;
doRequest({
method: 'POST',
urlPattern: [INSTALL_PLUGIN],
re... | [
"function",
"(",
"pluginName",
",",
"customParams",
",",
"callback",
")",
"{",
"[",
"pluginName",
",",
"customParams",
",",
"callback",
"]",
"=",
"doArgs",
"(",
"arguments",
",",
"[",
"'string'",
",",
"[",
"'object'",
",",
"{",
"}",
"]",
",",
"'function'... | Install a plugin
@param {string} pluginName
@param {object|undefined} customParams is optional
@param {function} callback | [
"Install",
"a",
"plugin"
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/src/main.js#L1086-L1101 | train | |
jansepar/node-jenkins-api | src/main.js | function (folderName, customParams, callback) {
[folderName, customParams, callback] = doArgs(arguments, ['string', ['object', {}], 'function']);
const mode = 'com.cloudbees.hudson.plugins.folder.Folder';
customParams.name = folderName;
customParams.mode = mode;
customParams.Submit = 'OK... | javascript | function (folderName, customParams, callback) {
[folderName, customParams, callback] = doArgs(arguments, ['string', ['object', {}], 'function']);
const mode = 'com.cloudbees.hudson.plugins.folder.Folder';
customParams.name = folderName;
customParams.mode = mode;
customParams.Submit = 'OK... | [
"function",
"(",
"folderName",
",",
"customParams",
",",
"callback",
")",
"{",
"[",
"folderName",
",",
"customParams",
",",
"callback",
"]",
"=",
"doArgs",
"(",
"arguments",
",",
"[",
"'string'",
",",
"[",
"'object'",
",",
"{",
"}",
"]",
",",
"'function'... | Create a new folder with given name
Requires Folder plugin in Jenkins:
@see https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Folders+Plugin
@see https://gist.github.com/stuart-warren/7786892
@param {string} folderName
@param {object|undefined} customParams is optional
@param {function} callback | [
"Create",
"a",
"new",
"folder",
"with",
"given",
"name"
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/src/main.js#L1114-L1127 | train | |
jansepar/node-jenkins-api | lib/main.js | appendParams | function appendParams(url, specificParams) {
// Assign default and specific parameters
var params = Object.assign({}, defaultParams, specificParams);
// Stringify the querystring params
var paramsString = qs.stringify(params);
// Empty params
if (paramsString === '') {
return url;
}
... | javascript | function appendParams(url, specificParams) {
// Assign default and specific parameters
var params = Object.assign({}, defaultParams, specificParams);
// Stringify the querystring params
var paramsString = qs.stringify(params);
// Empty params
if (paramsString === '') {
return url;
}
... | [
"function",
"appendParams",
"(",
"url",
",",
"specificParams",
")",
"{",
"// Assign default and specific parameters",
"var",
"params",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"defaultParams",
",",
"specificParams",
")",
";",
"// Stringify the querystring par... | Build REST params and correctly append them to URL.
@param {string} url to be extended with params.
@param {object} specificParams key/value pair of params.
@returns {string} the extended url. | [
"Build",
"REST",
"params",
"and",
"correctly",
"append",
"them",
"to",
"URL",
"."
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/lib/main.js#L256-L272 | train |
jansepar/node-jenkins-api | lib/main.js | buildUrl | function buildUrl(urlPattern, customParams) {
var url = formatUrl.apply(null, urlPattern);
url = appendParams(url, customParams);
return url;
} | javascript | function buildUrl(urlPattern, customParams) {
var url = formatUrl.apply(null, urlPattern);
url = appendParams(url, customParams);
return url;
} | [
"function",
"buildUrl",
"(",
"urlPattern",
",",
"customParams",
")",
"{",
"var",
"url",
"=",
"formatUrl",
".",
"apply",
"(",
"null",
",",
"urlPattern",
")",
";",
"url",
"=",
"appendParams",
"(",
"url",
",",
"customParams",
")",
";",
"return",
"url",
";",... | Just helper funckion to build the request URL.
@param {array<string>} urlPattern array in format of [urlFormat, arg1, arg2] used to build the URL.
@param {object} customParams key/value pair of params.
@returns {string} the URL built. | [
"Just",
"helper",
"funckion",
"to",
"build",
"the",
"request",
"URL",
"."
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/lib/main.js#L281-L286 | train |
jansepar/node-jenkins-api | lib/main.js | delete_build | function delete_build(jobName, buildNumber, customParams, callback) {
var _doArgs21 = doArgs(arguments, ['string', 'string|number', ['object', {}], 'function']);
var _doArgs22 = _slicedToArray(_doArgs21, 4);
jobName = _doArgs22[0];
buildNumber = _doArgs22[1];
customParams = _doArgs22[2];... | javascript | function delete_build(jobName, buildNumber, customParams, callback) {
var _doArgs21 = doArgs(arguments, ['string', 'string|number', ['object', {}], 'function']);
var _doArgs22 = _slicedToArray(_doArgs21, 4);
jobName = _doArgs22[0];
buildNumber = _doArgs22[1];
customParams = _doArgs22[2];... | [
"function",
"delete_build",
"(",
"jobName",
",",
"buildNumber",
",",
"customParams",
",",
"callback",
")",
"{",
"var",
"_doArgs21",
"=",
"doArgs",
"(",
"arguments",
",",
"[",
"'string'",
",",
"'string|number'",
",",
"[",
"'object'",
",",
"{",
"}",
"]",
","... | Deletes build data for certain job | [
"Deletes",
"build",
"data",
"for",
"certain",
"job"
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/lib/main.js#L569-L592 | train |
jansepar/node-jenkins-api | lib/main.js | update_job | function update_job(jobName, jobConfig, customParams, callback) {
var _doArgs29 = doArgs(arguments, ['string', 'string', ['object', {}], 'function']);
var _doArgs30 = _slicedToArray(_doArgs29, 4);
jobName = _doArgs30[0];
jobConfig = _doArgs30[1];
customParams = _doArgs30[2];
callba... | javascript | function update_job(jobName, jobConfig, customParams, callback) {
var _doArgs29 = doArgs(arguments, ['string', 'string', ['object', {}], 'function']);
var _doArgs30 = _slicedToArray(_doArgs29, 4);
jobName = _doArgs30[0];
jobConfig = _doArgs30[1];
customParams = _doArgs30[2];
callba... | [
"function",
"update_job",
"(",
"jobName",
",",
"jobConfig",
",",
"customParams",
",",
"callback",
")",
"{",
"var",
"_doArgs29",
"=",
"doArgs",
"(",
"arguments",
",",
"[",
"'string'",
",",
"'string'",
",",
"[",
"'object'",
",",
"{",
"}",
"]",
",",
"'funct... | Update a existing job based on a jobConfig xml string | [
"Update",
"a",
"existing",
"job",
"based",
"on",
"a",
"jobConfig",
"xml",
"string"
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/lib/main.js#L666-L694 | train |
jansepar/node-jenkins-api | lib/main.js | enable_job | function enable_job(jobName, customParams, callback) {
var _doArgs41 = doArgs(arguments, ['string', ['object', {}], 'function']);
var _doArgs42 = _slicedToArray(_doArgs41, 3);
jobName = _doArgs42[0];
customParams = _doArgs42[1];
callback = _doArgs42[2];
var self = this;
do... | javascript | function enable_job(jobName, customParams, callback) {
var _doArgs41 = doArgs(arguments, ['string', ['object', {}], 'function']);
var _doArgs42 = _slicedToArray(_doArgs41, 3);
jobName = _doArgs42[0];
customParams = _doArgs42[1];
callback = _doArgs42[2];
var self = this;
do... | [
"function",
"enable_job",
"(",
"jobName",
",",
"customParams",
",",
"callback",
")",
"{",
"var",
"_doArgs41",
"=",
"doArgs",
"(",
"arguments",
",",
"[",
"'string'",
",",
"[",
"'object'",
",",
"{",
"}",
"]",
",",
"'function'",
"]",
")",
";",
"var",
"_do... | Enables a job | [
"Enables",
"a",
"job"
] | 1f1ac16a6055bc162c7ecfdee286c2a458a1e19b | https://github.com/jansepar/node-jenkins-api/blob/1f1ac16a6055bc162c7ecfdee286c2a458a1e19b/lib/main.js#L824-L847 | train |
mapbox/tilebelt | index.js | tileToBBOX | function tileToBBOX(tile) {
var e = tile2lon(tile[0] + 1, tile[2]);
var w = tile2lon(tile[0], tile[2]);
var s = tile2lat(tile[1] + 1, tile[2]);
var n = tile2lat(tile[1], tile[2]);
return [w, s, e, n];
} | javascript | function tileToBBOX(tile) {
var e = tile2lon(tile[0] + 1, tile[2]);
var w = tile2lon(tile[0], tile[2]);
var s = tile2lat(tile[1] + 1, tile[2]);
var n = tile2lat(tile[1], tile[2]);
return [w, s, e, n];
} | [
"function",
"tileToBBOX",
"(",
"tile",
")",
"{",
"var",
"e",
"=",
"tile2lon",
"(",
"tile",
"[",
"0",
"]",
"+",
"1",
",",
"tile",
"[",
"2",
"]",
")",
";",
"var",
"w",
"=",
"tile2lon",
"(",
"tile",
"[",
"0",
"]",
",",
"tile",
"[",
"2",
"]",
"... | Get the bbox of a tile
@name tileToBBOX
@param {Array<number>} tile
@returns {Array<number>} bbox
@example
var bbox = tileToBBOX([5, 10, 10])
//=bbox | [
"Get",
"the",
"bbox",
"of",
"a",
"tile"
] | 7df684f198837d9ea0385a0b0b8f71c8d0f3acac | https://github.com/mapbox/tilebelt/blob/7df684f198837d9ea0385a0b0b8f71c8d0f3acac/index.js#L16-L22 | train |
mapbox/tilebelt | index.js | tileToGeoJSON | function tileToGeoJSON(tile) {
var bbox = tileToBBOX(tile);
var poly = {
type: 'Polygon',
coordinates: [[
[bbox[0], bbox[1]],
[bbox[0], bbox[3]],
[bbox[2], bbox[3]],
[bbox[2], bbox[1]],
[bbox[0], bbox[1]]
]]
};
return po... | javascript | function tileToGeoJSON(tile) {
var bbox = tileToBBOX(tile);
var poly = {
type: 'Polygon',
coordinates: [[
[bbox[0], bbox[1]],
[bbox[0], bbox[3]],
[bbox[2], bbox[3]],
[bbox[2], bbox[1]],
[bbox[0], bbox[1]]
]]
};
return po... | [
"function",
"tileToGeoJSON",
"(",
"tile",
")",
"{",
"var",
"bbox",
"=",
"tileToBBOX",
"(",
"tile",
")",
";",
"var",
"poly",
"=",
"{",
"type",
":",
"'Polygon'",
",",
"coordinates",
":",
"[",
"[",
"[",
"bbox",
"[",
"0",
"]",
",",
"bbox",
"[",
"1",
... | Get a geojson representation of a tile
@name tileToGeoJSON
@param {Array<number>} tile
@returns {Feature<Polygon>}
@example
var poly = tileToGeoJSON([5, 10, 10])
//=poly | [
"Get",
"a",
"geojson",
"representation",
"of",
"a",
"tile"
] | 7df684f198837d9ea0385a0b0b8f71c8d0f3acac | https://github.com/mapbox/tilebelt/blob/7df684f198837d9ea0385a0b0b8f71c8d0f3acac/index.js#L34-L47 | train |
mapbox/tilebelt | index.js | pointToTile | function pointToTile(lon, lat, z) {
var tile = pointToTileFraction(lon, lat, z);
tile[0] = Math.floor(tile[0]);
tile[1] = Math.floor(tile[1]);
return tile;
} | javascript | function pointToTile(lon, lat, z) {
var tile = pointToTileFraction(lon, lat, z);
tile[0] = Math.floor(tile[0]);
tile[1] = Math.floor(tile[1]);
return tile;
} | [
"function",
"pointToTile",
"(",
"lon",
",",
"lat",
",",
"z",
")",
"{",
"var",
"tile",
"=",
"pointToTileFraction",
"(",
"lon",
",",
"lat",
",",
"z",
")",
";",
"tile",
"[",
"0",
"]",
"=",
"Math",
".",
"floor",
"(",
"tile",
"[",
"0",
"]",
")",
";"... | Get the tile for a point at a specified zoom level
@name pointToTile
@param {number} lon
@param {number} lat
@param {number} z
@returns {Array<number>} tile
@example
var tile = pointToTile(1, 1, 20)
//=tile | [
"Get",
"the",
"tile",
"for",
"a",
"point",
"at",
"a",
"specified",
"zoom",
"level"
] | 7df684f198837d9ea0385a0b0b8f71c8d0f3acac | https://github.com/mapbox/tilebelt/blob/7df684f198837d9ea0385a0b0b8f71c8d0f3acac/index.js#L70-L75 | train |
mapbox/tilebelt | index.js | getChildren | function getChildren(tile) {
return [
[tile[0] * 2, tile[1] * 2, tile[2] + 1],
[tile[0] * 2 + 1, tile[1] * 2, tile[2 ] + 1],
[tile[0] * 2 + 1, tile[1] * 2 + 1, tile[2] + 1],
[tile[0] * 2, tile[1] * 2 + 1, tile[2] + 1]
];
} | javascript | function getChildren(tile) {
return [
[tile[0] * 2, tile[1] * 2, tile[2] + 1],
[tile[0] * 2 + 1, tile[1] * 2, tile[2 ] + 1],
[tile[0] * 2 + 1, tile[1] * 2 + 1, tile[2] + 1],
[tile[0] * 2, tile[1] * 2 + 1, tile[2] + 1]
];
} | [
"function",
"getChildren",
"(",
"tile",
")",
"{",
"return",
"[",
"[",
"tile",
"[",
"0",
"]",
"*",
"2",
",",
"tile",
"[",
"1",
"]",
"*",
"2",
",",
"tile",
"[",
"2",
"]",
"+",
"1",
"]",
",",
"[",
"tile",
"[",
"0",
"]",
"*",
"2",
"+",
"1",
... | Get the 4 tiles one zoom level higher
@name getChildren
@param {Array<number>} tile
@returns {Array<Array<number>>} tiles
@example
var tiles = getChildren([5, 10, 10])
//=tiles | [
"Get",
"the",
"4",
"tiles",
"one",
"zoom",
"level",
"higher"
] | 7df684f198837d9ea0385a0b0b8f71c8d0f3acac | https://github.com/mapbox/tilebelt/blob/7df684f198837d9ea0385a0b0b8f71c8d0f3acac/index.js#L87-L94 | train |
mapbox/tilebelt | index.js | hasSiblings | function hasSiblings(tile, tiles) {
var siblings = getSiblings(tile);
for (var i = 0; i < siblings.length; i++) {
if (!hasTile(tiles, siblings[i])) return false;
}
return true;
} | javascript | function hasSiblings(tile, tiles) {
var siblings = getSiblings(tile);
for (var i = 0; i < siblings.length; i++) {
if (!hasTile(tiles, siblings[i])) return false;
}
return true;
} | [
"function",
"hasSiblings",
"(",
"tile",
",",
"tiles",
")",
"{",
"var",
"siblings",
"=",
"getSiblings",
"(",
"tile",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"siblings",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
... | Get the 3 sibling tiles for a tile
@name getSiblings
@param {Array<number>} tile
@returns {Array<Array<number>>} tiles
@example
var tiles = getSiblings([5, 10, 10])
//=tiles | [
"Get",
"the",
"3",
"sibling",
"tiles",
"for",
"a",
"tile"
] | 7df684f198837d9ea0385a0b0b8f71c8d0f3acac | https://github.com/mapbox/tilebelt/blob/7df684f198837d9ea0385a0b0b8f71c8d0f3acac/index.js#L124-L130 | train |
mapbox/tilebelt | index.js | hasTile | function hasTile(tiles, tile) {
for (var i = 0; i < tiles.length; i++) {
if (tilesEqual(tiles[i], tile)) return true;
}
return false;
} | javascript | function hasTile(tiles, tile) {
for (var i = 0; i < tiles.length; i++) {
if (tilesEqual(tiles[i], tile)) return true;
}
return false;
} | [
"function",
"hasTile",
"(",
"tiles",
",",
"tile",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"tiles",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"tilesEqual",
"(",
"tiles",
"[",
"i",
"]",
",",
"tile",
")",
")",
"retur... | Check to see if an array of tiles contains a particular tile
@name hasTile
@param {Array<Array<number>>} tiles
@param {Array<number>} tile
@returns {boolean}
@example
var tiles = [
[0, 0, 5],
[0, 1, 5],
[1, 1, 5],
[1, 0, 5]
]
hasTile(tiles, [0, 0, 5])
//=boolean | [
"Check",
"to",
"see",
"if",
"an",
"array",
"of",
"tiles",
"contains",
"a",
"particular",
"tile"
] | 7df684f198837d9ea0385a0b0b8f71c8d0f3acac | https://github.com/mapbox/tilebelt/blob/7df684f198837d9ea0385a0b0b8f71c8d0f3acac/index.js#L149-L154 | train |
mapbox/tilebelt | index.js | tileToQuadkey | function tileToQuadkey(tile) {
var index = '';
for (var z = tile[2]; z > 0; z--) {
var b = 0;
var mask = 1 << (z - 1);
if ((tile[0] & mask) !== 0) b++;
if ((tile[1] & mask) !== 0) b += 2;
index += b.toString();
}
return index;
} | javascript | function tileToQuadkey(tile) {
var index = '';
for (var z = tile[2]; z > 0; z--) {
var b = 0;
var mask = 1 << (z - 1);
if ((tile[0] & mask) !== 0) b++;
if ((tile[1] & mask) !== 0) b += 2;
index += b.toString();
}
return index;
} | [
"function",
"tileToQuadkey",
"(",
"tile",
")",
"{",
"var",
"index",
"=",
"''",
";",
"for",
"(",
"var",
"z",
"=",
"tile",
"[",
"2",
"]",
";",
"z",
">",
"0",
";",
"z",
"--",
")",
"{",
"var",
"b",
"=",
"0",
";",
"var",
"mask",
"=",
"1",
"<<",
... | Get the quadkey for a tile
@name tileToQuadkey
@param {Array<number>} tile
@returns {string} quadkey
@example
var quadkey = tileToQuadkey([0, 1, 5])
//=quadkey | [
"Get",
"the",
"quadkey",
"for",
"a",
"tile"
] | 7df684f198837d9ea0385a0b0b8f71c8d0f3acac | https://github.com/mapbox/tilebelt/blob/7df684f198837d9ea0385a0b0b8f71c8d0f3acac/index.js#L185-L195 | train |
mapbox/tilebelt | index.js | quadkeyToTile | function quadkeyToTile(quadkey) {
var x = 0;
var y = 0;
var z = quadkey.length;
for (var i = z; i > 0; i--) {
var mask = 1 << (i - 1);
var q = +quadkey[z - i];
if (q === 1) x |= mask;
if (q === 2) y |= mask;
if (q === 3) {
x |= mask;
y |= ... | javascript | function quadkeyToTile(quadkey) {
var x = 0;
var y = 0;
var z = quadkey.length;
for (var i = z; i > 0; i--) {
var mask = 1 << (i - 1);
var q = +quadkey[z - i];
if (q === 1) x |= mask;
if (q === 2) y |= mask;
if (q === 3) {
x |= mask;
y |= ... | [
"function",
"quadkeyToTile",
"(",
"quadkey",
")",
"{",
"var",
"x",
"=",
"0",
";",
"var",
"y",
"=",
"0",
";",
"var",
"z",
"=",
"quadkey",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"z",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"va... | Get the tile for a quadkey
@name quadkeyToTile
@param {string} quadkey
@returns {Array<number>} tile
@example
var tile = quadkeyToTile('00001033')
//=tile | [
"Get",
"the",
"tile",
"for",
"a",
"quadkey"
] | 7df684f198837d9ea0385a0b0b8f71c8d0f3acac | https://github.com/mapbox/tilebelt/blob/7df684f198837d9ea0385a0b0b8f71c8d0f3acac/index.js#L207-L223 | train |
mapbox/tilebelt | index.js | bboxToTile | function bboxToTile(bboxCoords) {
var min = pointToTile(bboxCoords[0], bboxCoords[1], 32);
var max = pointToTile(bboxCoords[2], bboxCoords[3], 32);
var bbox = [min[0], min[1], max[0], max[1]];
var z = getBboxZoom(bbox);
if (z === 0) return [0, 0, 0];
var x = bbox[0] >>> (32 - z);
var y = bb... | javascript | function bboxToTile(bboxCoords) {
var min = pointToTile(bboxCoords[0], bboxCoords[1], 32);
var max = pointToTile(bboxCoords[2], bboxCoords[3], 32);
var bbox = [min[0], min[1], max[0], max[1]];
var z = getBboxZoom(bbox);
if (z === 0) return [0, 0, 0];
var x = bbox[0] >>> (32 - z);
var y = bb... | [
"function",
"bboxToTile",
"(",
"bboxCoords",
")",
"{",
"var",
"min",
"=",
"pointToTile",
"(",
"bboxCoords",
"[",
"0",
"]",
",",
"bboxCoords",
"[",
"1",
"]",
",",
"32",
")",
";",
"var",
"max",
"=",
"pointToTile",
"(",
"bboxCoords",
"[",
"2",
"]",
",",... | Get the smallest tile to cover a bbox
@name bboxToTile
@param {Array<number>} bbox
@returns {Array<number>} tile
@example
var tile = bboxToTile([ -178, 84, -177, 85 ])
//=tile | [
"Get",
"the",
"smallest",
"tile",
"to",
"cover",
"a",
"bbox"
] | 7df684f198837d9ea0385a0b0b8f71c8d0f3acac | https://github.com/mapbox/tilebelt/blob/7df684f198837d9ea0385a0b0b8f71c8d0f3acac/index.js#L235-L245 | train |
mapbox/tilebelt | index.js | pointToTileFraction | function pointToTileFraction(lon, lat, z) {
var sin = Math.sin(lat * d2r),
z2 = Math.pow(2, z),
x = z2 * (lon / 360 + 0.5),
y = z2 * (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI);
// Wrap Tile X
x = x % z2
if (x < 0) x = x + z2
return [x, y, z];
} | javascript | function pointToTileFraction(lon, lat, z) {
var sin = Math.sin(lat * d2r),
z2 = Math.pow(2, z),
x = z2 * (lon / 360 + 0.5),
y = z2 * (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI);
// Wrap Tile X
x = x % z2
if (x < 0) x = x + z2
return [x, y, z];
} | [
"function",
"pointToTileFraction",
"(",
"lon",
",",
"lat",
",",
"z",
")",
"{",
"var",
"sin",
"=",
"Math",
".",
"sin",
"(",
"lat",
"*",
"d2r",
")",
",",
"z2",
"=",
"Math",
".",
"pow",
"(",
"2",
",",
"z",
")",
",",
"x",
"=",
"z2",
"*",
"(",
"... | Get the precise fractional tile location for a point at a zoom level
@name pointToTileFraction
@param {number} lon
@param {number} lat
@param {number} z
@returns {Array<number>} tile fraction
var tile = pointToTileFraction(30.5, 50.5, 15)
//=tile | [
"Get",
"the",
"precise",
"fractional",
"tile",
"location",
"for",
"a",
"point",
"at",
"a",
"zoom",
"level"
] | 7df684f198837d9ea0385a0b0b8f71c8d0f3acac | https://github.com/mapbox/tilebelt/blob/7df684f198837d9ea0385a0b0b8f71c8d0f3acac/index.js#L271-L281 | train |
caseycesari/GeoJSON.js | geojson.js | addOptionals | function addOptionals(geojson, settings){
if(settings.crs && checkCRS(settings.crs)) {
if(settings.isPostgres)
geojson.geometry.crs = settings.crs;
else
geojson.crs = settings.crs;
}
if (settings.bbox) {
geojson.bbox = settings.bbox;
}
if (settings.extraGlobal) {
... | javascript | function addOptionals(geojson, settings){
if(settings.crs && checkCRS(settings.crs)) {
if(settings.isPostgres)
geojson.geometry.crs = settings.crs;
else
geojson.crs = settings.crs;
}
if (settings.bbox) {
geojson.bbox = settings.bbox;
}
if (settings.extraGlobal) {
... | [
"function",
"addOptionals",
"(",
"geojson",
",",
"settings",
")",
"{",
"if",
"(",
"settings",
".",
"crs",
"&&",
"checkCRS",
"(",
"settings",
".",
"crs",
")",
")",
"{",
"if",
"(",
"settings",
".",
"isPostgres",
")",
"geojson",
".",
"geometry",
".",
"crs... | Adds the optional GeoJSON properties crs and bbox if they have been specified | [
"Adds",
"the",
"optional",
"GeoJSON",
"properties",
"crs",
"and",
"bbox",
"if",
"they",
"have",
"been",
"specified"
] | 92c8cc50548b3c34716c5b82ef96de64ff4ff482 | https://github.com/caseycesari/GeoJSON.js/blob/92c8cc50548b3c34716c5b82ef96de64ff4ff482/geojson.js#L85-L101 | train |
caseycesari/GeoJSON.js | geojson.js | checkCRS | function checkCRS(crs) {
if (crs.type === 'name') {
if (crs.properties && crs.properties.name) {
return true;
} else {
throw new Error('Invalid CRS. Properties must contain "name" key');
}
} else if (crs.type === 'link') {
if (crs.properties && crs.propert... | javascript | function checkCRS(crs) {
if (crs.type === 'name') {
if (crs.properties && crs.properties.name) {
return true;
} else {
throw new Error('Invalid CRS. Properties must contain "name" key');
}
} else if (crs.type === 'link') {
if (crs.properties && crs.propert... | [
"function",
"checkCRS",
"(",
"crs",
")",
"{",
"if",
"(",
"crs",
".",
"type",
"===",
"'name'",
")",
"{",
"if",
"(",
"crs",
".",
"properties",
"&&",
"crs",
".",
"properties",
".",
"name",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"throw",
... | Verify that the structure of CRS object is valid | [
"Verify",
"that",
"the",
"structure",
"of",
"CRS",
"object",
"is",
"valid"
] | 92c8cc50548b3c34716c5b82ef96de64ff4ff482 | https://github.com/caseycesari/GeoJSON.js/blob/92c8cc50548b3c34716c5b82ef96de64ff4ff482/geojson.js#L104-L120 | train |
caseycesari/GeoJSON.js | geojson.js | setGeom | function setGeom(params) {
params.geom = {};
for(var param in params) {
if(params.hasOwnProperty(param) && geoms.indexOf(param) !== -1){
params.geom[param] = params[param];
delete params[param];
}
}
setGeomAttrList(params.geom);
} | javascript | function setGeom(params) {
params.geom = {};
for(var param in params) {
if(params.hasOwnProperty(param) && geoms.indexOf(param) !== -1){
params.geom[param] = params[param];
delete params[param];
}
}
setGeomAttrList(params.geom);
} | [
"function",
"setGeom",
"(",
"params",
")",
"{",
"params",
".",
"geom",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"param",
"in",
"params",
")",
"{",
"if",
"(",
"params",
".",
"hasOwnProperty",
"(",
"param",
")",
"&&",
"geoms",
".",
"indexOf",
"(",
"par... | Moves the user-specified geometry parameters under the `geom` key in param for easier access | [
"Moves",
"the",
"user",
"-",
"specified",
"geometry",
"parameters",
"under",
"the",
"geom",
"key",
"in",
"param",
"for",
"easier",
"access"
] | 92c8cc50548b3c34716c5b82ef96de64ff4ff482 | https://github.com/caseycesari/GeoJSON.js/blob/92c8cc50548b3c34716c5b82ef96de64ff4ff482/geojson.js#L124-L135 | train |
caseycesari/GeoJSON.js | geojson.js | setGeomAttrList | function setGeomAttrList(params) {
for(var param in params) {
if(params.hasOwnProperty(param)) {
if(typeof params[param] === 'string') {
geomAttrs.push(params[param]);
} else if (typeof params[param] === 'object') { // Array of coordinates for Point
geomAttrs.push(params[pa... | javascript | function setGeomAttrList(params) {
for(var param in params) {
if(params.hasOwnProperty(param)) {
if(typeof params[param] === 'string') {
geomAttrs.push(params[param]);
} else if (typeof params[param] === 'object') { // Array of coordinates for Point
geomAttrs.push(params[pa... | [
"function",
"setGeomAttrList",
"(",
"params",
")",
"{",
"for",
"(",
"var",
"param",
"in",
"params",
")",
"{",
"if",
"(",
"params",
".",
"hasOwnProperty",
"(",
"param",
")",
")",
"{",
"if",
"(",
"typeof",
"params",
"[",
"param",
"]",
"===",
"'string'",
... | Adds fields which contain geometry data to geomAttrs. This list is used when adding properties to the features so that no geometry fields are added the properties key | [
"Adds",
"fields",
"which",
"contain",
"geometry",
"data",
"to",
"geomAttrs",
".",
"This",
"list",
"is",
"used",
"when",
"adding",
"properties",
"to",
"the",
"features",
"so",
"that",
"no",
"geometry",
"fields",
"are",
"added",
"the",
"properties",
"key"
] | 92c8cc50548b3c34716c5b82ef96de64ff4ff482 | https://github.com/caseycesari/GeoJSON.js/blob/92c8cc50548b3c34716c5b82ef96de64ff4ff482/geojson.js#L141-L154 | train |
caseycesari/GeoJSON.js | geojson.js | getFeature | function getFeature(args) {
var item = args.item,
params = args.params,
propFunc = args.propFunc;
var feature = { "type": "Feature" };
feature.geometry = buildGeom(item, params);
feature.properties = propFunc.call(item);
return feature;
} | javascript | function getFeature(args) {
var item = args.item,
params = args.params,
propFunc = args.propFunc;
var feature = { "type": "Feature" };
feature.geometry = buildGeom(item, params);
feature.properties = propFunc.call(item);
return feature;
} | [
"function",
"getFeature",
"(",
"args",
")",
"{",
"var",
"item",
"=",
"args",
".",
"item",
",",
"params",
"=",
"args",
".",
"params",
",",
"propFunc",
"=",
"args",
".",
"propFunc",
";",
"var",
"feature",
"=",
"{",
"\"type\"",
":",
"\"Feature\"",
"}",
... | Creates a feature object to be added to the GeoJSON features array | [
"Creates",
"a",
"feature",
"object",
"to",
"be",
"added",
"to",
"the",
"GeoJSON",
"features",
"array"
] | 92c8cc50548b3c34716c5b82ef96de64ff4ff482 | https://github.com/caseycesari/GeoJSON.js/blob/92c8cc50548b3c34716c5b82ef96de64ff4ff482/geojson.js#L158-L169 | train |
caseycesari/GeoJSON.js | geojson.js | getPropFunction | function getPropFunction(params) {
var func;
if(!params.exclude && !params.include) {
func = function(properties) {
for(var attr in this) {
if(this.hasOwnProperty(attr) && (geomAttrs.indexOf(attr) === -1)) {
properties[attr] = this[attr];
}
}
};
}... | javascript | function getPropFunction(params) {
var func;
if(!params.exclude && !params.include) {
func = function(properties) {
for(var attr in this) {
if(this.hasOwnProperty(attr) && (geomAttrs.indexOf(attr) === -1)) {
properties[attr] = this[attr];
}
}
};
}... | [
"function",
"getPropFunction",
"(",
"params",
")",
"{",
"var",
"func",
";",
"if",
"(",
"!",
"params",
".",
"exclude",
"&&",
"!",
"params",
".",
"include",
")",
"{",
"func",
"=",
"function",
"(",
"properties",
")",
"{",
"for",
"(",
"var",
"attr",
"in"... | Returns the function to be used to build the properties object for each feature | [
"Returns",
"the",
"function",
"to",
"be",
"used",
"to",
"build",
"the",
"properties",
"object",
"for",
"each",
"feature"
] | 92c8cc50548b3c34716c5b82ef96de64ff4ff482 | https://github.com/caseycesari/GeoJSON.js/blob/92c8cc50548b3c34716c5b82ef96de64ff4ff482/geojson.js#L278-L313 | train |
caseycesari/GeoJSON.js | geojson.js | addExtra | function addExtra(properties, extra) {
for(var key in extra){
if(extra.hasOwnProperty(key)) {
properties[key] = extra[key];
}
}
return properties;
} | javascript | function addExtra(properties, extra) {
for(var key in extra){
if(extra.hasOwnProperty(key)) {
properties[key] = extra[key];
}
}
return properties;
} | [
"function",
"addExtra",
"(",
"properties",
",",
"extra",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"extra",
")",
"{",
"if",
"(",
"extra",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"properties",
"[",
"key",
"]",
"=",
"extra",
"[",
"key",
"]"... | Adds data contained in the `extra` parameter if it has been specified | [
"Adds",
"data",
"contained",
"in",
"the",
"extra",
"parameter",
"if",
"it",
"has",
"been",
"specified"
] | 92c8cc50548b3c34716c5b82ef96de64ff4ff482 | https://github.com/caseycesari/GeoJSON.js/blob/92c8cc50548b3c34716c5b82ef96de64ff4ff482/geojson.js#L317-L325 | train |
jdxcode/npm-register | lib/packages.js | fetchAllDependents | async function fetchAllDependents (name) {
let pkg = await npm.getLatest(name)
let deps = Object.keys(pkg.dependencies || {})
if (!deps.length) return []
let promises = []
for (let dep of deps) {
promises.push(fetchAllDependents(dep))
}
for (let subdeps of await Promise.all(promises)) {
deps = dep... | javascript | async function fetchAllDependents (name) {
let pkg = await npm.getLatest(name)
let deps = Object.keys(pkg.dependencies || {})
if (!deps.length) return []
let promises = []
for (let dep of deps) {
promises.push(fetchAllDependents(dep))
}
for (let subdeps of await Promise.all(promises)) {
deps = dep... | [
"async",
"function",
"fetchAllDependents",
"(",
"name",
")",
"{",
"let",
"pkg",
"=",
"await",
"npm",
".",
"getLatest",
"(",
"name",
")",
"let",
"deps",
"=",
"Object",
".",
"keys",
"(",
"pkg",
".",
"dependencies",
"||",
"{",
"}",
")",
"if",
"(",
"!",
... | traverses finding all dependents of a package | [
"traverses",
"finding",
"all",
"dependents",
"of",
"a",
"package"
] | 43a5015af5f8b14110ce0faddb14504fc8bca20f | https://github.com/jdxcode/npm-register/blob/43a5015af5f8b14110ce0faddb14504fc8bca20f/lib/packages.js#L40-L52 | train |
infor-design/design-system | scripts/node/build-icons.js | createIconFiles | function createIconFiles(srcFile, dest) {
const thisTaskName = swlog.logSubStart('create icon files');
return new Promise(resolve => {
const exportArtboardsOptions = [
'export',
'artboards',
srcFile,
`--formats=${options.iconFormats.join(',')}`,
'--include-symbols=NO',
'--sa... | javascript | function createIconFiles(srcFile, dest) {
const thisTaskName = swlog.logSubStart('create icon files');
return new Promise(resolve => {
const exportArtboardsOptions = [
'export',
'artboards',
srcFile,
`--formats=${options.iconFormats.join(',')}`,
'--include-symbols=NO',
'--sa... | [
"function",
"createIconFiles",
"(",
"srcFile",
",",
"dest",
")",
"{",
"const",
"thisTaskName",
"=",
"swlog",
".",
"logSubStart",
"(",
"'create icon files'",
")",
";",
"return",
"new",
"Promise",
"(",
"resolve",
"=>",
"{",
"const",
"exportArtboardsOptions",
"=",
... | Create the svg files form sketch layers
@see {@link https://developer.sketchapp.com/reference/api/#export}
@param {String} srcFile - The sketch file
@param {String} dest - The destination
@returns {Promise} | [
"Create",
"the",
"svg",
"files",
"form",
"sketch",
"layers"
] | 94fb5321415bf2555808d4d56ba88b342fb6b3e4 | https://github.com/infor-design/design-system/blob/94fb5321415bf2555808d4d56ba88b342fb6b3e4/scripts/node/build-icons.js#L105-L135 | train |
infor-design/design-system | scripts/node/build-icons.js | sortByFileFormat | function sortByFileFormat(srcDir, format) {
const initialFiles = `${srcDir}/*.${format}`
const files = glob.sync(initialFiles);
const dest = `${srcDir}/${format}`;
let count = 0;
createDirs([dest]);
// Loop through and move each file
const promises = files.map(f => {
return new Promise((resolve, rej... | javascript | function sortByFileFormat(srcDir, format) {
const initialFiles = `${srcDir}/*.${format}`
const files = glob.sync(initialFiles);
const dest = `${srcDir}/${format}`;
let count = 0;
createDirs([dest]);
// Loop through and move each file
const promises = files.map(f => {
return new Promise((resolve, rej... | [
"function",
"sortByFileFormat",
"(",
"srcDir",
",",
"format",
")",
"{",
"const",
"initialFiles",
"=",
"`",
"${",
"srcDir",
"}",
"${",
"format",
"}",
"`",
"const",
"files",
"=",
"glob",
".",
"sync",
"(",
"initialFiles",
")",
";",
"const",
"dest",
"=",
"... | Move icon types into proper directory
@param {String} srcDir - Directory of files
@param {Array} formats - Array of file formats | [
"Move",
"icon",
"types",
"into",
"proper",
"directory"
] | 94fb5321415bf2555808d4d56ba88b342fb6b3e4 | https://github.com/infor-design/design-system/blob/94fb5321415bf2555808d4d56ba88b342fb6b3e4/scripts/node/build-icons.js#L150-L185 | train |
infor-design/design-system | scripts/node/build-icons.js | createPagesMetadata | function createPagesMetadata(src, dest) {
return new Promise((resolve, reject) => {
const thisTaskName = swlog.logSubStart('create metadata file');
const outputStr = sketchtoolExec(`metadata ${src}`)
const ignoredPages = ['Symbols', 'Icon Sheet', '------------']
let customObj = { categories: [] };
... | javascript | function createPagesMetadata(src, dest) {
return new Promise((resolve, reject) => {
const thisTaskName = swlog.logSubStart('create metadata file');
const outputStr = sketchtoolExec(`metadata ${src}`)
const ignoredPages = ['Symbols', 'Icon Sheet', '------------']
let customObj = { categories: [] };
... | [
"function",
"createPagesMetadata",
"(",
"src",
",",
"dest",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"thisTaskName",
"=",
"swlog",
".",
"logSubStart",
"(",
"'create metadata file'",
")",
";",
"const",... | Get the metadata from the sketch file to map
icons names to page names
@param {String} src - The source of the sketch file
@param {String} dest - The destination
@returns {Promise} | [
"Get",
"the",
"metadata",
"from",
"the",
"sketch",
"file",
"to",
"map",
"icons",
"names",
"to",
"page",
"names"
] | 94fb5321415bf2555808d4d56ba88b342fb6b3e4 | https://github.com/infor-design/design-system/blob/94fb5321415bf2555808d4d56ba88b342fb6b3e4/scripts/node/build-icons.js#L194-L228 | train |
infor-design/design-system | scripts/node/build-icons.js | createDirs | function createDirs(arrPaths) {
arrPaths.forEach(path => {
if (!fs.existsSync(path)) {
fs.mkdirSync(path);
}
});
} | javascript | function createDirs(arrPaths) {
arrPaths.forEach(path => {
if (!fs.existsSync(path)) {
fs.mkdirSync(path);
}
});
} | [
"function",
"createDirs",
"(",
"arrPaths",
")",
"{",
"arrPaths",
".",
"forEach",
"(",
"path",
"=>",
"{",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"path",
")",
")",
"{",
"fs",
".",
"mkdirSync",
"(",
"path",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create directories if they don't exist
@param {array} arrPaths - the directory path(s) | [
"Create",
"directories",
"if",
"they",
"don",
"t",
"exist"
] | 94fb5321415bf2555808d4d56ba88b342fb6b3e4 | https://github.com/infor-design/design-system/blob/94fb5321415bf2555808d4d56ba88b342fb6b3e4/scripts/node/build-icons.js#L234-L240 | train |
infor-design/design-system | scripts/node/build-icons.js | optimizeSVGs | function optimizeSVGs(src) {
const startOptimizeTaskName = swlog.logSubStart('optimize SVGs');
// Optimize with svgo:
const svgoOptimize = new svgo({
js2svg: { useShortTags: false },
plugins: [
{ removeViewBox: false },
{ convertColors: { currentColor: '#000000' }},
{ removeDimensions: ... | javascript | function optimizeSVGs(src) {
const startOptimizeTaskName = swlog.logSubStart('optimize SVGs');
// Optimize with svgo:
const svgoOptimize = new svgo({
js2svg: { useShortTags: false },
plugins: [
{ removeViewBox: false },
{ convertColors: { currentColor: '#000000' }},
{ removeDimensions: ... | [
"function",
"optimizeSVGs",
"(",
"src",
")",
"{",
"const",
"startOptimizeTaskName",
"=",
"swlog",
".",
"logSubStart",
"(",
"'optimize SVGs'",
")",
";",
"// Optimize with svgo:",
"const",
"svgoOptimize",
"=",
"new",
"svgo",
"(",
"{",
"js2svg",
":",
"{",
"useShort... | Optimize the generated .svg icon files
@param {String} src - The source directory for svgs | [
"Optimize",
"the",
"generated",
".",
"svg",
"icon",
"files"
] | 94fb5321415bf2555808d4d56ba88b342fb6b3e4 | https://github.com/infor-design/design-system/blob/94fb5321415bf2555808d4d56ba88b342fb6b3e4/scripts/node/build-icons.js#L246-L281 | train |
JedWatson/react-hammerjs | gulpfile.js | getBumpTask | function getBumpTask(type) {
return function () {
return gulp.src(['./package.json', './bower.json'])
.pipe(bump({ type: type }))
.pipe(gulp.dest('./'));
};
} | javascript | function getBumpTask(type) {
return function () {
return gulp.src(['./package.json', './bower.json'])
.pipe(bump({ type: type }))
.pipe(gulp.dest('./'));
};
} | [
"function",
"getBumpTask",
"(",
"type",
")",
"{",
"return",
"function",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
"[",
"'./package.json'",
",",
"'./bower.json'",
"]",
")",
".",
"pipe",
"(",
"bump",
"(",
"{",
"type",
":",
"type",
"}",
")",
")"... | Version bump tasks | [
"Version",
"bump",
"tasks"
] | 14500eb2583654fac843ee9bd40f48fd4a65e818 | https://github.com/JedWatson/react-hammerjs/blob/14500eb2583654fac843ee9bd40f48fd4a65e818/gulpfile.js#L86-L92 | train |
pat310/google-trends-api | src/request.js | rereq | function rereq(options, done) {
let req;
req = https.request(options, (res) => {
let chunk = '';
res.on('data', (data) => {
chunk += data;
});
res.on('end', () => {
done(null, chunk.toString('utf8'));
});
});
req.on('error', (e) => {
done(e);
});
req.end();
} | javascript | function rereq(options, done) {
let req;
req = https.request(options, (res) => {
let chunk = '';
res.on('data', (data) => {
chunk += data;
});
res.on('end', () => {
done(null, chunk.toString('utf8'));
});
});
req.on('error', (e) => {
done(e);
});
req.end();
} | [
"function",
"rereq",
"(",
"options",
",",
"done",
")",
"{",
"let",
"req",
";",
"req",
"=",
"https",
".",
"request",
"(",
"options",
",",
"(",
"res",
")",
"=>",
"{",
"let",
"chunk",
"=",
"''",
";",
"res",
".",
"on",
"(",
"'data'",
",",
"(",
"dat... | simpler request method for avoiding double-promise confusion | [
"simpler",
"request",
"method",
"for",
"avoiding",
"double",
"-",
"promise",
"confusion"
] | 4ccdd273257a91aca27590d3a20e7814ed7cefa2 | https://github.com/pat310/google-trends-api/blob/4ccdd273257a91aca27590d3a20e7814ed7cefa2/src/request.js#L9-L26 | train |
shouldjs/should.js | lib/assertion.js | LightAssertionError | function LightAssertionError(options) {
merge(this, options);
if (!options.message) {
Object.defineProperty(this, "message", {
get: function() {
if (!this._message) {
this._message = this.generateMessage();
this.generatedMessage = true;
}
return this._message;
... | javascript | function LightAssertionError(options) {
merge(this, options);
if (!options.message) {
Object.defineProperty(this, "message", {
get: function() {
if (!this._message) {
this._message = this.generateMessage();
this.generatedMessage = true;
}
return this._message;
... | [
"function",
"LightAssertionError",
"(",
"options",
")",
"{",
"merge",
"(",
"this",
",",
"options",
")",
";",
"if",
"(",
"!",
"options",
".",
"message",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"\"message\"",
",",
"{",
"get",
":",
"f... | a bit hacky way how to get error to do not have stack | [
"a",
"bit",
"hacky",
"way",
"how",
"to",
"get",
"error",
"to",
"do",
"not",
"have",
"stack"
] | 690405e879d2a46c3bac38fbfabe1dce3c7de44d | https://github.com/shouldjs/should.js/blob/690405e879d2a46c3bac38fbfabe1dce3c7de44d/lib/assertion.js#L12-L26 | train |
shouldjs/should.js | lib/assertion.js | function(expr) {
if (expr) {
return this;
}
var params = this.params;
if ("obj" in params && !("actual" in params)) {
params.actual = params.obj;
} else if (!("obj" in params) && !("actual" in params)) {
params.actual = this.obj;
}
params.stackStartFunction = params.stac... | javascript | function(expr) {
if (expr) {
return this;
}
var params = this.params;
if ("obj" in params && !("actual" in params)) {
params.actual = params.obj;
} else if (!("obj" in params) && !("actual" in params)) {
params.actual = this.obj;
}
params.stackStartFunction = params.stac... | [
"function",
"(",
"expr",
")",
"{",
"if",
"(",
"expr",
")",
"{",
"return",
"this",
";",
"}",
"var",
"params",
"=",
"this",
".",
"params",
";",
"if",
"(",
"\"obj\"",
"in",
"params",
"&&",
"!",
"(",
"\"actual\"",
"in",
"params",
")",
")",
"{",
"para... | Base method for assertions.
Before calling this method need to fill Assertion#params object. This method usually called from other assertion methods.
`Assertion#params` can contain such properties:
* `operator` - required string containing description of this assertion
* `obj` - optional replacement for this.obj, it i... | [
"Base",
"method",
"for",
"assertions",
"."
] | 690405e879d2a46c3bac38fbfabe1dce3c7de44d | https://github.com/shouldjs/should.js/blob/690405e879d2a46c3bac38fbfabe1dce3c7de44d/lib/assertion.js#L76-L99 | train | |
shouldjs/should.js | should.js | has | function has(obj, key) {
var type = getGlobalType(obj);
var func = defaultTypeAdaptorStorage.requireAdaptor(type, 'has');
return func(obj, key);
} | javascript | function has(obj, key) {
var type = getGlobalType(obj);
var func = defaultTypeAdaptorStorage.requireAdaptor(type, 'has');
return func(obj, key);
} | [
"function",
"has",
"(",
"obj",
",",
"key",
")",
"{",
"var",
"type",
"=",
"getGlobalType",
"(",
"obj",
")",
";",
"var",
"func",
"=",
"defaultTypeAdaptorStorage",
".",
"requireAdaptor",
"(",
"type",
",",
"'has'",
")",
";",
"return",
"func",
"(",
"obj",
"... | return boolean if obj has such 'key' | [
"return",
"boolean",
"if",
"obj",
"has",
"such",
"key"
] | 690405e879d2a46c3bac38fbfabe1dce3c7de44d | https://github.com/shouldjs/should.js/blob/690405e879d2a46c3bac38fbfabe1dce3c7de44d/should.js#L856-L860 | train |
shouldjs/should.js | should.js | get | function get(obj, key) {
var type = getGlobalType(obj);
var func = defaultTypeAdaptorStorage.requireAdaptor(type, 'get');
return func(obj, key);
} | javascript | function get(obj, key) {
var type = getGlobalType(obj);
var func = defaultTypeAdaptorStorage.requireAdaptor(type, 'get');
return func(obj, key);
} | [
"function",
"get",
"(",
"obj",
",",
"key",
")",
"{",
"var",
"type",
"=",
"getGlobalType",
"(",
"obj",
")",
";",
"var",
"func",
"=",
"defaultTypeAdaptorStorage",
".",
"requireAdaptor",
"(",
"type",
",",
"'get'",
")",
";",
"return",
"func",
"(",
"obj",
"... | return value for given key | [
"return",
"value",
"for",
"given",
"key"
] | 690405e879d2a46c3bac38fbfabe1dce3c7de44d | https://github.com/shouldjs/should.js/blob/690405e879d2a46c3bac38fbfabe1dce3c7de44d/should.js#L863-L867 | train |
reworkcss/css | lib/stringify/identity.js | Compiler | function Compiler(options) {
options = options || {};
Base.call(this, options);
this.indentation = options.indent;
} | javascript | function Compiler(options) {
options = options || {};
Base.call(this, options);
this.indentation = options.indent;
} | [
"function",
"Compiler",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"Base",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"indentation",
"=",
"options",
".",
"indent",
";",
"}"
] | Initialize a new `Compiler`. | [
"Initialize",
"a",
"new",
"Compiler",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/stringify/identity.js#L19-L23 | train |
reworkcss/css | lib/stringify/source-map-support.js | mixin | function mixin(compiler) {
compiler._comment = compiler.comment;
compiler.map = new SourceMap();
compiler.position = { line: 1, column: 1 };
compiler.files = {};
for (var k in exports) compiler[k] = exports[k];
} | javascript | function mixin(compiler) {
compiler._comment = compiler.comment;
compiler.map = new SourceMap();
compiler.position = { line: 1, column: 1 };
compiler.files = {};
for (var k in exports) compiler[k] = exports[k];
} | [
"function",
"mixin",
"(",
"compiler",
")",
"{",
"compiler",
".",
"_comment",
"=",
"compiler",
".",
"comment",
";",
"compiler",
".",
"map",
"=",
"new",
"SourceMap",
"(",
")",
";",
"compiler",
".",
"position",
"=",
"{",
"line",
":",
"1",
",",
"column",
... | Mixin source map support into `compiler`.
@param {Compiler} compiler
@api public | [
"Mixin",
"source",
"map",
"support",
"into",
"compiler",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/stringify/source-map-support.js#L26-L32 | train |
reworkcss/css | lib/parse/index.js | updatePosition | function updatePosition(str) {
var lines = str.match(/\n/g);
if (lines) lineno += lines.length;
var i = str.lastIndexOf('\n');
column = ~i ? str.length - i : column + str.length;
} | javascript | function updatePosition(str) {
var lines = str.match(/\n/g);
if (lines) lineno += lines.length;
var i = str.lastIndexOf('\n');
column = ~i ? str.length - i : column + str.length;
} | [
"function",
"updatePosition",
"(",
"str",
")",
"{",
"var",
"lines",
"=",
"str",
".",
"match",
"(",
"/",
"\\n",
"/",
"g",
")",
";",
"if",
"(",
"lines",
")",
"lineno",
"+=",
"lines",
".",
"length",
";",
"var",
"i",
"=",
"str",
".",
"lastIndexOf",
"... | Update lineno and column based on `str`. | [
"Update",
"lineno",
"and",
"column",
"based",
"on",
"str",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L19-L24 | train |
reworkcss/css | lib/parse/index.js | Position | function Position(start) {
this.start = start;
this.end = { line: lineno, column: column };
this.source = options.source;
} | javascript | function Position(start) {
this.start = start;
this.end = { line: lineno, column: column };
this.source = options.source;
} | [
"function",
"Position",
"(",
"start",
")",
"{",
"this",
".",
"start",
"=",
"start",
";",
"this",
".",
"end",
"=",
"{",
"line",
":",
"lineno",
",",
"column",
":",
"column",
"}",
";",
"this",
".",
"source",
"=",
"options",
".",
"source",
";",
"}"
] | Store position information for a node | [
"Store",
"position",
"information",
"for",
"a",
"node"
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L43-L47 | train |
reworkcss/css | lib/parse/index.js | stylesheet | function stylesheet() {
var rulesList = rules();
return {
type: 'stylesheet',
stylesheet: {
source: options.source,
rules: rulesList,
parsingErrors: errorsList
}
};
} | javascript | function stylesheet() {
var rulesList = rules();
return {
type: 'stylesheet',
stylesheet: {
source: options.source,
rules: rulesList,
parsingErrors: errorsList
}
};
} | [
"function",
"stylesheet",
"(",
")",
"{",
"var",
"rulesList",
"=",
"rules",
"(",
")",
";",
"return",
"{",
"type",
":",
"'stylesheet'",
",",
"stylesheet",
":",
"{",
"source",
":",
"options",
".",
"source",
",",
"rules",
":",
"rulesList",
",",
"parsingError... | Parse stylesheet. | [
"Parse",
"stylesheet",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L80-L91 | train |
reworkcss/css | lib/parse/index.js | rules | function rules() {
var node;
var rules = [];
whitespace();
comments(rules);
while (css.length && css.charAt(0) != '}' && (node = atrule() || rule())) {
if (node !== false) {
rules.push(node);
comments(rules);
}
}
return rules;
} | javascript | function rules() {
var node;
var rules = [];
whitespace();
comments(rules);
while (css.length && css.charAt(0) != '}' && (node = atrule() || rule())) {
if (node !== false) {
rules.push(node);
comments(rules);
}
}
return rules;
} | [
"function",
"rules",
"(",
")",
"{",
"var",
"node",
";",
"var",
"rules",
"=",
"[",
"]",
";",
"whitespace",
"(",
")",
";",
"comments",
"(",
"rules",
")",
";",
"while",
"(",
"css",
".",
"length",
"&&",
"css",
".",
"charAt",
"(",
"0",
")",
"!=",
"'... | Parse ruleset. | [
"Parse",
"ruleset",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L113-L125 | train |
reworkcss/css | lib/parse/index.js | match | function match(re) {
var m = re.exec(css);
if (!m) return;
var str = m[0];
updatePosition(str);
css = css.slice(str.length);
return m;
} | javascript | function match(re) {
var m = re.exec(css);
if (!m) return;
var str = m[0];
updatePosition(str);
css = css.slice(str.length);
return m;
} | [
"function",
"match",
"(",
"re",
")",
"{",
"var",
"m",
"=",
"re",
".",
"exec",
"(",
"css",
")",
";",
"if",
"(",
"!",
"m",
")",
"return",
";",
"var",
"str",
"=",
"m",
"[",
"0",
"]",
";",
"updatePosition",
"(",
"str",
")",
";",
"css",
"=",
"cs... | Match `re` and return captures. | [
"Match",
"re",
"and",
"return",
"captures",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L131-L138 | train |
reworkcss/css | lib/parse/index.js | comments | function comments(rules) {
var c;
rules = rules || [];
while (c = comment()) {
if (c !== false) {
rules.push(c);
}
}
return rules;
} | javascript | function comments(rules) {
var c;
rules = rules || [];
while (c = comment()) {
if (c !== false) {
rules.push(c);
}
}
return rules;
} | [
"function",
"comments",
"(",
"rules",
")",
"{",
"var",
"c",
";",
"rules",
"=",
"rules",
"||",
"[",
"]",
";",
"while",
"(",
"c",
"=",
"comment",
"(",
")",
")",
"{",
"if",
"(",
"c",
"!==",
"false",
")",
"{",
"rules",
".",
"push",
"(",
"c",
")",... | Parse comments; | [
"Parse",
"comments",
";"
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L152-L161 | train |
reworkcss/css | lib/parse/index.js | comment | function comment() {
var pos = position();
if ('/' != css.charAt(0) || '*' != css.charAt(1)) return;
var i = 2;
while ("" != css.charAt(i) && ('*' != css.charAt(i) || '/' != css.charAt(i + 1))) ++i;
i += 2;
if ("" === css.charAt(i-1)) {
return error('End of comment missing');
}
... | javascript | function comment() {
var pos = position();
if ('/' != css.charAt(0) || '*' != css.charAt(1)) return;
var i = 2;
while ("" != css.charAt(i) && ('*' != css.charAt(i) || '/' != css.charAt(i + 1))) ++i;
i += 2;
if ("" === css.charAt(i-1)) {
return error('End of comment missing');
}
... | [
"function",
"comment",
"(",
")",
"{",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"if",
"(",
"'/'",
"!=",
"css",
".",
"charAt",
"(",
"0",
")",
"||",
"'*'",
"!=",
"css",
".",
"charAt",
"(",
"1",
")",
")",
"return",
";",
"var",
"i",
"=",
"2",... | Parse comment. | [
"Parse",
"comment",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L167-L189 | train |
reworkcss/css | lib/parse/index.js | selector | function selector() {
var m = match(/^([^{]+)/);
if (!m) return;
/* @fix Remove all comments from selectors
* http://ostermiller.org/findcomment.html */
return trim(m[0])
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m... | javascript | function selector() {
var m = match(/^([^{]+)/);
if (!m) return;
/* @fix Remove all comments from selectors
* http://ostermiller.org/findcomment.html */
return trim(m[0])
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m... | [
"function",
"selector",
"(",
")",
"{",
"var",
"m",
"=",
"match",
"(",
"/",
"^([^{]+)",
"/",
")",
";",
"if",
"(",
"!",
"m",
")",
"return",
";",
"/* @fix Remove all comments from selectors\n * http://ostermiller.org/findcomment.html */",
"return",
"trim",
"(",
"... | Parse selector. | [
"Parse",
"selector",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L195-L209 | train |
reworkcss/css | lib/parse/index.js | declarations | function declarations() {
var decls = [];
if (!open()) return error("missing '{'");
comments(decls);
// declarations
var decl;
while (decl = declaration()) {
if (decl !== false) {
decls.push(decl);
comments(decls);
}
}
if (!close()) return error("missing '}... | javascript | function declarations() {
var decls = [];
if (!open()) return error("missing '{'");
comments(decls);
// declarations
var decl;
while (decl = declaration()) {
if (decl !== false) {
decls.push(decl);
comments(decls);
}
}
if (!close()) return error("missing '}... | [
"function",
"declarations",
"(",
")",
"{",
"var",
"decls",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"open",
"(",
")",
")",
"return",
"error",
"(",
"\"missing '{'\"",
")",
";",
"comments",
"(",
"decls",
")",
";",
"// declarations",
"var",
"decl",
";",
"whi... | Parse declarations. | [
"Parse",
"declarations",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L245-L262 | train |
reworkcss/css | lib/parse/index.js | keyframe | function keyframe() {
var m;
var vals = [];
var pos = position();
while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
vals.push(m[1]);
match(/^,\s*/);
}
if (!vals.length) return;
return pos({
type: 'keyframe',
values: vals,
declarations: declarations()... | javascript | function keyframe() {
var m;
var vals = [];
var pos = position();
while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
vals.push(m[1]);
match(/^,\s*/);
}
if (!vals.length) return;
return pos({
type: 'keyframe',
values: vals,
declarations: declarations()... | [
"function",
"keyframe",
"(",
")",
"{",
"var",
"m",
";",
"var",
"vals",
"=",
"[",
"]",
";",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"while",
"(",
"m",
"=",
"match",
"(",
"/",
"^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*",
"/",
")",
")",
"{",
"val... | Parse keyframe. | [
"Parse",
"keyframe",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L268-L285 | train |
reworkcss/css | lib/parse/index.js | atkeyframes | function atkeyframes() {
var pos = position();
var m = match(/^@([-\w]+)?keyframes\s*/);
if (!m) return;
var vendor = m[1];
// identifier
var m = match(/^([-\w]+)\s*/);
if (!m) return error("@keyframes missing name");
var name = m[1];
if (!open()) return error("@keyframes missing ... | javascript | function atkeyframes() {
var pos = position();
var m = match(/^@([-\w]+)?keyframes\s*/);
if (!m) return;
var vendor = m[1];
// identifier
var m = match(/^([-\w]+)\s*/);
if (!m) return error("@keyframes missing name");
var name = m[1];
if (!open()) return error("@keyframes missing ... | [
"function",
"atkeyframes",
"(",
")",
"{",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"var",
"m",
"=",
"match",
"(",
"/",
"^@([-\\w]+)?keyframes\\s*",
"/",
")",
";",
"if",
"(",
"!",
"m",
")",
"return",
";",
"var",
"vendor",
"=",
"m",
"[",
"1",
... | Parse keyframes. | [
"Parse",
"keyframes",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L291-L320 | train |
reworkcss/css | lib/parse/index.js | atsupports | function atsupports() {
var pos = position();
var m = match(/^@supports *([^{]+)/);
if (!m) return;
var supports = trim(m[1]);
if (!open()) return error("@supports missing '{'");
var style = comments().concat(rules());
if (!close()) return error("@supports missing '}'");
return pos(... | javascript | function atsupports() {
var pos = position();
var m = match(/^@supports *([^{]+)/);
if (!m) return;
var supports = trim(m[1]);
if (!open()) return error("@supports missing '{'");
var style = comments().concat(rules());
if (!close()) return error("@supports missing '}'");
return pos(... | [
"function",
"atsupports",
"(",
")",
"{",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"var",
"m",
"=",
"match",
"(",
"/",
"^@supports *([^{]+)",
"/",
")",
";",
"if",
"(",
"!",
"m",
")",
"return",
";",
"var",
"supports",
"=",
"trim",
"(",
"m",
"[... | Parse supports. | [
"Parse",
"supports",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L326-L344 | train |
reworkcss/css | lib/parse/index.js | atmedia | function atmedia() {
var pos = position();
var m = match(/^@media *([^{]+)/);
if (!m) return;
var media = trim(m[1]);
if (!open()) return error("@media missing '{'");
var style = comments().concat(rules());
if (!close()) return error("@media missing '}'");
return pos({
type: '... | javascript | function atmedia() {
var pos = position();
var m = match(/^@media *([^{]+)/);
if (!m) return;
var media = trim(m[1]);
if (!open()) return error("@media missing '{'");
var style = comments().concat(rules());
if (!close()) return error("@media missing '}'");
return pos({
type: '... | [
"function",
"atmedia",
"(",
")",
"{",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"var",
"m",
"=",
"match",
"(",
"/",
"^@media *([^{]+)",
"/",
")",
";",
"if",
"(",
"!",
"m",
")",
"return",
";",
"var",
"media",
"=",
"trim",
"(",
"m",
"[",
"1",... | Parse media. | [
"Parse",
"media",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L372-L390 | train |
reworkcss/css | lib/parse/index.js | atpage | function atpage() {
var pos = position();
var m = match(/^@page */);
if (!m) return;
var sel = selector() || [];
if (!open()) return error("@page missing '{'");
var decls = comments();
// declarations
var decl;
while (decl = declaration()) {
decls.push(decl);
decls = d... | javascript | function atpage() {
var pos = position();
var m = match(/^@page */);
if (!m) return;
var sel = selector() || [];
if (!open()) return error("@page missing '{'");
var decls = comments();
// declarations
var decl;
while (decl = declaration()) {
decls.push(decl);
decls = d... | [
"function",
"atpage",
"(",
")",
"{",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"var",
"m",
"=",
"match",
"(",
"/",
"^@page *",
"/",
")",
";",
"if",
"(",
"!",
"m",
")",
"return",
";",
"var",
"sel",
"=",
"selector",
"(",
")",
"||",
"[",
"]"... | Parse paged media. | [
"Parse",
"paged",
"media",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L413-L437 | train |
reworkcss/css | lib/parse/index.js | atdocument | function atdocument() {
var pos = position();
var m = match(/^@([-\w]+)?document *([^{]+)/);
if (!m) return;
var vendor = trim(m[1]);
var doc = trim(m[2]);
if (!open()) return error("@document missing '{'");
var style = comments().concat(rules());
if (!close()) return error("@documen... | javascript | function atdocument() {
var pos = position();
var m = match(/^@([-\w]+)?document *([^{]+)/);
if (!m) return;
var vendor = trim(m[1]);
var doc = trim(m[2]);
if (!open()) return error("@document missing '{'");
var style = comments().concat(rules());
if (!close()) return error("@documen... | [
"function",
"atdocument",
"(",
")",
"{",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"var",
"m",
"=",
"match",
"(",
"/",
"^@([-\\w]+)?document *([^{]+)",
"/",
")",
";",
"if",
"(",
"!",
"m",
")",
"return",
";",
"var",
"vendor",
"=",
"trim",
"(",
"... | Parse document. | [
"Parse",
"document",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L443-L463 | train |
reworkcss/css | lib/parse/index.js | rule | function rule() {
var pos = position();
var sel = selector();
if (!sel) return error('selector missing');
comments();
return pos({
type: 'rule',
selectors: sel,
declarations: declarations()
});
} | javascript | function rule() {
var pos = position();
var sel = selector();
if (!sel) return error('selector missing');
comments();
return pos({
type: 'rule',
selectors: sel,
declarations: declarations()
});
} | [
"function",
"rule",
"(",
")",
"{",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"var",
"sel",
"=",
"selector",
"(",
")",
";",
"if",
"(",
"!",
"sel",
")",
"return",
"error",
"(",
"'selector missing'",
")",
";",
"comments",
"(",
")",
";",
"return",
... | Parse rule. | [
"Parse",
"rule",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L551-L563 | train |
reworkcss/css | lib/parse/index.js | addParent | function addParent(obj, parent) {
var isNode = obj && typeof obj.type === 'string';
var childParent = isNode ? obj : parent;
for (var k in obj) {
var value = obj[k];
if (Array.isArray(value)) {
value.forEach(function(v) { addParent(v, childParent); });
} else if (value && typeof value === 'obje... | javascript | function addParent(obj, parent) {
var isNode = obj && typeof obj.type === 'string';
var childParent = isNode ? obj : parent;
for (var k in obj) {
var value = obj[k];
if (Array.isArray(value)) {
value.forEach(function(v) { addParent(v, childParent); });
} else if (value && typeof value === 'obje... | [
"function",
"addParent",
"(",
"obj",
",",
"parent",
")",
"{",
"var",
"isNode",
"=",
"obj",
"&&",
"typeof",
"obj",
".",
"type",
"===",
"'string'",
";",
"var",
"childParent",
"=",
"isNode",
"?",
"obj",
":",
"parent",
";",
"for",
"(",
"var",
"k",
"in",
... | Adds non-enumerable parent node reference to each node. | [
"Adds",
"non",
"-",
"enumerable",
"parent",
"node",
"reference",
"to",
"each",
"node",
"."
] | 64910e8474385e4fde8cfe5369a9b768f3e08ac5 | https://github.com/reworkcss/css/blob/64910e8474385e4fde8cfe5369a9b768f3e08ac5/lib/parse/index.js#L580-L603 | train |
Stanko/react-plx | source/Plx.js | getElementTop | function getElementTop(el) {
let top = 0;
let element = el;
do {
top += element.offsetTop || 0;
element = element.offsetParent;
} while (element);
return top;
} | javascript | function getElementTop(el) {
let top = 0;
let element = el;
do {
top += element.offsetTop || 0;
element = element.offsetParent;
} while (element);
return top;
} | [
"function",
"getElementTop",
"(",
"el",
")",
"{",
"let",
"top",
"=",
"0",
";",
"let",
"element",
"=",
"el",
";",
"do",
"{",
"top",
"+=",
"element",
".",
"offsetTop",
"||",
"0",
";",
"element",
"=",
"element",
".",
"offsetParent",
";",
"}",
"while",
... | Get element's top offset | [
"Get",
"element",
"s",
"top",
"offset"
] | 47a88bc8c02632e19681299413ee614c12a459f6 | https://github.com/Stanko/react-plx/blob/47a88bc8c02632e19681299413ee614c12a459f6/source/Plx.js#L175-L185 | train |
Stanko/react-plx | source/Plx.js | getUnit | function getUnit(property, unit) {
let propertyUnit = unit || DEFAULT_UNIT;
if (ANGLE_PROPERTIES.indexOf(property) >= 0) {
propertyUnit = unit || DEFAULT_ANGLE_UNIT;
}
return propertyUnit;
} | javascript | function getUnit(property, unit) {
let propertyUnit = unit || DEFAULT_UNIT;
if (ANGLE_PROPERTIES.indexOf(property) >= 0) {
propertyUnit = unit || DEFAULT_ANGLE_UNIT;
}
return propertyUnit;
} | [
"function",
"getUnit",
"(",
"property",
",",
"unit",
")",
"{",
"let",
"propertyUnit",
"=",
"unit",
"||",
"DEFAULT_UNIT",
";",
"if",
"(",
"ANGLE_PROPERTIES",
".",
"indexOf",
"(",
"property",
")",
">=",
"0",
")",
"{",
"propertyUnit",
"=",
"unit",
"||",
"DE... | Returns CSS unit | [
"Returns",
"CSS",
"unit"
] | 47a88bc8c02632e19681299413ee614c12a459f6 | https://github.com/Stanko/react-plx/blob/47a88bc8c02632e19681299413ee614c12a459f6/source/Plx.js#L188-L196 | train |
Stanko/react-plx | source/Plx.js | parallax | function parallax(scrollPosition, start, duration, startValue, endValue, easing) {
let min = startValue;
let max = endValue;
const invert = startValue > endValue;
// Safety check, if "startValue" is in the wrong format
if (typeof startValue !== 'number') {
console.warn(`Plx, ERROR: startValue is not a n... | javascript | function parallax(scrollPosition, start, duration, startValue, endValue, easing) {
let min = startValue;
let max = endValue;
const invert = startValue > endValue;
// Safety check, if "startValue" is in the wrong format
if (typeof startValue !== 'number') {
console.warn(`Plx, ERROR: startValue is not a n... | [
"function",
"parallax",
"(",
"scrollPosition",
",",
"start",
",",
"duration",
",",
"startValue",
",",
"endValue",
",",
"easing",
")",
"{",
"let",
"min",
"=",
"startValue",
";",
"let",
"max",
"=",
"endValue",
";",
"const",
"invert",
"=",
"startValue",
">",
... | Calculates the current value for parallaxing property | [
"Calculates",
"the",
"current",
"value",
"for",
"parallaxing",
"property"
] | 47a88bc8c02632e19681299413ee614c12a459f6 | https://github.com/Stanko/react-plx/blob/47a88bc8c02632e19681299413ee614c12a459f6/source/Plx.js#L320-L388 | train |
Stanko/react-plx | source/Plx.js | colorParallax | function colorParallax(scrollPosition, start, duration, startValue, endValue, easing) {
let startObject = null;
let endObject = null;
if (startValue[0].toLowerCase() === 'r') {
startObject = rgbToObject(startValue);
} else {
startObject = hexToObject(startValue);
}
if (endValue[0].toLowerCase() ==... | javascript | function colorParallax(scrollPosition, start, duration, startValue, endValue, easing) {
let startObject = null;
let endObject = null;
if (startValue[0].toLowerCase() === 'r') {
startObject = rgbToObject(startValue);
} else {
startObject = hexToObject(startValue);
}
if (endValue[0].toLowerCase() ==... | [
"function",
"colorParallax",
"(",
"scrollPosition",
",",
"start",
",",
"duration",
",",
"startValue",
",",
"endValue",
",",
"easing",
")",
"{",
"let",
"startObject",
"=",
"null",
";",
"let",
"endObject",
"=",
"null",
";",
"if",
"(",
"startValue",
"[",
"0",... | Calculates current value for color parallax | [
"Calculates",
"current",
"value",
"for",
"color",
"parallax"
] | 47a88bc8c02632e19681299413ee614c12a459f6 | https://github.com/Stanko/react-plx/blob/47a88bc8c02632e19681299413ee614c12a459f6/source/Plx.js#L391-L417 | train |
Stanko/react-plx | source/Plx.js | applyProperty | function applyProperty(scrollPosition, propertyData, startPosition, duration, style, easing) {
const {
startValue,
endValue,
property,
unit,
} = propertyData;
// If property is one of the color properties
// Use it's parallax method
const isColor = COLOR_PROPERTIES.indexOf(property) > -1;
c... | javascript | function applyProperty(scrollPosition, propertyData, startPosition, duration, style, easing) {
const {
startValue,
endValue,
property,
unit,
} = propertyData;
// If property is one of the color properties
// Use it's parallax method
const isColor = COLOR_PROPERTIES.indexOf(property) > -1;
c... | [
"function",
"applyProperty",
"(",
"scrollPosition",
",",
"propertyData",
",",
"startPosition",
",",
"duration",
",",
"style",
",",
"easing",
")",
"{",
"const",
"{",
"startValue",
",",
"endValue",
",",
"property",
",",
"unit",
",",
"}",
"=",
"propertyData",
"... | Applies property parallax to the style object | [
"Applies",
"property",
"parallax",
"to",
"the",
"style",
"object"
] | 47a88bc8c02632e19681299413ee614c12a459f6 | https://github.com/Stanko/react-plx/blob/47a88bc8c02632e19681299413ee614c12a459f6/source/Plx.js#L420-L469 | train |
Stanko/react-plx | source/Plx.js | getClasses | function getClasses(lastSegmentScrolledBy, isInSegment, parallaxData) {
let cssClasses = null;
if (lastSegmentScrolledBy === null) {
cssClasses = 'Plx--above';
} else if (lastSegmentScrolledBy === parallaxData.length - 1 && !isInSegment) {
cssClasses = 'Plx--below';
} else if (lastSegmentScrolledBy !==... | javascript | function getClasses(lastSegmentScrolledBy, isInSegment, parallaxData) {
let cssClasses = null;
if (lastSegmentScrolledBy === null) {
cssClasses = 'Plx--above';
} else if (lastSegmentScrolledBy === parallaxData.length - 1 && !isInSegment) {
cssClasses = 'Plx--below';
} else if (lastSegmentScrolledBy !==... | [
"function",
"getClasses",
"(",
"lastSegmentScrolledBy",
",",
"isInSegment",
",",
"parallaxData",
")",
"{",
"let",
"cssClasses",
"=",
"null",
";",
"if",
"(",
"lastSegmentScrolledBy",
"===",
"null",
")",
"{",
"cssClasses",
"=",
"'Plx--above'",
";",
"}",
"else",
... | Returns CSS classes based on animation state | [
"Returns",
"CSS",
"classes",
"based",
"on",
"animation",
"state"
] | 47a88bc8c02632e19681299413ee614c12a459f6 | https://github.com/Stanko/react-plx/blob/47a88bc8c02632e19681299413ee614c12a459f6/source/Plx.js#L472-L491 | train |
Stanko/react-plx | source/Plx.js | omit | function omit(object, keysToOmit) {
const result = {};
Object.keys(object).forEach(key => {
if (keysToOmit.indexOf(key) === -1) {
result[key] = object[key];
}
});
return result;
} | javascript | function omit(object, keysToOmit) {
const result = {};
Object.keys(object).forEach(key => {
if (keysToOmit.indexOf(key) === -1) {
result[key] = object[key];
}
});
return result;
} | [
"function",
"omit",
"(",
"object",
",",
"keysToOmit",
")",
"{",
"const",
"result",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"object",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"if",
"(",
"keysToOmit",
".",
"indexOf",
"(",
"key",
")",
"==="... | Omits "keysToOmit" from "object" | [
"Omits",
"keysToOmit",
"from",
"object"
] | 47a88bc8c02632e19681299413ee614c12a459f6 | https://github.com/Stanko/react-plx/blob/47a88bc8c02632e19681299413ee614c12a459f6/source/Plx.js#L500-L510 | train |
hokaccha/node-jwt-simple | lib/jwt.js | assignProperties | function assignProperties(dest, source) {
for (var attr in source) {
if (source.hasOwnProperty(attr)) {
dest[attr] = source[attr];
}
}
} | javascript | function assignProperties(dest, source) {
for (var attr in source) {
if (source.hasOwnProperty(attr)) {
dest[attr] = source[attr];
}
}
} | [
"function",
"assignProperties",
"(",
"dest",
",",
"source",
")",
"{",
"for",
"(",
"var",
"attr",
"in",
"source",
")",
"{",
"if",
"(",
"source",
".",
"hasOwnProperty",
"(",
"attr",
")",
")",
"{",
"dest",
"[",
"attr",
"]",
"=",
"source",
"[",
"attr",
... | private util functions | [
"private",
"util",
"functions"
] | c58bfe5e5bb049015fcd55be5fc1b2d5c652dbcd | https://github.com/hokaccha/node-jwt-simple/blob/c58bfe5e5bb049015fcd55be5fc1b2d5c652dbcd/lib/jwt.js#L156-L162 | train |
CartoDB/carto-vl | src/renderer/decoder/polygonDecoder.js | resizeBuffers | function resizeBuffers (additionalSize) {
const minimumNeededSize = index + additionalSize;
if (minimumNeededSize > geomBuffer.vertices.length) {
const newSize = 2 * minimumNeededSize;
geomBuffer.vertices = resizeBuffer(geomBuffer.vertices, newSize);
geomBuffer.normals = resizeBuffer(geo... | javascript | function resizeBuffers (additionalSize) {
const minimumNeededSize = index + additionalSize;
if (minimumNeededSize > geomBuffer.vertices.length) {
const newSize = 2 * minimumNeededSize;
geomBuffer.vertices = resizeBuffer(geomBuffer.vertices, newSize);
geomBuffer.normals = resizeBuffer(geo... | [
"function",
"resizeBuffers",
"(",
"additionalSize",
")",
"{",
"const",
"minimumNeededSize",
"=",
"index",
"+",
"additionalSize",
";",
"if",
"(",
"minimumNeededSize",
">",
"geomBuffer",
".",
"vertices",
".",
"length",
")",
"{",
"const",
"newSize",
"=",
"2",
"*"... | Resize buffers as needed if `additionalSize` floats overflow the current buffers | [
"Resize",
"buffers",
"as",
"needed",
"if",
"additionalSize",
"floats",
"overflow",
"the",
"current",
"buffers"
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/src/renderer/decoder/polygonDecoder.js#L79-L86 | train |
CartoDB/carto-vl | src/renderer/decoder/polygonDecoder.js | addVertex | function addVertex (array, vertexIndex) {
geomBuffer.vertices[index] = array[vertexIndex];
geomBuffer.normals[index++] = 0;
geomBuffer.vertices[index] = array[vertexIndex + 1];
geomBuffer.normals[index++] = 0;
} | javascript | function addVertex (array, vertexIndex) {
geomBuffer.vertices[index] = array[vertexIndex];
geomBuffer.normals[index++] = 0;
geomBuffer.vertices[index] = array[vertexIndex + 1];
geomBuffer.normals[index++] = 0;
} | [
"function",
"addVertex",
"(",
"array",
",",
"vertexIndex",
")",
"{",
"geomBuffer",
".",
"vertices",
"[",
"index",
"]",
"=",
"array",
"[",
"vertexIndex",
"]",
";",
"geomBuffer",
".",
"normals",
"[",
"index",
"++",
"]",
"=",
"0",
";",
"geomBuffer",
".",
... | Add vertex in triangles. | [
"Add",
"vertex",
"in",
"triangles",
"."
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/src/renderer/decoder/polygonDecoder.js#L89-L94 | train |
CartoDB/carto-vl | src/utils/time/periodISO.js | yearWeek | function yearWeek (y, yd) {
const dow = isoDow(y, 1, 1);
const start = dow > 4 ? 9 - dow : 2 - dow;
if ((Math.abs(yd - start) % 7) !== 0) {
// y yd is not the start of any week
return [];
}
if (yd < start) {
// The week starts before the first week of the year => go back one ... | javascript | function yearWeek (y, yd) {
const dow = isoDow(y, 1, 1);
const start = dow > 4 ? 9 - dow : 2 - dow;
if ((Math.abs(yd - start) % 7) !== 0) {
// y yd is not the start of any week
return [];
}
if (yd < start) {
// The week starts before the first week of the year => go back one ... | [
"function",
"yearWeek",
"(",
"y",
",",
"yd",
")",
"{",
"const",
"dow",
"=",
"isoDow",
"(",
"y",
",",
"1",
",",
"1",
")",
";",
"const",
"start",
"=",
"dow",
">",
"4",
"?",
"9",
"-",
"dow",
":",
"2",
"-",
"dow",
";",
"if",
"(",
"(",
"Math",
... | Return year and week number given year and day number | [
"Return",
"year",
"and",
"week",
"number",
"given",
"year",
"and",
"day",
"number"
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/src/utils/time/periodISO.js#L51-L68 | train |
CartoDB/carto-vl | src/renderer/viz/colorspaces.js | XYZToSRGB | function XYZToSRGB ({ x, y, z, a }) {
// Poynton, "Frequently Asked Questions About Color," page 10
// Wikipedia: http://en.wikipedia.org/wiki/SRGB
// Wikipedia: http://en.wikipedia.org/wiki/CIE_1931_color_space
// Convert XYZ to linear RGB
const r = clamp(3.2406 * x - 1.5372 * y - 0.4986 * z, 0, 1... | javascript | function XYZToSRGB ({ x, y, z, a }) {
// Poynton, "Frequently Asked Questions About Color," page 10
// Wikipedia: http://en.wikipedia.org/wiki/SRGB
// Wikipedia: http://en.wikipedia.org/wiki/CIE_1931_color_space
// Convert XYZ to linear RGB
const r = clamp(3.2406 * x - 1.5372 * y - 0.4986 * z, 0, 1... | [
"function",
"XYZToSRGB",
"(",
"{",
"x",
",",
"y",
",",
"z",
",",
"a",
"}",
")",
"{",
"// Poynton, \"Frequently Asked Questions About Color,\" page 10",
"// Wikipedia: http://en.wikipedia.org/wiki/SRGB",
"// Wikipedia: http://en.wikipedia.org/wiki/CIE_1931_color_space",
"// Convert ... | Convert CIE XYZ to sRGB with the D65 white point | [
"Convert",
"CIE",
"XYZ",
"to",
"sRGB",
"with",
"the",
"D65",
"white",
"point"
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/src/renderer/viz/colorspaces.js#L118-L129 | train |
CartoDB/carto-vl | src/setup/config-service.js | checkConfig | function checkConfig (config) {
if (config) {
if (!util.isObject(config)) {
throw new CartoValidationError('\'config\' property must be an object.', CartoValidationErrorTypes.INCORRECT_TYPE);
}
_checkServerURL(config.serverURL);
}
} | javascript | function checkConfig (config) {
if (config) {
if (!util.isObject(config)) {
throw new CartoValidationError('\'config\' property must be an object.', CartoValidationErrorTypes.INCORRECT_TYPE);
}
_checkServerURL(config.serverURL);
}
} | [
"function",
"checkConfig",
"(",
"config",
")",
"{",
"if",
"(",
"config",
")",
"{",
"if",
"(",
"!",
"util",
".",
"isObject",
"(",
"config",
")",
")",
"{",
"throw",
"new",
"CartoValidationError",
"(",
"'\\'config\\' property must be an object.'",
",",
"CartoVali... | Check a valid config parameter.
@param {Object} config | [
"Check",
"a",
"valid",
"config",
"parameter",
"."
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/src/setup/config-service.js#L40-L47 | train |
CartoDB/carto-vl | src/utils/geometry.js | normalize | function normalize (x, y) {
const s = Math.hypot(x, y);
return [x / s, y / s];
} | javascript | function normalize (x, y) {
const s = Math.hypot(x, y);
return [x / s, y / s];
} | [
"function",
"normalize",
"(",
"x",
",",
"y",
")",
"{",
"const",
"s",
"=",
"Math",
".",
"hypot",
"(",
"x",
",",
"y",
")",
";",
"return",
"[",
"x",
"/",
"s",
",",
"y",
"/",
"s",
"]",
";",
"}"
] | Return the vector scaled to length 1 | [
"Return",
"the",
"vector",
"scaled",
"to",
"length",
"1"
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/src/utils/geometry.js#L84-L87 | train |
CartoDB/carto-vl | examples/editor/index.js | generateSnippet | function generateSnippet (config) {
const apiKey = config.b || 'default_public';
const username = config.c;
const serverURL = config.d || 'https://{user}.carto.com';
const vizSpec = config.e || '';
const center = config.f || { lat: 0, lng: 0 };
const zoom = config.g || 10;
const basemap = BA... | javascript | function generateSnippet (config) {
const apiKey = config.b || 'default_public';
const username = config.c;
const serverURL = config.d || 'https://{user}.carto.com';
const vizSpec = config.e || '';
const center = config.f || { lat: 0, lng: 0 };
const zoom = config.g || 10;
const basemap = BA... | [
"function",
"generateSnippet",
"(",
"config",
")",
"{",
"const",
"apiKey",
"=",
"config",
".",
"b",
"||",
"'default_public'",
";",
"const",
"username",
"=",
"config",
".",
"c",
";",
"const",
"serverURL",
"=",
"config",
".",
"d",
"||",
"'https://{user}.carto.... | Generates an HTML template for the given map configuration | [
"Generates",
"an",
"HTML",
"template",
"for",
"the",
"given",
"map",
"configuration"
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/examples/editor/index.js#L390-L454 | train |
CartoDB/carto-vl | src/utils/time/parseISO.js | startOfIsoWeek | function startOfIsoWeek (y, w) {
const dow = isoDow(y, 1, 1);
const startDay = dow > 4 ? 9 - dow : 2 - dow;
const startDate = new Date(y, 0, startDay);
return addDays(startDate, (w - 1) * 7);
} | javascript | function startOfIsoWeek (y, w) {
const dow = isoDow(y, 1, 1);
const startDay = dow > 4 ? 9 - dow : 2 - dow;
const startDate = new Date(y, 0, startDay);
return addDays(startDate, (w - 1) * 7);
} | [
"function",
"startOfIsoWeek",
"(",
"y",
",",
"w",
")",
"{",
"const",
"dow",
"=",
"isoDow",
"(",
"y",
",",
"1",
",",
"1",
")",
";",
"const",
"startDay",
"=",
"dow",
">",
"4",
"?",
"9",
"-",
"dow",
":",
"2",
"-",
"dow",
";",
"const",
"startDate",... | compute start date of yWw | [
"compute",
"start",
"date",
"of",
"yWw"
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/src/utils/time/parseISO.js#L160-L165 | train |
CartoDB/carto-vl | src/client/rsys.js | wRectangleTiles | function wRectangleTiles (z, wr) {
const [wMinx, wMiny, wMaxx, wMaxy] = wr;
const n = (1 << z); // for 0 <= z <= 30 equals Math.pow(2, z)
const clamp = x => Math.min(Math.max(x, 0), n - 1);
// compute tile coordinate ranges
const tMinx = clamp(Math.floor(n * (wMinx + 1) * 0.5));
const tMaxx = c... | javascript | function wRectangleTiles (z, wr) {
const [wMinx, wMiny, wMaxx, wMaxy] = wr;
const n = (1 << z); // for 0 <= z <= 30 equals Math.pow(2, z)
const clamp = x => Math.min(Math.max(x, 0), n - 1);
// compute tile coordinate ranges
const tMinx = clamp(Math.floor(n * (wMinx + 1) * 0.5));
const tMaxx = c... | [
"function",
"wRectangleTiles",
"(",
"z",
",",
"wr",
")",
"{",
"const",
"[",
"wMinx",
",",
"wMiny",
",",
"wMaxx",
",",
"wMaxy",
"]",
"=",
"wr",
";",
"const",
"n",
"=",
"(",
"1",
"<<",
"z",
")",
";",
"// for 0 <= z <= 30 equals Math.pow(2, z)",
"const",
... | TC tiles of a given zoom level that intersect a W rectangle
@param {number} z
@param {Array} - rectangle extents [minx, miny, maxx, maxy]
@return {Array} - array of TC tiles {x, y, z} | [
"TC",
"tiles",
"of",
"a",
"given",
"zoom",
"level",
"that",
"intersect",
"a",
"W",
"rectangle"
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/src/client/rsys.js#L95-L112 | train |
CartoDB/carto-vl | src/renderer/viz/expressions/aggregation/viewport/ViewportAggCalculator.js | _reset | function _reset (viewportExpressions, renderLayer) {
const metadata = renderLayer.viz.metadata;
viewportExpressions.forEach(expr => expr._resetViewportAgg(metadata, renderLayer));
} | javascript | function _reset (viewportExpressions, renderLayer) {
const metadata = renderLayer.viz.metadata;
viewportExpressions.forEach(expr => expr._resetViewportAgg(metadata, renderLayer));
} | [
"function",
"_reset",
"(",
"viewportExpressions",
",",
"renderLayer",
")",
"{",
"const",
"metadata",
"=",
"renderLayer",
".",
"viz",
".",
"metadata",
";",
"viewportExpressions",
".",
"forEach",
"(",
"expr",
"=>",
"expr",
".",
"_resetViewportAgg",
"(",
"metadata"... | Reset previous viewport aggregation function values.
It assumes that all dataframes of the renderLayer share the same metadata | [
"Reset",
"previous",
"viewport",
"aggregation",
"function",
"values",
".",
"It",
"assumes",
"that",
"all",
"dataframes",
"of",
"the",
"renderLayer",
"share",
"the",
"same",
"metadata"
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/src/renderer/viz/expressions/aggregation/viewport/ViewportAggCalculator.js#L43-L46 | train |
CartoDB/carto-vl | src/renderer/viz/expressions/aggregation/viewport/ViewportAggCalculator.js | _runInActiveDataframes | function _runInActiveDataframes (viewportExpressions, renderLayer) {
const dataframes = renderLayer.getActiveDataframes();
const inViewportFeaturesIDs = _runInDataframes(viewportExpressions, renderLayer, dataframes);
_runImprovedForPartialFeatures(viewportExpressions, renderLayer, inViewportFeaturesIDs);
} | javascript | function _runInActiveDataframes (viewportExpressions, renderLayer) {
const dataframes = renderLayer.getActiveDataframes();
const inViewportFeaturesIDs = _runInDataframes(viewportExpressions, renderLayer, dataframes);
_runImprovedForPartialFeatures(viewportExpressions, renderLayer, inViewportFeaturesIDs);
} | [
"function",
"_runInActiveDataframes",
"(",
"viewportExpressions",
",",
"renderLayer",
")",
"{",
"const",
"dataframes",
"=",
"renderLayer",
".",
"getActiveDataframes",
"(",
")",
";",
"const",
"inViewportFeaturesIDs",
"=",
"_runInDataframes",
"(",
"viewportExpressions",
"... | Run all viewport aggregations in the active dataframes | [
"Run",
"all",
"viewport",
"aggregations",
"in",
"the",
"active",
"dataframes"
] | 2cc704a0f3fda0943b3d3f84dac9466defb18f2c | https://github.com/CartoDB/carto-vl/blob/2cc704a0f3fda0943b3d3f84dac9466defb18f2c/src/renderer/viz/expressions/aggregation/viewport/ViewportAggCalculator.js#L51-L56 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.