_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q37300
train
function(step) { if (!step) { throw new Error('Not enough arguments'); } if (Array.isArray(step)) { step.forEach(function(s) { this.add(s); }, this); } else { if (step.nextDelay && step....
javascript
{ "resource": "" }
q37301
train
function(index) { var step; if (!this.steps[index]) { if (this.config.loop && this._loops < this.config.maxLoops) { this._loops++; step = this.steps[this._current = 0]; } else { return false; ...
javascript
{ "resource": "" }
q37302
train
function(nextDelay) { var delay = nextDelay || this.config.defaultDelay; if (delay && this._playing) { this._currentTimeout = setTimeout(function() { this._executeStep(++this._current); }.bind(this), delay); } }
javascript
{ "resource": "" }
q37303
train
function(images, callback) { var loaded = 0; images.forEach(function(src) { var image = new Image(); image.onload = function() { ++loaded; loaded === images.length && callback(); }; image.src ...
javascript
{ "resource": "" }
q37304
train
function(config, name) { if (config && config !== Object(config)) { throw new Error('Config object should be a key/value object.'); } var defaultConfig = { loop: false, maxLoops: Infinity }; var instance = Obje...
javascript
{ "resource": "" }
q37305
train
function(program) { this.cli = program; this.cmd = this.cli; if(process.env.CLI_TOOLKIT_HELP_CMD) { var alias = this.cli.finder.getCommandByName; var cmd = alias(process.env.CLI_TOOLKIT_HELP_CMD, this.cli.commands()); if(cmd) { this.cmd = cmd; } } this.eol = eol; this.format = fmt.TEXT...
javascript
{ "resource": "" }
q37306
AbstractFilter
train
function AbstractFilter(vertexSrc, fragmentSrc, uniforms) { /** * An array of shaders * @member {Shader[]} * @private */ this.shaders = []; /** * The extra padding that the filter might need * @member {number} */ this.padding = 0; /** * The uniforms as an o...
javascript
{ "resource": "" }
q37307
train
function(type, node) { return seen.indexOf(node) == -1 && ((type == 'AssignmentExpression' && node.right == expr) || (type == 'VariableDeclarator' && node.init == expr)); }
javascript
{ "resource": "" }
q37308
wrapNodeSocket
train
function wrapNodeSocket(socket, reportError) { // Data traveling from node socket to consumer var incoming = makeChannel(); // Data traveling from consumer to node socket var outgoing = makeChannel(); var onDrain2 = wrapHandler(onReadable, onError); onTake = wrapHandler(onTake, onError); var paused = fa...
javascript
{ "resource": "" }
q37309
request
train
function request (type, url, data) { return new Promise(function (fulfill, reject) { // Set ajax to correct XHR type. Source: https://gist.github.com/jed/993585 var Xhr = window.XMLHttpRequest||ActiveXObject, req = new Xhr('MSXML2.XMLHTTP.3.0'); req.open(type, url, true); req.setRequestHeader('Conte...
javascript
{ "resource": "" }
q37310
monkeyPatch
train
function monkeyPatch() { var script = function() { window.__karma__ = true; (function patch() { if (typeof window.__bs === 'undefined') { window.setTimeout(patch, 500); } else { var oldCanSync = window.__bs.prototype.canSync; window.__bs.prototype.canSync = function(data, optPath) { data.url...
javascript
{ "resource": "" }
q37311
startBrowserSync
train
function startBrowserSync(cordovaDir, platforms, opts, cb) { var defaults = { logFileChanges: true, logConnections: true, open: false, snippetOptions: { rule: { match: /<\/body>/i, fn: function(snippet, match) { return monkeyPatch() + snippet + match; } } }, minify: false, watchOpt...
javascript
{ "resource": "" }
q37312
productHunt
train
function productHunt() { let queryParams = { }; return { /** * Sets the request query parameters to fetch the * most popular products from Product Hunt. * * @return {Object} `productHunt` module */ popular() { queryParams.filter = 'popular'; return this; }, /** * Sets the request q...
javascript
{ "resource": "" }
q37313
readRequireConfig
train
function readRequireConfig( file ) { 'use strict'; var config = fs.readFileSync( file ); /*jshint -W054*/ var evaluate = new Function( 'var window = this;' + config + '; return require || window.require;' ); return evaluate.call( {} ); }
javascript
{ "resource": "" }
q37314
_detect
train
function _detect(eachFn, arr, iterator, mainCallback) { eachFn(arr, function (x, index, callback) { iterator(x, function (v, result) { if (v) { mainCallback(result || x); mainCallback = async.noop; } else { callback(); } }); }, function () { mainCallback(); })...
javascript
{ "resource": "" }
q37315
getCurrentTarget
train
function getCurrentTarget( slot ) { if( !G.target ) return null; for( var i = 0 ; i < G.target.length ; i++ ) { var target = G.target[i]; if( !slot || typeof target.slots[slot] === 'function' ) return target; } return null; }
javascript
{ "resource": "" }
q37316
validateNew
train
function validateNew(options) { options = validateOptions(options); //console.log('options after validation', util.inspect(options, {depth: null})); //return; //console.log('skemer.validateAdd called', arguments); return validateData.apply(this, [options, undefined].concat(Array.prototype.slice.call(...
javascript
{ "resource": "" }
q37317
train
function () { return validateData.apply(this, [this.options, undefined].concat(Array.prototype.slice.call(arguments))); }
javascript
{ "resource": "" }
q37318
reset
train
function reset(req, res) { this.state.slowlog.reset(); res.send(null, Constants.OK); }
javascript
{ "resource": "" }
q37319
validate
train
function validate(cmd, args, info) { AbstractCommand.prototype.validate.apply(this, arguments); var sub = info.command.sub , scmd = ('' + sub.cmd) , args = sub.args , amount; if(scmd === Constants.SUBCOMMAND.slowlog.get.name && args.length) { if(args.length > 1) { throw new CommandArgLength...
javascript
{ "resource": "" }
q37320
sassifyFn
train
function sassifyFn(rawObject) { var sassified = ''; Object.keys(rawObject).forEach(function iterateVariables(key) { var variable = rawObject[key]; var stringified = JSON.stringify(variable); // Trim off double quotes for CSS variables. stringified = stringified.substring(1, stringified.length - 1...
javascript
{ "resource": "" }
q37321
noval
train
function noval(value, recursive) { assertType(recursive, 'boolean', true, 'Invalid parameter: recursive'); if (recursive === undefined) recursive = false; if (value === undefined || value === null) { return true; } else if (typeof value === 'string') { return (value === ''); } else if (recursive...
javascript
{ "resource": "" }
q37322
_readContent
train
function _readContent (files, writeStream, separator) { return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => { const file = files.shift().trim(); return isFileProm(file).then((exists) => { const isPattern = -1 < separator.indexOf("{{filename}}"); return !exists ? _readCo...
javascript
{ "resource": "" }
q37323
hsetnx
train
function hsetnx(key, field, value, req) { var val = this.getKey(key, req) , exists = this.hexists(key, field, req); if(!val) { val = new HashMap(); this.setKey(key, val, undefined, undefined, undefined, req); } if(!exists) { // set on the hashmap val.setKey(field, value); } return exists...
javascript
{ "resource": "" }
q37324
hget
train
function hget(key, field, req) { // get at db level var val = this.getKey(key, req); if(!val) return null; // get at hash level val = val.getKey(field) if(!val) return null; return val; }
javascript
{ "resource": "" }
q37325
hexists
train
function hexists(key, field, req) { var val = this.getKey(key, req); if(!val) return 0; return val.keyExists(field); }
javascript
{ "resource": "" }
q37326
hgetall
train
function hgetall(key, req) { var val = this.getKey(key, req) , list = []; if(!val) return list; val.getKeys().forEach(function(k) { list.push(k, '' + val.getKey(k)); }); return list; }
javascript
{ "resource": "" }
q37327
hkeys
train
function hkeys(key, req) { var val = this.getKey(key, req); if(!val) return []; return val.getKeys(); }
javascript
{ "resource": "" }
q37328
hlen
train
function hlen(key, req) { var val = this.getKey(key, req); if(!val) return 0; return val.hlen(); }
javascript
{ "resource": "" }
q37329
hdel
train
function hdel(key /* field-1, field-N, req */) { var args = slice.call(arguments, 1) , req = typeof args[args.length - 1] === 'object' ? args.pop() : null , val = this.getKey(key, req) , deleted = 0 , i; // nothing at key if(!val) return 0; for(i = 0;i < args.length;i++) { deleted ...
javascript
{ "resource": "" }
q37330
hmget
train
function hmget(key /* field-1, field-N, req */) { var args = slice.call(arguments, 1) , req = typeof args[args.length - 1] === 'object' ? args.pop() : null , val = this.getKey(key, req) , value , list = [] , i; for(i = 0;i < args.length;i++) { if(!val) { list.push(null); ...
javascript
{ "resource": "" }
q37331
hmset
train
function hmset(key /* field-1, value-1, field-N, value-N, req */) { var args = slice.call(arguments, 1) , req = typeof args[args.length - 1] === 'object' ? args.pop() : null , val = this.getKey(key, req) , i; if(!val) { val = new HashMap(); this.setKey(key, val, undefined, undefined, un...
javascript
{ "resource": "" }
q37332
hincrbyfloat
train
function hincrbyfloat(key, field, amount, req) { var map = this.getKey(key, req) , val; if(!map) { map = new HashMap(); this.setKey(key, map, undefined, undefined, undefined, req); } val = utils.strtofloat(map.getKey(field)); amount = utils.strtofloat(amount); val += amount; map.setKey(field, ...
javascript
{ "resource": "" }
q37333
hincrby
train
function hincrby(key, field, amount, req) { var map = this.getKey(key, req) , val; if(!map) { map = new HashMap(); this.setKey(key, map, undefined, undefined, undefined, req); } val = utils.strtoint(map.getKey(field)); amount = utils.strtoint(amount); val += amount; map.setKey(field, val); r...
javascript
{ "resource": "" }
q37334
train
function(v) { if (v instanceof Vec3) { return new Vec3(this.x + v.x, this.y + v.y, this.z + v.z); } else if(v instanceof Vec2){ return new Vec3(this.x + v.x, this.y + v.y, this.z); } else if(typeof v === 'number') { return new Vec3(this.x + v, ...
javascript
{ "resource": "" }
q37335
train
function() { return { theta: Math.atan2(this.z, this.x), phi: Math.asin(this.y / this.length()) }; }
javascript
{ "resource": "" }
q37336
train
function(dec) { if(!dec){ dec = 2; } return '{x: ' + this.x.toFixed(dec) + ', y: ' + this.y.toFixed(dec) + ', z: ' + this.z.toFixed(dec) + '}'; }
javascript
{ "resource": "" }
q37337
train
function() { return new Vec3(Math.round(this.x), Math.round(this.y), Math.round(this.z)); }
javascript
{ "resource": "" }
q37338
train
function(m){ return new Vec3( this.x*m[0][0]+this.y*m[0][1]+this.z*m[0][2], this.x*m[1][0]+this.y*m[1][1]+this.z*m[1][2], this.x*m[2][0]+this.y*m[2][1]+this.z*m[2][2] ); }
javascript
{ "resource": "" }
q37339
train
function(m){ var x = this.x; var y = this.y; var z = this.z; this.x = x*m[0][0]+y*m[0][1]+z*m[0][2]; this.y = x*m[1][0]+y*m[1][1]+z*m[1][2]; this.z = x*m[2][0]+y*m[2][1]+z*m[2][2]; return this; }
javascript
{ "resource": "" }
q37340
train
function(p){ return new Vec3(Math.pow(this.x, p), Math.pow(this.y, p), Math.pow(this.z, p)); }
javascript
{ "resource": "" }
q37341
execSpawn
train
function execSpawn(command, args, resultMsg, errorMsg) { return superspawn.spawn(command, args).then(function(result) { return resultMsg + result; }, function(error) { return errorMsg + error; }); }
javascript
{ "resource": "" }
q37342
finishQuerying
train
function finishQuerying(domain, err, records) { // Set time until our next query var expiration = Date.now() + ttl * 1000; // If there was an error querying the domain if (err) { // If the domain was not found if (err.code == 'ENOTFOUND') { // If we have a function to handle missing...
javascript
{ "resource": "" }
q37343
finishProcessing
train
function finishProcessing(err) { if (err) return cb(err); db.eval(hmz, 2, 'processing_domains', 'expiring_domains', domain, next); }
javascript
{ "resource": "" }
q37344
iface
train
function iface(end) { if (end) { return db.quit(next); } else { // Get all the domains whose records expired some time before now db.eval(scoreRange,2,'expiring_domains','querying_domains', '-inf', Date.now(), function (err, res) { if (err) return cb(err); // Query ...
javascript
{ "resource": "" }
q37345
getAcadSem
train
function getAcadSem(acadWeekNumber) { var earliestSupportedWeek = 1; var lastWeekofSem1 = 23; var lastWeekofSem2 = 40; var lastWeekofSpecialSem1 = 46; var lastWeekofSpecialSem2 = 52; if (acadWeekNumber >= earliestSupportedWeek && acadWeekNumber <= lastWeekofSem1) { return sem1; } else if (acadWeekNum...
javascript
{ "resource": "" }
q37346
getAcadWeekName
train
function getAcadWeekName(acadWeekNumber) { switch (acadWeekNumber) { case 7: return { weekType: 'Recess', weekNumber: null }; case 15: return { weekType: 'Reading', weekNumber: null }; case 16: case 17: return { weekType: 'Examinati...
javascript
{ "resource": "" }
q37347
getAcadWeekInfo
train
function getAcadWeekInfo(date) { var currentAcad = getAcadYear(date); var acadYear = currentAcad.year; var acadYearStartDate = currentAcad.startDate; var acadWeekNumber = Math.ceil((date.getTime() - acadYearStartDate.getTime() + 1) / oneWeekDuration); var semester = getAcadSem(acadWeekNumber); var weekTyp...
javascript
{ "resource": "" }
q37348
execute
train
function execute(req, res) { // stored in milliseconds but this command returns seconds res.send(null, Math.round(this.state.lastsave / 1000)); }
javascript
{ "resource": "" }
q37349
Q_chainmap_graceful
train
function Q_chainmap_graceful(args, func, failureCallback) { return Q.when().then(function(inValue) { return args.reduce(function(soFar, arg) { return soFar.then(function(val) { return func(arg, val); }).fail(function(err) { if (failureCallback) { ...
javascript
{ "resource": "" }
q37350
isValueObject
train
function isValueObject(obj) { return (obj instanceof Number) || (obj instanceof String) || (obj instanceof Boolean) || (obj === null); }
javascript
{ "resource": "" }
q37351
enter
train
function enter(f, rejected) { return function() { try { return Promise.resolve(f.apply(this, arguments)).catch(rejected) } catch(e) { return rejected(e) } } }
javascript
{ "resource": "" }
q37352
internal_parse_scope
train
function internal_parse_scope(center, distributionScope) { // "?" or "*" is filted by this.require() if (distributionScope.length < 4) return this.require(":::"); // systemPart:pathPart:scopePart // - rx_tokens = /^([^:]+):(.*):([^:]+)$/ -> m[0],m[1],m[2] var rx_tokens = /^(.*):([^:]+)$/, m = distributionScope....
javascript
{ "resource": "" }
q37353
train
function(db) { function check_javascript_function(js, plv8, ERROR) { var fun; try { // We'll check only positive input if(js) { fun = (new Function('return (' + js + ')'))(); if(! (fun && (fun instanceof Function)) ) { throw TypeError("Input is not valid JavaScript function: " + (typeof ...
javascript
{ "resource": "" }
q37354
exec
train
function exec(cmd) { const ret = shell.exec(cmd, { silent: true }); if (ret.code != 0) { console.error("Error:", ret.stdout, ret.stderr); process.exit(1); } return ret; }
javascript
{ "resource": "" }
q37355
shutdown
train
function shutdown() { var timer for (var id in requests) if (timer = requests[id].timer) { clearTimeout(timer) requests[id].timer = null } }
javascript
{ "resource": "" }
q37356
sassTranspiler
train
function sassTranspiler(path) { return function () { return gulp.src(path) .pipe(sass({outputStyle: 'compressed'})) .pipe(autoprefixer({ browsers: ['last 2 versions'] })) .pipe(gulp.dest('dist')); } }
javascript
{ "resource": "" }
q37357
train
function(object, converters, property) { var self = this; object.__addSetter(property, this.SETTER_NAME , this.SETTER_WEIGHT, function(value, fields) { return self.apply(value, converters, property, fields, this); }); }
javascript
{ "resource": "" }
q37358
train
function(value, converters, property, fields, object) { _.each(converters, function(converter) { value = converter.call(object, value, fields, property); }); return value; }
javascript
{ "resource": "" }
q37359
rf
train
function rf(df1, df2) { var rchisqRatio; rchisqRatio = function(d) { return chisq.rchisq(d)() / d; }; if (df1 <= 0 || df2 <= 0) { return function() { return NaN; }; } return function() { return rchisqRatio(df1) / rchisqRatio(df2); }; }
javascript
{ "resource": "" }
q37360
_subscribersDelete
train
function _subscribersDelete(id, revokeMeters) { return Api.request({ method: 'DELETE', url: makeUrl([this._config.default, id]), data: { revoke_meters: revokeMeters || false }, headers: { 'Content-Type': 'application/json;charset=UTF-8' } }); }
javascript
{ "resource": "" }
q37361
parseDocToTree
train
function parseDocToTree(doc, defaultTitle) { // save the parsed tree const tree = []; const lines = doc.split('\n'); let line, m; // 保存一个文档区域 let section = null; let parentSection = null; // if in a ``` block let inBlock = false; // little trick,如果第一行不是 #,则增加一个 # if (!/^#(?!#)/.test(lines[0])) {...
javascript
{ "resource": "" }
q37362
treeDFS
train
function treeDFS(tree, callback) { for (let it of tree.slice()) { callback(it, tree); if (typeof it === 'object') { treeDFS(it.children, callback); } } }
javascript
{ "resource": "" }
q37363
treeToDoc
train
function treeToDoc(tree) { if (tree.length === 0) return ''; return tree.map((it) => { if (typeof it === 'object') { return `${'#'.repeat(it.level)} ${it.title}\n${treeToDoc(it.children)}`; } return it; }).join('\n'); }
javascript
{ "resource": "" }
q37364
callEngineScripts
train
function callEngineScripts(engines, project_dir) { return Q.all( engines.map(function(engine){ // CB-5192; on Windows scriptSrc doesn't have file extension so we shouldn't check whether the script exists var scriptPath = engine.scriptSrc ? '"' + engine.scriptSrc + '"' : null; ...
javascript
{ "resource": "" }
q37365
defineProperties
train
function defineProperties(target, options/*, source, ...*/) { if (options == null) options = {}; var i = 2, max = arguments.length, source, prop; for (; i < max; ++i) { source = arguments[i]; if (!(source instanceof Object)) continue; for (prop in source) { if (source[prop] == n...
javascript
{ "resource": "" }
q37366
setProperties
train
function setProperties(target/*, source, ...*/) { var i = 1, max = arguments.length, source, prop; for (; i < max; ++i) { source = arguments[i]; if (!(source instanceof Object)) continue; for (prop in source) { if (source[prop] == null) continue; target[prop] = source[prop];...
javascript
{ "resource": "" }
q37367
extendClass
train
function extendClass(parent, constructor) { var anonymous = function() {}; anonymous.prototype = parent.prototype; constructor.prototype = new anonymous(); constructor.constructor = constructor; defineProperties.apply(null, [constructor.prototype, { configurable: false }].concat(Array.prototype.slice.call(a...
javascript
{ "resource": "" }
q37368
dethrow
train
function dethrow(fn) { try { /* jshint validthis: true */ return fn.apply(this, Array.prototype.slice.call(arguments, 1)); } catch (e) {} }
javascript
{ "resource": "" }
q37369
portable
train
function portable(obj, fn) { if (typeof fn === 'string') fn = obj[fn]; return function() { return fn.apply(obj, arguments); }; }
javascript
{ "resource": "" }
q37370
isValidPath
train
function isValidPath(path, allowDots) { if (typeof path !== 'string') return false; if (!path) return false; if (!/^([a-z]:[\/\\])?[a-z0-9_~\/\.\-]+$/i.test(path)) return false; if (!allowDots && /^\.{1,2}$/.test(path)) return false; return true; }
javascript
{ "resource": "" }
q37371
csv
train
function csv(array) { if (!(array instanceof Array) || array.length === 0) return ''; array = array.slice(0); var i = array.length; while (i--) array[i] = '"' + (''+array[i]).replace(/(\\|")/g, '\\$1') + '"'; return array.join(', '); }
javascript
{ "resource": "" }
q37372
train
function(encoded) { if (encoded instanceof Array) { encoded = encoded.map(function(chunk) {return chunk.replace(/^0x/g, '')}).join(''); } // Each symbol is 4 bits var result = []; var nextIndex = 0; while (nextIndex < encoded.length) { var schemaLength = parseInt(enc...
javascript
{ "resource": "" }
q37373
openSocket
train
function openSocket (sessionInfo, callback) { var socketUrl, socketInfo, socket_endpoint, new_socket; _log(sessionInfo); socketUrl = sessionInfo.endpoints.socket[0]; socketInfo = url.parse(socketUrl); _log(socketInfo); socket_endpoint = socketUrl + me.setting.apiroot + '/feed/ws?s...
javascript
{ "resource": "" }
q37374
initialize
train
function initialize(options) { // log config.logfile = options.logfile || 'logs/spider.log'; log4js.configure({ appenders: [ { type: 'console', category: 'console'}, { type: 'dateFile', filename: config.logfile, pattern: 'yyyy-MM-dd', category: 'default' } ], replaceConsole: true })...
javascript
{ "resource": "" }
q37375
init
train
function init(ctx) { var server = ctx.server; server.ext('onRequest', checkIfSSL); return new Q(ctx); }
javascript
{ "resource": "" }
q37376
parse
train
function parse (strip, associate) { var signature = strip.split('->') if (signature.length !== 2) return null // Param types: var params = signature[0].split(',') for (var i = params.length; i--;) { var p = params[i].trim() if (p === '*') params[i] = null else params[i] = p } // Return type:...
javascript
{ "resource": "" }
q37377
require
train
function require(name, jumped){ if (cache[name]) return cache[name].exports; if (modules[name]) return call(name, require); throw new Error('cannot find module "' + name + '"'); }
javascript
{ "resource": "" }
q37378
call
train
function call(id, require){ var m = { exports: {} }; var mod = modules[id]; var name = mod[2]; var fn = mod[0]; fn.call(m.exports, function(req){ var dep = modules[id][1][req]; return require(dep || req); }, m, m.exports, outer, modules, cache, entries); // store to cache after...
javascript
{ "resource": "" }
q37379
train
function() { // Walk all of the elements in the DOM (try to only do this once) var elements = doc.getElementsByTagName('*'); var re = /url\((http.*)\)/ig; for (var i = 0; i < elements.length; i++) { var el = elements[i]; var style = win.getComputedStyle(el); // check for Images ...
javascript
{ "resource": "" }
q37380
Context
train
function Context(hook, opts) { var prop; this.hook = hook; //create new object, to avoid affecting input opts in other places //For example context.opts.plugin = Object is done, then it affects by reference this.opts = {}; for (prop in opts) { if (opts.hasOwnProperty(prop)) { this.o...
javascript
{ "resource": "" }
q37381
grow
train
function grow(area, min, max) { if( typeof min !== 'undefined' ) { min = parseInt( min ); if( isNaN( min ) ) min = 2; } if( typeof max !== 'undefined' ) { max = parseInt( max ); if( isNaN( max ) ) max = 8; } if( max < min ) max = min; var text = area.value; var lines = 1; var index = -1...
javascript
{ "resource": "" }
q37382
train
function(field){ var req = this.req; field = field.toLowerCase(); switch (field) { case 'referer': case 'referrer': return req.headers.referrer || req.headers.referer || ''; default: return req.headers[fi...
javascript
{ "resource": "" }
q37383
logToConsole
train
function logToConsole(tags, message) { if (enabled) { if (arguments.length < 2) { message = tags; tags = []; } if (!util.isArray(tags)) tags = []; var text = new Date().getTime() + ', '; if (tags.length > 0) { text = text + tags[0] + ', '...
javascript
{ "resource": "" }
q37384
parseTags
train
function parseTags(tags) { if (tags.length > 0 && util.isArray(tags[0])) { tags = tags[0]; } return tags; }
javascript
{ "resource": "" }
q37385
Logger
train
function Logger(tags) { tags = parseTags(Array.prototype.slice.call(arguments)); if (!(this instanceof Logger)) { return new Logger(tags); } this.tags = tags; }
javascript
{ "resource": "" }
q37386
rinse
train
function rinse (pageobj, finalarray, maps) { // Map where data will be inserted var map = maps.pagemap(); // Render data in temp object // var ruffian = plates.bind(partials[pageobj.mastertemplate], pageobj, map); var ruffian = partials[pageobj.mastertemplate]; // Render plates' simple case scenario //...
javascript
{ "resource": "" }
q37387
insertMultiFragment
train
function insertMultiFragment (collection, index, array) { // Only get the objects with the correct collection value var filtered = finalarray.filter(function (element) { return element.collection === collection; }); // Map data with corresponding partials var map = maps.multimap(collection) ...
javascript
{ "resource": "" }
q37388
insertSingleFragment
train
function insertSingleFragment () { for (var i = 0; i < finalarray.length; i++) { // Check whether the object belongs to a collection or not if (finalarray[i].collection === 'none') { var singlepartial = finalarray[i].partial , singledest = finalarray[i].destination , map = m...
javascript
{ "resource": "" }
q37389
readPartials
train
function readPartials(userDir, cwd) { if (cwd) { userDir = path.join(cwd, userDir); } // Use working directory of process if not specified else { userDir = path.join(path.dirname(process.argv[1]), userDir); } partials = {}; var filenames = fs.readdirSync(userDir); for (var i = 0; i < filenames.l...
javascript
{ "resource": "" }
q37390
compile
train
function compile(node) { switch (node.type) { case 'field': var obj = {}; obj[node.name] = node.value; return obj; case 'op': var obj = {}; var op = '$' + node.op; obj[op] = [ compile(node.left), compile(node.right) ]; return obj; } }
javascript
{ "resource": "" }
q37391
remove
train
function remove(el, opts) { var count; var full = (el == window); var $el = $(el); var data = $el.data('blockUI.history'); var to = $el.data('blockUI.timeout'); if (to) { clearTimeout(to); $el.removeData('blockUI.timeout'); } opts = $.extend({}, $.blockUI.defaults, opts || {}); bind(0...
javascript
{ "resource": "" }
q37392
reset
train
function reset(els,data,opts,el) { var $el = $(el); if ( $el.data('blockUI.isBlocked') ) return; els.each(function(i,o) { // remove via DOM calls so we don't lose event handlers if (this.parentNode) this.parentNode.removeChild(this); }); if (data && data.el) { data.el.style.display...
javascript
{ "resource": "" }
q37393
watchFile
train
function watchFile( file ) { // make sure file is at least something if ( !file || '' === file ) { return } // make sure it's a string file = file.toString() if ( watchers.hasOwnProperty( file ) ) {...
javascript
{ "resource": "" }
q37394
NameIt
train
function NameIt(input) { var res = { _: [] , } , foos = Object.keys(NameIt) , i = 0 ; for (; i < foos.length; ++i) { res._.push(res[foos[i]] = NameIt[foos[i]](input)); } return res; }
javascript
{ "resource": "" }
q37395
mergeIfNeed
train
function mergeIfNeed(rtarget, o) { for (var key in o) { if (!rtarget[key]) { rtarget[key] = o[key]; } } return rtarget; }
javascript
{ "resource": "" }
q37396
setHandlers
train
function setHandlers(enableException, enableUnhandled) { if(enableException === true) { process.on('uncaughtException', UncaughtExceptionHandler); } if(enableUnhandled === true) { process.on('unhandledRejection', unhandledRejectionHandler); } }
javascript
{ "resource": "" }
q37397
UncaughtExceptionHandler
train
function UncaughtExceptionHandler(error) { // Call module.exports.crit here so that we can intercept the call in the tests module.exports.crit(`Unhandled exception: ${error.message}`); module.exports.crit(error.stack.toString()); process.exit(1); }
javascript
{ "resource": "" }
q37398
unhandledRejectionHandler
train
function unhandledRejectionHandler(error) { let reasonString = error.message || error.msg || JSON.stringify(error); module.exports.crit(`Unhandled Promise Rejection - reason: [${reasonString}]`); module.exports.crit(error.stack.toString()); }
javascript
{ "resource": "" }
q37399
StoreError
train
function StoreError(type, message) { this.name = StoreError.name; Error.call(this); type = type || ERR; message = type + ' ' + (message || 'unknown internal error'); if(arguments.length > 2) { var args = [message].concat([].slice.call(arguments, 2)); message = util.format.apply(util, args); } this...
javascript
{ "resource": "" }