_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q41300
train
function(webhookId, callback) { utils.debug('Webhooks get: ' + webhookId); request.get({ path: '/webhooks/' + utils.toUUID(webhookId), }, callback); }
javascript
{ "resource": "" }
q41301
xBarPadding
train
function xBarPadding() { var domain = xBar.domain(); var barSpacing = (domain.length > 1 ? (xBar(domain[1]) - xBar(domain[0])) : xBar.rangeBand()); var barPadding = (barSpacing - xBar.rangeBand()); return barPadding; }
javascript
{ "resource": "" }
q41302
trimToXDomain
train
function trimToXDomain(array) { var start = 0, len = array.length, xDomainStart = parent.x.domain()[0]; // remove any data earlier than first full range while ( start < len ) { if ( array[start].date.getTime() >= xDomainStart.getTime() ) { break; } start += 1; } return (start === 0 ? arr...
javascript
{ "resource": "" }
q41303
drawHoverHighlightBars
train
function drawHoverHighlightBars(dataArray) { var hoverBar = parent.svgHoverRoot.selectAll('rect.highlightbar').data(dataArray); hoverBar.attr('x', valueX) .attr('width', xBar.rangeBand()); hoverBar.enter().append('rect') .attr('x', valueX) .attr('y', 0) .attr('height', parent.height) .attr('wi...
javascript
{ "resource": "" }
q41304
drawSelection
train
function drawSelection(dataArray) { var firstItem = (dataArray && dataArray.length > 0 ? dataArray.slice(0, 1) : []), firstItemX = (dataArray && dataArray.length > 0 ? valueX(dataArray[0]) : 0), lastItemX = (dataArray && dataArray.length > 0 ? valueX(dataArray[dataArray.length - 1]) : 0), width = (lastItemX ...
javascript
{ "resource": "" }
q41305
mongooseify
train
function mongooseify(obj, returnValues) { applyMethods(obj); traverse(obj, (key, value) => { applyMethods(value); }); function applyMethods(value) { if(value && value.hasOwnProperty('_id')) { value.toObject = jasmine.createSpy('toObject'); ...
javascript
{ "resource": "" }
q41306
train
function(type, envelope, complete) { // We send the message by navigating the browser to a special URL. // The iOS library will catch the navigation, prevent the UIWebView // from continuing, and use the data in the URL to execute code // within the iOS app. ...
javascript
{ "resource": "" }
q41307
train
function(type, messageId, json) { var self = this; var listenerList = this.listeners[type] || []; var executedCount = 0; var complete = function() { executedCount += 1; if (executedCount >= listenerList.length) { sel...
javascript
{ "resource": "" }
q41308
buildHasteMap
train
function buildHasteMap(rootPath, prefix) { var prefix = prefix || 'haste-map-provider'; return new HasteMapBuilder({ "extensions": [ "snap", "js", "json", "jsx", "node" ], "ignorePattern": /SOME_COMPLEX_IGNORE_PATTERN_UNLIKELY_TO_HAPPEN/,...
javascript
{ "resource": "" }
q41309
train
function(to_clean) { _.map(to_clean, function(value, key, to_clean) { if (value === undefined) { delete to_clean[key]; } }); return to_clean; }
javascript
{ "resource": "" }
q41310
create
train
function create(appName, callback) { commons.post(format('/%s/apps/', deis.version), { id: appName }, callback); }
javascript
{ "resource": "" }
q41311
list
train
function list(pageSize, callback) { var limit = 100; if (!isFunction(pageSize)) { limit = pageSize; }else { callback = pageSize; } commons.get(format('/%s/apps?limit=%s', deis.version, limit), callback); }
javascript
{ "resource": "" }
q41312
info
train
function info(appName, callback) { commons.get(format('/%s/apps/%s/', deis.version, appName), callback); }
javascript
{ "resource": "" }
q41313
logs
train
function logs(appName, callback) { commons.get(format('/%s/apps/%s/logs/', deis.version, appName), callback); }
javascript
{ "resource": "" }
q41314
run
train
function run(appName, command, callback) { commons.get(format('/%s/apps/%s/run/', deis.version, appName), callback); }
javascript
{ "resource": "" }
q41315
destroy
train
function destroy(appName, callback) { commons.del(format('/%s/apps/%s/', deis.version, appName), callback); }
javascript
{ "resource": "" }
q41316
start
train
function start(basedir, connectionCompleteCallback) { var defaultConfig = require("./config/defaults.json"); var config = Config.create(basedir, defaultConfig); var globalObject = { config: config }; var loginCompleteCallback = function(bot) { globalObject.bot = bot; bot.connect(config...
javascript
{ "resource": "" }
q41317
_createCommandHandler
train
function _createCommandHandler(commands) { return function(chatEvent, globalObject) { if (!chatEvent.command) { return; } var commandName = chatEvent.command; if (!globalObject.config.DubBotBase.areCommandsCaseSensitive) { commandName = commandName.toLowerC...
javascript
{ "resource": "" }
q41318
_registerCommands
train
function _registerCommands(basedir, globalObject) { var commandsDir = path.resolve(basedir, "commands"); var files; try { files = Utils.getAllFilePathsUnderDirectory(commandsDir); LOG.info("Found the following potential command files: {}", files); } catch (e) { LOG.error("Un...
javascript
{ "resource": "" }
q41319
_registerEventListeners
train
function _registerEventListeners(basedir, globalObject) { var bot = globalObject.bot; var eventListenerDir = path.resolve(basedir, "event_listeners"); var files; try { files = Utils.getAllFilePathsUnderDirectory(eventListenerDir); LOG.info("Found the following potential event listener f...
javascript
{ "resource": "" }
q41320
getMongoHandle
train
function getMongoHandle(mongoose) { var res = { mongoose: mongoose, modelDocs: {}, modelESchemas: {}, mongoMaps: {} }; var modelES = Schemaload.getExtendedSchemaModel(mongoose); return modelES.distinct('modelname').then((modelnames) => { debuglog(() => 'here disti...
javascript
{ "resource": "" }
q41321
getDomainsForBitField
train
function getDomainsForBitField(oModel, bitfield) { return oModel.domains.filter(domain => (getDomainBitIndex(domain, oModel) & bitfield)); }
javascript
{ "resource": "" }
q41322
loadModels
train
function loadModels(mongoose, modelPath) { if (mongoose === undefined) { throw new Error('expect a mongoose handle to be passed'); } return getMongoHandle(mongoose).then((modelHandle) => { debuglog(`got a mongo handle for ${modelPath}`); return _loadModelsFull(modelHandle, modelPath)...
javascript
{ "resource": "" }
q41323
difference
train
function difference(arrayA, arrayB) { var maxLength = _.max([ arrayA.length, arrayB.length ]); for (var i = 0, j = 0; i < maxLength; i += 1, j += 1) { if (arrayA[i] !== arrayB[j]) { if (arrayB[i-1] === arrayA[i]) { j -= 1; } else if (arrayB[i+1] === arrayA[i]) { j += 1; } else...
javascript
{ "resource": "" }
q41324
decode
train
function decode(buf) { let off = 0; var i; // unpack meta const meta = buf[(off += 1)]; // const VERSION = meta >> 4; const argv = meta & 0xf; const args = new Array(argv); // unpack args for (i = 0; i < argv; i += 1) { const len = buf.readUInt32BE(off); off += 4; args[i] = buf.slice(of...
javascript
{ "resource": "" }
q41325
appendListener
train
function appendListener(event, listener, once) { this.events[event] = this.events[event] || []; this.events[event].push({ "listener": listener, "once": !!once }); this.emit('newListener', event, listener); if (this.events[event].length > this.maxListeners) { console.warn('warni...
javascript
{ "resource": "" }
q41326
train
function(u){ var urlObj = url.parse(u) return u.replace( urlObj.search, '').replace('#', '') }
javascript
{ "resource": "" }
q41327
train
function(u){ var urlObj = url.parse(u) return urlObj.protocol + "//" + urlObj.hostname + urlObj.pathname }
javascript
{ "resource": "" }
q41328
PostEmitter
train
function PostEmitter() { var _this = this; //might be global this._listener = function(ev) { //check origin //then var data = ev.data; _this.emit.apply(_this, data instanceof Array ? data : [data]); }; window[attach](prefix + 'message', this._listener); }
javascript
{ "resource": "" }
q41329
sn_color_map
train
function sn_color_map(fillColors, keys) { var colorRange = d3.scale.ordinal().range(fillColors); var colorData = keys.map(function(el, i) { return {source:el, color:colorRange(i)}; }); // also provide a mapping of sources to corresponding colors var i, len, sourceName; for ( i = 0, len = colorData.length; i < le...
javascript
{ "resource": "" }
q41330
sn_color_color
train
function sn_color_color(d) { var s = Number(d.source); if ( isNaN(s) ) { return sn.runtime.colorData[d.source]; } return sn.runtime.colorData.reduce(function(c, obj) { return (obj.source === d.source ? obj.color : c); }, sn.runtime.colorData[0].color); }
javascript
{ "resource": "" }
q41331
_createConsumerMessage
train
function _createConsumerMessage(consumer, message, {chanId}) { const { iterator: consumerIterator, type: requestType, payload } = consumer if (requestType === cSelectRequest) { const {selectedChanIds} = payload const i = selectedChanIds.indexOf(chanId) const response = new Array(selectedCh...
javascript
{ "resource": "" }
q41332
train
function () { var stream = new $.streamqueue({ objectMode: true }); //Optionally injected additional javascript sourcecode injectIntoStream(stream, options.injectInto.js.pre); // App files without vendor files ...
javascript
{ "resource": "" }
q41333
train
function () { var stream = new $.streamqueue({ objectMode: true }); //Optionally injected additional css sourcecode injectIntoStream(stream, options.injectInto.css.pre); // App files without vendor files ...
javascript
{ "resource": "" }
q41334
merge
train
function merge(target, ...sources) { let targetObject = target; if (!isObj(target)) { targetObject = {}; } // for all the sources provided merge them with // the target object sources.forEach((s) => { // before merging check the source is an object if (isObj(s)) { targetObject = mergeObj...
javascript
{ "resource": "" }
q41335
lintStream
train
function lintStream(spec) { if (!spec || !spec.jslint) { throw new gulpUtil.PluginError(pluginName, 'The file path to jslint is required.'); } var errors = 0; function lint(source, callback) { var contents = source.contents.toString('utf8'); var result = context.jslint(contents...
javascript
{ "resource": "" }
q41336
rejectAll
train
function rejectAll(requests, error) { for (const request of requests) { request.abort(); request.reject(error); } }
javascript
{ "resource": "" }
q41337
UnauthorizedError
train
function UnauthorizedError(message) { Error.call(this); Error.captureStackTrace(this, this.constructor); this.status = 401; this.message = 'Unauthorized: ' + message; this.name = this.constructor.name; }
javascript
{ "resource": "" }
q41338
NotFoundError
train
function NotFoundError(message) { Error.call(this); Error.captureStackTrace(this, this.constructor); this.status = 404; this.message = 'Not Found: ' + message; this.name = this.constructor.name; }
javascript
{ "resource": "" }
q41339
train
function(el) { var self = this, $el = $(el); if ($el.length > 1) { $el.each(function() { self.addElement(this); }); } else if ($el.length === 0) { throw new Error("Invalid element!"); } if (this.$el.closest($el).length) { throw new Error("Element is a child of this view. This is only for ...
javascript
{ "resource": "" }
q41340
styler
train
function styler(...rawStyles) { const stylesBundle = buildStyles.apply(null, rawStyles); /** * Styling composer * * @param {...string} classNames - Class names of desired styles */ return function stylingComposer(classNames, error) { var parsedClassNames; const styles = []; const notFoun...
javascript
{ "resource": "" }
q41341
checkHasValue
train
function checkHasValue(value, message) { checkNotEmpty(message, "No error message passed to checkHasValue"); if (value === null || typeof value === "undefined") { throw new Error(message); } }
javascript
{ "resource": "" }
q41342
checkNotEmpty
train
function checkNotEmpty(string, message) { if (!message || !message.trim()) { throw new Error("No error message passed to checkNotEmpty"); } if (!string || !string.trim()) { throw new Error(message); } }
javascript
{ "resource": "" }
q41343
checkValueIsInObject
train
function checkValueIsInObject(value, object, message) { checkNotEmpty(message, "No error message passed to checkValueIsInObject"); var key = findValueInObject(value, object); if (typeof key === "undefined") { // Make sure the value's actually missing and it's not hidden behind undefined if...
javascript
{ "resource": "" }
q41344
deepEquals
train
function deepEquals(obj1, obj2) { if (typeof obj1 !== typeof obj2) { return false; } // NaN check if (obj1 !== obj1) { return obj2 !== obj2; } // Non-object types will compare correctly with === if (typeof obj1 !== "object") { return obj1 === obj2; } if (!_...
javascript
{ "resource": "" }
q41345
findValueInObject
train
function findValueInObject(value, object) { checkHasType(object, "object", "Non-object value provided as second argument to findValueInObject"); checkHasValue(object, "Invalid null object provided as second argument to findValueInObject"); for (var key in object) { var objValue = object[key]; ...
javascript
{ "resource": "" }
q41346
getAllFilePathsUnderDirectory
train
function getAllFilePathsUnderDirectory(directory) { // TODO: make this run in parallel, async var filesInBaseDir = fs.readdirSync(directory); var allFiles = []; if (!filesInBaseDir) { return allFiles; } for (var i = 0; i < filesInBaseDir.length; i++) { var filePath = path.reso...
javascript
{ "resource": "" }
q41347
_checkKeysFromFirstAreInSecond
train
function _checkKeysFromFirstAreInSecond(first, second) { for (var key in first) { if (!(key in second)) { return false; } var value1 = first[key]; var value2 = second[key]; if (!deepEquals(value1, value2)) { return false; } } return ...
javascript
{ "resource": "" }
q41348
getBody
train
function getBody(req) { return new Promise((resolve, reject) => { let data = ''; req .on('data', (chunk) => { data += chunk; }) .on('end', () => { resolve(data); }) .on('error', reject); }); }
javascript
{ "resource": "" }
q41349
train
function(req, res, next) { var accData = req.user.Account , newData = { name: req.body.name || accData.name, logo: req.body.logo || accData.logo, info: req.body.info || accData.info, email: req.body.email || accData.emai...
javascript
{ "resource": "" }
q41350
train
function(req, res, next){ var subdomain = req.body.subdomain; if (!subdomain) { return res.json(400, 'Company subdomain is mandatory!'); } AccountService .find({ where: { subdomain: subdomain } }) .then(function(result){ ...
javascript
{ "resource": "" }
q41351
finalize
train
function finalize(base, path, patches, inversePatches) { if (isProxy(base)) { var state = base[PROXY_STATE]; if (state.modified === true) { if (state.finalized === true) return state.copy; state.finalized = true; var result = finalizeObject(useProxies ...
javascript
{ "resource": "" }
q41352
produce
train
function produce(baseState, producer, patchListener) { // prettier-ignore if (arguments.length < 1 || arguments.length > 3) throw new Error("produce expects 1 to 3 arguments, got " + arguments.length); // curried invocation if (typeof baseState === "function") { // prettier-ignore ...
javascript
{ "resource": "" }
q41353
mergeOptions
train
function mergeOptions(config, pass) { var _this = this; var result = loadConfig(config); var plugins = result.plugins.map(function (descriptor) { return loadPluginDescriptor(descriptor); }); var presets = result.presets.map(function (descriptor) { return loadPresetDescrip...
javascript
{ "resource": "" }
q41354
loadConfig
train
function loadConfig(config) { var options = normalizeOptions(config); if (config.options.plugins != null && !Array.isArray(config.options.plugins)) { throw new Error(".plugins should be an array, null, or undefined"); } var plugins = (config.options.plugins || []).map(function (plugin, index) { var _n...
javascript
{ "resource": "" }
q41355
loadPresetDescriptor
train
function loadPresetDescriptor(descriptor) { return { type: "preset", options: loadDescriptor(descriptor).value, alias: descriptor.alias, loc: descriptor.loc, dirname: descriptor.dirname }; }
javascript
{ "resource": "" }
q41356
train
function(options) { options = options || {}; this._modelBindersMap = null; this._collectionBinder = null; this._bindingIndex = null; this._itemAlias = null; this._subviewsStruct = null; this._explicitSubviewsStruct = null; this._pendingRefresh = false; this._pendingRefreshRoot = false; this._subv...
javascript
{ "resource": "" }
q41357
train
function() { if(!this._modelBindersMap) this._initBinding(); if(!this._collectionBinder) { this._explicitSubviewsStruct = null; if(this._template) this.element.innerHTML = this._template; if(this.render !== noop) this.render(); this.renderSubviews(); } }
javascript
{ "resource": "" }
q41358
train
function() { if(this._isRunning && !this._isSuspended) { var shouldRefresh = true; if(typeof this.shouldRefresh === 'function') shouldRefresh = this.shouldRefresh(); if(shouldRefresh) { if(typeof this.refresh === 'function') this.refresh(); if(this._collectionBinder) { this._collection...
javascript
{ "resource": "" }
q41359
train
function() { var view = this; while(view.parentView) { view = view.parentView; } if(view.dispatcher !== null) { view.dispatcher.trigger({ type: 'refresh' }); this._pendingRefreshRoot = false; } }
javascript
{ "resource": "" }
q41360
train
function() { this._destroyBinding(); if(this._collectionBinder) this._collectionBinder.destroyBoundViews(); this._modelBindersMap = null; this._collectionBinder = null; this._bindingIndex = null; this._itemAlias = null; this.element.removeAttribute(settings.DATA_RENDERED_ATTR); this.undelegateEvents...
javascript
{ "resource": "" }
q41361
train
function() { if(this._collectionBinder) { this._collectionBinder.destroyBoundViews(); } else { var subView, i, l; // Destroy subviews if(this.subviews !== null) { for(i = 0, l = this.subviews.length; i < l; i++) { subView = this.subviews[i]; subView.destroyAll(); } } ...
javascript
{ "resource": "" }
q41362
train
function(keyPath) { if(typeof keyPath === 'string') keyPath = keyPath.split('.'); var rootCursorName = keyPath[0]; keyPath = keyPath.slice(1); var rootCursor = this.scope[rootCursorName]; if(!(rootCursor instanceof Cursor)) rootCursor = new Cursor(rootCursor, keyPath); var cursor = rootCursor.refine(keyP...
javascript
{ "resource": "" }
q41363
train
function(events) { if(!Array.isArray(events)) { if(arguments.length === 2 || arguments.length === 3) this.domEvents.push(Array.prototype.slice.apply(arguments)); return; } else if(!Array.isArray(events[0])) { events = Array.prototype.slice.apply(arguments); } Array.prototype.push.apply(this.domE...
javascript
{ "resource": "" }
q41364
train
function(viewName, options) { var subView, args; if(this._subviewsArgs && Array.isArray(this._subviewsArgs[viewName])) { args = this._subviewsArgs[viewName]; if(typeof args[0] === 'object' && args[0] !== null) options = immerge(options, args[0]); } options.parentView = this; if(viewName === 'View'...
javascript
{ "resource": "" }
q41365
train
function(element, viewName, options) { if(this._explicitSubviewsStruct === null) this._explicitSubviewsStruct = []; this._explicitSubviewsStruct.push({ viewName: viewName, element: element, options: options || {} }); }
javascript
{ "resource": "" }
q41366
train
function(force) { if(this._collectionBinder) { this._collectionBinder.refreshBinders(force); } else { this._refreshOwnBinders(force); if(this.subviews !== null) { for(var i = 0, l = this.subviews.length; i < l; i++) this.subviews[i].refreshBinders(force); } } }
javascript
{ "resource": "" }
q41367
train
function() { if(this._collectionBinder) { this._collectionBinder.refreshIndexedBinders(); } else { if(this._modelBindersMap) { this._modelBindersMap.refreshIndexedBinders(); } if(this.subviews !== null) { for(var i = 0, l = this.subviews.length; i < l; i++) this.subviews[i].refreshI...
javascript
{ "resource": "" }
q41368
train
function() { var l; var clonedSubview; var options = this.options; options.parentView = null; options.env = this.env; options._clone = true; var clonedView = new this.constructor(options); if(this.subviews !== null) { l = this.subviews.length; clonedView.subviews = new Array(l); while(l--...
javascript
{ "resource": "" }
q41369
train
function(element) { var i, l; this.element = element; this._rebindSubViews(element, { subviewIndex: 0, subviewsStructIndex: 0, index: 0 }); if(this._modelBindersMap) { this._modelBindersMap.setView(this); } if(this._collectionBinder) { this._collectionBinder.view = this; } }
javascript
{ "resource": "" }
q41370
BinderLogReader
train
function BinderLogReader () { this.config = defaultConfig var staticLogsUrl = this.config.host + ':' + this.config.elasticsearch.port this.client = new elasticsearch.Client({ host: staticLogsUrl, log: 'error' }) }
javascript
{ "resource": "" }
q41371
train
function (config) { if (!config) { config = defaultConfig } var error = validateConfig(config) if (error) { } config = assign(defaultConfig, config) return new BinderLogReader(config) }
javascript
{ "resource": "" }
q41372
train
function(done) { var source = __dirname + '/background.js'; var dest = self.dir + '/background.js'; fs.readFile(source, 'utf8', function(err, background) { if (err) return done(err); // Make background.js connect with the websocke...
javascript
{ "resource": "" }
q41373
closeServer
train
function closeServer(done) { if (self.server) { self.server.close(); self.server.removeListener('error', handlers.relayError); } self.httpServer.close(done); }
javascript
{ "resource": "" }
q41374
removeExtensionDir
train
function removeExtensionDir(done) { if (!self.dir) return done(null); rimraf(self.dir, done); }
javascript
{ "resource": "" }
q41375
createAndSpawn
train
function createAndSpawn(opts) { const spawned = createSpawn(opts) const termination = spawned.spawn() return { termination, proc: spawned.proc } }
javascript
{ "resource": "" }
q41376
boolStringOption
train
function boolStringOption(value){ if(value === 'true' || value === true) return true; if(value === 'false' || value === false) return false; return value; }
javascript
{ "resource": "" }
q41377
createExpressAppServer
train
function createExpressAppServer(app, port) { return new P(function(resolve, reject) { var appServer = app.listen(port, function() { var addr = appServer.address(); resolve({ app: app, appServer: appServer, serverUrl: url.format({ protocol: 'http', hostname: addr.address, ...
javascript
{ "resource": "" }
q41378
encode
train
function encode(args) { const argc = args.length; let len = 1; let off = 0; var i; // data length for (i = 0; i < argc; i += 1) { len += 4 + args[i].length; } // buffer const buf = Buffer.alloc(len); // pack meta buf[off += 1] = (VERSION << 4) | argc; // pack args for (i = 0; i < argc;...
javascript
{ "resource": "" }
q41379
proxy
train
function proxy(options, format) { var tty = options.tty , method = options.method , re = /(%[sdj])+/g , start , end; if(arguments.length === 1) { return method.apply(console, []); } var arg, i, replacing, replacements, matches, tag; replacing = (typeof format === 'string') && re.test(f...
javascript
{ "resource": "" }
q41380
format
train
function format(fmt) { var args = [].slice.call(arguments, 0); var tty = true; var test = (typeof fmt === 'function') ? fmt : null; if(test) { tty = test(); args.shift(); } args.unshift({scope: util, method: util.format, tty: tty}); //console.dir(args); return proxy.apply(null, args); }
javascript
{ "resource": "" }
q41381
main
train
function main(option, parser, force) { if(typeof option === 'function') { parser = option; option = null; } if(option !== false) { option = option || parse.option; parser = parser || parse; } //var mode = parse.auto; if(typeof parser === 'function') { module.exports.mode = parser(parse.m...
javascript
{ "resource": "" }
q41382
camel
train
function camel(s) { return s.replace(/_(.)/g, function(_, l) { return l.toUpperCase() }) }
javascript
{ "resource": "" }
q41383
camelize
train
function camelize(obj) { if (!obj || typeof obj === 'string') return obj if (Array.isArray(obj)) return obj.map(camelize) if (typeof obj === 'object') { return Object.keys(obj).reduce(function(camelizedObj, k) { camelizedObj[camel(k)] = camelize(obj[k]) return camelizedObj }, {})...
javascript
{ "resource": "" }
q41384
_mainMap
train
function _mainMap(data, schema, options) { options = options || {}; var mapping = _map(data, schema, options); if (options.removeChanged) { var mappedFields = _getMappedFields(schema); mappedFields.forEach(function (field) { _removeMappedFields(mapping, field); }); ...
javascript
{ "resource": "" }
q41385
_map
train
function _map(data, schema, options) { options = options || {}; if (!schema || data === null) { return data; } if (schema instanceof Array) { return _mapArray(data, schema, options); } if (typeof schema === 'object') { return _mapObject(data, schema, options); } r...
javascript
{ "resource": "" }
q41386
_removeMappedFields
train
function _removeMappedFields(mapping, path) { if (typeof path === 'number') { delete mapping[path]; return mapping; } var keys = path.split(_separator); if (keys.length <= 1) { delete mapping[path]; return mapping; } return _removeMappedFields( mapping[pat...
javascript
{ "resource": "" }
q41387
_getMappedFields
train
function _getMappedFields(schema) { if (schema === undefined || schema === null) { return; } if (schema instanceof Array) { return schema .reduce(function (memo, key) { var mappedField = _getMappedFields(key); if (mappedField !== undefined)...
javascript
{ "resource": "" }
q41388
_mapArray
train
function _mapArray(data, schema, options) { var base = []; if (data instanceof Array && options.keep) { base = _clone(data); } if (typeof data === 'object' && options.keep) { base = Object .keys(data) .map(function(key) { return data[key]; ...
javascript
{ "resource": "" }
q41389
_mapObject
train
function _mapObject(data, schema, options) { return Object .keys(schema) .reduce(function (memo, key) { memo[key] = _mapDataValue(data, schema[key]); return memo; }, options.keep ? _clone(data) : {}); }
javascript
{ "resource": "" }
q41390
_mapDataValue
train
function _mapDataValue(data, nestedSchema) { if (typeof nestedSchema === 'function') { return nestedSchema.apply(data); } else if (typeof nestedSchema === 'object') { return _map(data, nestedSchema); } else { return _getDataValue(data, nestedSchema); } }
javascript
{ "resource": "" }
q41391
_getDataValue
train
function _getDataValue(data, path) { if (data === undefined) { return undefined; } if (typeof path === 'number') { return data[path]; } if (typeof path === 'string') { var keys = path.split(_separator); if (keys.length <= 1) { return data[keys[0]]; ...
javascript
{ "resource": "" }
q41392
train
function (app) { let p = pathUtil.getCronPath(app.getBase(), app.getServerType()); if (p) { return Loader.load(p, app); } }
javascript
{ "resource": "" }
q41393
train
function (server, app) { let env = app.get(Constants.RESERVED.ENV); let p = path.join(app.getBase(), app.get(Constants.RESERVED.SERVICE_PATH), Constants.FILEPATH.CRON); if (!fs.existsSync(p)) { p = path.join(app.getBase(), Constants.FILEPATH.CONFIG_DIR, env, path.basename(Constants.FILEPATH.CRON)); if (!f...
javascript
{ "resource": "" }
q41394
train
function (isGlobal, server, err, msg, session, resp, opts, cb) { let fm; if (isGlobal) { fm = server.globalFilterService; } else { fm = server.filterService; } if (fm) { if (isGlobal) { fm.afterFilter(err, msg, session, resp, function () { // do nothing }); } else { f...
javascript
{ "resource": "" }
q41395
train
function (isGlobal, server, err, msg, session, resp, opts, cb) { let handler; if (isGlobal) { handler = server.app.get(Constants.RESERVED.GLOBAL_ERROR_HANDLER); } else { handler = server.app.get(Constants.RESERVED.ERROR_HANDLER); } if (!handler) { logger.debug('no default error handler to resolve ...
javascript
{ "resource": "" }
q41396
train
function (route) { if (!route) { return null; } let ts = route.split('.'); if (ts.length !== 3) { return null; } return { route: route, serverType: ts[0], handler: ts[1], method: ts[2] }; }
javascript
{ "resource": "" }
q41397
Metadata
train
function Metadata(resolve, reject, query, options) { this.resolve = this._wrapResolveForProfile(resolve); this.reject = reject; this.query = query; // The query in case we have to build a backtrace this.options = options || {}; this.cursor = false; }
javascript
{ "resource": "" }
q41398
start
train
function start(app, config, callback) { if (httpServer) { DEBUG && debug('***ignore*** http server is already running!'); callback && callback(false); return httpServer; } config = _.merge({}, DEF_CONFIG, config); DEBUG && debug('start http server http://' + config.host + ':' +...
javascript
{ "resource": "" }
q41399
stop
train
function stop(callback) { if (httpServer) { DEBUG && debug('stop http server'); try { httpServer.close(); } catch (e) { } httpServer = null; } else { DEBUG && debug('***ignore*** http server is not running!'); } callback && callback(false); }
javascript
{ "resource": "" }