_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q64900
test
function(config) { var me = this; var callback = config.success; if ((config.options && config.options.create) && this.path) { var folders = this.path.split("/"); if (folders[0] == '.' || folders[0] == '') { ...
javascript
{ "resource": "" }
q64901
test
function(config) { var me = this; var originalConfig = Ext.applyIf({}, config); if (this.fileSystem) { var failure = function(evt) { if ((config.options && config.options.create) && Ext.isString(this.path)) { ...
javascript
{ "resource": "" }
q64902
test
function(config) { if (config.size == null) { Ext.Logger.error('Ext.device.filesystem.FileEntry#write: You must specify a `size` of the file.'); return null; } var me = this; //noinspection JSValidateTypes ...
javascript
{ "resource": "" }
q64903
test
function (obj) { const keys = _.sortBy(_.keys(obj), function (key) { return key; }); return _.zipObject(keys, _.map(keys, function (key) { return obj[key]; })); }
javascript
{ "resource": "" }
q64904
test
function(err) { if (err) return done(err); var ret; if (typeof leave == 'function') { try { ret = leave.call(this, child, parent); } catch (err) { return done(err); } } done(null, ret); }
javascript
{ "resource": "" }
q64905
MultiKeyCache
test
function MultiKeyCache(options) { options = options || {}; var self = this; var dispose = options.dispose; options.dispose = function (key, value) { self._dispose(key); if (dispose) { dispose(key, value); } }; this.cache = new LRU(options); this._keyMap = {}; }
javascript
{ "resource": "" }
q64906
pipe
test
function pipe() { for (var _len6 = arguments.length, fs = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { fs[_key6] = arguments[_key6]; } return function () { var _this3 = this; var first = fs.shift(); for (var _len7 = arguments.length, args = Array(_len7), _key7 = 0; _key7 < _...
javascript
{ "resource": "" }
q64907
createRawHtml
test
function createRawHtml( createTemplateFn, templateLanguage, elCommentConfig, dataAttributes ) { // Construct the HTML string var comment = elCommentConfig.noComment ? "" : "<!-- " + elCommentConfig.createContent( dataAttributes ) + " -->", insertion = elCommentConfig.among ? comment : "", isLea...
javascript
{ "resource": "" }
q64908
createComplexTemplate
test
function createComplexTemplate ( templateLanguage, options ) { var t = getTemplateLanguageConstructs( templateLanguage ), indent = options && options.indentation || "", insert = options && options.insertion || "", lines = [ '<!-- top-level comment (single line) -->', ...
javascript
{ "resource": "" }
q64909
getTemplateLanguageConstructs
test
function getTemplateLanguageConstructs ( templateLanguage ) { var constructs; switch ( templateLanguage.toLowerCase() ) { case "handlebars": constructs = { startDelimiter: "{{", endDelimiter: "}}", if: "{{#if isActive}}", else...
javascript
{ "resource": "" }
q64910
defineModel
test
function defineModel(modelType, options) { var primaryAttributes; var attributes; var prototype; var staticProto; var ModelConstructor; var typeName; var namespace; if (types.isValidType(modelType).indexes) { throw ModelException('Model type cannot be an array `{{type}}`', null, null, { type: Strin...
javascript
{ "resource": "" }
q64911
Model
test
function Model(data) { var attributes = this.__proto__.constructor.attributes; var i, ilen; var dirty = false; Object.defineProperties(this, { _id: { configurable: false, enumerable: true, writable: false, value: ++uniqueId }, _isDirty: { configurable: false, enu...
javascript
{ "resource": "" }
q64912
Point
test
function Point(masterApikey, feedID, streamID) { /** @private */this.masterApiKey = masterApikey; /** @private */this.feedID = feedID.toString(); /** @private */this.streamID = streamID.toString(); }
javascript
{ "resource": "" }
q64913
test
function(tabBar, newTab) { var oldActiveItem = this.getActiveItem(), newActiveItem; this.setActiveItem(tabBar.indexOf(newTab)); newActiveItem = this.getActiveItem(); return this.forcedChange || oldActiveItem !== newActiveItem; }
javascript
{ "resource": "" }
q64914
test
function(point1, point2) { var Point = Ext.util.Point; this.point1 = Point.from(point1); this.point2 = Point.from(point2); }
javascript
{ "resource": "" }
q64915
test
function(lineSegment) { var point1 = this.point1, point2 = this.point2, point3 = lineSegment.point1, point4 = lineSegment.point2, x1 = point1.x, x2 = point2.x, x3 = point3.x, x4 = point4.x, y1 = point1.y, ...
javascript
{ "resource": "" }
q64916
SteroidsSocket
test
function SteroidsSocket(options) { var finalTarget; if (options.target && net.isIPv6(options.target)) { finalTarget = normalize6(options.target); } else { finalTarget = options.target; } this.target = finalTarget; this.port = options.port || 80; this.transport = options.tra...
javascript
{ "resource": "" }
q64917
timeoutCb
test
function timeoutCb() { if (!received) { self.emit('error', { type: 'socket: timeout', data: 'Connection problem: No response' }); } // Websockets Node module doen't support any close function, we're using the client // https://github.com/Worlize/WebSocket-Node/blob/master/lib/...
javascript
{ "resource": "" }
q64918
realWidth
test
function realWidth(str) { if (str == null) return 0; str = stripANSI(str); return str.length + (stripEmoji(str).match(/[^\x00-\xff]/g) || []).length; }
javascript
{ "resource": "" }
q64919
test
function (source, destination) { gulp.src(source) .pipe(conflict(destination)) .pipe(gulp.dest(destination)); }
javascript
{ "resource": "" }
q64920
test
function (source, destination) { if (!fs.existsSync(destination)) mkdir('-p', destination); cp('-R', source, destination); }
javascript
{ "resource": "" }
q64921
test
function (tracker, propList) { var trackingData = tracker[trackingKeyName]; propList.forEach(function (name) { Object.defineProperty(tracker, name, { enumerable: true, configurable: true, get: function () { return trackingData.object[name]; }, set: function (x) { tr...
javascript
{ "resource": "" }
q64922
test
function (tracker, methodList) { var trackingData = tracker[trackingKeyName]; methodList.forEach(function (name) { tracker[name] = function () { var context = this; var argsArray = Array.prototype.slice.call(arguments); // Only record actions called directly on the tracker. if (this === ...
javascript
{ "resource": "" }
q64923
test
function (object) { var propList = []; var methodList = []; for (var k in object) { if (typeof object[k] === "function") { methodList.push(k); } else { propList.push(k); } } return { propList: propList, methodList: methodList, }; }
javascript
{ "resource": "" }
q64924
test
function(config,callback,scope) { // Ext.data.utilities.check('SyncProxy', 'constructor', 'config', config, ['store','database_name','key']); // Ext.data.SyncProxy.superclass.constructor.call(this, config); this.store= config.store; // // System Name // this.store.readValue('Sencha.Sync.system_name',f...
javascript
{ "resource": "" }
q64925
test
function (content) { content = trim(content); if (this.mounted) { invoke(this, [ Constants.BLOCK, 'setMountedContent' ], content); } else { dom.contentNode(this).innerHTML = content; this.upgrade(); } }
javascript
{ "resource": "" }
q64926
test
function () { const props = dom.attrs.toObject(this); const xprops = this.xprops; const eprops = get(xtag, [ 'tags', this[ Constants.TAGNAME ], 'accessors' ], {}); for (let prop in eprops) { if (xprops.hasOwnProperty(prop) && eprops.ha...
javascript
{ "resource": "" }
q64927
test
function (deep) { // not to clone the contents const node = dom.cloneNode(this, false); dom.upgrade(node); node[ Constants.TMPL ] = this[ Constants.TMPL ]; node[ Constants.INSERTED ] = false; if (deep) { node.content = this.content; } // ???...
javascript
{ "resource": "" }
q64928
blockInit
test
function blockInit(node) { if (!node[ Constants.TAGNAME ]) { node[ Constants.INSERTED ] = false; node[ Constants.TAGNAME ] = node.tagName.toLowerCase(); node[ Constants.TMPL ] = {}; node[ Constants.UID ] = uniqueId(); return true; } return false; }
javascript
{ "resource": "" }
q64929
blockCreate
test
function blockCreate(node) { if (node.hasChildNodes()) { Array.prototype.forEach.call( node.querySelectorAll('script[type="text/x-template"][ref],template[ref]'), tmplCompileIterator, node ); } node[ Constants.BLOCK ] = new XBElement(node); }
javascript
{ "resource": "" }
q64930
accessorsCustomizer
test
function accessorsCustomizer(objValue, srcValue) { const objSetter = get(objValue, 'set'); const srcSetter = get(srcValue, 'set'); return merge({}, objValue, srcValue, { set: wrap(objSetter, wrap(srcSetter, wrapperFunction)) }); }
javascript
{ "resource": "" }
q64931
wrapperEvents
test
function wrapperEvents(srcFunc, objFunc, ...args) { const event = (args[ 0 ] instanceof Event) && args[ 0 ]; const isStopped = event ? () => event.immediatePropagationStopped : stubFalse; if (!isStopped() && isFunction(objFunc)) { objFunc.apply(this, args); } if (!isStopped() && isFunction...
javascript
{ "resource": "" }
q64932
accessorsIterator
test
function accessorsIterator(options, name, accessors) { const optionsSetter = get(options, 'set'); const updateSetter = wrap(name, wrapperAccessorsSetUpdate); accessors[ name ] = merge({}, options, { set: wrap(optionsSetter, wrap(updateSetter, wrapperFunction)) }); }
javascript
{ "resource": "" }
q64933
wrapperAccessorsSetUpdate
test
function wrapperAccessorsSetUpdate(accessorName, nextValue, prevValue) { if (nextValue !== prevValue && this.xprops.hasOwnProperty(accessorName) && this.mounted) { this[ Constants.BLOCK ].update(); } }
javascript
{ "resource": "" }
q64934
lifecycleRemoved
test
function lifecycleRemoved() { this[ Constants.INSERTED ] = false; const block = this[ Constants.BLOCK ]; if (block) { block.destroy(); this[ Constants.BLOCK ] = undefined; } }
javascript
{ "resource": "" }
q64935
lifecycleInserted
test
function lifecycleInserted() { if (this[ Constants.INSERTED ]) { return; } blockInit(this); this[ Constants.INSERTED ] = true; const isScriptContent = Boolean(this.querySelector('script')); // asynchronous read content // <xb-test><script>...</script><div>not found</div></xb-test...
javascript
{ "resource": "" }
q64936
test
function (obj, removeProp) { var newObj = {}; for (var prop in obj) { if (!obj.hasOwnProperty(prop) || prop === removeProp) { continue; } newObj[prop] = obj[prop]; } return newObj; }
javascript
{ "resource": "" }
q64937
toDashedProperties
test
function toDashedProperties ( hash ) { var transformed = {}; _.each( hash, function ( value, key ) { transformed[toDashed( key )] = value; } ); return transformed; }
javascript
{ "resource": "" }
q64938
toCamelCasedProperties
test
function toCamelCasedProperties ( hash ) { var transformed = {}; _.each( hash, function ( value, key ) { transformed[toCamelCase( key )] = value; } ); return transformed; }
javascript
{ "resource": "" }
q64939
dashedKeyAlternatives
test
function dashedKeyAlternatives ( hash ) { var keys = _.keys( toDashedProperties( hash ) ); return _.filter( keys, function ( key ) { return key.search(/[^-]-[a-z]/) !== -1; } ); }
javascript
{ "resource": "" }
q64940
test
function(selector, root) { var selectors = selector.split(','), length = selectors.length, i = 0, results = [], noDupResults = [], dupMatcher = {}, query, resultsLn, cmp; for (; i < length; i++) { ...
javascript
{ "resource": "" }
q64941
test
function(component, selector) { if (!selector) { return true; } var query = this.cache[selector]; if (!query) { this.cache[selector] = query = this.parse(selector); } return query.is(component); }
javascript
{ "resource": "" }
q64942
RouterDecorator
test
function RouterDecorator (Router) { function TelemetryRouter (options) { if (!(this instanceof TelemetryRouter)) { return new TelemetryRouter(options) } Router.call(this, options) } inherits(TelemetryRouter, Router) /** * Wraps getNearestContacts with telemetry * #getNearestContacts ...
javascript
{ "resource": "" }
q64943
test
function(config) { if (!this.active) { Ext.Logger.error('Ext.device.sqlite.SQLTransaction#executeSql: An attempt was made to use a SQLTransaction that is no longer usable.'); return null; } if (config.sqlStatement == null) { ...
javascript
{ "resource": "" }
q64944
test
function(index) { if (index < this.getLength()) { var item = {}; var row = this.rows[index]; this.names.forEach(function(name, index) { item[name] = row[index]; ...
javascript
{ "resource": "" }
q64945
createPayload
test
function createPayload(name, level, data) { return { date: getDate(), level: level, name: name, data: data }; }
javascript
{ "resource": "" }
q64946
__ENFORCETYPE
test
function __ENFORCETYPE(a, ...types) { if (env.application_env !== "development") return; let hasError = false; let expecting; let got; let i = 0; types.map( (t, index) => { if (a[index] === null) { hasError = true; expecting = t; got = "null...
javascript
{ "resource": "" }
q64947
assign
test
function assign(parent, val, keyOpts) { var target = parent, keyParts = keyOpts.val.toString().split('.'); keyParts.forEach(function(keyPart, idx) { if (keyParts.length === idx + 1) { if (val !== undefined) { if (Array.isArray(val) && Array.isArray(target[keyPart])) { val = t...
javascript
{ "resource": "" }
q64948
test
function(node1, node2) { // A shortcut for siblings if (node1.parentNode === node2.parentNode) { return (node1.data.index < node2.data.index) ? -1 : 1; } // @NOTE: with the following algorithm we can only go 80 levels deep in the tree // and each node can contain 100...
javascript
{ "resource": "" }
q64949
test
function(root) { var node = this.getNode(), recursive = this.getRecursive(), added = [], child = root; if (!root.childNodes.length || (!recursive && root !== node)) { return added; } if (!recursive) { return root.childNodes; ...
javascript
{ "resource": "" }
q64950
test
function(config) { var me = this; config = Ext.device.filesystem.Abstract.prototype.requestFileSystem(config); var successCallback = function(fs) { var fileSystem = Ext.create('Ext.device.filesystem.FileSystem', fs); config.success.call(config.scope || me, fileSystem); ...
javascript
{ "resource": "" }
q64951
test
function(operation, callback, scope) { var me = this, writer = me.getWriter(), request = me.buildRequest(operation); request.setConfig({ headers: me.getHeaders(), timeout: me.getTimeout(), method: me.getMethod(request), callback: ...
javascript
{ "resource": "" }
q64952
test
function(err) { var output; try { var fieldName = err.err.substring(err.err.lastIndexOf('.$') + 2, err.err.lastIndexOf('_1')); output = fieldName.charAt(0).toUpperCase() + fieldName.slice(1) + ' already exists'; } catch (ex) { output = 'Unique field already exists'; } return output; }
javascript
{ "resource": "" }
q64953
test
function( project ) { var current = process.cwd(); console.log( '\nCreating folder "' + project + '"...' ); // First, create the directory fs.mkdirSync( path.join( current, project ) ); console.log( '\nCopying the files in "' + project + '"...' ); // Then, copy the fi...
javascript
{ "resource": "" }
q64954
prewatch
test
function prewatch(theOptions) { if (config.watch) { return _.defaults(theOptions, watchify.args); } return theOptions; }
javascript
{ "resource": "" }
q64955
test
function(index, filters) { // We begin by making sure we are dealing with an array of sorters if (!Ext.isArray(filters)) { filters = [filters]; } var ln = filters.length, filterRoot = this.getFilterRoot(), currentFilters = this.getFilters(), ...
javascript
{ "resource": "" }
q64956
test
function(filters) { // We begin by making sure we are dealing with an array of sorters if (!Ext.isArray(filters)) { filters = [filters]; } var ln = filters.length, currentFilters = this.getFilters(), i, filter; for (i = 0; i < ln; i++) { ...
javascript
{ "resource": "" }
q64957
wrapperMergeResult
test
function wrapperMergeResult(srcFunc, objFunc, ...args) { let resultObjFunction = {}; let resultSrcFunction = {}; if (isFunction(objFunc)) { resultObjFunction = objFunc.apply(this, args); } if (isFunction(srcFunc)) { resultSrcFunction = srcFunc.apply(this, args); } return m...
javascript
{ "resource": "" }
q64958
wrapperOrResult
test
function wrapperOrResult(srcFunc, objFunc, ...args) { let resultObjFunction = false; let resultSrcFunction = false; if (isFunction(objFunc)) { resultObjFunction = objFunc.apply(this, args); } if (isFunction(srcFunc)) { resultSrcFunction = srcFunc.apply(this, args); } retur...
javascript
{ "resource": "" }
q64959
test
function(instance) { this._model = instance._model; this._instance = instance; this.id = instance.id; this.eachAttribute = function(cb) { return this._model.eachAttribute(cb); }; this.eachRelationship = function (cb) { return this._model.eachRelationship(cb); } this.attr = function(name) { return this._instance[n...
javascript
{ "resource": "" }
q64960
test
function(val) { var trimmed = val.trim(); if(trimmed.indexOf("'") === 0 && trimmed.lastIndexOf("'") === (trimmed.length - 1)) return '"' + trimmed.substring(1, trimmed.length - 1) + '"'; return val; }
javascript
{ "resource": "" }
q64961
test
function(typeName, obj) { this.type = typeName; if(typeof obj !== 'undefined') for(var key in obj) this[key] = obj[key]; }
javascript
{ "resource": "" }
q64962
test
function() { var idStr = '' + sforce.db.id++; return sforce.db._idTemplate.substring(0, 18 - idStr.length) + idStr; }
javascript
{ "resource": "" }
q64963
test
function(select) { var chars = new antlr4.InputStream(input); var lexer = new SelectLexer(chars); var tokens = new antlr4.CommonTokenStream(lexer); var parser = new SelectParser(tokens); parser.buildParseTrees = true; return parser.select(); }
javascript
{ "resource": "" }
q64964
test
function(obj) { var schema = sforce.db.schema; var objDesc = schema[obj.type]; if(typeof objDesc === 'undefined') throw 'No type exists by the name: ' + obj.type; for(var key in obj) { if({ Id:false, type:true }[key]) continue; var fieldDesc = null; for(var i = 0; i < objDesc.fields.len...
javascript
{ "resource": "" }
q64965
test
function(type, fields) { for(var i = 0; i < fields.length; i++) sforce.db.validateField(type, fields[i]); }
javascript
{ "resource": "" }
q64966
test
function(type, field) { var objDesc = sforce.db.schema[type]; for(var i = 0; i < objDesc.fields.length; i++) if(objDesc.fields[i].name === field) return; throw 'No field exists by the name: ' + field + 'in the type: ' + type; }
javascript
{ "resource": "" }
q64967
test
function(type, rel) { var objDesc = sforce.db.schema[type]; for(var i = 0; i < objDesc.childRelationships.length; i++) if(objDesc.childRelationships[i].relationshipName === rel) return; throw 'No child relationship exists by the name: ' + rel + 'in the type: ' + type; }
javascript
{ "resource": "" }
q64968
test
function(type) { var sos = sforce.db.sobjects; if(typeof sos[type] !== 'object') sos[type] = {}; return sos[type]; }
javascript
{ "resource": "" }
q64969
test
function(resultAry, isRoot) { if(resultAry.length == 0) { if(isRoot) return { done : 'true', queryLocator : null, size : 0, }; return null; } var records = null; if(resultAry.length == 1) records = resultAry[0]; else records = resultAry; return { done : ...
javascript
{ "resource": "" }
q64970
test
function(obj) { var matches = this.sequence[0].matches(obj); for(var i = 1; i < this.sequence.length; i += 2) { if(this.sequence[i] === '&') matches = matches && this.sequence[i+1].matches(obj); else matches = matches || this.sequence[i+1].matches(obj); } return matches; }
javascript
{ "resource": "" }
q64971
addContents
test
function addContents($, contents) { console.log('addContents', contents); var body = document.getElementsByTagName('BODY'); if (!body) return; var $body = $(body[0]), contentsStyle = [ 'position:fixed;right:1em;top:1em;', 'padding:0.5em;min-width:120px;', 'font-size:90%;li...
javascript
{ "resource": "" }
q64972
addTop
test
function addTop($, top) { console.log('addTop', top); $(top.join(',')).each(function (i, obj) { //$(obj).append(' <a href="#" style="display:none;font-size: 12px;color: #333;">Top</a>'); $(obj).prepend(['<div style="position: relative;width: 1px;">', '<a href="javascript:;" style="position:...
javascript
{ "resource": "" }
q64973
test
function() { var actions = this.getActions(), namespace = this.getNamespace(), action, cls, methods, i, ln, method; for (action in actions) { if (actions.hasOwnProperty(action)) { cls = namespace[action]; if (!cls) { ...
javascript
{ "resource": "" }
q64974
test
function(transaction, event) { var success = !!event.getStatus(), functionName = success ? 'success' : 'failure', callback = transaction && transaction.getCallback(), result; if (callback) { // this doesnt make any sense. why do we have both result and da...
javascript
{ "resource": "" }
q64975
test
function(options, success, response) { var me = this, i = 0, ln, events, event, transaction, transactions; if (success) { events = me.createEvents(response); for (ln = events.length; i < ln; ++i) { event = events[i]; ...
javascript
{ "resource": "" }
q64976
test
function(options) { return options && options.getTid ? Ext.direct.Manager.getTransaction(options.getTid()) : null; }
javascript
{ "resource": "" }
q64977
test
function(action, method, args) { var me = this, callData = method.getCallData(args), data = callData.data, callback = callData.callback, scope = callData.scope, transaction; transaction = Ext.create('Ext.direct.Transaction', { prov...
javascript
{ "resource": "" }
q64978
test
function(transaction) { return { action: transaction.getAction(), method: transaction.getMethod(), data: transaction.getData(), type: 'rpc', tid: transaction.getId() }; }
javascript
{ "resource": "" }
q64979
test
function(transaction) { var me = this, enableBuffer = me.getEnableBuffer(); if (transaction.getForm()) { me.sendFormRequest(transaction); return; } me.callBuffer.push(transaction); if (enableBuffer) { if (!me.callTask) { ...
javascript
{ "resource": "" }
q64980
test
function() { var buffer = this.callBuffer, ln = buffer.length; if (ln > 0) { this.sendRequest(ln == 1 ? buffer[0] : buffer); this.callBuffer = []; } }
javascript
{ "resource": "" }
q64981
test
function(action, method, form, callback, scope) { var me = this, transaction, isUpload, params; transaction = new Ext.direct.Transaction({ provider: me, action: action, method: method.getName(), args: [form, callback, scope], callb...
javascript
{ "resource": "" }
q64982
test
function(transaction) { var me = this; Ext.Ajax.request({ url: me.getUrl(), params: transaction.params, callback: me.onData, scope: me, form: transaction.form, isUpload: transaction.isUpload, transaction: transaction ...
javascript
{ "resource": "" }
q64983
inlineBlockFix
test
function inlineBlockFix(decl){ var origRule = decl.parent; origRule.append( { prop:'*display', value:'inline' }, { prop:'*zoom', value:'1' } ); }
javascript
{ "resource": "" }
q64984
stubPlainTextFiles
test
function stubPlainTextFiles(resourceRoots, destination) { _.forEach(resourceRoots, function (resource) { // Replace the webstorm file:// scheme with an absolute file path var filePath = resource.replace('file://$PROJECT_DIR$', destination); filePath = filePath.replace('.idea/', ''); // Extract the loc...
javascript
{ "resource": "" }
q64985
resolveJetbrainsExe
test
function resolveJetbrainsExe(jetbrainsDirectory) { var exists = false; var webstormInstallPaths = io.resolveDirMatches(jetbrainsDirectory, /^WebStorm\s*[.\d]+$/); // Check that the Webstorm folder have a bin folder, empty folders are a known issue. for (var j = 0; j < webstormInstallPaths.length; j++) { va...
javascript
{ "resource": "" }
q64986
Route
test
function Route (method, path, callback, options) { this.path = path; this.method = method; this.callback = callback; this.regexp = utils.pathRegexp(path, this.keys = [], options.sensitive, options.strict); }
javascript
{ "resource": "" }
q64987
TransportDecorator
test
function TransportDecorator (Transport) { function TelemetryTransport (contact, options) { if (!(this instanceof TelemetryTransport)) { return new TelemetryTransport(contact, options) } assert.ok(options, 'Missing required options parameter') this._telopts = options.telemetry this.telemet...
javascript
{ "resource": "" }
q64988
getRandomArrValue
test
function getRandomArrValue(arr, min = 0, max = arr.length - 1) { return arr[getRandomInt(min, max)]; }
javascript
{ "resource": "" }
q64989
random
test
function random(number = 1) { if (1 > number) { throw Error(`Can't use numbers bellow 1, ${number} passed`); } if (number === 1) { return getRandomArrValue(dinosaurs); } else { const l = dinosaurs.length - 1; return new Array(number).fill().map(() => getRandomArrValue(dinosaurs, 0, l)); } }
javascript
{ "resource": "" }
q64990
Response
test
function Response (ghosttrain, callback) { this.charset = ''; this.headers = {}; this.statusCode = 200; this.app = ghosttrain; this._callback = callback; }
javascript
{ "resource": "" }
q64991
test
function () { var body; var app = this.app; // If status provide, set that, and set `body` to the content correctly if (typeof arguments[0] === 'number') { this.status(arguments[0]); body = arguments[1]; } else { body = arguments[0]; } var type = this.get('Content-Type');...
javascript
{ "resource": "" }
q64992
test
function () { var data; if (arguments.length === 2) { this.status(arguments[0]); data = arguments[1]; } else { data = arguments[0]; } if (!this.get('Content-Type')) this.contentType('application/json'); return this.send(data); }
javascript
{ "resource": "" }
q64993
test
function (field, value) { if (arguments.length === 2) this.headers[field] = value; else { for (var prop in field) this.headers[prop] = field[prop]; } return this; }
javascript
{ "resource": "" }
q64994
test
function (body) { var type = this.get('Content-Type'); if (type === 'application/json') this._callback(JSON.parse(body || '{}')); else this._callback(body); }
javascript
{ "resource": "" }
q64995
test
function (args) { // Find the minimum expected length. var expected = Array.prototype.slice.call(arguments, 1); var minimum = expected.length var hasOptionalTypes = false; for (var i = 0; i < expected.length; i++) { if (!isValidType(expected[i])) { throw Error('Expected argument ' + i ...
javascript
{ "resource": "" }
q64996
test
function (expected, args, minimum) { var shiftedArgs = []; var curArg = args.length - 1; var remainingOptionalArgs = expected.length - minimum; var optionalIndiceSegments = []; var optionalIndiceSegment = []; var availableArgsSegments = []; var availableArgsSegment = []; // Fill the return arra...
javascript
{ "resource": "" }
q64997
test
function () { availableArgsSegment.unshift(curArg); curArg--; remainingOptionalArgs--; if (curArg < 0 || remainingOptionalArgs < 0) { throw Error(getExpectedVsRecieved_(expected, args)); } }
javascript
{ "resource": "" }
q64998
test
function (expected, expectedIndex, actual, actualIndex) { // Check how many optional types in front of this argument that match the current value. var consecutiveOptionals = countTrailingOptionals_(expected, expectedIndex, actual[actualIndex]); // Check how many required types are behind this argument that ma...
javascript
{ "resource": "" }
q64999
test
function (expected, expectedIndex, value) { var i = expectedIndex + 1; var matchingOptionals = 0; var inBetweenOptionals = 0; var tmpInBetween = 0; while (i < expected.length && isOptionalType(expected[i])) { if (isOfType(value, expected[i])) { matchingOptionals++; inBetweenOption...
javascript
{ "resource": "" }