_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q9500
queryCoversRange
train
function queryCoversRange(lessRestrictive, moreRestrictive) { // Short curcuit if there is an exact match if (lessRestrictive === moreRestrictive) { return true; } const lessRestrictiveParts = explodeMediaQuery(lessRestrictive); const moreRestrictiveParts = explodeMediaQuery(moreRestrictive); return l...
javascript
{ "resource": "" }
q9501
explodeMediaQuery
train
function explodeMediaQuery(query) { return query .split(',') .map(part => part.trim()) .map(orSection => orSection.split('and').map(part => part.trim())); }
javascript
{ "resource": "" }
q9502
arrayContainsAllElementsOfArray
train
function arrayContainsAllElementsOfArray(smaller, larger) { return smaller.reduce((prev, element) => { return prev && larger.indexOf(element) >= 0; }, true); }
javascript
{ "resource": "" }
q9503
distributeQueryAcrossQuery
train
function distributeQueryAcrossQuery(firstQuery, secondQuery) { const aParts = explodeMediaQuery(firstQuery); const bParts = explodeMediaQuery(secondQuery); return aParts .map(aPart => bParts.map(bPart => `${aPart} and ${bPart}`).join(', ')) .join(', '); }
javascript
{ "resource": "" }
q9504
Resolver
train
function Resolver(options) { if (!(this instanceof Resolver)) { return new Resolver(options); } options = options || {}; if (!isObject(options)) { throw new Error('options must be an object'); } this._resolver = new cares.Resolver(options); if (options.servers) { ...
javascript
{ "resource": "" }
q9505
format
train
function format(input, level, options) { if (util.isArray(input)) { return array(input, level, options); } else if (util.isObject(input)) { return object(input, level, options); } else { return stringify(input, options); } }
javascript
{ "resource": "" }
q9506
object
train
function object(input, level, options) { var spaces = options.spaces; var inner = indent(level, spaces); var outer = indent(level - 1, spaces); var keys = Object.keys(input); if (options.sortKeys) keys.sort(naturalSort()); var str = keys.map(function (key) { return inner + stringify(key) + ': ' ...
javascript
{ "resource": "" }
q9507
array
train
function array(input, level, options) { var spaces = options.spaces; var inner = indent(level, spaces); var outer = indent(level - 1, spaces); var str = input .map(function (value) { return inner + format(value, level + 1, options); }) .join(',\n'); return [ '[', str, outer + ']' ].join('\...
javascript
{ "resource": "" }
q9508
outImgToXYZ
train
function outImgToXYZ(i, j, faceIdx, faceSize) { var a = 2 * i / faceSize, b = 2 * j / faceSize; switch(faceIdx) { case 0: // back return({x:-1, y:1-a, z:1-b}); case 1: // left return({x:a-1, y:-1, z:1-b}); case 2: // front return({x: 1, y:a-1, z:1-b}); case 3: // right return({x:1-a, y:1, z:1-...
javascript
{ "resource": "" }
q9509
passId
train
function passId (trace, i, j) { let id = (trace.id != null ? trace.id : trace) let n = i let m = j let key = id << 16 | (n & 0xff) << 8 | m & 0xff return key }
javascript
{ "resource": "" }
q9510
getBox
train
function getBox (items, i, j) { let ilox, iloy, ihix, ihiy, jlox, jloy, jhix, jhiy let iitem = items[i], jitem = items[j] if (iitem.length > 2) { ilox = iitem[0] ihix = iitem[2] iloy = iitem[1] ihiy = iitem[3] } else if (iitem.length) { ilox = iloy = iitem[0] ihix = ihiy = iitem[1] } else { ilox =...
javascript
{ "resource": "" }
q9511
train
function(opt) { var vKeys = ["cancelBin", "queueBin", "submitBin"]; var msg = "Missing engine binaries parameters keys \"cancelBin\", \"queueBin\", \"submitBin\""; for (var k in vKeys) if (!opt.hasOwnProperty(k)) throw (msg); engine.configure(opt); }
javascript
{ "resource": "" }
q9512
train
function() { var displayString = '###############################\n' + '###### Current jobs pool ######\n' + '###############################\n'; var c = 0; for (var key in jobsArray) {; c++; displayString += '# ' + key + ' : ' + jobsArray[key].status + '\n'; } if (c === 0) d...
javascript
{ "resource": "" }
q9513
train
function(opt) { //console.log(opt) if (isStarted) return; var self = this; if (!opt) { throw "Options required to start manager : \"cacheDir\", \"tcp\", \"port\""; } cacheDir = opt.cacheDir + '/' + scheduler_id; TCPip = opt.tcp; TCPport = opt....
javascript
{ "resource": "" }
q9514
serial
train
function serial(promises) { const results = []; return promises .reduce((chain, promise) => chain.then(result => { results.push(result); return promise }), Promise.resolve()) .then(result => { results.push(result); ...
javascript
{ "resource": "" }
q9515
singleToMulti
train
function singleToMulti(mapping) { const newMapping = {}; Object.entries(mapping.mapping).forEach(m => { newMapping[m[0]] = [m[1]]; }); return { created: mapping.created, fields: [mapping.field], key: mapping.key, mapping: newMapping }; }
javascript
{ "resource": "" }
q9516
mappingToTable
train
function mappingToTable(mapping) { const mp = mapping.hasOwnProperty('field') ? singleToMulti(mapping) : mapping; const keyField = {key: mp.key, format: 'text'}; const data = { fields: [keyField].concat(mp.fields), records: Object.entries(mp.mapping).map(entry => { const rcd = {}; rcd[mp.key] ...
javascript
{ "resource": "" }
q9517
tableToMapping
train
function tableToMapping(table, key, ignore=['index']) { const now = new Date(); const mapping = { created: now.toString(), fields: table.fields.filter(e => e.key !== key) .filter(e => !ignore.includes(e.key)), key: key, mapping: {} }; table.records.forEach(row => { mapping.mapping[row[...
javascript
{ "resource": "" }
q9518
csvToMapping
train
function csvToMapping(csvString) { const lines = csvString.split(/\n|\r|\r\n/); const header = lines.shift().split(','); const key = header.shift(); const now = new Date(); const headerIdx = []; const fields = []; header.forEach((h, i) => { if (h === '') return; headerIdx.push(i); fields.push(...
javascript
{ "resource": "" }
q9519
train
function(milliseconds) { var formattedDate = '', self = this, dateObj = new Date(milliseconds), format = { d: function() { var day = format.j() return (day < 10) ? '0' + day : day }, D: function() { return self.weekdays[format.w()].substring(0, 3) }, j: function() ...
javascript
{ "resource": "" }
q9520
train
function(date, full) { return ((full == true) ? this.months[date] : ((this.months[date].length > 3) ? this.months[date].substring(0, 3) : this.months[date])) }
javascript
{ "resource": "" }
q9521
train
function(offset) { offset = offset || 0 var year = this.year var monthNum = this.month monthNum += offset if(monthNum < 0) { year-- } if(monthNum > 11) { year++ } return year }
javascript
{ "resource": "" }
q9522
train
function(offset) { var month = this.getOffsetMonth(offset) , year = this.getOffsetYear(offset) // checks to see if february is a leap year otherwise return the respective # of days return (month == 1 && !(year & 3) && (year % 1e2 || !(year % 4e2))) ? 29 : this.daysInMonth[month] }
javascript
{ "resource": "" }
q9523
train
function() { var html = '' for(i = 0, x = this.weekdays.length; i < x; i++) { html += '<th>' + this.weekdays[i].substring(0, 2) + '</th>' } return html }
javascript
{ "resource": "" }
q9524
train
function(offset) { var monthNum = this.month offset = offset || 0 monthNum += offset if(monthNum < 0) { monthNum = 11 } if(monthNum > 11) { monthNum = 0 } var month = this.getOffsetMonth(offset) , year = this.getOffsetYear(offset) // get the first day of the month we are currently viewing ...
javascript
{ "resource": "" }
q9525
train
function() { // First deselect everything this.el.all('td.selected').removeClass('selected') for (var i=0,date;date=this.selected[i];i++) { var cell = this.el.one('.pane[data-month="' + date.month + '"][data-year="' + date.year + '"] td[data-day="' + date.day + '"]') if (cell._node) { cell.add...
javascript
{ "resource": "" }
q9526
train
function () { let _that = this[PRIVATE]; if (_that.initialized() && _that.running()) { _that.gameboy.stopEmulator |= 2; _that.frames = 0; //Reset internal variables } }
javascript
{ "resource": "" }
q9527
readUInt64BE
train
function readUInt64BE(buffer, start) { var data = buffer.slice(start, start + 8); return data.readUInt32BE(4, 8); }
javascript
{ "resource": "" }
q9528
expressInit
train
function expressInit( req, res, next ) { req.next = next; req.context = {}; // patching this according to how express does it // not jshint ignoring the following lines because then it // warns that expreq and expres aren't used. // This works according to express implemenetation // DO NOT CHANGE IT req.__proto...
javascript
{ "resource": "" }
q9529
parseAhead
train
function parseAhead( router, req, done ) { var idx = 0; var stack = router.stack; var params = {}; var method = req.method ? req.method.toLowerCase() : undefined; next(); function next() { var layer = stack[ idx++ ]; if ( !layer ) { // strip dangling query params params = _.transform( params, function(...
javascript
{ "resource": "" }
q9530
prefix
train
function prefix( state, url ) { if ( state.config.urlPrefix ) { if ( _.isRegExp( url ) ) { return regex.prefix( state.config.urlPrefix, url ); } else { var prefixIndex = url.indexOf( state.config.urlPrefix ); var appliedPrefix = prefixIndex === 0 ? '' : state.config.urlPrefix; return buildUrl( appliedP...
javascript
{ "resource": "" }
q9531
NWTNodeList
train
function NWTNodeList(nodes) { localnwt.implement('DelayableQueue', this); var wrappedNodes = []; for( var i = 0, node ; node = nodes[i] ; i++ ) { wrappedNodes.push(new NWTNodeInstance(node)); } this.nodes = wrappedNodes; var iteratedFunctions = [ 'anim', 'appendTo', 'remove', 'addClass', 'removeClass',...
javascript
{ "resource": "" }
q9532
registerTask
train
function registerTask( task ) { grunt.registerMultiTask( task.name, task.help, function () { var done = this.async(); if ( ensureSketchtool() ) { var options = this.options(); var commands = []; this.files.forEach( function( file ) { file.src.filter( function ( src ) { var command = crea...
javascript
{ "resource": "" }
q9533
parseString
train
function parseString (xml, callback) { var doc, error, plist; try { doc = new DOMParser().parseFromString(xml); plist = parsePlistXML(doc.documentElement); } catch(e) { error = e; } callback(error, plist); }
javascript
{ "resource": "" }
q9534
parseStringSync
train
function parseStringSync (xml) { var doc = new DOMParser().parseFromString(xml); var plist; if (doc.documentElement.nodeName !== 'plist') { throw new Error('malformed document. First element should be <plist>'); } plist = parsePlistXML(doc.documentElement); // if the plist is an array with 1 element, p...
javascript
{ "resource": "" }
q9535
train
function(implClass, modClass) { var impls = { DelayableQueue : [ /** * Returns a queueable interface to the original object * This allows us to insert delays between chainable method calls using the .wait() method * Currently this is only implemented for the node class, but it should be possible to ...
javascript
{ "resource": "" }
q9536
train
function() { var self = this, item; self.inWork = true; if (!self.queue.length) { return; } item = self.queue.shift(); if (item.type == 'wait') { setTimeout(function(){ self._process(); }, item.duration*1000); } else { self.c...
javascript
{ "resource": "" }
q9537
train
function(event, callback) { var args = Array.prototype.slice.call(arguments, 1); localnwt.event._eventData = args; var customEvt = y.createEvent("UIEvents"); customEvt.initEvent(event, true, false); this._node.dispatchEvent(customEvt); }
javascript
{ "resource": "" }
q9538
isRunning
train
function isRunning(specs) { return specs.dataset.some(coll => { return coll.contents.some(e => { return ['ready', 'queued', 'running', 'interrupted'].includes(e.status); }); }); }
javascript
{ "resource": "" }
q9539
train
function(dir) { var curr = this.menu.one('li.active'), targetNode = curr[dir](); this.menu.one('li.active').removeClass('active'); targetNode.addClass('active'); return this; }
javascript
{ "resource": "" }
q9540
train
function(items) { var itemMarkup = '', i; for (i=0; i< items.length; i++) { itemMarkup += '<li><a href="#" data-value="' + items[i] + '">' + this.highlighter(items[i]) + '</a></li>'; } var inputRegion = this.node.region(); this.menu.setHtml(itemMarkup) this.menu.one('li').addClass('active') ...
javascript
{ "resource": "" }
q9541
erotic
train
function erotic(transparent) { const { stack } = new Error() const caller = getCallerFromArguments(arguments) const entryStack = getEntryStack(stack, transparent) return makeCallback(caller, entryStack, transparent) }
javascript
{ "resource": "" }
q9542
S3StreamDownload
train
function S3StreamDownload (s3, s3Params, options) { var downloader = new Downloader(s3, s3Params, options); return new DownloadStream(downloader); }
javascript
{ "resource": "" }
q9543
train
function(next) { self.loadAllExtensions(function() { // Add middleware to make html5mode work in angular. self.routers.page.use(function(request, response, next) { // If between JSON and HTML it prefers HTML, return index.html content since // we know its a direct browser reque...
javascript
{ "resource": "" }
q9544
train
function(next) { self.collect('field', function(error, fields) { if (error) { return callback(error); } self.fields = fields; self.loadAllTypes(next); }); }
javascript
{ "resource": "" }
q9545
train
function(next) { self.storage.init(function(error, collections) { if (error) { return next(error); } self.collections = collections; next(); }); }
javascript
{ "resource": "" }
q9546
processHandler
train
function processHandler(fn) { if (_.isFunction(handler)) { return fn(null, handler); } if (_.isString(handler)) { return self.processStringHandler(mycro, handler, fn); } if (_.isObject(handler)) { ...
javascript
{ "resource": "" }
q9547
cleanItem
train
function cleanItem(value) { var newvalue = null; if (Array.isArray(value)) { if (value.indexOf("consumer") > -1) { value.forEach(function (key2) { ids[key2] = "roles"; }); } newvalue = []; value.forE...
javascript
{ "resource": "" }
q9548
cleanItem3
train
function cleanItem3(value, parent) { var newvalue = null; if (Array.isArray(value)) { newvalue = []; var isAllNumbers = (value.length > 0); var isAllStrings = (value.length > 0) value.forEach(function (item) { if (typeof item !== 'number...
javascript
{ "resource": "" }
q9549
train
function (icuString, options) { icuString = this.cleanWhiteSpace(icuString); //args before kwargs if (typeof options !== 'undefined') { if (typeof options.string !== 'undefined') { var stringRe = new RegExp(('\{' + options.string + '\}'), 'g'); icuStr...
javascript
{ "resource": "" }
q9550
train
function (msgs, pluralForms) { var msgKey = 'digit'; var hasVariableName = false; for (var i=0; i<msgs.length; i++) { if (msgs[i].match(/%\([a-zA-Z0-9_.|]+\)d/g) !== null) { var match = msgs[i].match(/%\([a-zA-Z0-9_.|]+\)d/g)[0]; msgKey = match.substri...
javascript
{ "resource": "" }
q9551
removeFromList
train
function removeFromList (array, obj) { for (var i = 0; i < array.length; i++) { if (array[i] === obj) { array.splice(i, 1); } return; } }
javascript
{ "resource": "" }
q9552
findWhere
train
function findWhere (array, obj) { var props = Object.keys(obj); for (var i = 0; i < array.length; i++) { var passable = true; for (var j = 0; j < props.length; j++) { if (array[i][props[j]] !== obj[props[j]]) { passable = false; } } if (passable) return array[i]; } retu...
javascript
{ "resource": "" }
q9553
update
train
function update (obj1, obj2) { Object.keys(obj2).forEach(function (prop) { obj1[prop] = obj2[prop]; }); return obj1; }
javascript
{ "resource": "" }
q9554
randomAlpha
train
function randomAlpha (n) { var alpha = "abcdefghijklmnopqrstuvwxyz"; var res = ""; for (var i = 0; i < n; i++) { res += alpha.charAt(Math.floor(Math.random() * alpha.length)); } return res; }
javascript
{ "resource": "" }
q9555
Impromptu
train
function Impromptu() { this.state = new Impromptu.State() this._setRootPath(Impromptu.DEFAULT_CONFIG_DIR) this.log = new Impromptu.Log(this.state) this.exec = Impromptu.Exec(this.log) this.color = new Impromptu.Color(this.state) this.repository = new Impromptu.RepositoryFactory() this.db = new Impromptu....
javascript
{ "resource": "" }
q9556
checkFile
train
function checkFile( path ) { if ( typeof path === "undefined" || ! grunt.file.exists( path ) ) { grunt.log.error( "Source file \"" + path + "\" not found." ); return false; } return true; }
javascript
{ "resource": "" }
q9557
isIncludeFile
train
function isIncludeFile( path ) { if ( fs.statSync( path ).isFile() && getIncludeFileExtensions().indexOf( getFileExtension( path ) ) !== - 1 ) return true; return false; }
javascript
{ "resource": "" }
q9558
parseJSON
train
function parseJSON( path, content ) { return JSON.parse( content, function( key, value ) { if ( options.stripComments && key === "{{comment}}" ) return undefined; // Replace variables in their values if ( Object.keys( options.variables ).length && typeof v...
javascript
{ "resource": "" }
q9559
replaceVariables
train
function replaceVariables( value ) { return value.replace( options.variableRegex, function( match, key ) { if ( options.variables[ key ] === undefined ) { grunt.log.warn( "No variable definition found for: " + key ); return ""; } ...
javascript
{ "resource": "" }
q9560
parseDirectory
train
function parseDirectory( path ) { return fs.readdirSync( path ) .map( function( file ) { var filePath = path + "/" + file; if ( isIncludeFile( filePath ) ) return parseFile( filePath ); else if ( isDirectory( filePath ) ) return...
javascript
{ "resource": "" }
q9561
train
function(e) { var thumbOffset = this.thumb.region().height/2; this.setPositionIfValid(e._e.pageY - (this.node.region().top + this.scrollbarOffset) - thumbOffset); }
javascript
{ "resource": "" }
q9562
_parseNetworkLocation
train
function _parseNetworkLocation(networkLocation, obj) { var pos = networkLocation.indexOf(':'); if (pos === -1) { obj.host = networkLocation; } else { obj.host = networkLocation.substring(0, pos); if (pos < (networkLocation.length - 1)) { obj.port = networkLocation.substring(pos + 1); } } }
javascript
{ "resource": "" }
q9563
train
function(exists, done) { if (exists) { done(new AbstractCache.Error('The cache is currently locked.')) } else { client.get("lock-process:" + name, done) } }
javascript
{ "resource": "" }
q9564
capitalize
train
function capitalize (s) { if (!s) return s; if (s.length === 1) return s.toUpperCase(); return s[0].toUpperCase() + s.substring(1); }
javascript
{ "resource": "" }
q9565
generateOperations
train
function generateOperations (plural) { var operations = []; controller.methods().forEach(function (verb) { var operation = {}; var titlePlural = capitalize(controller.model().plural()); var titleSingular = capitalize(controller.model().singular()); // Don't do head, post/put for single...
javascript
{ "resource": "" }
q9566
DB
train
function DB() { this.requests = {} process.on('message', function(message) { if (message.type !== 'cache:response') { return } /** @type {{error: Error, response: string, uid: string, method: string}} */ var data = message.data // The requests for this UID may not exist because there can ...
javascript
{ "resource": "" }
q9567
read
train
function read (parser, type, key, limit = Infinity) { let count = 0 pipeline(parser, new Writable({ write (obj, enc, cb) { if (typeof type === 'string') key = type if (typeof type === 'number') { limit = type type = undefined } if (typeof key === 'number') { li...
javascript
{ "resource": "" }
q9568
Ruleset
train
function Ruleset(rules, composite) { if (!(this instanceof Ruleset)) { return new Ruleset(rules, composite); } this.composite = composite || 'all'; this.rules = rules || []; }
javascript
{ "resource": "" }
q9569
stop
train
function stop(next) { if (phantomProcess) { seleniumServerProcess.on('close', function (code, signal) { // this should really resolve both callbacks rather than guessing phantom wrapper will terminate instantly if (typeof next === 'function' && !seleniumServerProcess ) { ...
javascript
{ "resource": "" }
q9570
scaleBoxGroup
train
function scaleBoxGroup(selection) { selection.classed('mb-3', true); // Scale type const scaleOptions = [ {key: 'linear', name: 'Linear'}, {key: 'log', name: 'Log'} ]; selection.append('div') .classed('scale', true) .classed('mb-1', true) .call(lbox.selectBox, 'Scale') .call(l...
javascript
{ "resource": "" }
q9571
AbstractCache
train
function AbstractCache(state, name, options) { this.state = state this.name = name this.options = options this._update = this._update.bind(this) this._setLock = false this._setCallbacks = [] this._needsRefresh = false this.state.on('refreshCache', function (needsRefresh) { this._needsRefresh = nee...
javascript
{ "resource": "" }
q9572
succeedLambdaCallback
train
function succeedLambdaCallback(callback, response, event, context) { return executePreSuccessCallback(response, event, context) .then(() => callback(null, response)) .catch(err => { console.error(`Unexpected failure after executePreSuccessCallback`, err); return callback(null, response); }); }
javascript
{ "resource": "" }
q9573
TwitterAPIConnection
train
function TwitterAPIConnection(n) { RED.nodes.createNode(this,n); var node = this; node.consumerKey = n.consumerKey; node.consumerSecret = n.consumerSecret; node.accessToken = n.accessToken; node.accessSecret = n.accessSecret; var id = node.consumerKey; ...
javascript
{ "resource": "" }
q9574
buildSchema
train
function buildSchema(models, typeMap) { let type; var _models$map$reduce = models.map(model => { type = typeMap[model.modelName]; return { query: (0, _buildQuery2.default)(model, type), mutation: (0, _buildMutation2.default)(model, type) }; }).reduce((fields, modelField) => { fields.q...
javascript
{ "resource": "" }
q9575
loadDefaultStageHandlingOptions
train
function loadDefaultStageHandlingOptions() { const options = require('./stages-options.json'); const defaultOptions = options ? options.stageHandlingOptions : {}; const defaults = { envStageName: 'STAGE', streamNameStageSeparator: '_', resourceNameStageSeparator: '_', injectInCase: 'upper', e...
javascript
{ "resource": "" }
q9576
toStageSuffixedName
train
function toStageSuffixedName(unsuffixedName, separator, stage, inCase) { const name = trim(unsuffixedName); const stageSuffix = isNotBlank(stage) ? `${trimOrEmpty(separator)}${toCase(trim(stage), inCase)}` : ''; return isNotBlank(name) && isNotBlank(stageSuffix) && !name.endsWith(stageSuffix) ? `${name}${stageSuf...
javascript
{ "resource": "" }
q9577
toCase
train
function toCase(value, asCase) { if (isNotBlank(value)) { // Convert the given asCase argument to lowercase to facilitate matching const caseToUse = trimOrEmpty(asCase && asCase.toLowerCase ? asCase.toLowerCase() : asCase); // Convert the given stage into the requested case return caseToUse === 'lowe...
javascript
{ "resource": "" }
q9578
filterArgs
train
function filterArgs(defaultArgs, opt) { opt = opt || {}; const packValueToNonNull = value => (0, _assign2.default)({}, value, { type: new _graphql.GraphQLNonNull(value.type) }); return (0, _entries2.default)(defaultArgs).filter(_ref => { var _ref2 = (0, _slicedToArray3.default)(_ref, 2); let arg = _ref2[...
javascript
{ "resource": "" }
q9579
toMongooseArgs
train
function toMongooseArgs(args) { // Covert name_first to name: {first} let keyDepth = []; return (0, _entries2.default)(args).reduce((args, _ref7) => { var _ref8 = (0, _slicedToArray3.default)(_ref7, 2); let key = _ref8[0]; let value = _ref8[1]; keyDepth = key.split('_'); if (keyDepth.length ...
javascript
{ "resource": "" }
q9580
directoryCleanEverything
train
function directoryCleanEverything(dirPath, includeExtension, toRemove, replacement) { if(!fs.existsSync(dirPath)) return; let isDirectory = fs.statSync(dirPath).isDirectory(); // try cleaning package.json in current dir if(!isDirectory && dirPath.match(new RegExp(includeExtension + "$", "g"))) { ...
javascript
{ "resource": "" }
q9581
resolveVarValue
train
function resolveVarValue (name, values) { if (is.undef(values) || is.args.empty(arguments)) { message('Error: Missing arguments'); return undefined; } if (!is.string(name) || !is.object(values)) { message('Error: Check arguments type'); return undefined; } const var...
javascript
{ "resource": "" }
q9582
message
train
function message (text) { const normalText = text.toLowerCase(); if (~normalText.indexOf('warning')) { log.warn(text) } else if (~normalText.indexOf('error')) { log.error(text); } else { log.debug(text); } }
javascript
{ "resource": "" }
q9583
toObjectFromDynamoDBMap
train
function toObjectFromDynamoDBMap(dynamoDBMap) { if (!dynamoDBMap || typeof dynamoDBMap !== 'object') { return dynamoDBMap; } const object = {}; const keys = Object.getOwnPropertyNames(dynamoDBMap); for (let i = 0; i < keys.length; ++i) { const key = keys[i]; object[key] = toValueFromAttributeValue...
javascript
{ "resource": "" }
q9584
toValueFromAttributeValue
train
function toValueFromAttributeValue(attributeValue) { if (!attributeValue || typeof attributeValue !== 'object') { return attributeValue; } const values = Object.getOwnPropertyNames(attributeValue).map(type => { return toValueFromAttributeTypeAndValue(type, attributeValue[type]) }); if (values.length !...
javascript
{ "resource": "" }
q9585
toValueFromAttributeTypeAndValue
train
function toValueFromAttributeTypeAndValue(attributeType, value) { switch (attributeType) { case 'S': return value; case 'N': return toNumberOrIntegerLike(value); case 'BOOL': return value === true || value === 'true'; case 'NULL': return null; case 'M': return toObjec...
javascript
{ "resource": "" }
q9586
toKeyValueStrings
train
function toKeyValueStrings(dynamoDBMap) { return dynamoDBMap && typeof dynamoDBMap === 'object' ? Object.getOwnPropertyNames(dynamoDBMap).map(key => `${key}:${stringify(toValueFromAttributeValue(dynamoDBMap[key]))}`) : []; }
javascript
{ "resource": "" }
q9587
toKeyValuePairs
train
function toKeyValuePairs(dynamoDBMap) { return dynamoDBMap && typeof dynamoDBMap === 'object' ? Object.getOwnPropertyNames(dynamoDBMap).map(key => [key, toValueFromAttributeValue(dynamoDBMap[key])]) : []; }
javascript
{ "resource": "" }
q9588
forInitial
train
function forInitial(props) { const { navigation, scene } = props; const focused = navigation.state.index === scene.index; const opacity = focused ? 1 : 0; // If not focused, move the scene far away. const translate = focused ? 0 : 1000000; return { opacity, transform: [{ translateX: translate }, { ...
javascript
{ "resource": "" }
q9589
forHorizontal
train
function forHorizontal(props) { const { layout, position, scene } = props; if (!layout.isMeasured) { return forInitial(props); } const interpolate = getSceneIndicesForInterpolationInputRange(props); if (!interpolate) return { opacity: 0 }; const { first, last } = interpolate; const index = scene.in...
javascript
{ "resource": "" }
q9590
forFadeFromBottomAndroid
train
function forFadeFromBottomAndroid(props) { const { layout, position, scene } = props; if (!layout.isMeasured) { return forInitial(props); } const interpolate = getSceneIndicesForInterpolationInputRange(props); if (!interpolate) return { opacity: 0 }; const { first, last } = interpolate; const index...
javascript
{ "resource": "" }
q9591
forFade
train
function forFade(props) { const { layout, position, scene } = props; if (!layout.isMeasured) { return forInitial(props); } const interpolate = getSceneIndicesForInterpolationInputRange(props); if (!interpolate) return { opacity: 0 }; const { first, last } = interpolate; const index = scene.index; ...
javascript
{ "resource": "" }
q9592
loadAndServe
train
function loadAndServe() { ip2co.dbLoad(); ip2co.listenHTTP({hostname: appConfig.listenOpt.http.hostname, port: appConfig.listenOpt.http.port}); }
javascript
{ "resource": "" }
q9593
extrapolateDatesFromLines
train
function extrapolateDatesFromLines(claimLines, returnChildObj) { var lowTime; var highTime; var pointTime; if (returnChildObj.date_time) { if (returnChildObj.date_time.low) { lowTime = returnChildObj.date_time.low; } if (returnChildObj.date_time.high) { hi...
javascript
{ "resource": "" }
q9594
$var
train
function $var(params, fn, envs) { if (params == null) { return params; } if (typeof params === 'string') { if (envs && envs[params] !== undefined) { return envs[params]; } return; } if (Array.isArray(params) && params.length === 2) { const key = p...
javascript
{ "resource": "" }
q9595
$path
train
function $path(params) { if (params == null) { return params; } if (typeof params === 'string') { const path = require('path'); if (path.isAbsolute(params)) { return params; } return path.resolve(process.cwd(), params); } throw new Error('$path ex...
javascript
{ "resource": "" }
q9596
$file
train
function $file(params, fn) { if (params == null) { return params; } let file, encoding; if (typeof params === 'string') { file = params; } else if (Array.isArray(params) && params.length === 2) { file = params[0]; encoding = params[1]; } if ( typeof fi...
javascript
{ "resource": "" }
q9597
$number
train
function $number(params) { if (params == null) { return params; } if (typeof params === 'number') { return params; } if (typeof params === 'string') { return Number(params); } throw new Error('$number expects a number or string'); }
javascript
{ "resource": "" }
q9598
train
function(db, namespace) { var collection = this; collection.trigger('request', collection); fetch(db, namespace, function(err, res) { if (err) { throw err; } collection.reset(res, {parse: true}); collection.trigger('sync', collection); }); return collection; }
javascript
{ "resource": "" }
q9599
BFFS
train
function BFFS(options) { if (!this) return new BFFS(options); options = this.init(options); var store = options.store; var prefix = options.prefix; var env = options.env; var cdn = options.cdn; // // We keep the running status of builds in redis. // this.store = store; // // Everything else ...
javascript
{ "resource": "" }