_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q39100
train
function(o) { return gui.Type.isGuiClass(o) && gui.Class.ancestorsAndSelf(o).some(function(C) { return C === edb.Object || C === edb.Array; }); }
javascript
{ "resource": "" }
q39101
train
function() { return Array.map(this, function(thing) { if (edb.Type.is(thing)) { return thing.toJSON(); } return thing; }); }
javascript
{ "resource": "" }
q39102
observes
train
function observes(array) { var key = array.$instanceid; return edb.Array._observers[key] ? true : false; }
javascript
{ "resource": "" }
q39103
train
function(tick) { var snapshot, handlers, observers = this._observers; if (tick.type === edb.TICK_PUBLISH_CHANGES) { snapshot = gui.Object.copy(this._changes); this._changes = Object.create(null); gui.Object.each(snapshot, function(instanceid, changes) { if ((handlers = observers[instanceid])) { ha...
javascript
{ "resource": "" }
q39104
decorateAccess
train
function decorateAccess(proto, methods) { methods.forEach(function(method) { proto[method] = beforeaccess(proto[method]); }); }
javascript
{ "resource": "" }
q39105
lookupDescriptor
train
function lookupDescriptor(proto, key) { if (proto.hasOwnProperty(key)) { return Object.getOwnPropertyDescriptor(proto, key); } else if ((proto = Object.getPrototypeOf(proto))) { return lookupDescriptor(proto, key); } else { return null; } }
javascript
{ "resource": "" }
q39106
guidedconvert
train
function guidedconvert(args, array) { return args.map(function(o) { if (o !== undefined) { if (gui.Type.isConstructor(array.$of)) { o = constructas(array.$of, o); } else { o = filterfrom(function(x) { return array.$of(x); }, o); } } return o; }); }
javascript
{ "resource": "" }
q39107
train
function(array, args) { args = gui.Array.from(args); if (!gui.Type.isNull(array.$of)) { if (gui.Type.isFunction(array.$of)) { return guidedconvert(args, array); } else { var type = gui.Type.of(array.$of); throw new Error(array + ' cannot be $of ' + type); } } else { return autoco...
javascript
{ "resource": "" }
q39108
getter
train
function getter(key, base) { return function() { var result = base.apply(this); if (edb.$accessaware && !suspend) { edb.Object.$onaccess(this, key); } return result; }; }
javascript
{ "resource": "" }
q39109
train
function(type, target) { var handler, input = this._configure(type.constructor, type); if (target) { console.error("Deprecated API is deprecated", target.spirit); if ((handler = target.$oninput || target.oninput)) { handler.call(target, input); } } else { gui.Broadcast.dispatch(edb.BROADCAST_OUTPU...
javascript
{ "resource": "" }
q39110
train
function(Type) { if (Type) { if (this._map) { var classid = Type.$classid; var typeobj = this._map[classid]; return typeobj ? true : false; } return false; } else { throw new Error("Something is undefined"); } }
javascript
{ "resource": "" }
q39111
train
function(Type, type) { var classid = Type.$classid; this._map[classid] = type; return new edb.Input(Type, type); }
javascript
{ "resource": "" }
q39112
train
function(type, filter, tabs) { if (isType(type)) { return JSON.stringify(parse(type), filter, tabs); } else { throw new TypeError("Expected edb.Object|edb.Array"); } }
javascript
{ "resource": "" }
q39113
asObject
train
function asObject(type) { var map = gui.Object.map(type, mapObject, type); return { $object: gui.Object.extend({ $classname: type.$classname, $instanceid: type.$instanceid, $originalid: type.$originalid }, map) }; }
javascript
{ "resource": "" }
q39114
mapObject
train
function mapObject(key, value) { var c = key.charAt(0); if (c === "_" || c === "$") { return undefined; } else if (isArray(this) && key.match(INTRINSIC)) { return undefined; } else if (isType(value)) { return parse(value); } else if (gui.Type.isComplex(value)) { switch (value.constructor) { ca...
javascript
{ "resource": "" }
q39115
mapArray
train
function mapArray(type) { return Array.map(type, function(thing) { return isType(thing) ? parse(thing) : thing; }); }
javascript
{ "resource": "" }
q39116
train
function(input) { var needstesting = !this._matches.length; if (needstesting || this._matches.every(function(match) { return match.$instanceid !== input.$instanceid; })) { return this._maybeinput(input); } return false; }
javascript
{ "resource": "" }
q39117
train
function(types, handler, required) { types.forEach(function(Type) { if (gui.Type.isDefined(Type)) { this._addchecks(Type.$classid, [handler]); this._watches.push(Type); if (required) { this._needing.push(Type); } } else { throw new TypeError("Could not register input for undefined Type"...
javascript
{ "resource": "" }
q39118
train
function(types, handler) { types.forEach(function(Type) { gui.Array.remove(this._watches, Type); gui.Array.remove(this._needing, Type); this._removechecks(Type.$classid, [handler]); if (!this._watches.length) { this._subscribe(false); } }, this); }
javascript
{ "resource": "" }
q39119
train
function(input) { var best = edb.InputPlugin._bestmatch(input.type, this._watches, true); if (best) { this._updatematch(input, best); this.done = this._done(); this._updatehandlers(input); return true; } return false; }
javascript
{ "resource": "" }
q39120
train
function(input) { var matches = this._matches; var watches = this._watches; var best = edb.InputPlugin._bestmatch(input.type, watches, true); if (best) { var oldinput = matches.filter(function(input) { return input.type === best; })[0]; var index = matches.indexOf(oldinput); matches.splice(index...
javascript
{ "resource": "" }
q39121
train
function(input) { gui.Class.ancestorsAndSelf(input.type, function(Type) { var list = this._trackedtypes[Type.$classid]; if (list) { list.forEach(function(checks) { var handler = checks[0]; handler.oninput(input); }); } }, this); }
javascript
{ "resource": "" }
q39122
train
function() { var needs = this._needing; var haves = this._matches; return needs.every(function(Type) { return haves.some(function(input) { return (input.data instanceof Type); }); }); }
javascript
{ "resource": "" }
q39123
train
function(arg, context) { switch (gui.Type.of(arg)) { case "function": return [arg]; case "string": return this._breakarray(arg.split(" "), context); case "object": console.error("Expected function. Got object."); } }
javascript
{ "resource": "" }
q39124
train
function(target, types, up, action) { types.forEach(function(type) { action(type, this._rateone( up ? target : type, up ? type : target )); }, this); }
javascript
{ "resource": "" }
q39125
train
function(id) { var config, script; return { as: function($edbml) { config = edbml.$runtimeconfigure($edbml); script = gui.Object.assert(id, config); script.$bind = function() { console.error('Deprecated API is deprecated: $bind'); }; script.lock = function(out) { return script({ ...
javascript
{ "resource": "" }
q39126
train
function($edbml) { return function configured($in) { $edbml.$out = ($in && $in.$out) ? $in.$out : new edbml.Out(); $edbml.$att = new edbml.Att(); $edbml.$input = function(Type) { return this.script.$input.get(Type); }.bind(this); return $edbml.apply(this, arguments); }; }
javascript
{ "resource": "" }
q39127
train
function(func, thisp) { var key = gui.KeyMaster.generateKey(); this._invokables[key] = function(value, checked) { return func.apply(thisp, [gui.Type.cast(value), checked]); }; return key; }
javascript
{ "resource": "" }
q39128
train
function(e) { this._latestevent = e ? { type: e.type, value: e.target.value, checked: e.target.checked } : null; }
javascript
{ "resource": "" }
q39129
train
function() { var html = ""; gui.Object.nonmethods(this).forEach(function(att) { html += this._out(att); }, this); return html; }
javascript
{ "resource": "" }
q39130
train
function(html) { this._newdom = this._parse(html); this._crawl(this._newdom, this._olddom, this._newdom, this._keyid, {}); this._olddom = this._newdom; }
javascript
{ "resource": "" }
q39131
train
function(newnode, oldnode, lastnode, id, ids) { var result = true, oldid = this._assistant.id(oldnode); if ((result = this._check(newnode, oldnode, lastnode, id, ids))) { if (oldid) { ids = gui.Object.copy(ids); lastnode = newnode; ids[oldid] = true; id = oldid; } result = this._crawl(ne...
javascript
{ "resource": "" }
q39132
train
function(newnode, oldnode, ids) { var result = true; var update = null; if (this._attschanged(newnode.attributes, oldnode.attributes, ids)) { var newid = this._assistant.id(newnode); var oldid = this._assistant.id(oldnode); if (newid && newid === oldid) { update = new edbml.AttsUpdate(this._doc).setu...
javascript
{ "resource": "" }
q39133
train
function(newnode, oldnode) { if (newnode && oldnode) { return newnode.id && newnode.id === oldnode.id && this._maybesoft(newnode) && this._maybesoft(oldnode); } else { return Array.every(newnode.childNodes, function(node) { var res = true; switch (node.nodeType) { case Node.TEXT_NODE: ...
javascript
{ "resource": "" }
q39134
train
function(newnode, oldnode, ids) { var updates = []; var news = this._assistant.index(newnode.childNodes); var olds = this._assistant.index(oldnode.childNodes); /* * Add elements? */ var child = newnode.lastElementChild, topid = this._assistant.id(oldnode), oldid = null, newid = null; while (c...
javascript
{ "resource": "" }
q39135
train
function(update, ids) { this._updates.push(update); if (update.type === edbml.Update.TYPE_HARD) { this._hardupdates[update.id] = true; } else { update.ids = ids || {}; } return this; }
javascript
{ "resource": "" }
q39136
train
function(report) { if (edbml.debug) { if (gui.KeyMaster.isKey(this.id)) { report = report.replace(this.id, "(anonymous)"); } console.debug(report); } }
javascript
{ "resource": "" }
q39137
train
function() { edbml.Update.prototype.update.call(this); var element = this.element(); if (this._beforeUpdate(element)) { this._update(element); this._afterUpdate(element); this._report(); } }
javascript
{ "resource": "" }
q39138
train
function() { var summary = this._summary.join(', '); var message = 'edbml.AttsUpdate "#' + this.id + '" ' + summary; edbml.Update.prototype._report.call(this, message); // TODO: this would break super keyword algorithm!!! // edbml.Update.prototype._report.call(this, edbml.AttsUpdate \# + // this.id + \ + t...
javascript
{ "resource": "" }
q39139
train
function() { edbml.Update.prototype.update.call(this); var element = this.element(); if (element && this._beforeUpdate(element)) { //gui.DOMPlugin.html ( element, this.xelement.outerHTML ); gui.DOMPlugin.html(element, this.xelement.innerHTML); this._afterUpdate(element); this._report(); } }
javascript
{ "resource": "" }
q39140
train
function() { var count = 0, elm = this.element(); if (this._map) { if ((count = edbml.FunctionUpdate._remap(elm, this._map))) { this._report("remapped " + count + " keys"); } } else { if ((count = edbml.FunctionUpdate._revoke(elm))) { this._report("revoked " + count + " keys"); } } }
javascript
{ "resource": "" }
q39141
train
function(element) { var atts = []; new gui.Crawler('functionupdate').descend(element, { handleElement: function(elm) { if (elm !== element) { Array.forEach(elm.attributes, function(att) { if (att.value.contains("edbml.$run")) { atts.push([elm, att]); } }); if (elm.spirit && ...
javascript
{ "resource": "" }
q39142
train
function() { gui.Plugin.prototype.ondestruct.call(this); if (this.loaded) { gui.Tick.cancelFrame(this._frameindex); this.spirit.life.remove(gui.LIFE_ENTER, this); gui.Broadcast.remove(edb.BROADCAST_ACCESS, this); if (this.$input) { // TODO: interface for this (dispose) this.$input.ondestruct(...
javascript
{ "resource": "" }
q39143
train
function(html) { var changed = this._html !== html; var focused = this._focusedfield(); if (changed) { this._html = html; this._updater.update(html); if(focused) { this._restorefocus(focused); } } this._status(this.spirit); this.ran = true; // TODO: deprecate and use 'spirit.life....
javascript
{ "resource": "" }
q39144
train
function(changes) { if (changes.some(function(c) { var id = c.object.$instanceid, clas = c.object.$classname, name = c.name; if(edbml.$rendering && edbml.$rendering[id]) { console.error( 'Don\'t update "' + name + '" of the ' + clas + ' while ' + 'rendering, it will cause the ren...
javascript
{ "resource": "" }
q39145
train
function(l) { if (l.type === gui.LIFE_ENTER) { if (!this.spirit.life.rendered) { // spirit did a manual run? this.run.apply(this, this._arguments || []); } this.spirit.life.remove(l.type, this); this._arguments = null; } }
javascript
{ "resource": "" }
q39146
train
function() { edbml.$rendering = this._oldfokkers || {}; gui.Broadcast.add(edb.BROADCAST_ACCESS, this); edb.$accessaware = true; this._newfokkers = {}; }
javascript
{ "resource": "" }
q39147
train
function() { var oldfokkers = this._oldfokkers, newfokkers = this._newfokkers; edbml.$rendering = null; gui.Broadcast.remove(edb.BROADCAST_ACCESS, this); edb.$accessaware = false; Object.keys(oldfokkers).forEach(function(id) { if (!newfokkers[id]) { oldfokkers[id].object.removeObserver(this...
javascript
{ "resource": "" }
q39148
train
function() { gui.Tick.cancelFrame(this._frameindex); var spirit = this.spirit; var input = this.$input; var runnow = function() { if (!spirit.life.destructed && (!input || input.done)) { this.run(); } }.bind(this); if (spirit.life.entered) { if (spirit.life.rendered) { this._fram...
javascript
{ "resource": "" }
q39149
train
function(elm) { var index = -1; var parts = []; function hasid(elm) { if (elm.id) { try { gui.DOMPlugin.q(elm.parentNode, elm.id); return true; } catch (malformedexception) {} } return false; } while (elm && elm.nodeType === Node.ELEMENT_NODE) { if (hasid(elm)) { ...
javascript
{ "resource": "" }
q39150
train
function(selector) { var texts = 'textarea, input:not([type=checkbox]):not([type=radio])'; var field = gui.DOMPlugin.qdoc(selector); if(field && field !== document.activeElement) { field.focus(); if (gui.CSSPlugin.matches(field, texts)) { field.setSelectionRange( field.value.length, fi...
javascript
{ "resource": "" }
q39151
train
function() { gui.Spirit.prototype.onconfigure.call(this); if (this.dom.embedded()) { var id, parent = this.dom.parent(gui.Spirit); if (parent && (id = this.scriptid)) { parent.script.load(gui.Object.lookup(id)); } } }
javascript
{ "resource": "" }
q39152
train
function() { /* * Automatically load spirit scripts by naming convention? * ns.MySpirit would automatically load ns.MySpirit.edbml */ var edbmlscript, basespirit = gui.Spirit.prototype; gui.Function.decorateAfter(basespirit, 'onconfigure', function() { if (edbml.bootload && !this.script.loaded) { ...
javascript
{ "resource": "" }
q39153
train
function(node) { var newNode = function(data, next) { var that = {}; that.getData = function() { return data; }; that.getNext = function() { return next; }; return that; }; var top ...
javascript
{ "resource": "" }
q39154
execute
train
function execute(req, res) { //console.dir(req.args); var hmap = req.db.getKey(req.args[0], req); if(hmap === undefined) { return res.send(null, [0, []]); } //console.dir(hmap.getKeys()) var scanner = new Scanner( hmap.getKeys(), req.info.cursor, req.info.pattern, req.info.count, hma...
javascript
{ "resource": "" }
q39155
lexPhrase
train
function lexPhrase(req, res) { var now = elapse.start(); var body = req ? req.body : null; var phrase = typeof(body) === 'object' ? body.phrase : null; if (!phrase) { return res.jsonp(412, {"code":412, "message": meta.module + '|lex|EXCEPTION|invalid request body: ' + (b...
javascript
{ "resource": "" }
q39156
walk
train
function walk (dir, mapper, exclude, include, stopfile) { let files = fs.readdirSync(dir).map((file) => path.join(dir, file)) if (exclude) files = files.filter((file) => !exclude.test(file)) let directories = files.filter(utils.is.dir) files = files.filter(utils.is.file) if (include) files = files....
javascript
{ "resource": "" }
q39157
getEmoticons
train
function getEmoticons(arr) { var nested = arr.map(function (str) { return str.match(between); }); return flatten(nested) .filter(function (el) { return el; }) .filter(emoticonsPredicate) .map(function (str) { return str.slice(1, str.length - 1); }); }
javascript
{ "resource": "" }
q39158
train
function (diffSeq, targetModel) { var self = this; this.targetModel = targetModel; // know if a trace has already been added to cmdList for {path <-> AdaptationPrimitive} var traceAlreadyProcessed = function (cmd) { return self.alreadyProcessedTraces[cmd.modelElement.path()] && self.alreadyProcessedTraces[c...
javascript
{ "resource": "" }
q39159
train
function (cmd) { self.alreadyProcessedTraces[cmd.modelElement.path()] = self.alreadyProcessedTraces[cmd.modelElement.path()] || {}; self.alreadyProcessedTraces[cmd.modelElement.path()][cmd.toString()] = cmd; }
javascript
{ "resource": "" }
q39160
train
function (element) { if (element) { if (element.metaClassName() === 'org.kevoree.ComponentInstance') { // if parent is this node platform: it's ok return (element.eContainer().name === this.node.getName()); } else if (element.metaClassName() === 'org.kevoree.Channel') { // if this channel has bindi...
javascript
{ "resource": "" }
q39161
train
function (list) { list.sort(function (a, b) { if (COMMAND_RANK[a.toString()] > COMMAND_RANK[b.toString()]) { return 1; } else if (COMMAND_RANK[a.toString()] < COMMAND_RANK[b.toString()]) { return -1; } else { return 0; } }); return list; }
javascript
{ "resource": "" }
q39162
del
train
function del(/* key-1, key-N, req */) { var args = slice.call(arguments, 0) , req = typeof args[args.length-1] === 'object' ? args.pop() : null; var deleted = 0; for(var i = 0;i < args.length;i++) { if(this.keyExists(args[i])) { this.delKey(args[i], req); deleted++; } } return deleted;...
javascript
{ "resource": "" }
q39163
rename
train
function rename(key, newkey, req) { var val = this.getKey(key); this.delKey(key); this.setKey(newkey, val); return OK; }
javascript
{ "resource": "" }
q39164
renamenx
train
function renamenx(key, newkey, req) { var exists = this.keyExists(newkey); if(!exists) { this.rename(key, newkey, req); } return exists ? 0 : 1; }
javascript
{ "resource": "" }
q39165
move
train
function move(key, index, req) { var val = this.getKey(key) , db = this.store.getDatabase(index, this.options); //console.dir(val); if(!val || db.keyExists(key)) return 0; db.setKey(key, val); this.delKey(key); return 1; }
javascript
{ "resource": "" }
q39166
transform
train
function transform(flapjack, options) { var filePath = options.filePath; var appName = this.getAppName(filePath, options.appName); var appInfo = this.pancakes.cook(flapjack, null); var validations = this.getSchemaValidations(appInfo, null); var schema = this.stringify(validations); var deps = (o...
javascript
{ "resource": "" }
q39167
getSchemaValidations
train
function getSchemaValidations(appInfo, resources) { if (!appInfo.includeSchemas) { return null; } // if resources not passed in, then get from pancakes resources = resources || this.pancakes.cook('resources', null); var validations = {}; _.each(resources, function (resource) { _.each(resou...
javascript
{ "resource": "" }
q39168
stringify
train
function stringify(validations) { if (!validations) { return ''; } return JSON.stringify(validations, function (key, value) { if (_.isRegExp(value)) { return value.toString(); } switch (value) { case String: return 'String'; case Boolean: return 'Boolean'; ...
javascript
{ "resource": "" }
q39169
Client
train
function Client(API_URL, token, opts) { if (!(this instanceof Client)) return new Client(API_URL, token, opts); if (typeof token == 'object') { opts = token; token = null; } Emitter.call(this); var self = this; opts = opts || {}; self.cache = new LRU(opts.maxSize || 500); self.pending = {}; ...
javascript
{ "resource": "" }
q39170
HyperError
train
function HyperError(res) { Error.call(this); Error.captureStackTrace(this, arguments.callee); this.name = 'HyperError'; this.status = res.status; if (res.body && res.body.error) this.message = res.body.error.message; else this.message = res.text; }
javascript
{ "resource": "" }
q39171
train
function(spec, banner, strict) { spec = spec || {}; banner = banner || "Usage:"; var self = this; var incoming = process.argv.slice(2); // incoming params /** * Returns extra items frob b * @param a * @param b * @returns {Array} ...
javascript
{ "resource": "" }
q39172
train
function(parsed) { var end = false, message = "", code = 0, outer = console.log; var setted = Object.keys(self); var specced = Object.keys(parsed); var required = arrayDiff(setted, specced); var unexpected = arrayDiff(specced, setted); ...
javascript
{ "resource": "" }
q39173
validate
train
function validate(cmd, args, info) { AbstractCommand.prototype.validate.apply(this, arguments); var op = ('' + args[0]).toLowerCase(); if(op !== BITOP.AND && op !== BITOP.OR && op !== BITOP.XOR && op !== BITOP.NOT) { throw CommandSyntax; } if(op === BITOP.NOT && args.length !== 3) { throw BitopNot...
javascript
{ "resource": "" }
q39174
ServerState
train
function ServerState() { // server configuration this._conf = new Configuration(); this._conf.once('load', this.onConfigLoad.bind(this)); // the server bind address information // if listen() is never called this is null this._addr = null; // timestamp for the last save of the rdb file this._lastsave...
javascript
{ "resource": "" }
q39175
pause
train
function pause(timeout) { var log = this._logger; // keep list of matching clients var clients = []; this._conn.forEach(function(conn) { if(!conn.client.isSlave()) { clients.push(conn); conn.pause(); } }) function resume() { log.notice('resume %s connections', clients.length); cl...
javascript
{ "resource": "" }
q39176
expire
train
function expire() { var dbs = this._store.databases, i; for(i in dbs) { dbs[i].delExpiredKeys(); } }
javascript
{ "resource": "" }
q39177
debug
train
function debug(rusage, memory) { var dbs = this._store.databases , i , db , size; for(i in dbs) { db = dbs[i]; size = db.dbsize(); if(size) { this._logger.debug('DB %s: %s keys (%s volatile)', i, size, db.expiring); } } this._logger.debug('%s clients connected, %s heap, %s rss ...
javascript
{ "resource": "" }
q39178
onConfigLoad
train
function onConfigLoad() { var file = this._conf.get(ConfigName.LOGFILE); this._logger.level(this._conf.get(ConfigName.LOGLEVEL)); //console.dir('config loaded.'); if(file && !this._conf.get(ConfigName.DAEMONIZE)) { this._logger.stream(file); } if(this._conf.isDefault()) { this._logger.warning('no co...
javascript
{ "resource": "" }
q39179
Panopticon
train
function Panopticon(options) { var isInstance = this instanceof Panopticon; if (!isInstance) { return new Panopticon(options); } EventEmitter.call(this); this.id = instanceCount; instanceCount += 1; // First we sort out the methods and data which handle are local to this process. genericSetup(this, options...
javascript
{ "resource": "" }
q39180
train
function(index) { var calls = this.all(); var call = calls[index]; return call ? call.object : null; }
javascript
{ "resource": "" }
q39181
isBuildInType
train
function isBuildInType(type) { return type === Function || type === String || type === Boolean || type === Number || type === RegExp || type === Object || type === Array || type === Date }
javascript
{ "resource": "" }
q39182
isCustomType
train
function isCustomType(type) { return ria.__API.isClassConstructor(type) || ria.__API.isInterface(type) || ria.__API.isEnum(type) || ria.__API.isIdentifier(type) || ria.__API.isDelegate(type) || ria.__API.isSpecification(type); //|| ArrayOfD...
javascript
{ "resource": "" }
q39183
smartIndexOf
train
function smartIndexOf(array, test) { var index = -1; if (!array || !test) return index; var length = array.length; if (!length) return index; while (++index < length) { if (test(array[index], index, array)) return index; } return -1; }
javascript
{ "resource": "" }
q39184
indexById
train
function indexById(array, id) { if (!array) return -1; return smartIndexOf(array, function (obj) { return obj.id === id; }); }
javascript
{ "resource": "" }
q39185
querySearch
train
function querySearch( query, single, embed, callback ) { var embd = ''; if ( single ) { for ( var key in embed ) { if ( embed.hasOwnProperty(key) ) { embd += '&embed[]=' + embed[key]; } } } var url = apiBaseUrl + ( single ? endpoints['query']...
javascript
{ "resource": "" }
q39186
idSearch
train
function idSearch( id, type, callback ) { if ( ! endpoints['id'].hasOwnProperty(type) ) { return callback(new Error('No valid type')); } var url = apiBaseUrl+endpoints['id'][type] + id; fetch(url, function(result) { callback(result); }); }
javascript
{ "resource": "" }
q39187
showSearch
train
function showSearch( id, embed, callback ) { var embd = ''; for ( var key in embed ) { if ( embed.hasOwnProperty(key) ) { embd += ( 0 == key ? '?' : '&' ) + 'embed[]=' + embed[key]; } } var url = apiBaseUrl+endpoints['show'] + id + embd; fetch(url, function(result) { ...
javascript
{ "resource": "" }
q39188
showPeople
train
function showPeople( id, callback ) { var url = apiBaseUrl+endpoints['people'] + id; fetch(url, function(result) { callback(result); }); }
javascript
{ "resource": "" }
q39189
scheduleSearch
train
function scheduleSearch( country, date, callback ) { var url = apiBaseUrl+endpoints['schedule'].replace('$1', country).replace('$2', date); fetch(url, function(result) { callback(result); }); }
javascript
{ "resource": "" }
q39190
fetch
train
function fetch( url, callback ) { request({ url: url, json: true }, function( err, resp, data ) { if (err) { return callback(err); } if ( 200 != resp.statusCode ) { return callback(new Error(resp.statusMessage)); } callback(data); }); }
javascript
{ "resource": "" }
q39191
train
function( packageFilename, options ) { if( typeof options === 'undefined' ) options = {}; packageFilename = Path.resolve( packageFilename ); if( false == FS.existsSync() ) this.fatal( "Package file not found: \"" + packageFilename + "\"" ); var prjDir = Path.dirname( packageFilename ); ...
javascript
{ "resource": "" }
q39192
addAnnotation
train
function addAnnotation(target, key, index, data) { const classAnnotationsStore = container.get(AnnotationsServiceName.ClassAnnotationsStore); if (index === undefined) { // property classAnnotationsStore.addPropertyAnnotation(target.constructor, key, Constraints, data); } else { /...
javascript
{ "resource": "" }
q39193
createStaticFileRegex
train
function createStaticFileRegex() { var regex = '^\\/(', staticViews = this.views.static; // Get directories in public/ var files = getStaticDirs.call(this); // Iterate over files and append to regex for (var path, dir, re, i=0; i < files.length; i++) { dir = files[i]; path = dir.replace(this.re...
javascript
{ "resource": "" }
q39194
getStaticDirs
train
function getStaticDirs() { var files = fs.readdirSync(this.path + '/' + this.paths.public), dirs = []; for (var file, stat, i=0; i < files.length; i++) { file = files[i]; stat = fs.lstatSync(this.path + '/' + this.paths.public + file); if ( stat.isDirectory() ) dirs.push(file); } return dirs; }
javascript
{ "resource": "" }
q39195
sequenceMessages
train
function sequenceMessages(batch, context) { const states = batch.states; const messages = batch.messages; if (messages.length < 2 || !context.streamProcessing.sequencingRequired) { return messages; } // First prepare the messages for sequencing by normalizing all of the messages' sequence numbers prep...
javascript
{ "resource": "" }
q39196
getAuthorization
train
function getAuthorization(user, auth) { if (auth === AUTH_BASIC) { return 'Basic ' + btoa(user.username + ':' + user.password); } else if (auth === AUTH_TOKEN) { return 'Token token=' + user.token; } }
javascript
{ "resource": "" }
q39197
getParams
train
function getParams(user, auth, url, options, headers) { return _.extend({ url: url, headers: _.extend({ 'User-Agent': user.userAgent, 'Authorization': getAuthorization(user, auth) }, headers) }, options); }
javascript
{ "resource": "" }
q39198
makeRequest
train
function makeRequest(user, auth, url, cb, options = {}, headers = {}) { const params = getParams(user, auth, url, options, headers); const promise = new Promise((resolve, reject) => { request(params, (err, response, body) => { if (!err && [200, 201, 204, 301].indexOf(response.statusCode) > ...
javascript
{ "resource": "" }
q39199
extractHeaders
train
function extractHeaders(options) { let headers = {}; if (options && options.headers) { headers = options.headers; delete options.headers; } return headers; }
javascript
{ "resource": "" }