_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q50900
remove_null_undefined
train
function remove_null_undefined(object) { Object.keys(object).forEach(key => { if (object[key] === null || typeof object[key] === "undefined") { delete object[key] } }) return object }
javascript
{ "resource": "" }
q50901
get_related_columns
train
function get_related_columns(collection) { return Object.keys(collection.attributes) .filter(attribute => collection.attributes[attribute].collection || collection.attributes[attribute].model) }
javascript
{ "resource": "" }
q50902
compile_constraints
train
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
{ "resource": "" }
q50903
replace_env_values
train
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
{ "resource": "" }
q50904
getJunctionTableFromModelAndRelatedColumn
train
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
{ "resource": "" }
q50905
hash_password
train
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
{ "resource": "" }
q50906
toJSON
train
function toJSON() { const model = this.toObject() delete model.password delete model.salt // Return the modified user object. return utils.remove_null_undefined(model) }
javascript
{ "resource": "" }
q50907
custom_routes
train
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
{ "resource": "" }
q50908
random
train
function random (utxos, outputs, feeRate) { utxos = shuffle(utxos) return accumulative(utxos, outputs, feeRate) }
javascript
{ "resource": "" }
q50909
train
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
{ "resource": "" }
q50910
train
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
{ "resource": "" }
q50911
train
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
{ "resource": "" }
q50912
train
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
{ "resource": "" }
q50913
train
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
{ "resource": "" }
q50914
hasRest
train
function hasRest(pattern) { for (let elem of pattern.elements) { if (isRestElement(t, elem)) { return true } } return false }
javascript
{ "resource": "" }
q50915
getDirective
train
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
{ "resource": "" }
q50916
flipPixels
train
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
{ "resource": "" }
q50917
parseOrientationTag
train
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
{ "resource": "" }
q50918
computeFinalBuffer
train
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
{ "resource": "" }
q50919
contextRenderer
train
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
{ "resource": "" }
q50920
train
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
{ "resource": "" }
q50921
train
function (value, prefix) { return angular.isString(value) && angular.isString(prefix) && value.lastIndexOf(prefix, 0) === 0; }
javascript
{ "resource": "" }
q50922
train
function (value, constraint) { var pattern = asRegExp(constraint.value); return valdrUtil.isEmpty(value) || pattern.test(value); }
javascript
{ "resource": "" }
q50923
train
function (value, constraint) { if (valdrUtil.isEmpty(value)) { return true; } if (valdrUtil.isNaN(Number(value))) { return false; } return doValidate(value, constraint); }
javascript
{ "resource": "" }
q50924
train
function (typeName, fieldName, value) { var validResult = { valid: true }, typeConstraints = constraintsForType(typeName); if (valdrUtil.has(typeConstraints, fieldName)) { var fieldConstraints = typeConstraints[fieldName], fieldIsValid = tr...
javascript
{ "resource": "" }
q50925
train
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
{ "resource": "" }
q50926
train
function(tech) { return (this.level.getConfig().bundleBuildLevels || []) .concat([PATH.resolve(this.root, PATH.dirname(this.getNodePrefix()), 'blocks')]); }
javascript
{ "resource": "" }
q50927
train
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
{ "resource": "" }
q50928
train
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
{ "resource": "" }
q50929
train
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
{ "resource": "" }
q50930
train
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
{ "resource": "" }
q50931
train
function(nodeName, objectOrBaseName, objectOrStatic, staticObject) { var explicitBase = typeof objectOrBaseName === 'string', baseName = explicitBase? objectOrBaseName : nodeName, staticObj = typeof objectOrBaseName !== 'string'? objectOrStatic: staticObject, obj = explicitB...
javascript
{ "resource": "" }
q50932
train
function(nodeName, objectOrBaseName, objectOrStatic, staticObject) { cache = {}; var stack = registry[nodeName] || []; stack.push(Array.prototype.slice.call(arguments, 0)); registry[nodeName] = stack; }
javascript
{ "resource": "" }
q50933
d3_format_group
train
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
{ "resource": "" }
q50934
l
train
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
{ "resource": "" }
q50935
brush
train
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
{ "resource": "" }
q50936
recurse
train
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
{ "resource": "" }
q50937
revalue
train
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
{ "resource": "" }
q50938
d3_layout_hierarchyRebind
train
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
{ "resource": "" }
q50939
squarify
train
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
{ "resource": "" }
q50940
stickify
train
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
{ "resource": "" }
q50941
token
train
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
{ "resource": "" }
q50942
resample
train
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
{ "resource": "" }
q50943
d3_geom_hullCCW
train
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
{ "resource": "" }
q50944
d3_geom_polygonIntersect
train
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
{ "resource": "" }
q50945
train
function(o) { this.__base(o); this.root = o.root; this.target = o.target; this.npmPackages = o.npmPackages === undefined? ['package.json']: o.npmPackages; }
javascript
{ "resource": "" }
q50946
train
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
{ "resource": "" }
q50947
train
function(o) { this.__base(o); this.url = o.url; this.paths = ['']; this.timeout = typeof o.timeout !== 'undefined'? Number(o.timeout) : SCM_VALIDITY_TIMEOUT; }
javascript
{ "resource": "" }
q50948
train
function(o) { this.__base(o); this.treeish = o.treeish; this.branch = o.branch || 'master'; this.origin = o.origin || 'origin'; }
javascript
{ "resource": "" }
q50949
train
function(o) { this.__base(o); this.paths = Array.isArray(o.paths)? o.paths : [o.paths || '']; this.revision = o.revision || 'HEAD'; }
javascript
{ "resource": "" }
q50950
train
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
{ "resource": "" }
q50951
train
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
{ "resource": "" }
q50952
train
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
{ "resource": "" }
q50953
train
function(techName) { var p = this.getTechs()[techName]; return typeof p !== 'undefined'? this.resolveTech(p, {force: true}) : null; }
javascript
{ "resource": "" }
q50954
train
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
{ "resource": "" }
q50955
train
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
{ "resource": "" }
q50956
train
function(block, mod) { return PATH.join.apply(null, [block, '_' + mod, block + '_' + mod]); }
javascript
{ "resource": "" }
q50957
train
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
{ "resource": "" }
q50958
train
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
{ "resource": "" }
q50959
train
function(from) { this._declIntrospector || (this._declIntrospector = this.createIntrospector({ creator: function(res, match) { if (match && match.tech) { return this._mergeMatchToDecl(match, res); } return res; } ...
javascript
{ "resource": "" }
q50960
train
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
{ "resource": "" }
q50961
train
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
{ "resource": "" }
q50962
train
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
{ "resource": "" }
q50963
vimeo_fetcher
train
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
{ "resource": "" }
q50964
findMeta
train
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
{ "resource": "" }
q50965
wlCheck
train
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
{ "resource": "" }
q50966
createUpdateRDF
train
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
{ "resource": "" }
q50967
filter
train
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
{ "resource": "" }
q50968
ignore
train
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
{ "resource": "" }
q50969
listdir
train
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
{ "resource": "" }
q50970
filter
train
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
{ "resource": "" }
q50971
log
train
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
{ "resource": "" }
q50972
getManifest
train
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
{ "resource": "" }
q50973
getXpiInfo
train
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
{ "resource": "" }
q50974
addPrefs
train
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
{ "resource": "" }
q50975
Checkit
train
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
{ "resource": "" }
q50976
checkSync
train
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
{ "resource": "" }
q50977
Runner
train
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
{ "resource": "" }
q50978
addVerifiedConditional
train
function addVerifiedConditional(validations, conditional) { _.each(conditional[0], function(val, key) { validations[key] = validations[key] || []; validations[key] = validations[key].concat(val); }) }
javascript
{ "resource": "" }
q50979
checkConditional
train
function checkConditional(runner, conditional) { try { return conditional[1].call(runner, runner.target, runner.context); } catch (e) {} }
javascript
{ "resource": "" }
q50980
processItemAsync
train
function processItemAsync(runner, currentValidation, key, context) { return Promise.resolve(true).then(function() { return processItem(runner, currentValidation, key, context) }); }
javascript
{ "resource": "" }
q50981
train
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
{ "resource": "" }
q50982
train
function(val, param) { return checkNumber(val) || checkNumber(param) || parseFloat(val) <= parseFloat(param); }
javascript
{ "resource": "" }
q50983
train
function(flat) { return this.transform(function(acc, val, key) { var json = val.toJSON(); acc[key] = flat && _.isArray(json) ? json[0] : json }, {}); }
javascript
{ "resource": "" }
q50984
prepValidations
train
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
{ "resource": "" }
q50985
mergeQueries
train
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
{ "resource": "" }
q50986
validateProp
train
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
{ "resource": "" }
q50987
setInflectType
train
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
{ "resource": "" }
q50988
processBsbError
train
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
{ "resource": "" }
q50989
runBuild
train
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
{ "resource": "" }
q50990
compileFile
train
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
{ "resource": "" }
q50991
compileFileSync
train
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
{ "resource": "" }
q50992
compact
train
function compact(value, keepNewlines) { var check = keepNewlines ? / +/g : /\s+/g; return value.replace(check, ' '); }
javascript
{ "resource": "" }
q50993
Helpers
train
function Helpers(options) { this.config = {}; for (var key in options || {}) { this.config[key] = options[key]; } this.ancestor = []; }
javascript
{ "resource": "" }
q50994
Minimize
train
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
{ "resource": "" }
q50995
traverser
train
function traverser(element, content, next) { return function () { return minimize.traverse(element.children, content, sync, step(element, 'close', next)) }; }
javascript
{ "resource": "" }
q50996
step
train
function step(element, type, cb) { return function generate(error, html) { html += minimize.helpers[type](element); return returns(error, html, cb); } }
javascript
{ "resource": "" }
q50997
run
train
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
{ "resource": "" }
q50998
createPlug
train
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
{ "resource": "" }
q50999
reduce
train
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
{ "resource": "" }