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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Multicolour/multicolour | lib/utils.js | remove_null_undefined | function remove_null_undefined(object) {
Object.keys(object).forEach(key => {
if (object[key] === null || typeof object[key] === "undefined") {
delete object[key]
}
})
return object
} | javascript | function remove_null_undefined(object) {
Object.keys(object).forEach(key => {
if (object[key] === null || typeof object[key] === "undefined") {
delete object[key]
}
})
return object
} | [
"function",
"remove_null_undefined",
"(",
"object",
")",
"{",
"Object",
".",
"keys",
"(",
"object",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"if",
"(",
"object",
"[",
"key",
"]",
"===",
"null",
"||",
"typeof",
"object",
"[",
"key",
"]",
"===",
"\"... | Remove any null or undefined values from
an object and return it.
@param {Object} object to remove empties from.
@return {Object} object without empties. | [
"Remove",
"any",
"null",
"or",
"undefined",
"values",
"from",
"an",
"object",
"and",
"return",
"it",
"."
] | fd4fb3454a928ab9829617be49ff341367252272 | https://github.com/Multicolour/multicolour/blob/fd4fb3454a928ab9829617be49ff341367252272/lib/utils.js#L48-L56 | train |
Multicolour/multicolour | lib/utils.js | get_related_columns | function get_related_columns(collection) {
return Object.keys(collection.attributes)
.filter(attribute => collection.attributes[attribute].collection || collection.attributes[attribute].model)
} | javascript | function get_related_columns(collection) {
return Object.keys(collection.attributes)
.filter(attribute => collection.attributes[attribute].collection || collection.attributes[attribute].model)
} | [
"function",
"get_related_columns",
"(",
"collection",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"collection",
".",
"attributes",
")",
".",
"filter",
"(",
"attribute",
"=>",
"collection",
".",
"attributes",
"[",
"attribute",
"]",
".",
"collection",
"||",
... | Get related column names from a collection.
Does not include foreign key declarations.
@param {Waterline.Collection} collection to get related attributes of.
@return {Array<string>} array of related attribute names. | [
"Get",
"related",
"column",
"names",
"from",
"a",
"collection",
".",
"Does",
"not",
"include",
"foreign",
"key",
"declarations",
"."
] | fd4fb3454a928ab9829617be49ff341367252272 | https://github.com/Multicolour/multicolour/blob/fd4fb3454a928ab9829617be49ff341367252272/lib/utils.js#L65-L68 | train |
Multicolour/multicolour | lib/utils.js | compile_constraints | function compile_constraints(request, constraints) {
const Constraints = require("./constraints")
// Exit if there aren't any constraints.
if (!constraints)
return {}
return new Constraints()
.set_source(request)
.set_rules(constraints)
.compile()
.results
} | javascript | function compile_constraints(request, constraints) {
const Constraints = require("./constraints")
// Exit if there aren't any constraints.
if (!constraints)
return {}
return new Constraints()
.set_source(request)
.set_rules(constraints)
.compile()
.results
} | [
"function",
"compile_constraints",
"(",
"request",
",",
"constraints",
")",
"{",
"const",
"Constraints",
"=",
"require",
"(",
"\"./constraints\"",
")",
"// Exit if there aren't any constraints.",
"if",
"(",
"!",
"constraints",
")",
"return",
"{",
"}",
"return",
"new... | Compile any constraints and return an object.
@param {Hapi.Request} request to the server.
@param {Waterline.Collection} collection to get constraints from.
@return {Object} compiled constraints. | [
"Compile",
"any",
"constraints",
"and",
"return",
"an",
"object",
"."
] | fd4fb3454a928ab9829617be49ff341367252272 | https://github.com/Multicolour/multicolour/blob/fd4fb3454a928ab9829617be49ff341367252272/lib/utils.js#L94-L106 | train |
Multicolour/multicolour | lib/cli/plugins/init.js | replace_env_values | function replace_env_values(val_in) {
if (!val_in)
return ""
let val_out = val_in
const matches = val_in.match(/\$\w+/g)
if (matches)
matches.forEach(env => {
const value = process.env[env.substring(1, env.length)]
val_out = value.replace(new RegExp(`${env}`, "g"), value) // eslint-disa... | javascript | function replace_env_values(val_in) {
if (!val_in)
return ""
let val_out = val_in
const matches = val_in.match(/\$\w+/g)
if (matches)
matches.forEach(env => {
const value = process.env[env.substring(1, env.length)]
val_out = value.replace(new RegExp(`${env}`, "g"), value) // eslint-disa... | [
"function",
"replace_env_values",
"(",
"val_in",
")",
"{",
"if",
"(",
"!",
"val_in",
")",
"return",
"\"\"",
"let",
"val_out",
"=",
"val_in",
"const",
"matches",
"=",
"val_in",
".",
"match",
"(",
"/",
"\\$\\w+",
"/",
"g",
")",
"if",
"(",
"matches",
")",... | Replace any environmentals that appear in the
string.
@param {string} val_in to do replace on.
@return {string} String with replacements done. | [
"Replace",
"any",
"environmentals",
"that",
"appear",
"in",
"the",
"string",
"."
] | fd4fb3454a928ab9829617be49ff341367252272 | https://github.com/Multicolour/multicolour/blob/fd4fb3454a928ab9829617be49ff341367252272/lib/cli/plugins/init.js#L28-L43 | train |
Multicolour/multicolour | lib/handlers/get.js | getJunctionTableFromModelAndRelatedColumn | function getJunctionTableFromModelAndRelatedColumn(model, parentTableName, relatedColumnTableName) {
const junctionTableName = Object.keys(model.waterline.schema)
.find(schemaName => {
const tables = model.waterline.schema[schemaName].tables
if (!tables) return false
return tables[0] === paren... | javascript | function getJunctionTableFromModelAndRelatedColumn(model, parentTableName, relatedColumnTableName) {
const junctionTableName = Object.keys(model.waterline.schema)
.find(schemaName => {
const tables = model.waterline.schema[schemaName].tables
if (!tables) return false
return tables[0] === paren... | [
"function",
"getJunctionTableFromModelAndRelatedColumn",
"(",
"model",
",",
"parentTableName",
",",
"relatedColumnTableName",
")",
"{",
"const",
"junctionTableName",
"=",
"Object",
".",
"keys",
"(",
"model",
".",
"waterline",
".",
"schema",
")",
".",
"find",
"(",
... | Get the junction table waterline generates for
many-to-many related tables.
@param { Waterline.Collection } model to get schemas from
@param { string } parentTableName to check relationships
@param { string } relatedColumnTableName to check relationships
@return { Waterline.Collection | false } The junction table or u... | [
"Get",
"the",
"junction",
"table",
"waterline",
"generates",
"for",
"many",
"-",
"to",
"-",
"many",
"related",
"tables",
"."
] | fd4fb3454a928ab9829617be49ff341367252272 | https://github.com/Multicolour/multicolour/blob/fd4fb3454a928ab9829617be49ff341367252272/lib/handlers/get.js#L61-L82 | train |
Multicolour/multicolour | lib/user-model.js | hash_password | function hash_password(values, next) {
// If no password was provided, just move on and exit.
if (!values.password || values.password.length > 1000) {
return next()
}
this
.findOne(values)
.then(user => {
// Create a salt for this user if they don't have one.
const salt = user && user.s... | javascript | function hash_password(values, next) {
// If no password was provided, just move on and exit.
if (!values.password || values.password.length > 1000) {
return next()
}
this
.findOne(values)
.then(user => {
// Create a salt for this user if they don't have one.
const salt = user && user.s... | [
"function",
"hash_password",
"(",
"values",
",",
"next",
")",
"{",
"// If no password was provided, just move on and exit.",
"if",
"(",
"!",
"values",
".",
"password",
"||",
"values",
".",
"password",
".",
"length",
">",
"1000",
")",
"{",
"return",
"next",
"(",
... | Hash a plain text password using PBKDF2 and SHA256.
@param {Object} values to be written to the database.
@param {Function} next callback, used to finish the operation.
@return {void} | [
"Hash",
"a",
"plain",
"text",
"password",
"using",
"PBKDF2",
"and",
"SHA256",
"."
] | fd4fb3454a928ab9829617be49ff341367252272 | https://github.com/Multicolour/multicolour/blob/fd4fb3454a928ab9829617be49ff341367252272/lib/user-model.js#L12-L37 | train |
Multicolour/multicolour | lib/user-model.js | toJSON | function toJSON() {
const model = this.toObject()
delete model.password
delete model.salt
// Return the modified user object.
return utils.remove_null_undefined(model)
} | javascript | function toJSON() {
const model = this.toObject()
delete model.password
delete model.salt
// Return the modified user object.
return utils.remove_null_undefined(model)
} | [
"function",
"toJSON",
"(",
")",
"{",
"const",
"model",
"=",
"this",
".",
"toObject",
"(",
")",
"delete",
"model",
".",
"password",
"delete",
"model",
".",
"salt",
"// Return the modified user object.",
"return",
"utils",
".",
"remove_null_undefined",
"(",
"model... | When returning a user from the database,
we don't want the password to be exposed.
@return {Object} modified user object. | [
"When",
"returning",
"a",
"user",
"from",
"the",
"database",
"we",
"don",
"t",
"want",
"the",
"password",
"to",
"be",
"exposed",
"."
] | fd4fb3454a928ab9829617be49ff341367252272 | https://github.com/Multicolour/multicolour/blob/fd4fb3454a928ab9829617be49ff341367252272/lib/user-model.js#L87-L94 | train |
Multicolour/multicolour | lib/cli/init/content/blueprints/person.js | custom_routes | function custom_routes(hapi_server, multicolour) {
// Joi is an amazing validation library,
// read me at https://github.com/hapijs/joi/blob/v10.2.2/API.md
const Joi = require("joi")
// Set up a simple route that counts examples.
hapi_server.route({
method: "GET",
path: "/example/count"... | javascript | function custom_routes(hapi_server, multicolour) {
// Joi is an amazing validation library,
// read me at https://github.com/hapijs/joi/blob/v10.2.2/API.md
const Joi = require("joi")
// Set up a simple route that counts examples.
hapi_server.route({
method: "GET",
path: "/example/count"... | [
"function",
"custom_routes",
"(",
"hapi_server",
",",
"multicolour",
")",
"{",
"// Joi is an amazing validation library,",
"// read me at https://github.com/hapijs/joi/blob/v10.2.2/API.md",
"const",
"Joi",
"=",
"require",
"(",
"\"joi\"",
")",
"// Set up a simple route that counts e... | We can add any custom routes we like by defining them
in the custom_routes function.
There's no magic, no trade offs you simply write the code
you would normally write here.
Multicolour will not modify, read or actually do anything
to your custom code, it's yours and yours only.
@param {Hapi} hapi_server running yo... | [
"We",
"can",
"add",
"any",
"custom",
"routes",
"we",
"like",
"by",
"defining",
"them",
"in",
"the",
"custom_routes",
"function",
"."
] | fd4fb3454a928ab9829617be49ff341367252272 | https://github.com/Multicolour/multicolour/blob/fd4fb3454a928ab9829617be49ff341367252272/lib/cli/init/content/blueprints/person.js#L133-L182 | train |
bitcoinjs/coinselect | stats/strategies.js | random | function random (utxos, outputs, feeRate) {
utxos = shuffle(utxos)
return accumulative(utxos, outputs, feeRate)
} | javascript | function random (utxos, outputs, feeRate) {
utxos = shuffle(utxos)
return accumulative(utxos, outputs, feeRate)
} | [
"function",
"random",
"(",
"utxos",
",",
"outputs",
",",
"feeRate",
")",
"{",
"utxos",
"=",
"shuffle",
"(",
"utxos",
")",
"return",
"accumulative",
"(",
"utxos",
",",
"outputs",
",",
"feeRate",
")",
"}"
] | similar to bitcoind | [
"similar",
"to",
"bitcoind"
] | 288f24d221e5f1e5beac883043cc706914b2b2bd | https://github.com/bitcoinjs/coinselect/blob/288f24d221e5f1e5beac883043cc706914b2b2bd/stats/strategies.js#L75-L79 | train |
derrickpelletier/geohash-poly | index.js | function (point, geopoly) {
var inside = 0;
if(geopoly.type !== "Polygon" && geopoly.type !== "MultiPolygon") return false;
var shape = geopoly.type === 'Polygon' ? [geopoly.coordinates] : geopoly.coordinates;
shape.forEach(function (polygon) {
polygon.forEach(function (ring) {
if(pip([point.longitu... | javascript | function (point, geopoly) {
var inside = 0;
if(geopoly.type !== "Polygon" && geopoly.type !== "MultiPolygon") return false;
var shape = geopoly.type === 'Polygon' ? [geopoly.coordinates] : geopoly.coordinates;
shape.forEach(function (polygon) {
polygon.forEach(function (ring) {
if(pip([point.longitu... | [
"function",
"(",
"point",
",",
"geopoly",
")",
"{",
"var",
"inside",
"=",
"0",
";",
"if",
"(",
"geopoly",
".",
"type",
"!==",
"\"Polygon\"",
"&&",
"geopoly",
".",
"type",
"!==",
"\"MultiPolygon\"",
")",
"return",
"false",
";",
"var",
"shape",
"=",
"geo... | utilizing point-in-poly but providing support for geojson polys and holes. | [
"utilizing",
"point",
"-",
"in",
"-",
"poly",
"but",
"providing",
"support",
"for",
"geojson",
"polys",
"and",
"holes",
"."
] | 0965a3b1035186895a3b5fa8121a1624dfb792d3 | https://github.com/derrickpelletier/geohash-poly/blob/0965a3b1035186895a3b5fa8121a1624dfb792d3/index.js#L21-L33 | train | |
nirvanatikku/jQuery-TubePlayer-Plugin | dist/jquery.tubeplayer.js | function(fn) {
return function(evt, param) {
var p = TP.getPkg(evt);
if (p.ytplayer) {
var ret = fn(evt, param, p);
if (typeof(ret) === "undefined") {
ret = p.$player;
}
return ret;
}
... | javascript | function(fn) {
return function(evt, param) {
var p = TP.getPkg(evt);
if (p.ytplayer) {
var ret = fn(evt, param, p);
if (typeof(ret) === "undefined") {
ret = p.$player;
}
return ret;
}
... | [
"function",
"(",
"fn",
")",
"{",
"return",
"function",
"(",
"evt",
",",
"param",
")",
"{",
"var",
"p",
"=",
"TP",
".",
"getPkg",
"(",
"evt",
")",
";",
"if",
"(",
"p",
".",
"ytplayer",
")",
"{",
"var",
"ret",
"=",
"fn",
"(",
"evt",
",",
"param... | This method is the base method for all the events
that are bound to the TubePlayer. | [
"This",
"method",
"is",
"the",
"base",
"method",
"for",
"all",
"the",
"events",
"that",
"are",
"bound",
"to",
"the",
"TubePlayer",
"."
] | d03aef44a7b157776e218338705ba12e65831f00 | https://github.com/nirvanatikku/jQuery-TubePlayer-Plugin/blob/d03aef44a7b157776e218338705ba12e65831f00/dist/jquery.tubeplayer.js#L246-L258 | train | |
screener-io/screener-storybook | src/runner.js | function(storybook, baseUrl, previewRoute) {
// clean baseUrl. remove query/hash/trailing-slash
var urlObj = url.parse(baseUrl);
urlObj = omit(urlObj, 'hash', 'search', 'query');
urlObj.pathname = urlObj.pathname.replace(/\/$/, '');
baseUrl = url.format(urlObj);
// transform into states
var states = [];
... | javascript | function(storybook, baseUrl, previewRoute) {
// clean baseUrl. remove query/hash/trailing-slash
var urlObj = url.parse(baseUrl);
urlObj = omit(urlObj, 'hash', 'search', 'query');
urlObj.pathname = urlObj.pathname.replace(/\/$/, '');
baseUrl = url.format(urlObj);
// transform into states
var states = [];
... | [
"function",
"(",
"storybook",
",",
"baseUrl",
",",
"previewRoute",
")",
"{",
"// clean baseUrl. remove query/hash/trailing-slash",
"var",
"urlObj",
"=",
"url",
".",
"parse",
"(",
"baseUrl",
")",
";",
"urlObj",
"=",
"omit",
"(",
"urlObj",
",",
"'hash'",
",",
"'... | transform storybook object into screener states | [
"transform",
"storybook",
"object",
"into",
"screener",
"states"
] | 48854c1814f49ffcd3954864bc2505b665626843 | https://github.com/screener-io/screener-storybook/blob/48854c1814f49ffcd3954864bc2505b665626843/src/runner.js#L9-L31 | train | |
screener-io/screener-storybook | src/scripts/story-steps.js | function(current) {
if (current && current.props) {
if (current.props.isScreenerComponent === true) {
return current.props.steps;
} else {
var steps = null;
if (typeof current.props.st... | javascript | function(current) {
if (current && current.props) {
if (current.props.isScreenerComponent === true) {
return current.props.steps;
} else {
var steps = null;
if (typeof current.props.st... | [
"function",
"(",
"current",
")",
"{",
"if",
"(",
"current",
"&&",
"current",
".",
"props",
")",
"{",
"if",
"(",
"current",
".",
"props",
".",
"isScreenerComponent",
"===",
"true",
")",
"{",
"return",
"current",
".",
"props",
".",
"steps",
";",
"}",
"... | recursively find screener steps | [
"recursively",
"find",
"screener",
"steps"
] | 48854c1814f49ffcd3954864bc2505b665626843 | https://github.com/screener-io/screener-storybook/blob/48854c1814f49ffcd3954864bc2505b665626843/src/scripts/story-steps.js#L40-L75 | train | |
screener-io/screener-storybook | src/scripts/story-steps.js | function(current) {
if (typeof current.steps === 'object' && typeof current.steps.map === 'function' && current.steps.length > 0) {
return current.steps;
}
var steps = null;
if (typeof current.render === 'function') {
... | javascript | function(current) {
if (typeof current.steps === 'object' && typeof current.steps.map === 'function' && current.steps.length > 0) {
return current.steps;
}
var steps = null;
if (typeof current.render === 'function') {
... | [
"function",
"(",
"current",
")",
"{",
"if",
"(",
"typeof",
"current",
".",
"steps",
"===",
"'object'",
"&&",
"typeof",
"current",
".",
"steps",
".",
"map",
"===",
"'function'",
"&&",
"current",
".",
"steps",
".",
"length",
">",
"0",
")",
"{",
"return",... | recursively find screener steps in render function | [
"recursively",
"find",
"screener",
"steps",
"in",
"render",
"function"
] | 48854c1814f49ffcd3954864bc2505b665626843 | https://github.com/screener-io/screener-storybook/blob/48854c1814f49ffcd3954864bc2505b665626843/src/scripts/story-steps.js#L83-L107 | train | |
vacuumlabs/babel-plugin-extensible-destructuring | src/index.js | hasRest | function hasRest(pattern) {
for (let elem of pattern.elements) {
if (isRestElement(t, elem)) {
return true
}
}
return false
} | javascript | function hasRest(pattern) {
for (let elem of pattern.elements) {
if (isRestElement(t, elem)) {
return true
}
}
return false
} | [
"function",
"hasRest",
"(",
"pattern",
")",
"{",
"for",
"(",
"let",
"elem",
"of",
"pattern",
".",
"elements",
")",
"{",
"if",
"(",
"isRestElement",
"(",
"t",
",",
"elem",
")",
")",
"{",
"return",
"true",
"}",
"}",
"return",
"false",
"}"
] | Test if an ArrayPattern's elements contain any RestElements. | [
"Test",
"if",
"an",
"ArrayPattern",
"s",
"elements",
"contain",
"any",
"RestElements",
"."
] | ac5d8b0737628b1af4923d30a92162b26ec582bf | https://github.com/vacuumlabs/babel-plugin-extensible-destructuring/blob/ac5d8b0737628b1af4923d30a92162b26ec582bf/src/index.js#L102-L109 | train |
vacuumlabs/babel-plugin-extensible-destructuring | src/index.js | getDirective | function getDirective(path) {
for (let directive of path.node.directives) {
let dirstr = directive.value.value
if (dirstr.startsWith('use ')) {
let uses = dirstr.substr(4).split(',').map((use) => use.trim())
if (uses.indexOf('extensible') !== -1) {
return 1
}
if... | javascript | function getDirective(path) {
for (let directive of path.node.directives) {
let dirstr = directive.value.value
if (dirstr.startsWith('use ')) {
let uses = dirstr.substr(4).split(',').map((use) => use.trim())
if (uses.indexOf('extensible') !== -1) {
return 1
}
if... | [
"function",
"getDirective",
"(",
"path",
")",
"{",
"for",
"(",
"let",
"directive",
"of",
"path",
".",
"node",
".",
"directives",
")",
"{",
"let",
"dirstr",
"=",
"directive",
".",
"value",
".",
"value",
"if",
"(",
"dirstr",
".",
"startsWith",
"(",
"'use... | 0 - no directive 1 - 'use extensible' directive -1 - 'use !extensible' directive | [
"0",
"-",
"no",
"directive",
"1",
"-",
"use",
"extensible",
"directive",
"-",
"1",
"-",
"use",
"!extensible",
"directive"
] | ac5d8b0737628b1af4923d30a92162b26ec582bf | https://github.com/vacuumlabs/babel-plugin-extensible-destructuring/blob/ac5d8b0737628b1af4923d30a92162b26ec582bf/src/index.js#L384-L398 | train |
johansatge/jpeg-autorotate | src/transform.js | flipPixels | function flipPixels(buffer, width, height) {
const newBuffer = Buffer.alloc(buffer.length)
for (let x = 0; x < width; x += 1) {
for (let y = 0; y < height; y += 1) {
const offset = (width * y + x) << 2
const newOffset = (width * y + width - 1 - x) << 2
const pixel = buffer.readUInt32BE(offset,... | javascript | function flipPixels(buffer, width, height) {
const newBuffer = Buffer.alloc(buffer.length)
for (let x = 0; x < width; x += 1) {
for (let y = 0; y < height; y += 1) {
const offset = (width * y + x) << 2
const newOffset = (width * y + width - 1 - x) << 2
const pixel = buffer.readUInt32BE(offset,... | [
"function",
"flipPixels",
"(",
"buffer",
",",
"width",
",",
"height",
")",
"{",
"const",
"newBuffer",
"=",
"Buffer",
".",
"alloc",
"(",
"buffer",
".",
"length",
")",
"for",
"(",
"let",
"x",
"=",
"0",
";",
"x",
"<",
"width",
";",
"x",
"+=",
"1",
"... | Flip a buffer horizontally | [
"Flip",
"a",
"buffer",
"horizontally"
] | 2b4a37f9b929122b3e29b19ddc1f5c16e6db6733 | https://github.com/johansatge/jpeg-autorotate/blob/2b4a37f9b929122b3e29b19ddc1f5c16e6db6733/src/transform.js#L73-L84 | train |
johansatge/jpeg-autorotate | src/main.js | parseOrientationTag | function parseOrientationTag({buffer, exifData}) {
let orientation = null
if (exifData['0th'] && exifData['0th'][piexif.ImageIFD.Orientation]) {
orientation = parseInt(exifData['0th'][piexif.ImageIFD.Orientation])
}
if (orientation === null) {
throw new CustomError(m.errors.no_orientation, 'No orientati... | javascript | function parseOrientationTag({buffer, exifData}) {
let orientation = null
if (exifData['0th'] && exifData['0th'][piexif.ImageIFD.Orientation]) {
orientation = parseInt(exifData['0th'][piexif.ImageIFD.Orientation])
}
if (orientation === null) {
throw new CustomError(m.errors.no_orientation, 'No orientati... | [
"function",
"parseOrientationTag",
"(",
"{",
"buffer",
",",
"exifData",
"}",
")",
"{",
"let",
"orientation",
"=",
"null",
"if",
"(",
"exifData",
"[",
"'0th'",
"]",
"&&",
"exifData",
"[",
"'0th'",
"]",
"[",
"piexif",
".",
"ImageIFD",
".",
"Orientation",
"... | Extract the orientation tag from the given EXIF data | [
"Extract",
"the",
"orientation",
"tag",
"from",
"the",
"given",
"EXIF",
"data"
] | 2b4a37f9b929122b3e29b19ddc1f5c16e6db6733 | https://github.com/johansatge/jpeg-autorotate/blob/2b4a37f9b929122b3e29b19ddc1f5c16e6db6733/src/main.js#L96-L111 | train |
johansatge/jpeg-autorotate | src/main.js | computeFinalBuffer | function computeFinalBuffer(image, thumbnail, exifData, orientation) {
exifData['0th'][piexif.ImageIFD.Orientation] = 1
if (typeof exifData['Exif'][piexif.ExifIFD.PixelXDimension] !== 'undefined') {
exifData['Exif'][piexif.ExifIFD.PixelXDimension] = image.width
}
if (typeof exifData['Exif'][piexif.ExifIFD.P... | javascript | function computeFinalBuffer(image, thumbnail, exifData, orientation) {
exifData['0th'][piexif.ImageIFD.Orientation] = 1
if (typeof exifData['Exif'][piexif.ExifIFD.PixelXDimension] !== 'undefined') {
exifData['Exif'][piexif.ExifIFD.PixelXDimension] = image.width
}
if (typeof exifData['Exif'][piexif.ExifIFD.P... | [
"function",
"computeFinalBuffer",
"(",
"image",
",",
"thumbnail",
",",
"exifData",
",",
"orientation",
")",
"{",
"exifData",
"[",
"'0th'",
"]",
"[",
"piexif",
".",
"ImageIFD",
".",
"Orientation",
"]",
"=",
"1",
"if",
"(",
"typeof",
"exifData",
"[",
"'Exif'... | Compute the final buffer by updating the original EXIF data and linking it to the rotated buffer | [
"Compute",
"the",
"final",
"buffer",
"by",
"updating",
"the",
"original",
"EXIF",
"data",
"and",
"linking",
"it",
"to",
"the",
"rotated",
"buffer"
] | 2b4a37f9b929122b3e29b19ddc1f5c16e6db6733 | https://github.com/johansatge/jpeg-autorotate/blob/2b4a37f9b929122b3e29b19ddc1f5c16e6db6733/src/main.js#L131-L149 | train |
chrisyip/koa-pug | src/pug.js | contextRenderer | function contextRenderer (tpl, locals, options, noCache) {
var finalLocals = merge({}, helpers, defaultLocals, this.state, locals)
this.body = renderer(tpl, finalLocals, options, noCache)
this.type = 'text/html'
return this
} | javascript | function contextRenderer (tpl, locals, options, noCache) {
var finalLocals = merge({}, helpers, defaultLocals, this.state, locals)
this.body = renderer(tpl, finalLocals, options, noCache)
this.type = 'text/html'
return this
} | [
"function",
"contextRenderer",
"(",
"tpl",
",",
"locals",
",",
"options",
",",
"noCache",
")",
"{",
"var",
"finalLocals",
"=",
"merge",
"(",
"{",
"}",
",",
"helpers",
",",
"defaultLocals",
",",
"this",
".",
"state",
",",
"locals",
")",
"this",
".",
"bo... | Render function that attached to app context
@param {String} tpl the template path, search start from viewPath
@param {Object} locals locals, will merged with global locals and ctx.state
@param {Object} options options that pass to Pug compiler, merged with global default options
@param {Boolean} noCache use c... | [
"Render",
"function",
"that",
"attached",
"to",
"app",
"context"
] | 1ac559fdd1a6d43c91bec8c83cde9c3853d8fa12 | https://github.com/chrisyip/koa-pug/blob/1ac559fdd1a6d43c91bec8c83cde9c3853d8fa12/src/pug.js#L103-L109 | train |
netceteragroup/valdr | src/message/valdrMessage-directive.js | function (restrict) {
return ['$compile', function ($compile) {
return {
restrict: restrict,
require: ['?^valdrType', '?^ngModel', '?^valdrFormGroup'],
link: function (scope, element, attrs, controllers) {
var valdrTypeController = controllers[0],
ngModelControll... | javascript | function (restrict) {
return ['$compile', function ($compile) {
return {
restrict: restrict,
require: ['?^valdrType', '?^ngModel', '?^valdrFormGroup'],
link: function (scope, element, attrs, controllers) {
var valdrTypeController = controllers[0],
ngModelControll... | [
"function",
"(",
"restrict",
")",
"{",
"return",
"[",
"'$compile'",
",",
"function",
"(",
"$compile",
")",
"{",
"return",
"{",
"restrict",
":",
"restrict",
",",
"require",
":",
"[",
"'?^valdrType'",
",",
"'?^ngModel'",
",",
"'?^valdrFormGroup'",
"]",
",",
... | This directive appends a validation message to the parent element of any input, select or textarea element, which
is nested in a valdr-type directive and has an ng-model bound to it.
If the form element is wrapped in an element marked with the class defined in valdrClasses.formGroup,
the messages is appended to this el... | [
"This",
"directive",
"appends",
"a",
"validation",
"message",
"to",
"the",
"parent",
"element",
"of",
"any",
"input",
"select",
"or",
"textarea",
"element",
"which",
"is",
"nested",
"in",
"a",
"valdr",
"-",
"type",
"directive",
"and",
"has",
"an",
"ng",
"-... | 2a6174f18402087602c98b82b33a7ed05dfb8020 | https://github.com/netceteragroup/valdr/blob/2a6174f18402087602c98b82b33a7ed05dfb8020/src/message/valdrMessage-directive.js#L9-L45 | train | |
netceteragroup/valdr | src/core/valdrUtil-service.js | function (value, prefix) {
return angular.isString(value) &&
angular.isString(prefix) &&
value.lastIndexOf(prefix, 0) === 0;
} | javascript | function (value, prefix) {
return angular.isString(value) &&
angular.isString(prefix) &&
value.lastIndexOf(prefix, 0) === 0;
} | [
"function",
"(",
"value",
",",
"prefix",
")",
"{",
"return",
"angular",
".",
"isString",
"(",
"value",
")",
"&&",
"angular",
".",
"isString",
"(",
"prefix",
")",
"&&",
"value",
".",
"lastIndexOf",
"(",
"prefix",
",",
"0",
")",
"===",
"0",
";",
"}"
] | Checks if a string value starts with a given prefix.
@param value the value
@param prefix the prefix
@returns {boolean} true if the given value starts with the given prefix. | [
"Checks",
"if",
"a",
"string",
"value",
"starts",
"with",
"a",
"given",
"prefix",
"."
] | 2a6174f18402087602c98b82b33a7ed05dfb8020 | https://github.com/netceteragroup/valdr/blob/2a6174f18402087602c98b82b33a7ed05dfb8020/src/core/valdrUtil-service.js#L90-L94 | train | |
netceteragroup/valdr | src/core/validators/patternValidator.js | function (value, constraint) {
var pattern = asRegExp(constraint.value);
return valdrUtil.isEmpty(value) || pattern.test(value);
} | javascript | function (value, constraint) {
var pattern = asRegExp(constraint.value);
return valdrUtil.isEmpty(value) || pattern.test(value);
} | [
"function",
"(",
"value",
",",
"constraint",
")",
"{",
"var",
"pattern",
"=",
"asRegExp",
"(",
"constraint",
".",
"value",
")",
";",
"return",
"valdrUtil",
".",
"isEmpty",
"(",
"value",
")",
"||",
"pattern",
".",
"test",
"(",
"value",
")",
";",
"}"
] | Checks if the value matches the pattern defined in the constraint.
@param value the value to validate
@param constraint the constraint with the regexp as value
@returns {boolean} true if valid | [
"Checks",
"if",
"the",
"value",
"matches",
"the",
"pattern",
"defined",
"in",
"the",
"constraint",
"."
] | 2a6174f18402087602c98b82b33a7ed05dfb8020 | https://github.com/netceteragroup/valdr/blob/2a6174f18402087602c98b82b33a7ed05dfb8020/src/core/validators/patternValidator.js#L39-L42 | train | |
netceteragroup/valdr | src/core/validators/digitsValidator.js | function (value, constraint) {
if (valdrUtil.isEmpty(value)) {
return true;
}
if (valdrUtil.isNaN(Number(value))) {
return false;
}
return doValidate(value, constraint);
} | javascript | function (value, constraint) {
if (valdrUtil.isEmpty(value)) {
return true;
}
if (valdrUtil.isNaN(Number(value))) {
return false;
}
return doValidate(value, constraint);
} | [
"function",
"(",
"value",
",",
"constraint",
")",
"{",
"if",
"(",
"valdrUtil",
".",
"isEmpty",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"valdrUtil",
".",
"isNaN",
"(",
"Number",
"(",
"value",
")",
")",
")",
"{",
"return",... | Checks if the value is a number within accepted range.
@param value the value to validate
@param constraint the validation constraint, it is expected to have integer and fraction properties (maximum
number of integral/fractional digits accepted for this number)
@returns {boolean} true if valid | [
"Checks",
"if",
"the",
"value",
"is",
"a",
"number",
"within",
"accepted",
"range",
"."
] | 2a6174f18402087602c98b82b33a7ed05dfb8020 | https://github.com/netceteragroup/valdr/blob/2a6174f18402087602c98b82b33a7ed05dfb8020/src/core/validators/digitsValidator.js#L44-L54 | train | |
netceteragroup/valdr | src/core/valdr-service.js | function (typeName, fieldName, value) {
var validResult = { valid: true },
typeConstraints = constraintsForType(typeName);
if (valdrUtil.has(typeConstraints, fieldName)) {
var fieldConstraints = typeConstraints[fieldName],
fieldIsValid = tr... | javascript | function (typeName, fieldName, value) {
var validResult = { valid: true },
typeConstraints = constraintsForType(typeName);
if (valdrUtil.has(typeConstraints, fieldName)) {
var fieldConstraints = typeConstraints[fieldName],
fieldIsValid = tr... | [
"function",
"(",
"typeName",
",",
"fieldName",
",",
"value",
")",
"{",
"var",
"validResult",
"=",
"{",
"valid",
":",
"true",
"}",
",",
"typeConstraints",
"=",
"constraintsForType",
"(",
"typeName",
")",
";",
"if",
"(",
"valdrUtil",
".",
"has",
"(",
"type... | Validates the value of the given type with the constraints for the given field name.
@param typeName the type name
@param fieldName the field name
@param value the value to validate
@returns {*} | [
"Validates",
"the",
"value",
"of",
"the",
"given",
"type",
"with",
"the",
"constraints",
"for",
"the",
"given",
"field",
"name",
"."
] | 2a6174f18402087602c98b82b33a7ed05dfb8020 | https://github.com/netceteragroup/valdr/blob/2a6174f18402087602c98b82b33a7ed05dfb8020/src/core/valdr-service.js#L102-L147 | train | |
netceteragroup/valdr | src/core/validators/hibernateEmailValidator.js | function (value) {
if (valdrUtil.isEmpty(value)) {
return true;
}
// split email at '@' and consider local and domain part separately
var emailParts = value.split('@');
if (emailParts.length !== 2) {
return false;
}
if (!localPattern.test(ema... | javascript | function (value) {
if (valdrUtil.isEmpty(value)) {
return true;
}
// split email at '@' and consider local and domain part separately
var emailParts = value.split('@');
if (emailParts.length !== 2) {
return false;
}
if (!localPattern.test(ema... | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"valdrUtil",
".",
"isEmpty",
"(",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"// split email at '@' and consider local and domain part separately",
"var",
"emailParts",
"=",
"value",
".",
"split",
"(",
"'@'... | Checks if the value is a valid email address using the same patterns as Hibernate uses in its bean validation
implementation.
@param value the value to validate
@returns {boolean} true if valid | [
"Checks",
"if",
"the",
"value",
"is",
"a",
"valid",
"email",
"address",
"using",
"the",
"same",
"patterns",
"as",
"Hibernate",
"uses",
"in",
"its",
"bean",
"validation",
"implementation",
"."
] | 2a6174f18402087602c98b82b33a7ed05dfb8020 | https://github.com/netceteragroup/valdr/blob/2a6174f18402087602c98b82b33a7ed05dfb8020/src/core/validators/hibernateEmailValidator.js#L21-L37 | train | |
bem-archive/bem-tools | lib/nodes/bundle.js | function(tech) {
return (this.level.getConfig().bundleBuildLevels || [])
.concat([PATH.resolve(this.root, PATH.dirname(this.getNodePrefix()), 'blocks')]);
} | javascript | function(tech) {
return (this.level.getConfig().bundleBuildLevels || [])
.concat([PATH.resolve(this.root, PATH.dirname(this.getNodePrefix()), 'blocks')]);
} | [
"function",
"(",
"tech",
")",
"{",
"return",
"(",
"this",
".",
"level",
".",
"getConfig",
"(",
")",
".",
"bundleBuildLevels",
"||",
"[",
"]",
")",
".",
"concat",
"(",
"[",
"PATH",
".",
"resolve",
"(",
"this",
".",
"root",
",",
"PATH",
".",
"dirname... | Constructs array of levels to build tech from.
@param {String} tech Tech name.
@return {Array} Array of levels. | [
"Constructs",
"array",
"of",
"levels",
"to",
"build",
"tech",
"from",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/bundle.js#L156-L159 | train | |
bem-archive/bem-tools | lib/nodes/bundle.js | function(techName, techPath, declPath, bundleNode, magicNode, forked) {
var arch = this.ctx.arch,
buildNode = new BemBuildNode.BemBuildNode({
root: this.root,
bundlesLevel: this.level,
levels: this.getLevels(techName),
declPath: declPa... | javascript | function(techName, techPath, declPath, bundleNode, magicNode, forked) {
var arch = this.ctx.arch,
buildNode = new BemBuildNode.BemBuildNode({
root: this.root,
bundlesLevel: this.level,
levels: this.getLevels(techName),
declPath: declPa... | [
"function",
"(",
"techName",
",",
"techPath",
",",
"declPath",
",",
"bundleNode",
",",
"magicNode",
",",
"forked",
")",
"{",
"var",
"arch",
"=",
"this",
".",
"ctx",
".",
"arch",
",",
"buildNode",
"=",
"new",
"BemBuildNode",
".",
"BemBuildNode",
"(",
"{",... | Create a bem build node, add it to the arch, add
dependencies to it. Then create a meta node and link
it to the build node.
@param {String} techName
@param {String} techPath
@param {String} declPath
@param {String} bundleNode
@param {String} magicNode
@param {Boolean} [forked]
@return {Node} | [
"Create",
"a",
"bem",
"build",
"node",
"add",
"it",
"to",
"the",
"arch",
"add",
"dependencies",
"to",
"it",
".",
"Then",
"create",
"a",
"meta",
"node",
"and",
"link",
"it",
"to",
"the",
"build",
"node",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/bundle.js#L206-L253 | train | |
bem-archive/bem-tools | lib/nodes/bundle.js | function(techName, techPath, bundleNode, magicNode, force, forked) {
var arch = this.ctx.arch,
node = this.useFileOrBuild(new BemCreateNode.BemCreateNode({
root: this.root,
level: this.level,
item: this.item,
techPath: techPath,
... | javascript | function(techName, techPath, bundleNode, magicNode, force, forked) {
var arch = this.ctx.arch,
node = this.useFileOrBuild(new BemCreateNode.BemCreateNode({
root: this.root,
level: this.level,
item: this.item,
techPath: techPath,
... | [
"function",
"(",
"techName",
",",
"techPath",
",",
"bundleNode",
",",
"magicNode",
",",
"force",
",",
"forked",
")",
"{",
"var",
"arch",
"=",
"this",
".",
"ctx",
".",
"arch",
",",
"node",
"=",
"this",
".",
"useFileOrBuild",
"(",
"new",
"BemCreateNode",
... | Create a bem create node, add it to the arch,
add dependencies to it.
@param {String} techName
@param {String} techPath
@param {String} bundleNode
@param {String} magicNode
@param {Boolean} [force]
@param {Boolean} [forked]
@return {Node | undefined} | [
"Create",
"a",
"bem",
"create",
"node",
"add",
"it",
"to",
"the",
"arch",
"add",
"dependencies",
"to",
"it",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/bundle.js#L267-L301 | train | |
bem-archive/bem-tools | lib/nodes/bundle.js | function(tech, bundleNode, magicNode) {
var arch = this.ctx.arch,
filePath = this.getBundlePath(tech);
if (!PATH.existsSync(PATH.resolve(this.root, filePath))) return;
var node = new fileNodes.FileNode({
root: this.root,
path: filePath
});
... | javascript | function(tech, bundleNode, magicNode) {
var arch = this.ctx.arch,
filePath = this.getBundlePath(tech);
if (!PATH.existsSync(PATH.resolve(this.root, filePath))) return;
var node = new fileNodes.FileNode({
root: this.root,
path: filePath
});
... | [
"function",
"(",
"tech",
",",
"bundleNode",
",",
"magicNode",
")",
"{",
"var",
"arch",
"=",
"this",
".",
"ctx",
".",
"arch",
",",
"filePath",
"=",
"this",
".",
"getBundlePath",
"(",
"tech",
")",
";",
"if",
"(",
"!",
"PATH",
".",
"existsSync",
"(",
... | Create file node, add it to the arch, add dependencies to it.
@param {String} tech
@param {String} bundleNode
@param {String} magicNode
@return {Node | undefined} | [
"Create",
"file",
"node",
"add",
"it",
"to",
"the",
"arch",
"add",
"dependencies",
"to",
"it",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/bundle.js#L311-L330 | train | |
bem-archive/bem-tools | lib/nodes/bundle.js | function(tech, bundleNode, magicNode) {
var ctx = this.ctx,
arch = ctx.arch,
levelNode = arch.getNode(PATH.relative(this.root, this.level.dir)),
depsTech = this.level.getTech('deps.js').getTechName(),
bundles = arch.getChildren(levelNode)
.filter(... | javascript | function(tech, bundleNode, magicNode) {
var ctx = this.ctx,
arch = ctx.arch,
levelNode = arch.getNode(PATH.relative(this.root, this.level.dir)),
depsTech = this.level.getTech('deps.js').getTechName(),
bundles = arch.getChildren(levelNode)
.filter(... | [
"function",
"(",
"tech",
",",
"bundleNode",
",",
"magicNode",
")",
"{",
"var",
"ctx",
"=",
"this",
".",
"ctx",
",",
"arch",
"=",
"ctx",
".",
"arch",
",",
"levelNode",
"=",
"arch",
".",
"getNode",
"(",
"PATH",
".",
"relative",
"(",
"this",
".",
"roo... | Overriden. Creates BemDecl node linked to the deps.js nodes of the bundles within containing level.
@param tech
@param bundleNode
@param magicNode
@return {*} | [
"Overriden",
".",
"Creates",
"BemDecl",
"node",
"linked",
"to",
"the",
"deps",
".",
"js",
"nodes",
"of",
"the",
"bundles",
"within",
"containing",
"level",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/bundle.js#L489-L512 | train | |
bem-archive/bem-tools | lib/nodesregistry.js | function(nodeName, objectOrBaseName, objectOrStatic, staticObject) {
var explicitBase = typeof objectOrBaseName === 'string',
baseName = explicitBase? objectOrBaseName : nodeName,
staticObj = typeof objectOrBaseName !== 'string'? objectOrStatic: staticObject,
obj = explicitB... | javascript | function(nodeName, objectOrBaseName, objectOrStatic, staticObject) {
var explicitBase = typeof objectOrBaseName === 'string',
baseName = explicitBase? objectOrBaseName : nodeName,
staticObj = typeof objectOrBaseName !== 'string'? objectOrStatic: staticObject,
obj = explicitB... | [
"function",
"(",
"nodeName",
",",
"objectOrBaseName",
",",
"objectOrStatic",
",",
"staticObject",
")",
"{",
"var",
"explicitBase",
"=",
"typeof",
"objectOrBaseName",
"===",
"'string'",
",",
"baseName",
"=",
"explicitBase",
"?",
"objectOrBaseName",
":",
"nodeName",
... | Calls INHERIT for specified parameters set and put the result into cache.
@param {String} nodeName Name of the node
@param {Object|String} objectOrBaseName Object definition or name of the class to inherit from
@param {Object|Object} objectOrStatic Object with static members definition|object definition
@param {Objec... | [
"Calls",
"INHERIT",
"for",
"specified",
"parameters",
"set",
"and",
"put",
"the",
"result",
"into",
"cache",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodesregistry.js#L22-L42 | train | |
bem-archive/bem-tools | lib/nodesregistry.js | function(nodeName, objectOrBaseName, objectOrStatic, staticObject) {
cache = {};
var stack = registry[nodeName] || [];
stack.push(Array.prototype.slice.call(arguments, 0));
registry[nodeName] = stack;
} | javascript | function(nodeName, objectOrBaseName, objectOrStatic, staticObject) {
cache = {};
var stack = registry[nodeName] || [];
stack.push(Array.prototype.slice.call(arguments, 0));
registry[nodeName] = stack;
} | [
"function",
"(",
"nodeName",
",",
"objectOrBaseName",
",",
"objectOrStatic",
",",
"staticObject",
")",
"{",
"cache",
"=",
"{",
"}",
";",
"var",
"stack",
"=",
"registry",
"[",
"nodeName",
"]",
"||",
"[",
"]",
";",
"stack",
".",
"push",
"(",
"Array",
"."... | Stores specified arguments into registry for further processing with INHERIT.
@param {String} nodeName Name of the node
@param {Object|String} objectOrBaseName Object definition or name of the class to inherit from
@param {Object|Object} objectOrStatic Object with static members definition|object definition
@param {O... | [
"Stores",
"specified",
"arguments",
"into",
"registry",
"for",
"further",
"processing",
"with",
"INHERIT",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodesregistry.js#L66-L75 | train | |
bem-archive/bem-tools | lib/data/d3.js | d3_format_group | function d3_format_group(value) {
var i = value.lastIndexOf("."),
f = i >= 0 ? value.substring(i) : (i = value.length, ""),
t = [];
while (i > 0) t.push(value.substring(i -= 3, i + 3));
return t.reverse().join(",") + f;
} | javascript | function d3_format_group(value) {
var i = value.lastIndexOf("."),
f = i >= 0 ? value.substring(i) : (i = value.length, ""),
t = [];
while (i > 0) t.push(value.substring(i -= 3, i + 3));
return t.reverse().join(",") + f;
} | [
"function",
"d3_format_group",
"(",
"value",
")",
"{",
"var",
"i",
"=",
"value",
".",
"lastIndexOf",
"(",
"\".\"",
")",
",",
"f",
"=",
"i",
">=",
"0",
"?",
"value",
".",
"substring",
"(",
"i",
")",
":",
"(",
"i",
"=",
"value",
".",
"length",
",",... | Apply comma grouping for thousands. | [
"Apply",
"comma",
"grouping",
"for",
"thousands",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L712-L718 | train |
bem-archive/bem-tools | lib/data/d3.js | l | function l(e) {
var o = d3.event; // Events can be reentrant (e.g., focus).
d3.event = e;
try {
listener.call(node, node.__data__, i);
} finally {
d3.event = o;
}
} | javascript | function l(e) {
var o = d3.event; // Events can be reentrant (e.g., focus).
d3.event = e;
try {
listener.call(node, node.__data__, i);
} finally {
d3.event = o;
}
} | [
"function",
"l",
"(",
"e",
")",
"{",
"var",
"o",
"=",
"d3",
".",
"event",
";",
"// Events can be reentrant (e.g., focus).",
"d3",
".",
"event",
"=",
"e",
";",
"try",
"{",
"listener",
".",
"call",
"(",
"node",
",",
"node",
".",
"__data__",
",",
"i",
"... | wrapped event listener that preserves i | [
"wrapped",
"event",
"listener",
"that",
"preserves",
"i"
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L2001-L2009 | train |
bem-archive/bem-tools | lib/data/d3.js | brush | function brush(g) {
g.each(function() {
var g = d3.select(this),
bg = g.selectAll(".background").data([0]),
fg = g.selectAll(".extent").data([0]),
tz = g.selectAll(".resize").data(resizes, String),
e;
// Prepare the brush container for events.
g
.... | javascript | function brush(g) {
g.each(function() {
var g = d3.select(this),
bg = g.selectAll(".background").data([0]),
fg = g.selectAll(".extent").data([0]),
tz = g.selectAll(".resize").data(resizes, String),
e;
// Prepare the brush container for events.
g
.... | [
"function",
"brush",
"(",
"g",
")",
"{",
"g",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"g",
"=",
"d3",
".",
"select",
"(",
"this",
")",
",",
"bg",
"=",
"g",
".",
"selectAll",
"(",
"\".background\"",
")",
".",
"data",
"(",
"[",
"0",
... | the extent in data space, lazily created | [
"the",
"extent",
"in",
"data",
"space",
"lazily",
"created"
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L4288-L4344 | train |
bem-archive/bem-tools | lib/data/d3.js | recurse | function recurse(data, depth, nodes) {
var childs = children.call(hierarchy, data, depth),
node = d3_layout_hierarchyInline ? data : {data: data};
node.depth = depth;
nodes.push(node);
if (childs && (n = childs.length)) {
var i = -1,
n,
c = node.children = [],
... | javascript | function recurse(data, depth, nodes) {
var childs = children.call(hierarchy, data, depth),
node = d3_layout_hierarchyInline ? data : {data: data};
node.depth = depth;
nodes.push(node);
if (childs && (n = childs.length)) {
var i = -1,
n,
c = node.children = [],
... | [
"function",
"recurse",
"(",
"data",
",",
"depth",
",",
"nodes",
")",
"{",
"var",
"childs",
"=",
"children",
".",
"call",
"(",
"hierarchy",
",",
"data",
",",
"depth",
")",
",",
"node",
"=",
"d3_layout_hierarchyInline",
"?",
"data",
":",
"{",
"data",
":"... | Recursively compute the node depth and value. Also converts the data representation into a standard hierarchy structure. | [
"Recursively",
"compute",
"the",
"node",
"depth",
"and",
"value",
".",
"Also",
"converts",
"the",
"data",
"representation",
"into",
"a",
"standard",
"hierarchy",
"structure",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L5979-L6003 | train |
bem-archive/bem-tools | lib/data/d3.js | revalue | function revalue(node, depth) {
var children = node.children,
v = 0;
if (children && (n = children.length)) {
var i = -1,
n,
j = depth + 1;
while (++i < n) v += revalue(children[i], j);
} else if (value) {
v = +value.call(hierarchy, d3_layout_hierarchyInline ? n... | javascript | function revalue(node, depth) {
var children = node.children,
v = 0;
if (children && (n = children.length)) {
var i = -1,
n,
j = depth + 1;
while (++i < n) v += revalue(children[i], j);
} else if (value) {
v = +value.call(hierarchy, d3_layout_hierarchyInline ? n... | [
"function",
"revalue",
"(",
"node",
",",
"depth",
")",
"{",
"var",
"children",
"=",
"node",
".",
"children",
",",
"v",
"=",
"0",
";",
"if",
"(",
"children",
"&&",
"(",
"n",
"=",
"children",
".",
"length",
")",
")",
"{",
"var",
"i",
"=",
"-",
"1... | Recursively re-evaluates the node value. | [
"Recursively",
"re",
"-",
"evaluates",
"the",
"node",
"value",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L6006-L6019 | train |
bem-archive/bem-tools | lib/data/d3.js | d3_layout_hierarchyRebind | function d3_layout_hierarchyRebind(object, hierarchy) {
d3.rebind(object, hierarchy, "sort", "children", "value");
// Add an alias for links, for convenience.
object.links = d3_layout_hierarchyLinks;
// If the new API is used, enabling inlining.
object.nodes = function(d) {
d3_layout_hierarchyInline = t... | javascript | function d3_layout_hierarchyRebind(object, hierarchy) {
d3.rebind(object, hierarchy, "sort", "children", "value");
// Add an alias for links, for convenience.
object.links = d3_layout_hierarchyLinks;
// If the new API is used, enabling inlining.
object.nodes = function(d) {
d3_layout_hierarchyInline = t... | [
"function",
"d3_layout_hierarchyRebind",
"(",
"object",
",",
"hierarchy",
")",
"{",
"d3",
".",
"rebind",
"(",
"object",
",",
"hierarchy",
",",
"\"sort\"",
",",
"\"children\"",
",",
"\"value\"",
")",
";",
"// Add an alias for links, for convenience.",
"object",
".",
... | A method assignment helper for hierarchy subclasses. | [
"A",
"method",
"assignment",
"helper",
"for",
"hierarchy",
"subclasses",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L6055-L6068 | train |
bem-archive/bem-tools | lib/data/d3.js | squarify | function squarify(node) {
var children = node.children;
if (children && children.length) {
var rect = pad(node),
row = [],
remaining = children.slice(), // copy-on-write
child,
best = Infinity, // the best row score so far
score, // the current row score
... | javascript | function squarify(node) {
var children = node.children;
if (children && children.length) {
var rect = pad(node),
row = [],
remaining = children.slice(), // copy-on-write
child,
best = Infinity, // the best row score so far
score, // the current row score
... | [
"function",
"squarify",
"(",
"node",
")",
"{",
"var",
"children",
"=",
"node",
".",
"children",
";",
"if",
"(",
"children",
"&&",
"children",
".",
"length",
")",
"{",
"var",
"rect",
"=",
"pad",
"(",
"node",
")",
",",
"row",
"=",
"[",
"]",
",",
"r... | Recursively arranges the specified node's children into squarified rows. | [
"Recursively",
"arranges",
"the",
"specified",
"node",
"s",
"children",
"into",
"squarified",
"rows",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L6629-L6662 | train |
bem-archive/bem-tools | lib/data/d3.js | stickify | function stickify(node) {
var children = node.children;
if (children && children.length) {
var rect = pad(node),
remaining = children.slice(), // copy-on-write
child,
row = [];
scale(remaining, rect.dx * rect.dy / node.value);
row.area = 0;
while (child = re... | javascript | function stickify(node) {
var children = node.children;
if (children && children.length) {
var rect = pad(node),
remaining = children.slice(), // copy-on-write
child,
row = [];
scale(remaining, rect.dx * rect.dy / node.value);
row.area = 0;
while (child = re... | [
"function",
"stickify",
"(",
"node",
")",
"{",
"var",
"children",
"=",
"node",
".",
"children",
";",
"if",
"(",
"children",
"&&",
"children",
".",
"length",
")",
"{",
"var",
"rect",
"=",
"pad",
"(",
"node",
")",
",",
"remaining",
"=",
"children",
"."... | Recursively resizes the specified node's children into existing rows. Preserves the existing layout! | [
"Recursively",
"resizes",
"the",
"specified",
"node",
"s",
"children",
"into",
"existing",
"rows",
".",
"Preserves",
"the",
"existing",
"layout!"
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L6666-L6685 | train |
bem-archive/bem-tools | lib/data/d3.js | token | function token() {
if (re.lastIndex >= text.length) return EOF; // special case: end of file
if (eol) { eol = false; return EOL; } // special case: end of line
// special case: quotes
var j = re.lastIndex;
if (text.charCodeAt(j) === 34) {
var i = j;
while (i++ < text.length) {
i... | javascript | function token() {
if (re.lastIndex >= text.length) return EOF; // special case: end of file
if (eol) { eol = false; return EOL; } // special case: end of line
// special case: quotes
var j = re.lastIndex;
if (text.charCodeAt(j) === 34) {
var i = j;
while (i++ < text.length) {
i... | [
"function",
"token",
"(",
")",
"{",
"if",
"(",
"re",
".",
"lastIndex",
">=",
"text",
".",
"length",
")",
"return",
"EOF",
";",
"// special case: end of file",
"if",
"(",
"eol",
")",
"{",
"eol",
"=",
"false",
";",
"return",
"EOL",
";",
"}",
"// special ... | work-around bug in FF 3.6 @private Returns the next token. | [
"work",
"-",
"around",
"bug",
"in",
"FF",
"3",
".",
"6"
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L6852-L6885 | train |
bem-archive/bem-tools | lib/data/d3.js | resample | function resample(coordinates) {
var i = 0,
n = coordinates.length,
j,
m,
resampled = n ? [coordinates[0]] : coordinates,
resamples,
origin = arc.source();
while (++i < n) {
resamples = arc.source(coordinates[i - 1])(coordinates[i]).coordinates;
for (... | javascript | function resample(coordinates) {
var i = 0,
n = coordinates.length,
j,
m,
resampled = n ? [coordinates[0]] : coordinates,
resamples,
origin = arc.source();
while (++i < n) {
resamples = arc.source(coordinates[i - 1])(coordinates[i]).coordinates;
for (... | [
"function",
"resample",
"(",
"coordinates",
")",
"{",
"var",
"i",
"=",
"0",
",",
"n",
"=",
"coordinates",
".",
"length",
",",
"j",
",",
"m",
",",
"resampled",
"=",
"n",
"?",
"[",
"coordinates",
"[",
"0",
"]",
"]",
":",
"coordinates",
",",
"resample... | Resample coordinates, creating great arcs between each. | [
"Resample",
"coordinates",
"creating",
"great",
"arcs",
"between",
"each",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L7729-L7745 | train |
bem-archive/bem-tools | lib/data/d3.js | d3_geom_hullCCW | function d3_geom_hullCCW(i1, i2, i3, v) {
var t, a, b, c, d, e, f;
t = v[i1]; a = t[0]; b = t[1];
t = v[i2]; c = t[0]; d = t[1];
t = v[i3]; e = t[0]; f = t[1];
return ((f-b)*(c-a) - (d-b)*(e-a)) > 0;
} | javascript | function d3_geom_hullCCW(i1, i2, i3, v) {
var t, a, b, c, d, e, f;
t = v[i1]; a = t[0]; b = t[1];
t = v[i2]; c = t[0]; d = t[1];
t = v[i3]; e = t[0]; f = t[1];
return ((f-b)*(c-a) - (d-b)*(e-a)) > 0;
} | [
"function",
"d3_geom_hullCCW",
"(",
"i1",
",",
"i2",
",",
"i3",
",",
"v",
")",
"{",
"var",
"t",
",",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
",",
"f",
";",
"t",
"=",
"v",
"[",
"i1",
"]",
";",
"a",
"=",
"t",
"[",
"0",
"]",
";",
"b... | are three points in counter-clockwise order? | [
"are",
"three",
"points",
"in",
"counter",
"-",
"clockwise",
"order?"
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L8019-L8025 | train |
bem-archive/bem-tools | lib/data/d3.js | d3_geom_polygonIntersect | function d3_geom_polygonIntersect(c, d, a, b) {
var x1 = c[0], x2 = d[0], x3 = a[0], x4 = b[0],
y1 = c[1], y2 = d[1], y3 = a[1], y4 = b[1],
x13 = x1 - x3,
x21 = x2 - x1,
x43 = x4 - x3,
y13 = y1 - y3,
y21 = y2 - y1,
y43 = y4 - y3,
ua = (x43 * y13 - y43 * x13) / (y43 * x2... | javascript | function d3_geom_polygonIntersect(c, d, a, b) {
var x1 = c[0], x2 = d[0], x3 = a[0], x4 = b[0],
y1 = c[1], y2 = d[1], y3 = a[1], y4 = b[1],
x13 = x1 - x3,
x21 = x2 - x1,
x43 = x4 - x3,
y13 = y1 - y3,
y21 = y2 - y1,
y43 = y4 - y3,
ua = (x43 * y13 - y43 * x13) / (y43 * x2... | [
"function",
"d3_geom_polygonIntersect",
"(",
"c",
",",
"d",
",",
"a",
",",
"b",
")",
"{",
"var",
"x1",
"=",
"c",
"[",
"0",
"]",
",",
"x2",
"=",
"d",
"[",
"0",
"]",
",",
"x3",
"=",
"a",
"[",
"0",
"]",
",",
"x4",
"=",
"b",
"[",
"0",
"]",
... | Intersect two infinite lines cd and ab. | [
"Intersect",
"two",
"infinite",
"lines",
"cd",
"and",
"ab",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/data/d3.js#L8102-L8113 | train |
bem-archive/bem-tools | lib/nodes/lib.js | function(o) {
this.__base(o);
this.root = o.root;
this.target = o.target;
this.npmPackages = o.npmPackages === undefined? ['package.json']: o.npmPackages;
} | javascript | function(o) {
this.__base(o);
this.root = o.root;
this.target = o.target;
this.npmPackages = o.npmPackages === undefined? ['package.json']: o.npmPackages;
} | [
"function",
"(",
"o",
")",
"{",
"this",
".",
"__base",
"(",
"o",
")",
";",
"this",
".",
"root",
"=",
"o",
".",
"root",
";",
"this",
".",
"target",
"=",
"o",
".",
"target",
";",
"this",
".",
"npmPackages",
"=",
"o",
".",
"npmPackages",
"===",
"u... | LibraryNode instance constructor.
@class LibraryNode
@constructs
@param {Object} o Node options.
@param {String} o.root Project root path.
@param {String} o.target Library path. | [
"LibraryNode",
"instance",
"constructor",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/lib.js#L38-L43 | train | |
bem-archive/bem-tools | lib/nodes/lib.js | function() {
var _this = this;
return QFS.statLink(this.getPath())
.fail(function() {
return false;
})
.then(function(stat) {
if (!stat) return;
/* jshint -W109 */
if (!stat.isSymbolicLink()) {
... | javascript | function() {
var _this = this;
return QFS.statLink(this.getPath())
.fail(function() {
return false;
})
.then(function(stat) {
if (!stat) return;
/* jshint -W109 */
if (!stat.isSymbolicLink()) {
... | [
"function",
"(",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"return",
"QFS",
".",
"statLink",
"(",
"this",
".",
"getPath",
"(",
")",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"return",
"false",
";",
"}",
")",
".",
"then",
"(",
"function"... | Make node.
@return {Promise * Undefined} | [
"Make",
"node",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/lib.js#L180-L222 | train | |
bem-archive/bem-tools | lib/nodes/lib.js | function(o) {
this.__base(o);
this.url = o.url;
this.paths = [''];
this.timeout = typeof o.timeout !== 'undefined'? Number(o.timeout) : SCM_VALIDITY_TIMEOUT;
} | javascript | function(o) {
this.__base(o);
this.url = o.url;
this.paths = [''];
this.timeout = typeof o.timeout !== 'undefined'? Number(o.timeout) : SCM_VALIDITY_TIMEOUT;
} | [
"function",
"(",
"o",
")",
"{",
"this",
".",
"__base",
"(",
"o",
")",
";",
"this",
".",
"url",
"=",
"o",
".",
"url",
";",
"this",
".",
"paths",
"=",
"[",
"''",
"]",
";",
"this",
".",
"timeout",
"=",
"typeof",
"o",
".",
"timeout",
"!==",
"'und... | ScmLibraryNode instance constructor.
@class ScmLibraryNode
@constructs
@param {Object} o Node options.
@param {String} o.root Project root path.
@param {String} o.target Library path.
@param {String} o.url Repository URL.
@param {String[]} [o.paths=['']] Paths to checkout. | [
"ScmLibraryNode",
"instance",
"constructor",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/lib.js#L247-L252 | train | |
bem-archive/bem-tools | lib/nodes/lib.js | function(o) {
this.__base(o);
this.treeish = o.treeish;
this.branch = o.branch || 'master';
this.origin = o.origin || 'origin';
} | javascript | function(o) {
this.__base(o);
this.treeish = o.treeish;
this.branch = o.branch || 'master';
this.origin = o.origin || 'origin';
} | [
"function",
"(",
"o",
")",
"{",
"this",
".",
"__base",
"(",
"o",
")",
";",
"this",
".",
"treeish",
"=",
"o",
".",
"treeish",
";",
"this",
".",
"branch",
"=",
"o",
".",
"branch",
"||",
"'master'",
";",
"this",
".",
"origin",
"=",
"o",
".",
"orig... | GitLibraryNode instance constructor.
@class GitLibraryNode
@constructs
@param {Object} o Node options.
@param {String} o.root Project root path.
@param {String} o.target Library path.
@param {String} o.url Repository URL.
@param {String[]} [o.paths=['']] Paths to checkout.
@param {String} [o.treeish] ... | [
"GitLibraryNode",
"instance",
"constructor",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/lib.js#L366-L371 | train | |
bem-archive/bem-tools | lib/nodes/lib.js | function(o) {
this.__base(o);
this.paths = Array.isArray(o.paths)? o.paths : [o.paths || ''];
this.revision = o.revision || 'HEAD';
} | javascript | function(o) {
this.__base(o);
this.paths = Array.isArray(o.paths)? o.paths : [o.paths || ''];
this.revision = o.revision || 'HEAD';
} | [
"function",
"(",
"o",
")",
"{",
"this",
".",
"__base",
"(",
"o",
")",
";",
"this",
".",
"paths",
"=",
"Array",
".",
"isArray",
"(",
"o",
".",
"paths",
")",
"?",
"o",
".",
"paths",
":",
"[",
"o",
".",
"paths",
"||",
"''",
"]",
";",
"this",
"... | SvnLibraryNode instance constructor.
@class SvnLibraryNode
@constructs
@param {Object} o Node options.
@param {String} o.root Project root path.
@param {String} o.target Library path.
@param {String} o.url Repository URL.
@param {String[]} [o.paths=['']] Paths to checkout.
@param {String} [o.revision='... | [
"SvnLibraryNode",
"instance",
"constructor",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/lib.js#L474-L478 | train | |
bem-archive/bem-tools | lib/nodes/lib.js | function() {
var _this = this,
base = this.__base();
if (this.revision === 'HEAD') return base;
return Q.all(this.paths.map(function(path) {
return QFS.exists(PATH.resolve(_this.root, _this.target, path))
.then(function(exists) {
... | javascript | function() {
var _this = this,
base = this.__base();
if (this.revision === 'HEAD') return base;
return Q.all(this.paths.map(function(path) {
return QFS.exists(PATH.resolve(_this.root, _this.target, path))
.then(function(exists) {
... | [
"function",
"(",
")",
"{",
"var",
"_this",
"=",
"this",
",",
"base",
"=",
"this",
".",
"__base",
"(",
")",
";",
"if",
"(",
"this",
".",
"revision",
"===",
"'HEAD'",
")",
"return",
"base",
";",
"return",
"Q",
".",
"all",
"(",
"this",
".",
"paths",... | Check validity of node.
Use output of `svn info` to check revision property.
If revision is the same as in config on all paths then
return promised true.
@return {Promise * Boolean} | [
"Check",
"validity",
"of",
"node",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/lib.js#L489-L514 | train | |
bem-archive/bem-tools | lib/level.js | function(path, opts) {
opts = opts || {};
this.dir = PATH.resolve(path.path || path);
this.projectRoot = opts.projectRoot || PATH.resolve('');
// NOTE: keep this.path for backwards compatibility
this.path = this.bemDir = PATH.join(this.dir, '.bem');
path = PATH.relative... | javascript | function(path, opts) {
opts = opts || {};
this.dir = PATH.resolve(path.path || path);
this.projectRoot = opts.projectRoot || PATH.resolve('');
// NOTE: keep this.path for backwards compatibility
this.path = this.bemDir = PATH.join(this.dir, '.bem');
path = PATH.relative... | [
"function",
"(",
"path",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"dir",
"=",
"PATH",
".",
"resolve",
"(",
"path",
".",
"path",
"||",
"path",
")",
";",
"this",
".",
"projectRoot",
"=",
"opts",
".",
"projectRoo... | Construct an instance of Level.
@class Level base class.
@constructs
@param {String | Object} path Level directory path.
@param {Object} [opts] Optional parameters | [
"Construct",
"an",
"instance",
"of",
"Level",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/level.js#L126-L146 | train | |
bem-archive/bem-tools | lib/level.js | function(techIdent, opts) {
if (typeof opts === 'boolean') {
//legacy code used `force` second argument
opts = {force: opts};
}
opts = opts || {};
if(bemUtil.isPath(techIdent)) {
return this.resolveTechPath(techIdent);
}
if(!opts.force ... | javascript | function(techIdent, opts) {
if (typeof opts === 'boolean') {
//legacy code used `force` second argument
opts = {force: opts};
}
opts = opts || {};
if(bemUtil.isPath(techIdent)) {
return this.resolveTechPath(techIdent);
}
if(!opts.force ... | [
"function",
"(",
"techIdent",
",",
"opts",
")",
"{",
"if",
"(",
"typeof",
"opts",
"===",
"'boolean'",
")",
"{",
"//legacy code used `force` second argument",
"opts",
"=",
"{",
"force",
":",
"opts",
"}",
";",
"}",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",... | Resolve tech identifier into tech module path.
@param {String} techIdent Tech identifier.
@param {Object|Boolean} [opts] Options to use during resolution. If boolean value
is passed, it gets used as `options.force` for backward compatibility.
@param {Boolean} [opts.force=false] Flag to not use tech name resolution.
... | [
"Resolve",
"tech",
"identifier",
"into",
"tech",
"module",
"path",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/level.js#L221-L234 | train | |
bem-archive/bem-tools | lib/level.js | function(techName) {
var p = this.getTechs()[techName];
return typeof p !== 'undefined'? this.resolveTech(p, {force: true}) : null;
} | javascript | function(techName) {
var p = this.getTechs()[techName];
return typeof p !== 'undefined'? this.resolveTech(p, {force: true}) : null;
} | [
"function",
"(",
"techName",
")",
"{",
"var",
"p",
"=",
"this",
".",
"getTechs",
"(",
")",
"[",
"techName",
"]",
";",
"return",
"typeof",
"p",
"!==",
"'undefined'",
"?",
"this",
".",
"resolveTech",
"(",
"p",
",",
"{",
"force",
":",
"true",
"}",
")"... | Resolve tech name into tech module path.
@param {String} techName Tech name.
@return {String} Tech module path. | [
"Resolve",
"tech",
"name",
"into",
"tech",
"module",
"path",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/level.js#L242-L245 | train | |
bem-archive/bem-tools | lib/level.js | function(techPath) {
// Get absolute path if path starts with "."
// NOTE: Can not replace check to !isAbsolute()
if(techPath.substring(0, 1) === '.') {
// Resolve relative path starting at level `.bem/` directory
techPath = PATH.join(this.bemDir, techPath);
... | javascript | function(techPath) {
// Get absolute path if path starts with "."
// NOTE: Can not replace check to !isAbsolute()
if(techPath.substring(0, 1) === '.') {
// Resolve relative path starting at level `.bem/` directory
techPath = PATH.join(this.bemDir, techPath);
... | [
"function",
"(",
"techPath",
")",
"{",
"// Get absolute path if path starts with \".\"",
"// NOTE: Can not replace check to !isAbsolute()",
"if",
"(",
"techPath",
".",
"substring",
"(",
"0",
",",
"1",
")",
"===",
"'.'",
")",
"{",
"// Resolve relative path starting at level ... | Resolve tech module path.
@throws {Error} In case when tech module is not found.
@param {String} techPath Tech path (relative or absolute).
@return {String} Tech module path. | [
"Resolve",
"tech",
"module",
"path",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/level.js#L254-L283 | train | |
bem-archive/bem-tools | lib/level.js | function(item) {
var getter, args;
if (item.block) {
getter = 'block';
args = [item.block];
if (item.elem) {
getter = 'elem';
args.push(item.elem);
}
if (item.mod) {
getter += '-mod';
... | javascript | function(item) {
var getter, args;
if (item.block) {
getter = 'block';
args = [item.block];
if (item.elem) {
getter = 'elem';
args.push(item.elem);
}
if (item.mod) {
getter += '-mod';
... | [
"function",
"(",
"item",
")",
"{",
"var",
"getter",
",",
"args",
";",
"if",
"(",
"item",
".",
"block",
")",
"{",
"getter",
"=",
"'block'",
";",
"args",
"=",
"[",
"item",
".",
"block",
"]",
";",
"if",
"(",
"item",
".",
"elem",
")",
"{",
"getter"... | Get relative to level directory path prefix on the filesystem
to specified BEM entity described as an object with special
properties.
@param {Object} item BEM entity object.
@param {String} item.block Block name.
@param {String} item.elem Element name.
@param {String} item.mod Modifier name.
@param {String} ite... | [
"Get",
"relative",
"to",
"level",
"directory",
"path",
"prefix",
"on",
"the",
"filesystem",
"to",
"specified",
"BEM",
"entity",
"described",
"as",
"an",
"object",
"with",
"special",
"properties",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/level.js#L455-L475 | train | |
bem-archive/bem-tools | lib/level.js | function(block, mod) {
return PATH.join.apply(null,
[block,
'_' + mod,
block + '_' + mod]);
} | javascript | function(block, mod) {
return PATH.join.apply(null,
[block,
'_' + mod,
block + '_' + mod]);
} | [
"function",
"(",
"block",
",",
"mod",
")",
"{",
"return",
"PATH",
".",
"join",
".",
"apply",
"(",
"null",
",",
"[",
"block",
",",
"'_'",
"+",
"mod",
",",
"block",
"+",
"'_'",
"+",
"mod",
"]",
")",
";",
"}"
] | Get relative path prefix for block modifier.
@param {String} block Block name.
@param {String} mod Modifier name.
@return {String} Path prefix. | [
"Get",
"relative",
"path",
"prefix",
"for",
"block",
"modifier",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/level.js#L519-L524 | train | |
bem-archive/bem-tools | lib/level.js | function(path) {
if (PATH.isAbsolute(path)) path = PATH.relative(this.dir, path);
var matchTechs = this.matchTechsOrder().map(function(t) {
return this.getTech(t);
}, this);
return this.matchOrder().reduce(function(match, matcher) {
// Skip if already m... | javascript | function(path) {
if (PATH.isAbsolute(path)) path = PATH.relative(this.dir, path);
var matchTechs = this.matchTechsOrder().map(function(t) {
return this.getTech(t);
}, this);
return this.matchOrder().reduce(function(match, matcher) {
// Skip if already m... | [
"function",
"(",
"path",
")",
"{",
"if",
"(",
"PATH",
".",
"isAbsolute",
"(",
"path",
")",
")",
"path",
"=",
"PATH",
".",
"relative",
"(",
"this",
".",
"dir",
",",
"path",
")",
";",
"var",
"matchTechs",
"=",
"this",
".",
"matchTechsOrder",
"(",
")"... | Match path against all matchers and return first match.
Match object will contain `block`, `suffix` and `tech` fields
and can also contain any of the `elem`, `mod` and `val` fields
or all of them.
@param {String} path Path to match (absolute or relative).
@return {Boolean|Object} BEM entity object in case of positi... | [
"Match",
"path",
"against",
"all",
"matchers",
"and",
"return",
"first",
"match",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/level.js#L628-L655 | train | |
bem-archive/bem-tools | lib/level.js | function(blockName) {
// TODO: support any custom naming scheme, e.g. flat, when there are
// no directories for blocks
var decl = this.getDeclByIntrospection(PATH.dirname(this.get('block', [blockName])));
return decl.length? decl.shift() : {};
} | javascript | function(blockName) {
// TODO: support any custom naming scheme, e.g. flat, when there are
// no directories for blocks
var decl = this.getDeclByIntrospection(PATH.dirname(this.get('block', [blockName])));
return decl.length? decl.shift() : {};
} | [
"function",
"(",
"blockName",
")",
"{",
"// TODO: support any custom naming scheme, e.g. flat, when there are",
"// no directories for blocks",
"var",
"decl",
"=",
"this",
".",
"getDeclByIntrospection",
"(",
"PATH",
".",
"dirname",
"(",
"this",
".",
"get",
"(",
"'block'",... | Get declaration for block.
@param {String} blockName Block name to get declaration for.
@return {Object} Block declaration object. | [
"Get",
"declaration",
"for",
"block",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/level.js#L887-L892 | train | |
bem-archive/bem-tools | lib/level.js | function(from) {
this._declIntrospector || (this._declIntrospector = this.createIntrospector({
creator: function(res, match) {
if (match && match.tech) {
return this._mergeMatchToDecl(match, res);
}
return res;
}
... | javascript | function(from) {
this._declIntrospector || (this._declIntrospector = this.createIntrospector({
creator: function(res, match) {
if (match && match.tech) {
return this._mergeMatchToDecl(match, res);
}
return res;
}
... | [
"function",
"(",
"from",
")",
"{",
"this",
".",
"_declIntrospector",
"||",
"(",
"this",
".",
"_declIntrospector",
"=",
"this",
".",
"createIntrospector",
"(",
"{",
"creator",
":",
"function",
"(",
"res",
",",
"match",
")",
"{",
"if",
"(",
"match",
"&&",
... | Get declaration of level directory or one of its subdirectories.
@param {String} [from] Relative path to subdirectory of level directory to start introspection from.
@return {Array} Array of declaration. | [
"Get",
"declaration",
"of",
"level",
"directory",
"or",
"one",
"of",
"its",
"subdirectories",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/level.js#L900-L914 | train | |
bem-archive/bem-tools | lib/level.js | function(opts) {
var level = this;
if (!opts) opts = {
opts: false
};
// clone opts
opts = bemUtil.extend({}, opts);
// set default options
opts.from || (opts.from = '.');
// initial value initializer
opts.init || (opts.init = func... | javascript | function(opts) {
var level = this;
if (!opts) opts = {
opts: false
};
// clone opts
opts = bemUtil.extend({}, opts);
// set default options
opts.from || (opts.from = '.');
// initial value initializer
opts.init || (opts.init = func... | [
"function",
"(",
"opts",
")",
"{",
"var",
"level",
"=",
"this",
";",
"if",
"(",
"!",
"opts",
")",
"opts",
"=",
"{",
"opts",
":",
"false",
"}",
";",
"// clone opts",
"opts",
"=",
"bemUtil",
".",
"extend",
"(",
"{",
"}",
",",
"opts",
")",
";",
"/... | Creates preconfigured introspection functions.
@param {Object} [opts] Introspector options.
@param {String} [opts.from] Relative path to subdirectory of level directory to start introspection from.
@param {Function} [opts.init] Function to return initial value of introspection.
@param {Function} [opts.filter] Func... | [
"Creates",
"preconfigured",
"introspection",
"functions",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/level.js#L1239-L1301 | train | |
bem-archive/bem-tools | lib/techs/v2/project.js | function(path, opts) {
var bemDir = PATH.join(path, '.bem'),
levels = PATH.join(bemDir, 'levels'),
// .bem/levels/create blocks.js level prototype
blocks = this.createLevel({
forceTech: ['examples', 'tech-docs'],
outputDir: levels,
... | javascript | function(path, opts) {
var bemDir = PATH.join(path, '.bem'),
levels = PATH.join(bemDir, 'levels'),
// .bem/levels/create blocks.js level prototype
blocks = this.createLevel({
forceTech: ['examples', 'tech-docs'],
outputDir: levels,
... | [
"function",
"(",
"path",
",",
"opts",
")",
"{",
"var",
"bemDir",
"=",
"PATH",
".",
"join",
"(",
"path",
",",
"'.bem'",
")",
",",
"levels",
"=",
"PATH",
".",
"join",
"(",
"bemDir",
",",
"'levels'",
")",
",",
"// .bem/levels/create blocks.js level prototype"... | Create the following project structure
.bem/
levels/
blocks.js
bundles.js
docs.js
examplex.js
tech-docs.js
techs/
level.js
node_modules/
@param {String} path Absolute path to the project directory
@param {Object} opts Options to the `bem create` command
@return {Promise * Undefined} | [
"Create",
"the",
"following",
"project",
"structure"
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/techs/v2/project.js#L45-L100 | train | |
bem-archive/bem-tools | lib/nodes/build.js | function() {
return Q.all(this.tech
.getPaths(PATH.resolve(this.root, this.output), this.tech.getBuildSuffixes())
.map(function(path) {
return QFS.lastModified(path)
.fail(function() {
return -1;
});
... | javascript | function() {
return Q.all(this.tech
.getPaths(PATH.resolve(this.root, this.output), this.tech.getBuildSuffixes())
.map(function(path) {
return QFS.lastModified(path)
.fail(function() {
return -1;
});
... | [
"function",
"(",
")",
"{",
"return",
"Q",
".",
"all",
"(",
"this",
".",
"tech",
".",
"getPaths",
"(",
"PATH",
".",
"resolve",
"(",
"this",
".",
"root",
",",
"this",
".",
"output",
")",
",",
"this",
".",
"tech",
".",
"getBuildSuffixes",
"(",
")",
... | Get files minimum mtime in milliseconds or -1 in case of any file doesn't exist.
@return {Promise * Number} | [
"Get",
"files",
"minimum",
"mtime",
"in",
"milliseconds",
"or",
"-",
"1",
"in",
"case",
"of",
"any",
"file",
"doesn",
"t",
"exist",
"."
] | c3a167e86deb7c5e178c18244f3190dfda101f90 | https://github.com/bem-archive/bem-tools/blob/c3a167e86deb7c5e178c18244f3190dfda101f90/lib/nodes/build.js#L250-L264 | train | |
nodeca/embedza | lib/domains/vimeo.com.js | vimeo_fetcher | async function vimeo_fetcher(env) {
tpl.query.url = env.src;
let response;
try {
response = await env.self.request(url.format(tpl));
} catch (err) {
if (err.statusCode) {
throw new EmbedzaError(
`Vimeo fetcher: Bad response code: ${err.statusCode}`,
... | javascript | async function vimeo_fetcher(env) {
tpl.query.url = env.src;
let response;
try {
response = await env.self.request(url.format(tpl));
} catch (err) {
if (err.statusCode) {
throw new EmbedzaError(
`Vimeo fetcher: Bad response code: ${err.statusCode}`,
... | [
"async",
"function",
"vimeo_fetcher",
"(",
"env",
")",
"{",
"tpl",
".",
"query",
".",
"url",
"=",
"env",
".",
"src",
";",
"let",
"response",
";",
"try",
"{",
"response",
"=",
"await",
"env",
".",
"self",
".",
"request",
"(",
"url",
".",
"format",
"... | Add a custom fetcher that retrieves only oembed data using a hardcoded endpoint. The reason being that we have quite a lot of vimeo videos, and fetching html page for each of them triggers a temporary 1-day ip+user-agent ban with 429 status code. This way fetcher misses out on favicon and flashplayer urls, but this d... | [
"Add",
"a",
"custom",
"fetcher",
"that",
"retrieves",
"only",
"oembed",
"data",
"using",
"a",
"hardcoded",
"endpoint",
".",
"The",
"reason",
"being",
"that",
"we",
"have",
"quite",
"a",
"lot",
"of",
"vimeo",
"videos",
"and",
"fetching",
"html",
"page",
"fo... | e2b127cba4f655513cdc5254deef8ee125273da8 | https://github.com/nodeca/embedza/blob/e2b127cba4f655513cdc5254deef8ee125273da8/lib/domains/vimeo.com.js#L37-L70 | train |
nodeca/embedza | lib/utils/index.js | findMeta | function findMeta(meta, names) {
if (!meta) return null;
if (!_.isArray(names)) names = [ names ];
let record;
names.some((name) => {
record = _.find(meta, (item) => item.name === name);
return record;
});
return (record || {}).value;
} | javascript | function findMeta(meta, names) {
if (!meta) return null;
if (!_.isArray(names)) names = [ names ];
let record;
names.some((name) => {
record = _.find(meta, (item) => item.name === name);
return record;
});
return (record || {}).value;
} | [
"function",
"findMeta",
"(",
"meta",
",",
"names",
")",
"{",
"if",
"(",
"!",
"meta",
")",
"return",
"null",
";",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"names",
")",
")",
"names",
"=",
"[",
"names",
"]",
";",
"let",
"record",
";",
"names",
"... | Get meta value by list of names in priority order | [
"Get",
"meta",
"value",
"by",
"list",
"of",
"names",
"in",
"priority",
"order"
] | e2b127cba4f655513cdc5254deef8ee125273da8 | https://github.com/nodeca/embedza/blob/e2b127cba4f655513cdc5254deef8ee125273da8/lib/utils/index.js#L11-L24 | train |
nodeca/embedza | lib/utils/index.js | wlCheck | function wlCheck(wl, record, value) {
if (!value) value = 'allow';
let wlItem = _.get(wl, record);
if (_.isArray(wlItem)) return wlItem.indexOf(value) !== -1;
return wlItem === value;
} | javascript | function wlCheck(wl, record, value) {
if (!value) value = 'allow';
let wlItem = _.get(wl, record);
if (_.isArray(wlItem)) return wlItem.indexOf(value) !== -1;
return wlItem === value;
} | [
"function",
"wlCheck",
"(",
"wl",
",",
"record",
",",
"value",
")",
"{",
"if",
"(",
"!",
"value",
")",
"value",
"=",
"'allow'",
";",
"let",
"wlItem",
"=",
"_",
".",
"get",
"(",
"wl",
",",
"record",
")",
";",
"if",
"(",
"_",
".",
"isArray",
"(",... | Check record allowed in whitelist | [
"Check",
"record",
"allowed",
"in",
"whitelist"
] | e2b127cba4f655513cdc5254deef8ee125273da8 | https://github.com/nodeca/embedza/blob/e2b127cba4f655513cdc5254deef8ee125273da8/lib/utils/index.js#L84-L92 | train |
mozilla-jetpack/jpm | lib/rdf.js | createUpdateRDF | function createUpdateRDF(manifest) {
var header = [{
name: "RDF",
attrs: {
"xmlns": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"xmlns:em": "http://www.mozilla.org/2004/em-rdf#"
},
children: []
}];
var description = {
name: "Description",
attrs: {
"about": "urn:mozilla... | javascript | function createUpdateRDF(manifest) {
var header = [{
name: "RDF",
attrs: {
"xmlns": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"xmlns:em": "http://www.mozilla.org/2004/em-rdf#"
},
children: []
}];
var description = {
name: "Description",
attrs: {
"about": "urn:mozilla... | [
"function",
"createUpdateRDF",
"(",
"manifest",
")",
"{",
"var",
"header",
"=",
"[",
"{",
"name",
":",
"\"RDF\"",
",",
"attrs",
":",
"{",
"\"xmlns\"",
":",
"\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"",
",",
"\"xmlns:em\"",
":",
"\"http://www.mozilla.org/2004/em-r... | Creates an `update.rdf` file based off of an addon's `package.json`
object manifest. Returns a string of the composed RDF file.
@param {Object} manifest
@return {String} | [
"Creates",
"an",
"update",
".",
"rdf",
"file",
"based",
"off",
"of",
"an",
"addon",
"s",
"package",
".",
"json",
"object",
"manifest",
".",
"Returns",
"a",
"string",
"of",
"the",
"composed",
"RDF",
"file",
"."
] | 5e671fc7745fbf08b373557e40eac6cc74cc65d3 | https://github.com/mozilla-jetpack/jpm/blob/5e671fc7745fbf08b373557e40eac6cc74cc65d3/lib/rdf.js#L200-L272 | train |
mozilla-jetpack/jpm | lib/zip.js | filter | function filter(options, includes, root, filepath, stat) {
var paths = path.relative(root, filepath).split(path.sep);
// always include test/tests directory when running jpm test
if (options.command === "test") {
if (/^tests?$/.test(paths[0])) {
if (paths.length === 1 && stat.isDirectory()) {
re... | javascript | function filter(options, includes, root, filepath, stat) {
var paths = path.relative(root, filepath).split(path.sep);
// always include test/tests directory when running jpm test
if (options.command === "test") {
if (/^tests?$/.test(paths[0])) {
if (paths.length === 1 && stat.isDirectory()) {
re... | [
"function",
"filter",
"(",
"options",
",",
"includes",
",",
"root",
",",
"filepath",
",",
"stat",
")",
"{",
"var",
"paths",
"=",
"path",
".",
"relative",
"(",
"root",
",",
"filepath",
")",
".",
"split",
"(",
"path",
".",
"sep",
")",
";",
"// always i... | Filter for deciding what is included in a xpi based on a list of included files | [
"Filter",
"for",
"deciding",
"what",
"is",
"included",
"in",
"a",
"xpi",
"based",
"on",
"a",
"list",
"of",
"included",
"files"
] | 5e671fc7745fbf08b373557e40eac6cc74cc65d3 | https://github.com/mozilla-jetpack/jpm/blob/5e671fc7745fbf08b373557e40eac6cc74cc65d3/lib/zip.js#L52-L66 | train |
mozilla-jetpack/jpm | lib/ignore.js | ignore | function ignore(dir, options) {
var jpmignore = path.join(dir, ".jpmignore");
var defaultRules = ["*.zip", ".*", "test/", ".jpmignore", "*.xpi"];
return utils.getManifest({addonDir: options.addonDir})
.then(function(manifest) {
return fs.exists(jpmignore);
})
.then(function(exists) {
if (... | javascript | function ignore(dir, options) {
var jpmignore = path.join(dir, ".jpmignore");
var defaultRules = ["*.zip", ".*", "test/", ".jpmignore", "*.xpi"];
return utils.getManifest({addonDir: options.addonDir})
.then(function(manifest) {
return fs.exists(jpmignore);
})
.then(function(exists) {
if (... | [
"function",
"ignore",
"(",
"dir",
",",
"options",
")",
"{",
"var",
"jpmignore",
"=",
"path",
".",
"join",
"(",
"dir",
",",
"\".jpmignore\"",
")",
";",
"var",
"defaultRules",
"=",
"[",
"\"*.zip\"",
",",
"\".*\"",
",",
"\"test/\"",
",",
"\".jpmignore\"",
"... | Look for .jpmignore in the given directory and use it to filter files
and sub-directories fallback to use default filter rules if .jpmignore
doesn't exist.
@param {String} dir
@param {Object} options
@return {Promise} | [
"Look",
"for",
".",
"jpmignore",
"in",
"the",
"given",
"directory",
"and",
"use",
"it",
"to",
"filter",
"files",
"and",
"sub",
"-",
"directories",
"fallback",
"to",
"use",
"default",
"filter",
"rules",
"if",
".",
"jpmignore",
"doesn",
"t",
"exist",
"."
] | 5e671fc7745fbf08b373557e40eac6cc74cc65d3 | https://github.com/mozilla-jetpack/jpm/blob/5e671fc7745fbf08b373557e40eac6cc74cc65d3/lib/ignore.js#L22-L83 | train |
mozilla-jetpack/jpm | lib/ignore.js | listdir | function listdir(dir, rules, root, included) {
return fs.readdir(dir)
.then(function(files) {
return when.all(files.map(function(f) {
f = path.join(dir, f);
return when(fs.stat(f), function(stat) {
return {
path: f,
isDirectory: stat.isDirectory()
};
});
... | javascript | function listdir(dir, rules, root, included) {
return fs.readdir(dir)
.then(function(files) {
return when.all(files.map(function(f) {
f = path.join(dir, f);
return when(fs.stat(f), function(stat) {
return {
path: f,
isDirectory: stat.isDirectory()
};
});
... | [
"function",
"listdir",
"(",
"dir",
",",
"rules",
",",
"root",
",",
"included",
")",
"{",
"return",
"fs",
".",
"readdir",
"(",
"dir",
")",
".",
"then",
"(",
"function",
"(",
"files",
")",
"{",
"return",
"when",
".",
"all",
"(",
"files",
".",
"map",
... | filter a dir based on filter rules
@param {String} dir
@param {Array} rules
@param {Array} root
@param {Boolean} included
@return {Promise} | [
"filter",
"a",
"dir",
"based",
"on",
"filter",
"rules"
] | 5e671fc7745fbf08b373557e40eac6cc74cc65d3 | https://github.com/mozilla-jetpack/jpm/blob/5e671fc7745fbf08b373557e40eac6cc74cc65d3/lib/ignore.js#L95-L135 | train |
mozilla-jetpack/jpm | lib/ignore.js | filter | function filter(p, rules, root, isDirectory, included) {
p = path.relative(root, p);
for (var i in rules) {
var rule = rules[i];
if (isDirectory) {
if (rule.match(p) || rule.match("/" + p) ||
rule.match(p + "/") || rule.match("/" + p + "/")
) {
return rule.negate;
}
... | javascript | function filter(p, rules, root, isDirectory, included) {
p = path.relative(root, p);
for (var i in rules) {
var rule = rules[i];
if (isDirectory) {
if (rule.match(p) || rule.match("/" + p) ||
rule.match(p + "/") || rule.match("/" + p + "/")
) {
return rule.negate;
}
... | [
"function",
"filter",
"(",
"p",
",",
"rules",
",",
"root",
",",
"isDirectory",
",",
"included",
")",
"{",
"p",
"=",
"path",
".",
"relative",
"(",
"root",
",",
"p",
")",
";",
"for",
"(",
"var",
"i",
"in",
"rules",
")",
"{",
"var",
"rule",
"=",
"... | check if a given file or dir should be kept
@param {String} p
@param {Array} rules
@param {String} root
@param {Boolean} isDirectory
@param {Boolean} included
@return {Boolean} | [
"check",
"if",
"a",
"given",
"file",
"or",
"dir",
"should",
"be",
"kept"
] | 5e671fc7745fbf08b373557e40eac6cc74cc65d3 | https://github.com/mozilla-jetpack/jpm/blob/5e671fc7745fbf08b373557e40eac6cc74cc65d3/lib/ignore.js#L147-L164 | train |
mozilla-jetpack/jpm | lib/utils.js | log | function log(type) {
var messages = Array.prototype.slice.call(arguments);
messages.shift();
// Concatenate default strings and first message argument into
// one string so we can use `printf`-like replacement
var first = "JPM [" + type + "] " + (messages.shift() + "");
if (process.env.NODE_ENV !== "test")... | javascript | function log(type) {
var messages = Array.prototype.slice.call(arguments);
messages.shift();
// Concatenate default strings and first message argument into
// one string so we can use `printf`-like replacement
var first = "JPM [" + type + "] " + (messages.shift() + "");
if (process.env.NODE_ENV !== "test")... | [
"function",
"log",
"(",
"type",
")",
"{",
"var",
"messages",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"messages",
".",
"shift",
"(",
")",
";",
"// Concatenate default strings and first message argument into",
"// one... | Exports a `console` object that has several methods
similar to a traditional console like `log`, `warn`, `error`,
and `verbose`, which feed through a simple logging messenger.
@param {String} type
@param {String} messages... | [
"Exports",
"a",
"console",
"object",
"that",
"has",
"several",
"methods",
"similar",
"to",
"a",
"traditional",
"console",
"like",
"log",
"warn",
"error",
"and",
"verbose",
"which",
"feed",
"through",
"a",
"simple",
"logging",
"messenger",
"."
] | 5e671fc7745fbf08b373557e40eac6cc74cc65d3 | https://github.com/mozilla-jetpack/jpm/blob/5e671fc7745fbf08b373557e40eac6cc74cc65d3/lib/utils.js#L24-L34 | train |
mozilla-jetpack/jpm | lib/utils.js | getManifest | function getManifest(options) {
options = _.assign({
addonDir: process.cwd(),
xpiPath: null
}, options);
return when.promise(function(resolve, reject) {
if (options.xpiPath) {
return getXpiInfo(options.xpiPath)
.then(function(xpiInfo) {
resolve(xpiInfo.manifest);
})
... | javascript | function getManifest(options) {
options = _.assign({
addonDir: process.cwd(),
xpiPath: null
}, options);
return when.promise(function(resolve, reject) {
if (options.xpiPath) {
return getXpiInfo(options.xpiPath)
.then(function(xpiInfo) {
resolve(xpiInfo.manifest);
})
... | [
"function",
"getManifest",
"(",
"options",
")",
"{",
"options",
"=",
"_",
".",
"assign",
"(",
"{",
"addonDir",
":",
"process",
".",
"cwd",
"(",
")",
",",
"xpiPath",
":",
"null",
"}",
",",
"options",
")",
";",
"return",
"when",
".",
"promise",
"(",
... | Returns the `package.json` manifest as an object
from the `cwd`, or `null` if not found.
If you pass in an optional XPI filename, the manifest will be returned
from this directory after a temporary XPI extraction.
@param {Object} options
- `addonDir` directory of the add-on source code, defaulting
to the working direc... | [
"Returns",
"the",
"package",
".",
"json",
"manifest",
"as",
"an",
"object",
"from",
"the",
"cwd",
"or",
"null",
"if",
"not",
"found",
".",
"If",
"you",
"pass",
"in",
"an",
"optional",
"XPI",
"filename",
"the",
"manifest",
"will",
"be",
"returned",
"from"... | 5e671fc7745fbf08b373557e40eac6cc74cc65d3 | https://github.com/mozilla-jetpack/jpm/blob/5e671fc7745fbf08b373557e40eac6cc74cc65d3/lib/utils.js#L59-L81 | train |
mozilla-jetpack/jpm | lib/utils.js | getXpiInfo | function getXpiInfo(xpiPath) {
return extractXPI(xpiPath)
.then(function(tmpXPI) {
var getInfo;
var packageFile = path.join(tmpXPI.path, "package.json");
var installRdfFile = path.join(tmpXPI.path, "install.rdf");
if (fileExists(packageFile)) {
getInfo = getXpiInfoFromManifest(req... | javascript | function getXpiInfo(xpiPath) {
return extractXPI(xpiPath)
.then(function(tmpXPI) {
var getInfo;
var packageFile = path.join(tmpXPI.path, "package.json");
var installRdfFile = path.join(tmpXPI.path, "install.rdf");
if (fileExists(packageFile)) {
getInfo = getXpiInfoFromManifest(req... | [
"function",
"getXpiInfo",
"(",
"xpiPath",
")",
"{",
"return",
"extractXPI",
"(",
"xpiPath",
")",
".",
"then",
"(",
"function",
"(",
"tmpXPI",
")",
"{",
"var",
"getInfo",
";",
"var",
"packageFile",
"=",
"path",
".",
"join",
"(",
"tmpXPI",
".",
"path",
"... | Returns a promise that resolves with an info object about an XPI file.
@param {String} xpiPath - path to the XPI file
@return {Object} xpiInfo
- manifest: manifest object, which might be empty.
- id: GUID of the XPI.
- version: version string for the XPI. | [
"Returns",
"a",
"promise",
"that",
"resolves",
"with",
"an",
"info",
"object",
"about",
"an",
"XPI",
"file",
"."
] | 5e671fc7745fbf08b373557e40eac6cc74cc65d3 | https://github.com/mozilla-jetpack/jpm/blob/5e671fc7745fbf08b373557e40eac6cc74cc65d3/lib/utils.js#L102-L133 | train |
mozilla-jetpack/jpm | lib/profile.js | addPrefs | function addPrefs(profile, options) {
var userPrefs = options.prefs || {};
return when.promise(function(resolve, reject) {
Object.keys(userPrefs).forEach(function(key) {
profile.setPreference(key, userPrefs[key]);
});
profile.updatePreferences();
resolve(profile);
});
} | javascript | function addPrefs(profile, options) {
var userPrefs = options.prefs || {};
return when.promise(function(resolve, reject) {
Object.keys(userPrefs).forEach(function(key) {
profile.setPreference(key, userPrefs[key]);
});
profile.updatePreferences();
resolve(profile);
});
} | [
"function",
"addPrefs",
"(",
"profile",
",",
"options",
")",
"{",
"var",
"userPrefs",
"=",
"options",
".",
"prefs",
"||",
"{",
"}",
";",
"return",
"when",
".",
"promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"Object",
".",
"keys",
... | Set any of the preferences passed via options. | [
"Set",
"any",
"of",
"the",
"preferences",
"passed",
"via",
"options",
"."
] | 5e671fc7745fbf08b373557e40eac6cc74cc65d3 | https://github.com/mozilla-jetpack/jpm/blob/5e671fc7745fbf08b373557e40eac6cc74cc65d3/lib/profile.js#L39-L49 | train |
tgriesser/checkit | core.js | Checkit | function Checkit(validations, options) {
if (!(this instanceof Checkit)) {
return new Checkit(validations, options);
}
this.conditional = [];
options = _.clone(options || {});
this.labels = options.labels || {};
this.messages = options.messages || {};
this.language ... | javascript | function Checkit(validations, options) {
if (!(this instanceof Checkit)) {
return new Checkit(validations, options);
}
this.conditional = [];
options = _.clone(options || {});
this.labels = options.labels || {};
this.messages = options.messages || {};
this.language ... | [
"function",
"Checkit",
"(",
"validations",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Checkit",
")",
")",
"{",
"return",
"new",
"Checkit",
"(",
"validations",
",",
"options",
")",
";",
"}",
"this",
".",
"conditional",
"=",
"[... | The top level `Checkit` constructor, accepting the `validations` to be run and any additional `options`. | [
"The",
"top",
"level",
"Checkit",
"constructor",
"accepting",
"the",
"validations",
"to",
"be",
"run",
"and",
"any",
"additional",
"options",
"."
] | 7938418df789653cf9dcdee9c71ca59074dfba3f | https://github.com/tgriesser/checkit/blob/7938418df789653cf9dcdee9c71ca59074dfba3f/core.js#L11-L22 | train |
tgriesser/checkit | core.js | checkSync | function checkSync(validations, input, key) {
var arr = new Checkit(validations).runSync(input);
if (arr[0] === null) return arr;
if (arr[0] instanceof CheckitError) {
return [arr[0].get(key), null]
}
return arr;
} | javascript | function checkSync(validations, input, key) {
var arr = new Checkit(validations).runSync(input);
if (arr[0] === null) return arr;
if (arr[0] instanceof CheckitError) {
return [arr[0].get(key), null]
}
return arr;
} | [
"function",
"checkSync",
"(",
"validations",
",",
"input",
",",
"key",
")",
"{",
"var",
"arr",
"=",
"new",
"Checkit",
"(",
"validations",
")",
".",
"runSync",
"(",
"input",
")",
";",
"if",
"(",
"arr",
"[",
"0",
"]",
"===",
"null",
")",
"return",
"a... | Synchronously check an individual field against a rule. | [
"Synchronously",
"check",
"an",
"individual",
"field",
"against",
"a",
"rule",
"."
] | 7938418df789653cf9dcdee9c71ca59074dfba3f | https://github.com/tgriesser/checkit/blob/7938418df789653cf9dcdee9c71ca59074dfba3f/core.js#L106-L113 | train |
tgriesser/checkit | core.js | Runner | function Runner(checkit, target, context) {
this.errors = {};
this.checkit = checkit;
this.conditional = checkit.conditional;
this.target = _.clone(target || {})
this.context = _.clone(context || {})
this.validator = new Validator(this.target, checkit.language)
} | javascript | function Runner(checkit, target, context) {
this.errors = {};
this.checkit = checkit;
this.conditional = checkit.conditional;
this.target = _.clone(target || {})
this.context = _.clone(context || {})
this.validator = new Validator(this.target, checkit.language)
} | [
"function",
"Runner",
"(",
"checkit",
",",
"target",
",",
"context",
")",
"{",
"this",
".",
"errors",
"=",
"{",
"}",
";",
"this",
".",
"checkit",
"=",
"checkit",
";",
"this",
".",
"conditional",
"=",
"checkit",
".",
"conditional",
";",
"this",
".",
"... | The validator is the object which is dispatched with the `run` call from the `checkit.run` method. | [
"The",
"validator",
"is",
"the",
"object",
"which",
"is",
"dispatched",
"with",
"the",
"run",
"call",
"from",
"the",
"checkit",
".",
"run",
"method",
"."
] | 7938418df789653cf9dcdee9c71ca59074dfba3f | https://github.com/tgriesser/checkit/blob/7938418df789653cf9dcdee9c71ca59074dfba3f/core.js#L117-L124 | train |
tgriesser/checkit | core.js | addVerifiedConditional | function addVerifiedConditional(validations, conditional) {
_.each(conditional[0], function(val, key) {
validations[key] = validations[key] || [];
validations[key] = validations[key].concat(val);
})
} | javascript | function addVerifiedConditional(validations, conditional) {
_.each(conditional[0], function(val, key) {
validations[key] = validations[key] || [];
validations[key] = validations[key].concat(val);
})
} | [
"function",
"addVerifiedConditional",
"(",
"validations",
",",
"conditional",
")",
"{",
"_",
".",
"each",
"(",
"conditional",
"[",
"0",
"]",
",",
"function",
"(",
"val",
",",
"key",
")",
"{",
"validations",
"[",
"key",
"]",
"=",
"validations",
"[",
"key"... | Only if we explicitly return `true` do we go ahead and add the validations to the stack for a particular rule. | [
"Only",
"if",
"we",
"explicitly",
"return",
"true",
"do",
"we",
"go",
"ahead",
"and",
"add",
"the",
"validations",
"to",
"the",
"stack",
"for",
"a",
"particular",
"rule",
"."
] | 7938418df789653cf9dcdee9c71ca59074dfba3f | https://github.com/tgriesser/checkit/blob/7938418df789653cf9dcdee9c71ca59074dfba3f/core.js#L166-L171 | train |
tgriesser/checkit | core.js | checkConditional | function checkConditional(runner, conditional) {
try {
return conditional[1].call(runner, runner.target, runner.context);
} catch (e) {}
} | javascript | function checkConditional(runner, conditional) {
try {
return conditional[1].call(runner, runner.target, runner.context);
} catch (e) {}
} | [
"function",
"checkConditional",
"(",
"runner",
",",
"conditional",
")",
"{",
"try",
"{",
"return",
"conditional",
"[",
"1",
"]",
".",
"call",
"(",
"runner",
",",
"runner",
".",
"target",
",",
"runner",
".",
"context",
")",
";",
"}",
"catch",
"(",
"e",
... | Runs through each of the `conditional` validations, and merges them with the other validations if the condition passes; either by returning `true` or a fulfilled promise. | [
"Runs",
"through",
"each",
"of",
"the",
"conditional",
"validations",
"and",
"merges",
"them",
"with",
"the",
"other",
"validations",
"if",
"the",
"condition",
"passes",
";",
"either",
"by",
"returning",
"true",
"or",
"a",
"fulfilled",
"promise",
"."
] | 7938418df789653cf9dcdee9c71ca59074dfba3f | https://github.com/tgriesser/checkit/blob/7938418df789653cf9dcdee9c71ca59074dfba3f/core.js#L176-L180 | train |
tgriesser/checkit | core.js | processItemAsync | function processItemAsync(runner, currentValidation, key, context) {
return Promise.resolve(true).then(function() {
return processItem(runner, currentValidation, key, context)
});
} | javascript | function processItemAsync(runner, currentValidation, key, context) {
return Promise.resolve(true).then(function() {
return processItem(runner, currentValidation, key, context)
});
} | [
"function",
"processItemAsync",
"(",
"runner",
",",
"currentValidation",
",",
"key",
",",
"context",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"true",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"processItem",
"(",
"runner",
",",
... | Processes an individual item in the validation collection for the current validation object. Returns the value from the completed validation, which will be a boolean, or potentially a promise if the current object is an async validation. | [
"Processes",
"an",
"individual",
"item",
"in",
"the",
"validation",
"collection",
"for",
"the",
"current",
"validation",
"object",
".",
"Returns",
"the",
"value",
"from",
"the",
"completed",
"validation",
"which",
"will",
"be",
"a",
"boolean",
"or",
"potentially... | 7938418df789653cf9dcdee9c71ca59074dfba3f | https://github.com/tgriesser/checkit/blob/7938418df789653cf9dcdee9c71ca59074dfba3f/core.js#L214-L218 | train |
tgriesser/checkit | core.js | function(val, item) {
if (_.isString(val)) return val.indexOf(item) !== -1;
if (_.isArray(val)) return _.indexOf(val, item) !== -1;
if (_.isObject(val)) return _.has(val, item);
return false;
} | javascript | function(val, item) {
if (_.isString(val)) return val.indexOf(item) !== -1;
if (_.isArray(val)) return _.indexOf(val, item) !== -1;
if (_.isObject(val)) return _.has(val, item);
return false;
} | [
"function",
"(",
"val",
",",
"item",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"val",
")",
")",
"return",
"val",
".",
"indexOf",
"(",
"item",
")",
"!==",
"-",
"1",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"val",
")",
")",
"return",
"_"... | Check that an item contains another item, either a string, array, or object. | [
"Check",
"that",
"an",
"item",
"contains",
"another",
"item",
"either",
"a",
"string",
"array",
"or",
"object",
"."
] | 7938418df789653cf9dcdee9c71ca59074dfba3f | https://github.com/tgriesser/checkit/blob/7938418df789653cf9dcdee9c71ca59074dfba3f/core.js#L321-L326 | train | |
tgriesser/checkit | core.js | function(val, param) {
return checkNumber(val) || checkNumber(param) || parseFloat(val) <= parseFloat(param);
} | javascript | function(val, param) {
return checkNumber(val) || checkNumber(param) || parseFloat(val) <= parseFloat(param);
} | [
"function",
"(",
"val",
",",
"param",
")",
"{",
"return",
"checkNumber",
"(",
"val",
")",
"||",
"checkNumber",
"(",
"param",
")",
"||",
"parseFloat",
"(",
"val",
")",
"<=",
"parseFloat",
"(",
"param",
")",
";",
"}"
] | Check if one item is less than or equal to another | [
"Check",
"if",
"one",
"item",
"is",
"less",
"than",
"or",
"equal",
"to",
"another"
] | 7938418df789653cf9dcdee9c71ca59074dfba3f | https://github.com/tgriesser/checkit/blob/7938418df789653cf9dcdee9c71ca59074dfba3f/core.js#L380-L382 | train | |
tgriesser/checkit | core.js | function(flat) {
return this.transform(function(acc, val, key) {
var json = val.toJSON();
acc[key] = flat && _.isArray(json) ? json[0] : json
}, {});
} | javascript | function(flat) {
return this.transform(function(acc, val, key) {
var json = val.toJSON();
acc[key] = flat && _.isArray(json) ? json[0] : json
}, {});
} | [
"function",
"(",
"flat",
")",
"{",
"return",
"this",
".",
"transform",
"(",
"function",
"(",
"acc",
",",
"val",
",",
"key",
")",
"{",
"var",
"json",
"=",
"val",
".",
"toJSON",
"(",
")",
";",
"acc",
"[",
"key",
"]",
"=",
"flat",
"&&",
"_",
".",
... | Creates a JSON object of the validations, if `true` is passed - it will flatten the error into a single value per item. | [
"Creates",
"a",
"JSON",
"object",
"of",
"the",
"validations",
"if",
"true",
"is",
"passed",
"-",
"it",
"will",
"flatten",
"the",
"error",
"into",
"a",
"single",
"value",
"per",
"item",
"."
] | 7938418df789653cf9dcdee9c71ca59074dfba3f | https://github.com/tgriesser/checkit/blob/7938418df789653cf9dcdee9c71ca59074dfba3f/core.js#L498-L503 | train | |
tgriesser/checkit | core.js | prepValidations | function prepValidations(validations) {
validations = _.cloneDeep(validations);
for (var key in validations) {
var validation = validations[key];
if (!_.isArray(validation)) validations[key] = validation = [validation];
for (var i = 0, l = validation.length; i < l; i++) {
validation[i] = assembleV... | javascript | function prepValidations(validations) {
validations = _.cloneDeep(validations);
for (var key in validations) {
var validation = validations[key];
if (!_.isArray(validation)) validations[key] = validation = [validation];
for (var i = 0, l = validation.length; i < l; i++) {
validation[i] = assembleV... | [
"function",
"prepValidations",
"(",
"validations",
")",
"{",
"validations",
"=",
"_",
".",
"cloneDeep",
"(",
"validations",
")",
";",
"for",
"(",
"var",
"key",
"in",
"validations",
")",
"{",
"var",
"validation",
"=",
"validations",
"[",
"key",
"]",
";",
... | Preps the validations being sent to the `run` block, to standardize the format and allow for maximum flexibility when passing to the validation blocks. | [
"Preps",
"the",
"validations",
"being",
"sent",
"to",
"the",
"run",
"block",
"to",
"standardize",
"the",
"format",
"and",
"allow",
"for",
"maximum",
"flexibility",
"when",
"passing",
"to",
"the",
"validation",
"blocks",
"."
] | 7938418df789653cf9dcdee9c71ca59074dfba3f | https://github.com/tgriesser/checkit/blob/7938418df789653cf9dcdee9c71ca59074dfba3f/core.js#L540-L550 | train |
goldibex/targaryen | lib/database/query.js | mergeQueries | function mergeQueries(query, options) {
if (options == null) {
return query;
}
Object.keys(options).forEach(key => {
let label = key;
let value = options[key];
validateProp(key, value);
switch (key) {
case 'orderByKey':
label = orderedBy;
value = orderByKey;
break;
... | javascript | function mergeQueries(query, options) {
if (options == null) {
return query;
}
Object.keys(options).forEach(key => {
let label = key;
let value = options[key];
validateProp(key, value);
switch (key) {
case 'orderByKey':
label = orderedBy;
value = orderByKey;
break;
... | [
"function",
"mergeQueries",
"(",
"query",
",",
"options",
")",
"{",
"if",
"(",
"options",
"==",
"null",
")",
"{",
"return",
"query",
";",
"}",
"Object",
".",
"keys",
"(",
"options",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"let",
"label",
"=",
"... | Validate and merge partial query parameters to a query object.
@param {Query} query Query to merges properties to
@param {Partial<Query>} options Partial query parameters
@returns {Query} | [
"Validate",
"and",
"merge",
"partial",
"query",
"parameters",
"to",
"a",
"query",
"object",
"."
] | e4151e75642ea6383e41278c09b1eb02984abadc | https://github.com/goldibex/targaryen/blob/e4151e75642ea6383e41278c09b1eb02984abadc/lib/database/query.js#L96-L135 | train |
goldibex/targaryen | lib/database/query.js | validateProp | function validateProp(key, value) {
const type = typeof value;
switch (key) {
case 'orderByKey':
case 'orderByPriority':
case 'orderByValue':
if (!value) {
throw new Error(`"query.${key}" should not be set to false. Set it off by setting an other order.`);
}
break;
case 'orderByChild':
... | javascript | function validateProp(key, value) {
const type = typeof value;
switch (key) {
case 'orderByKey':
case 'orderByPriority':
case 'orderByValue':
if (!value) {
throw new Error(`"query.${key}" should not be set to false. Set it off by setting an other order.`);
}
break;
case 'orderByChild':
... | [
"function",
"validateProp",
"(",
"key",
",",
"value",
")",
"{",
"const",
"type",
"=",
"typeof",
"value",
";",
"switch",
"(",
"key",
")",
"{",
"case",
"'orderByKey'",
":",
"case",
"'orderByPriority'",
":",
"case",
"'orderByValue'",
":",
"if",
"(",
"!",
"v... | Validate a query property
@param {string} key Property name
@param {any} value Property value | [
"Validate",
"a",
"query",
"property"
] | e4151e75642ea6383e41278c09b1eb02984abadc | https://github.com/goldibex/targaryen/blob/e4151e75642ea6383e41278c09b1eb02984abadc/lib/database/query.js#L143-L187 | train |
fortunejs/fortune-json-api | lib/helpers.js | setInflectType | function setInflectType (inflect, types) {
// use inflections if set as object else start fresh
const out = typeof inflect === 'boolean' ? {} : inflect
// if inflect is boolean use it for all types,
// else use default for unset types
const setInflect = typeof inflect === 'boolean' ? inflect : inflectTypeDef... | javascript | function setInflectType (inflect, types) {
// use inflections if set as object else start fresh
const out = typeof inflect === 'boolean' ? {} : inflect
// if inflect is boolean use it for all types,
// else use default for unset types
const setInflect = typeof inflect === 'boolean' ? inflect : inflectTypeDef... | [
"function",
"setInflectType",
"(",
"inflect",
",",
"types",
")",
"{",
"// use inflections if set as object else start fresh",
"const",
"out",
"=",
"typeof",
"inflect",
"===",
"'boolean'",
"?",
"{",
"}",
":",
"inflect",
"// if inflect is boolean use it for all types,",
"//... | Generate a list of which types are inflected.
@param {Boolean|Object} inflect setting from defaults or user override
@param {String[]} types array of declared types
@return {Object} | [
"Generate",
"a",
"list",
"of",
"which",
"types",
"are",
"inflected",
"."
] | 1475c5aea69726d3b2eef938f0044e372f940e37 | https://github.com/fortunejs/fortune-json-api/blob/1475c5aea69726d3b2eef938f0044e372f940e37/lib/helpers.js#L495-L515 | train |
rrdelaney/bs-loader | packages/bsb-js/utils.js | processBsbError | function processBsbError(err /*: Error | string */) /*: Error[] */ {
if (typeof err === 'string') {
const errors = errorRegexes
// $FlowIssue: err is definitely a string
.map((r /*: RegExp */) => err.match(r))
.reduce((a, s) => a.concat(s), [])
.filter(x => x)
return (errors.length > 0 ... | javascript | function processBsbError(err /*: Error | string */) /*: Error[] */ {
if (typeof err === 'string') {
const errors = errorRegexes
// $FlowIssue: err is definitely a string
.map((r /*: RegExp */) => err.match(r))
.reduce((a, s) => a.concat(s), [])
.filter(x => x)
return (errors.length > 0 ... | [
"function",
"processBsbError",
"(",
"err",
"/*: Error | string */",
")",
"/*: Error[] */",
"{",
"if",
"(",
"typeof",
"err",
"===",
"'string'",
")",
"{",
"const",
"errors",
"=",
"errorRegexes",
"// $FlowIssue: err is definitely a string",
".",
"map",
"(",
"(",
"r",
... | This function is only ever called if an error has been caught. We try to process said error according to known formats, but we default to what we got as an argument if they don't match. This way we always throw an error, thus avoiding successful builds if something has gone wrong. | [
"This",
"function",
"is",
"only",
"ever",
"called",
"if",
"an",
"error",
"has",
"been",
"caught",
".",
"We",
"try",
"to",
"process",
"said",
"error",
"according",
"to",
"known",
"formats",
"but",
"we",
"default",
"to",
"what",
"we",
"got",
"as",
"an",
... | a7e39fc01a25e6345a79a7f0972c8a03f5c59ec1 | https://github.com/rrdelaney/bs-loader/blob/a7e39fc01a25e6345a79a7f0972c8a03f5c59ec1/packages/bsb-js/utils.js#L42-L54 | train |
rrdelaney/bs-loader | packages/bsb-js/index.js | runBuild | function runBuild(cwd /*: string */) /*: Promise<string> */ {
return new Promise((resolve, reject) => {
exec(bsb, {maxBuffer: Infinity, cwd}, (err, stdout, stderr) => {
const output = `${stdout.toString()}\n${stderr.toString()}`
if (err) {
reject(output)
} else {
resolve(output)
... | javascript | function runBuild(cwd /*: string */) /*: Promise<string> */ {
return new Promise((resolve, reject) => {
exec(bsb, {maxBuffer: Infinity, cwd}, (err, stdout, stderr) => {
const output = `${stdout.toString()}\n${stderr.toString()}`
if (err) {
reject(output)
} else {
resolve(output)
... | [
"function",
"runBuild",
"(",
"cwd",
"/*: string */",
")",
"/*: Promise<string> */",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"exec",
"(",
"bsb",
",",
"{",
"maxBuffer",
":",
"Infinity",
",",
"cwd",
"}",
",",
"("... | Runs `bsb` async | [
"Runs",
"bsb",
"async"
] | a7e39fc01a25e6345a79a7f0972c8a03f5c59ec1 | https://github.com/rrdelaney/bs-loader/blob/a7e39fc01a25e6345a79a7f0972c8a03f5c59ec1/packages/bsb-js/index.js#L30-L41 | train |
rrdelaney/bs-loader | packages/bsb-js/index.js | compileFile | function compileFile(
buildDir /*: string */,
moduleType /*: BsModuleFormat | 'js' */,
path /*: string */,
id /*: ?string */ = null,
) /*: Promise<Compilation> */ {
if (id && buildRuns[id] !== undefined) {
buildRuns[id] = runBuild(buildDir)
}
const buildProcess = id ? buildRuns[id] : runBuild(buildDi... | javascript | function compileFile(
buildDir /*: string */,
moduleType /*: BsModuleFormat | 'js' */,
path /*: string */,
id /*: ?string */ = null,
) /*: Promise<Compilation> */ {
if (id && buildRuns[id] !== undefined) {
buildRuns[id] = runBuild(buildDir)
}
const buildProcess = id ? buildRuns[id] : runBuild(buildDi... | [
"function",
"compileFile",
"(",
"buildDir",
"/*: string */",
",",
"moduleType",
"/*: BsModuleFormat | 'js' */",
",",
"path",
"/*: string */",
",",
"id",
"/*: ?string */",
"=",
"null",
",",
")",
"/*: Promise<Compilation> */",
"{",
"if",
"(",
"id",
"&&",
"buildRuns",
... | Compiles a Reason file to JS | [
"Compiles",
"a",
"Reason",
"file",
"to",
"JS"
] | a7e39fc01a25e6345a79a7f0972c8a03f5c59ec1 | https://github.com/rrdelaney/bs-loader/blob/a7e39fc01a25e6345a79a7f0972c8a03f5c59ec1/packages/bsb-js/index.js#L61-L101 | train |
rrdelaney/bs-loader | packages/bsb-js/index.js | compileFileSync | function compileFileSync(
buildDir /*: string */,
moduleType /*: BsModuleFormat | 'js' */,
path /*: string */,
) /*: string */ {
try {
runBuildSync(buildDir)
} catch (e) {
throw utils.processBsbError(e.output.toString())
}
const res = readFileSync(path)
return utils.transformSrc(moduleType, res... | javascript | function compileFileSync(
buildDir /*: string */,
moduleType /*: BsModuleFormat | 'js' */,
path /*: string */,
) /*: string */ {
try {
runBuildSync(buildDir)
} catch (e) {
throw utils.processBsbError(e.output.toString())
}
const res = readFileSync(path)
return utils.transformSrc(moduleType, res... | [
"function",
"compileFileSync",
"(",
"buildDir",
"/*: string */",
",",
"moduleType",
"/*: BsModuleFormat | 'js' */",
",",
"path",
"/*: string */",
",",
")",
"/*: string */",
"{",
"try",
"{",
"runBuildSync",
"(",
"buildDir",
")",
"}",
"catch",
"(",
"e",
")",
"{",
... | Compiles a Reason file to JS sync | [
"Compiles",
"a",
"Reason",
"file",
"to",
"JS",
"sync"
] | a7e39fc01a25e6345a79a7f0972c8a03f5c59ec1 | https://github.com/rrdelaney/bs-loader/blob/a7e39fc01a25e6345a79a7f0972c8a03f5c59ec1/packages/bsb-js/index.js#L104-L117 | train |
Swaagie/minimize | lib/helpers.js | compact | function compact(value, keepNewlines) {
var check = keepNewlines ? / +/g : /\s+/g;
return value.replace(check, ' ');
} | javascript | function compact(value, keepNewlines) {
var check = keepNewlines ? / +/g : /\s+/g;
return value.replace(check, ' ');
} | [
"function",
"compact",
"(",
"value",
",",
"keepNewlines",
")",
"{",
"var",
"check",
"=",
"keepNewlines",
"?",
"/",
" +",
"/",
"g",
":",
"/",
"\\s+",
"/",
"g",
";",
"return",
"value",
".",
"replace",
"(",
"check",
",",
"' '",
")",
";",
"}"
] | Compact the value, replace multiple white spaces and newlines
with a single white space.
@param {String} value Value to compact
@param {Boolean} keepNewlines Do not remove newlines
@return {String} Compacted data
@api private | [
"Compact",
"the",
"value",
"replace",
"multiple",
"white",
"spaces",
"and",
"newlines",
"with",
"a",
"single",
"white",
"space",
"."
] | 4689d8e2c1c094b2bcc85ae308c531e0b487763b | https://github.com/Swaagie/minimize/blob/4689d8e2c1c094b2bcc85ae308c531e0b487763b/lib/helpers.js#L37-L40 | train |
Swaagie/minimize | lib/helpers.js | Helpers | function Helpers(options) {
this.config = {};
for (var key in options || {}) {
this.config[key] = options[key];
}
this.ancestor = [];
} | javascript | function Helpers(options) {
this.config = {};
for (var key in options || {}) {
this.config[key] = options[key];
}
this.ancestor = [];
} | [
"function",
"Helpers",
"(",
"options",
")",
"{",
"this",
".",
"config",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"options",
"||",
"{",
"}",
")",
"{",
"this",
".",
"config",
"[",
"key",
"]",
"=",
"options",
"[",
"key",
"]",
";",
"}",
... | Helper constructor.
@Constructor
@param {Object} options
@api public | [
"Helper",
"constructor",
"."
] | 4689d8e2c1c094b2bcc85ae308c531e0b487763b | https://github.com/Swaagie/minimize/blob/4689d8e2c1c094b2bcc85ae308c531e0b487763b/lib/helpers.js#L49-L57 | train |
Swaagie/minimize | lib/minimize.js | Minimize | function Minimize(parser, options) {
if ('object' !== typeof options) {
options = parser || {};
options.dom = options.dom || {};
parser = void 0;
}
this.emits = emits;
this.plugins = Object.create(null);
this.helpers = new Helpers(options);
//
// Prepare the parser.
//
this.htmlparser = ... | javascript | function Minimize(parser, options) {
if ('object' !== typeof options) {
options = parser || {};
options.dom = options.dom || {};
parser = void 0;
}
this.emits = emits;
this.plugins = Object.create(null);
this.helpers = new Helpers(options);
//
// Prepare the parser.
//
this.htmlparser = ... | [
"function",
"Minimize",
"(",
"parser",
",",
"options",
")",
"{",
"if",
"(",
"'object'",
"!==",
"typeof",
"options",
")",
"{",
"options",
"=",
"parser",
"||",
"{",
"}",
";",
"options",
".",
"dom",
"=",
"options",
".",
"dom",
"||",
"{",
"}",
";",
"pa... | Minimizer constructor.
@Constructor
@param {Function} parser HTMLParser2 instance, i.e. to support SVG if required.
@param {Object} options parsing options, optional
@api public | [
"Minimizer",
"constructor",
"."
] | 4689d8e2c1c094b2bcc85ae308c531e0b487763b | https://github.com/Swaagie/minimize/blob/4689d8e2c1c094b2bcc85ae308c531e0b487763b/lib/minimize.js#L23-L46 | train |
Swaagie/minimize | lib/minimize.js | traverser | function traverser(element, content, next) {
return function () {
return minimize.traverse(element.children, content, sync, step(element, 'close', next))
};
} | javascript | function traverser(element, content, next) {
return function () {
return minimize.traverse(element.children, content, sync, step(element, 'close', next))
};
} | [
"function",
"traverser",
"(",
"element",
",",
"content",
",",
"next",
")",
"{",
"return",
"function",
"(",
")",
"{",
"return",
"minimize",
".",
"traverse",
"(",
"element",
".",
"children",
",",
"content",
",",
"sync",
",",
"step",
"(",
"element",
",",
... | For all children run same iterator.
@param {Object} element Current element
@param {String} content Current minimized HTML, memo.
@param {Function} next Completion callback.
@returns {Function} Runner.
@api private | [
"For",
"all",
"children",
"run",
"same",
"iterator",
"."
] | 4689d8e2c1c094b2bcc85ae308c531e0b487763b | https://github.com/Swaagie/minimize/blob/4689d8e2c1c094b2bcc85ae308c531e0b487763b/lib/minimize.js#L162-L166 | train |
Swaagie/minimize | lib/minimize.js | step | function step(element, type, cb) {
return function generate(error, html) {
html += minimize.helpers[type](element);
return returns(error, html, cb);
}
} | javascript | function step(element, type, cb) {
return function generate(error, html) {
html += minimize.helpers[type](element);
return returns(error, html, cb);
}
} | [
"function",
"step",
"(",
"element",
",",
"type",
",",
"cb",
")",
"{",
"return",
"function",
"generate",
"(",
"error",
",",
"html",
")",
"{",
"html",
"+=",
"minimize",
".",
"helpers",
"[",
"type",
"]",
"(",
"element",
")",
";",
"return",
"returns",
"(... | Minimize single level of HTML.
@param {Object} element Properties
@param {String} type Element type
@param {Function} cb Completion callback
@api private | [
"Minimize",
"single",
"level",
"of",
"HTML",
"."
] | 4689d8e2c1c094b2bcc85ae308c531e0b487763b | https://github.com/Swaagie/minimize/blob/4689d8e2c1c094b2bcc85ae308c531e0b487763b/lib/minimize.js#L176-L181 | train |
Swaagie/minimize | lib/minimize.js | run | function run(element, cb) {
return function level(error, content) {
debug('Traversing children of element %s', element.name);
if (sync) {
return traverser(element, content, cb)();
}
setImmediate(traverser(element, content, cb));
}
} | javascript | function run(element, cb) {
return function level(error, content) {
debug('Traversing children of element %s', element.name);
if (sync) {
return traverser(element, content, cb)();
}
setImmediate(traverser(element, content, cb));
}
} | [
"function",
"run",
"(",
"element",
",",
"cb",
")",
"{",
"return",
"function",
"level",
"(",
"error",
",",
"content",
")",
"{",
"debug",
"(",
"'Traversing children of element %s'",
",",
"element",
".",
"name",
")",
";",
"if",
"(",
"sync",
")",
"{",
"retur... | Traverse children of current element.
@param {Object} element Properties
@param {Function} cb Completion callback
@api private | [
"Traverse",
"children",
"of",
"current",
"element",
"."
] | 4689d8e2c1c094b2bcc85ae308c531e0b487763b | https://github.com/Swaagie/minimize/blob/4689d8e2c1c094b2bcc85ae308c531e0b487763b/lib/minimize.js#L190-L200 | train |
Swaagie/minimize | lib/minimize.js | createPlug | function createPlug(element) {
return function plug(plugin, fn) {
fn = fn || minimize.emits('plugin');
debug('Running plugin for element %s', element.name);
minimize.plugins[plugin].element.call(minimize, element, fn);
}
} | javascript | function createPlug(element) {
return function plug(plugin, fn) {
fn = fn || minimize.emits('plugin');
debug('Running plugin for element %s', element.name);
minimize.plugins[plugin].element.call(minimize, element, fn);
}
} | [
"function",
"createPlug",
"(",
"element",
")",
"{",
"return",
"function",
"plug",
"(",
"plugin",
",",
"fn",
")",
"{",
"fn",
"=",
"fn",
"||",
"minimize",
".",
"emits",
"(",
"'plugin'",
")",
";",
"debug",
"(",
"'Running plugin for element %s'",
",",
"element... | Create plugins for element.
@param {Object} element Properties.
@return {Function} Plugin function to run.
@api private | [
"Create",
"plugins",
"for",
"element",
"."
] | 4689d8e2c1c094b2bcc85ae308c531e0b487763b | https://github.com/Swaagie/minimize/blob/4689d8e2c1c094b2bcc85ae308c531e0b487763b/lib/minimize.js#L222-L229 | train |
Swaagie/minimize | lib/minimize.js | reduce | function reduce(html, element, next) {
//
// Run the registered plugins before the element is processed.
// Note that the plugins are not run in order.
//
if (sync) {
plugins.forEach(createPlug(element));
return open(element, html, run(element, next));
}
async.eachSeries(plugins... | javascript | function reduce(html, element, next) {
//
// Run the registered plugins before the element is processed.
// Note that the plugins are not run in order.
//
if (sync) {
plugins.forEach(createPlug(element));
return open(element, html, run(element, next));
}
async.eachSeries(plugins... | [
"function",
"reduce",
"(",
"html",
",",
"element",
",",
"next",
")",
"{",
"//",
"// Run the registered plugins before the element is processed.",
"// Note that the plugins are not run in order.",
"//",
"if",
"(",
"sync",
")",
"{",
"plugins",
".",
"forEach",
"(",
"create... | Reduce each HTML element and its children.
@param {String} html Current compiled HTML, memo.
@param {Object} element Current element.
@param {Function} step Completion callback
@returns {String} minimized HTML.
@api private | [
"Reduce",
"each",
"HTML",
"element",
"and",
"its",
"children",
"."
] | 4689d8e2c1c094b2bcc85ae308c531e0b487763b | https://github.com/Swaagie/minimize/blob/4689d8e2c1c094b2bcc85ae308c531e0b487763b/lib/minimize.js#L240-L254 | 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.