_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q53500
errNameFromDesc
train
function errNameFromDesc(desc) { assert.string(desc, 'desc'); // takes an error description, split on spaces, camel case it correctly, // then append 'Error' at the end of it. // e.g., the passed in description is 'Internal Server Error' // the output is 'InternalServerError' var pieces = desc.split(/\s+/); var name = _.reduce(pieces, function(acc, piece) { // lowercase all, then capitalize it. var normalizedPiece = _.capitalize(piece.toLowerCase()); return acc + normalizedPiece; }, ''); // strip all non word characters name = name.replace(/\W+/g, ''); // append 'Error' at the end of it only if it doesn't already end with it. if (!_.endsWith(name, 'Error')) { name += 'Error'; } return name; }
javascript
{ "resource": "" }
q53501
makeErrFromCode
train
function makeErrFromCode(statusCode) { // assert! assert.number(statusCode, 'statusCode'); assert.equal(statusCode >= 400, true); // drop the first arg var args = _.drop(_.toArray(arguments)); var name = helpers.errNameFromCode(statusCode); var ErrCtor = httpErrors[name]; // assert constructor was found assert.func(ErrCtor); // pass every other arg down to constructor return makeInstance(ErrCtor, makeErrFromCode, args); }
javascript
{ "resource": "" }
q53502
makeInstance
train
function makeInstance(constructor, constructorOpt, args) { // pass args to the constructor function F() { // eslint-disable-line require-jsdoc return constructor.apply(this, args); } F.prototype = constructor.prototype; // new up an instance, and capture stack trace from the // passed in constructorOpt var errInstance = new F(); Error.captureStackTrace(errInstance, constructorOpt); // return the error instance return errInstance; }
javascript
{ "resource": "" }
q53503
makeConstructor
train
function makeConstructor(name, defaults) { assert.string(name, 'name'); assert.optionalObject(defaults, 'defaults'); // code property doesn't have 'Error' in it. remove it. var defaultCode = name.replace(new RegExp('[Ee]rror$'), ''); var prototypeDefaults = _.assign({}, { name: name, code: (defaults && defaults.code) || defaultCode, restCode: _.get(defaults, 'restCode', defaultCode) }, defaults); // assert that this constructor doesn't already exist. assert.equal( typeof module.exports[name], 'undefined', 'Constructor already exists!' ); // dynamically create a constructor. // must be anonymous fn. var ErrCtor = function() { // eslint-disable-line require-jsdoc, func-style // call super RestError.apply(this, arguments); this.name = name; }; util.inherits(ErrCtor, RestError); // copy over all options to prototype _.assign(ErrCtor.prototype, prototypeDefaults); // assign display name ErrCtor.displayName = name; // return constructor to user, they can choose how to store and manage it. return ErrCtor; }
javascript
{ "resource": "" }
q53504
factory
train
function factory(options) { assert.optionalObject(options, 'options'); var opts = _.assign({ topLevelFields: false }, options); var serializer = new ErrorSerializer(opts); // rebind the serialize function since this will be lost when we export it // as a POJO serializer.serialize = serializer.serialize.bind(serializer); return serializer; }
javascript
{ "resource": "" }
q53505
CamundaForm
train
function CamundaForm(options) { if(!options) { throw new Error('CamundaForm need to be initialized with options.'); } var done = options.done = options.done || function(err) { if(err) throw err; }; if (options.client) { this.client = options.client; } else { this.client = new CamSDK.Client(options.clientConfig || {}); } if (!options.taskId && !options.processDefinitionId && !options.processDefinitionKey) { return done(new Error('Cannot initialize Taskform: either \'taskId\' or \'processDefinitionId\' or \'processDefinitionKey\' must be provided')); } this.taskId = options.taskId; if(this.taskId) { this.taskBasePath = this.client.baseUrl + '/task/' + this.taskId; } this.processDefinitionId = options.processDefinitionId; this.processDefinitionKey = options.processDefinitionKey; this.formElement = options.formElement; this.containerElement = options.containerElement; this.formUrl = options.formUrl; if(!this.formElement && !this.containerElement) { return done(new Error('CamundaForm needs to be initilized with either \'formElement\' or \'containerElement\'')); } if(!this.formElement && !this.formUrl) { return done(new Error('Camunda form needs to be intialized with either \'formElement\' or \'formUrl\'')); } /** * A VariableManager instance * @type {VariableManager} */ this.variableManager = new VariableManager({ client: this.client }); /** * An array of FormFieldHandlers * @type {FormFieldHandlers[]} */ this.formFieldHandlers = options.formFieldHandlers || [ InputFieldHandler, ChoicesFieldHandler, FileDownloadHandler ]; this.businessKey = null; this.fields = []; this.scripts = []; this.options = options; // init event support Events.attach(this); this.initialize(done); }
javascript
{ "resource": "" }
q53506
toArray
train
function toArray(obj) { var a, arr = []; for (a in obj) { arr.push(obj[a]); } return arr; }
javascript
{ "resource": "" }
q53507
ensureEvents
train
function ensureEvents(obj, name) { obj._events = obj._events || {}; obj._events[name] = obj._events[name] || []; }
javascript
{ "resource": "" }
q53508
AbstractFormField
train
function AbstractFormField(element, variableManager) { this.element = $( element ); this.variableManager = variableManager; this.variableName = null; this.initialize(); }
javascript
{ "resource": "" }
q53509
train
function (eventName, arg1, arg2) { var callbacks = this._eventCallbacks[eventName]; if (callbacks) { for (var i = 0; i < callbacks.length; i++) { callbacks[i](arg1, arg2); } } }
javascript
{ "resource": "" }
q53510
Container
train
function Container(registry, options) { this.registry = registry; this.owner = options && options.owner ? options.owner : null; this.cache = _emberMetalDictionary.default(options && options.cache ? options.cache : null); this.factoryCache = _emberMetalDictionary.default(options && options.factoryCache ? options.factoryCache : null); this.validationCache = _emberMetalDictionary.default(options && options.validationCache ? options.validationCache : null); this._fakeContainerToInject = _emberRuntimeMixinsContainer_proxy.buildFakeContainerWithDeprecations(this); this[CONTAINER_OVERRIDE] = undefined; }
javascript
{ "resource": "" }
q53511
train
function (fullName, options) { _emberMetalDebug.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); return factoryFor(this, this.registry.normalize(fullName), options); }
javascript
{ "resource": "" }
q53512
Registry
train
function Registry(options) { this.fallback = options && options.fallback ? options.fallback : null; if (options && options.resolver) { this.resolver = options.resolver; if (typeof this.resolver === 'function') { deprecateResolverFunction(this); } } this.registrations = _emberMetalDictionary.default(options && options.registrations ? options.registrations : null); this._typeInjections = _emberMetalDictionary.default(null); this._injections = _emberMetalDictionary.default(null); this._factoryTypeInjections = _emberMetalDictionary.default(null); this._factoryInjections = _emberMetalDictionary.default(null); this._localLookupCache = new _emberMetalEmpty_object.default(); this._normalizeCache = _emberMetalDictionary.default(null); this._resolveCache = _emberMetalDictionary.default(null); this._failCache = _emberMetalDictionary.default(null); this._options = _emberMetalDictionary.default(null); this._typeOptions = _emberMetalDictionary.default(null); }
javascript
{ "resource": "" }
q53513
train
function (fullName) { if (this.resolver && this.resolver.normalize) { return this.resolver.normalize(fullName); } else if (this.fallback) { return this.fallback.normalizeFullName(fullName); } else { return fullName; } }
javascript
{ "resource": "" }
q53514
train
function (fullName, options) { _emberMetalDebug.assert('fullName must be a proper full name', this.validateFullName(fullName)); var source = undefined; source = options && options.source && this.normalize(options.source); return has(this, this.normalize(fullName), source); }
javascript
{ "resource": "" }
q53515
train
function () { var _this = this; var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; if (this._bootPromise) { return this._bootPromise; } this._bootPromise = new _emberRuntimeExtRsvp.default.Promise(function (resolve) { return resolve(_this._bootSync(options)); }); return this._bootPromise; }
javascript
{ "resource": "" }
q53516
train
function () { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; options.base = this; options.application = this; return _emberApplicationSystemApplicationInstance.default.create(options); }
javascript
{ "resource": "" }
q53517
train
function () { this._super.apply(this, arguments); _emberMetal.default.BOOTED = false; this._booted = false; this._bootPromise = null; this._bootResolver = null; if (_emberRuntimeSystemLazy_load._loaded.application === this) { _emberRuntimeSystemLazy_load._loaded.application = undefined; } if (this._globalsMode && this.__deprecatedInstance__) { this.__deprecatedInstance__.destroy(); } }
javascript
{ "resource": "" }
q53518
train
function () { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; options.base = this; return _emberApplicationSystemEngineInstance.default.create(options); }
javascript
{ "resource": "" }
q53519
train
function () { var _constructor$buildRegistry; var registry = this.__registry__ = this.constructor.buildRegistry(this, (_constructor$buildRegistry = {}, _constructor$buildRegistry[GLIMMER] = this[GLIMMER], _constructor$buildRegistry)); return registry; }
javascript
{ "resource": "" }
q53520
train
function (fullName) { var parsedName = this.parseName(fullName); var description; if (parsedName.type === 'template') { return 'template at ' + parsedName.fullNameWithoutType.replace(/\./g, '/'); } description = parsedName.root + '.' + _emberRuntimeSystemString.classify(parsedName.name).replace(/\./g, ''); if (parsedName.type !== 'model') { description += _emberRuntimeSystemString.classify(parsedName.type); } return description; }
javascript
{ "resource": "" }
q53521
train
function (parsedName) { var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); return _emberHtmlbarsTemplate_registry.get(templateName) || _emberHtmlbarsTemplate_registry.get(_emberRuntimeSystemString.decamelize(templateName)); }
javascript
{ "resource": "" }
q53522
train
function (parsedName) { var className = _emberRuntimeSystemString.classify(parsedName.name); var factory = _emberMetalProperty_get.get(parsedName.root, className); if (factory) { return factory; } }
javascript
{ "resource": "" }
q53523
train
function (type) { var namespace = _emberMetalProperty_get.get(this, 'namespace'); var suffix = _emberRuntimeSystemString.classify(type); var typeRegexp = new RegExp(suffix + '$'); var known = _emberMetalDictionary.default(null); var knownKeys = Object.keys(namespace); for (var index = 0, _length = knownKeys.length; index < _length; index++) { var _name = knownKeys[index]; if (typeRegexp.test(_name)) { var containerName = this.translateToContainerFullname(type, _name); known[containerName] = true; } } return known; }
javascript
{ "resource": "" }
q53524
train
function (typesAdded, typesUpdated) { var _this = this; var modelTypes = this.getModelTypes(); var releaseMethods = _emberRuntimeSystemNative_array.A(); var typesToSend; typesToSend = modelTypes.map(function (type) { var klass = type.klass; var wrapped = _this.wrapModelType(klass, type.name); releaseMethods.push(_this.observeModelType(type.name, typesUpdated)); return wrapped; }); typesAdded(typesToSend); var release = function () { releaseMethods.forEach(function (fn) { return fn(); }); _this.releaseMethods.removeObject(release); }; this.releaseMethods.pushObject(release); return release; }
javascript
{ "resource": "" }
q53525
train
function (modelName, recordsAdded, recordsUpdated, recordsRemoved) { var _this2 = this; var releaseMethods = _emberRuntimeSystemNative_array.A(); var klass = this._nameToClass(modelName); var records = this.getRecords(klass, modelName); var release; var recordUpdated = function (updatedRecord) { recordsUpdated([updatedRecord]); }; var recordsToSend = records.map(function (record) { releaseMethods.push(_this2.observeRecord(record, recordUpdated)); return _this2.wrapRecord(record); }); var contentDidChange = function (array, idx, removedCount, addedCount) { for (var i = idx; i < idx + addedCount; i++) { var record = _emberRuntimeMixinsArray.objectAt(array, i); var wrapped = _this2.wrapRecord(record); releaseMethods.push(_this2.observeRecord(record, recordUpdated)); recordsAdded([wrapped]); } if (removedCount) { recordsRemoved(idx, removedCount); } }; var observer = { didChange: contentDidChange, willChange: function () { return this; } }; _emberRuntimeMixinsArray.addArrayObserver(records, this, observer); release = function () { releaseMethods.forEach(function (fn) { fn(); }); _emberRuntimeMixinsArray.removeArrayObserver(records, _this2, observer); _this2.releaseMethods.removeObject(release); }; recordsAdded(recordsToSend); this.releaseMethods.pushObject(release); return release; }
javascript
{ "resource": "" }
q53526
train
function (modelName, typesUpdated) { var _this3 = this; var klass = this._nameToClass(modelName); var records = this.getRecords(klass, modelName); var onChange = function () { typesUpdated([_this3.wrapModelType(klass, modelName)]); }; var observer = { didChange: function () { _emberMetalRun_loop.default.scheduleOnce('actions', this, onChange); }, willChange: function () { return this; } }; _emberRuntimeMixinsArray.addArrayObserver(records, this, observer); var release = function () { _emberRuntimeMixinsArray.removeArrayObserver(records, _this3, observer); }; return release; }
javascript
{ "resource": "" }
q53527
train
function () { var _this5 = this; var namespaces = _emberRuntimeSystemNative_array.A(_emberRuntimeSystemNamespace.default.NAMESPACES); var types = _emberRuntimeSystemNative_array.A(); namespaces.forEach(function (namespace) { for (var key in namespace) { if (!namespace.hasOwnProperty(key)) { continue; } // Even though we will filter again in `getModelTypes`, // we should not call `lookupFactory` on non-models // (especially when `EmberENV.MODEL_FACTORY_INJECTIONS` is `true`) if (!_this5.detect(namespace[key])) { continue; } var name = _emberRuntimeSystemString.dasherize(key); if (!(namespace instanceof _emberApplicationSystemApplication.default) && namespace.toString()) { name = namespace + '/' + name; } types.push(name); } }); return types; }
javascript
{ "resource": "" }
q53528
train
function (record) { var recordToSend = { object: record }; recordToSend.columnValues = this.getRecordColumnValues(record); recordToSend.searchKeywords = this.getRecordKeywords(record); recordToSend.filterValues = this.getRecordFilterValues(record); recordToSend.color = this.getRecordColor(record); return recordToSend; }
javascript
{ "resource": "" }
q53529
unlessHelper
train
function unlessHelper(params, hash, options) { return ifUnless(params, hash, options, !_emberViewsStreamsShould_display.default(params[0])); }
javascript
{ "resource": "" }
q53530
ComponentNodeManager
train
function ComponentNodeManager(component, isAngleBracket, scope, renderNode, attrs, block, expectElement) { this.component = component; this.isAngleBracket = isAngleBracket; this.scope = scope; this.renderNode = renderNode; this.attrs = attrs; this.block = block; this.expectElement = expectElement; }
javascript
{ "resource": "" }
q53531
getArrayValues
train
function getArrayValues(params) { var l = params.length; var out = new Array(l); for (var i = 0; i < l; i++) { out[i] = _emberHtmlbarsHooksGetValue.default(params[i]); } return out; }
javascript
{ "resource": "" }
q53532
instrument
train
function instrument(component, callback, context) { var instrumentName, val, details, end; // Only instrument if there's at least one subscriber. if (_emberMetalInstrumentation.subscribers.length) { if (component) { instrumentName = component.instrumentName; } else { instrumentName = 'node'; } details = {}; if (component) { component.instrumentDetails(details); } end = _emberMetalInstrumentation._instrumentStart('render.' + instrumentName, function viewInstrumentDetails() { return details; }); val = callback.call(context); if (end) { end(); } return val; } else { return callback.call(context); } }
javascript
{ "resource": "" }
q53533
makeBoundHelper
train
function makeBoundHelper(fn) { _emberMetalDebug.deprecate('Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to use `Ember.Helper` or `Ember.Helper.helper`.', false, { id: 'ember-htmlbars.make-bound-helper', until: '3.0.0' }); return _emberHtmlbarsHelper.helper(fn); }
javascript
{ "resource": "" }
q53534
htmlSafe
train
function htmlSafe(str) { if (str === null || str === undefined) { str = ''; } else if (typeof str !== 'string') { str = '' + str; } return new _htmlbarsUtil.SafeString(str); }
javascript
{ "resource": "" }
q53535
train
function () { _emberMetalDebug.assert('Must pass a valid object to Ember.Binding.disconnect()', !!this._toObj); // Remove an observer on the object so we're no longer notified of // changes that should update bindings. _emberMetalObserver.removeObserver(this._fromObj, this._fromPath, this, 'fromDidChange'); // If the binding is two-way, remove the observer from the target as well. if (!this._oneWay) { _emberMetalObserver.removeObserver(this._toObj, this._to, this, 'toDidChange'); } this._readyToSync = false; // Disable scheduled syncs... return this; }
javascript
{ "resource": "" }
q53536
ChainNode
train
function ChainNode(parent, key, value) { this._parent = parent; this._key = key; // _watching is true when calling get(this._parent, this._key) will // return the value of this node. // // It is false for the root of a chain (because we have no parent) // and for global paths (because the parent node is the object with // the observer on it) this._watching = value === undefined; this._chains = undefined; this._object = undefined; this.count = 0; this._value = value; this._paths = {}; if (this._watching) { this._object = parent.value(); if (this._object) { addChainWatcher(this._object, this._key, this); } } }
javascript
{ "resource": "" }
q53537
train
function (path) { var paths = this._paths; paths[path] = (paths[path] || 0) + 1; var key = firstKey(path); var tail = path.slice(key.length + 1); this.chain(key, tail); }
javascript
{ "resource": "" }
q53538
match
train
function match(dependentKey, regexp) { return _emberMetalComputed.computed(dependentKey, function () { var value = _emberMetalProperty_get.get(this, dependentKey); return typeof value === 'string' ? regexp.test(value) : false; }); }
javascript
{ "resource": "" }
q53539
equal
train
function equal(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) === value; }); }
javascript
{ "resource": "" }
q53540
gt
train
function gt(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) > value; }); }
javascript
{ "resource": "" }
q53541
gte
train
function gte(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) >= value; }); }
javascript
{ "resource": "" }
q53542
lt
train
function lt(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) < value; }); }
javascript
{ "resource": "" }
q53543
lte
train
function lte(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) <= value; }); }
javascript
{ "resource": "" }
q53544
deprecatingAlias
train
function deprecatingAlias(dependentKey, options) { return _emberMetalComputed.computed(dependentKey, { get: function (key) { _emberMetalDebug.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options); return _emberMetalProperty_get.get(this, dependentKey); }, set: function (key, value) { _emberMetalDebug.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options); _emberMetalProperty_set.set(this, dependentKey, value); return value; } }); }
javascript
{ "resource": "" }
q53545
suspendListener
train
function suspendListener(obj, eventName, target, method, callback) { return suspendListeners(obj, [eventName], target, method, callback); }
javascript
{ "resource": "" }
q53546
sendEvent
train
function sendEvent(obj, eventName, params, actions) { if (!actions) { var meta = _emberMetalMeta.peekMeta(obj); actions = meta && meta.matchingListeners(eventName); } if (!actions || actions.length === 0) { return; } for (var i = actions.length - 3; i >= 0; i -= 3) { // looping in reverse for once listeners var target = actions[i]; var method = actions[i + 1]; var flags = actions[i + 2]; if (!method) { continue; } if (flags & _emberMetalMeta_listeners.SUSPENDED) { continue; } if (flags & _emberMetalMeta_listeners.ONCE) { removeListener(obj, eventName, target, method); } if (!target) { target = obj; } if ('string' === typeof method) { if (params) { _emberMetalUtils.applyStr(target, method, params); } else { target[method](); } } else { if (params) { _emberMetalUtils.apply(target, method, params); } else { method.call(target); } } } return true; }
javascript
{ "resource": "" }
q53547
on
train
function on() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var func = args.pop(); var events = args; func.__ember_listens__ = events; return func; }
javascript
{ "resource": "" }
q53548
expandProperties
train
function expandProperties(pattern, callback) { _emberMetalDebug.assert('A computed property key must be a string', typeof pattern === 'string'); _emberMetalDebug.assert('Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"', pattern.indexOf(' ') === -1); var parts = pattern.split(SPLIT_REGEX); var properties = [parts]; for (var i = 0; i < parts.length; i++) { var part = parts[i]; if (part.indexOf(',') >= 0) { properties = duplicateAndReplace(properties, part.split(','), i); } } for (var i = 0; i < properties.length; i++) { callback(properties[i].join('').replace(END_WITH_EACH_REGEX, '.[]')); } }
javascript
{ "resource": "" }
q53549
InjectedProperty
train
function InjectedProperty(type, name) { this.type = type; this.name = name; this._super$Constructor(injectedPropertyGet); AliasedPropertyPrototype.oneWay.call(this); }
javascript
{ "resource": "" }
q53550
_instrumentStart
train
function _instrumentStart(name, _payload) { var listeners = cache[name]; if (!listeners) { listeners = populateListeners(name); } if (listeners.length === 0) { return; } var payload = _payload(); var STRUCTURED_PROFILE = _emberMetalCore.default.STRUCTURED_PROFILE; var timeName; if (STRUCTURED_PROFILE) { timeName = name + ': ' + payload.object; console.time(timeName); } var l = listeners.length; var beforeValues = new Array(l); var i, listener; var timestamp = time(); for (i = 0; i < l; i++) { listener = listeners[i]; beforeValues[i] = listener.before(name, timestamp, payload); } return function _instrumentEnd() { var i, l, listener; var timestamp = time(); for (i = 0, l = listeners.length; i < l; i++) { listener = listeners[i]; if (typeof listener.after === 'function') { listener.after(name, timestamp, payload, beforeValues[i]); } } if (STRUCTURED_PROFILE) { console.timeEnd(timeName); } }; }
javascript
{ "resource": "" }
q53551
subscribe
train
function subscribe(pattern, object) { var paths = pattern.split('.'); var path; var regex = []; for (var i = 0, l = paths.length; i < l; i++) { path = paths[i]; if (path === '*') { regex.push('[^\\.]*'); } else { regex.push(path); } } regex = regex.join('\\.'); regex = regex + '(\\..*)?'; var subscriber = { pattern: pattern, regex: new RegExp('^' + regex + '$'), object: object }; subscribers.push(subscriber); cache = {}; return subscriber; }
javascript
{ "resource": "" }
q53552
unsubscribe
train
function unsubscribe(subscriber) { var index; for (var i = 0, l = subscribers.length; i < l; i++) { if (subscribers[i] === subscriber) { index = i; } } subscribers.splice(index, 1); cache = {}; }
javascript
{ "resource": "" }
q53553
train
function (key) { if (this.size === 0) { return; } var values = this._values; var guid = _emberMetalUtils.guidFor(key); return values[guid]; }
javascript
{ "resource": "" }
q53554
train
function (callback /*, ...thisArg*/) { if (typeof callback !== 'function') { missingFunction(callback); } if (this.size === 0) { return; } var length = arguments.length; var map = this; var cb, thisArg; if (length === 2) { thisArg = arguments[1]; cb = function (key) { callback.call(thisArg, map.get(key), key, map); }; } else { cb = function (key) { callback(map.get(key), key, map); }; } this._keys.forEach(cb); }
javascript
{ "resource": "" }
q53555
ownMap
train
function ownMap(name, Meta) { var key = memberProperty(name); var capitalized = capitalize(name); Meta.prototype['writable' + capitalized] = function () { return this._getOrCreateOwnMap(key); }; Meta.prototype['readable' + capitalized] = function () { return this[key]; }; }
javascript
{ "resource": "" }
q53556
inheritedMap
train
function inheritedMap(name, Meta) { var key = memberProperty(name); var capitalized = capitalize(name); Meta.prototype['write' + capitalized] = function (subkey, value) { var map = this._getOrCreateOwnMap(key); map[subkey] = value; }; Meta.prototype['peek' + capitalized] = function (subkey) { return this._findInherited(key, subkey); }; Meta.prototype['forEach' + capitalized] = function (fn) { var pointer = this; var seen = new _emberMetalEmpty_object.default(); while (pointer !== undefined) { var map = pointer[key]; if (map) { for (var _key in map) { if (!seen[_key]) { seen[_key] = true; fn(_key, map[_key]); } } } pointer = pointer.parent; } }; Meta.prototype['clear' + capitalized] = function () { this[key] = undefined; }; Meta.prototype['deleteFrom' + capitalized] = function (subkey) { delete this._getOrCreateOwnMap(key)[subkey]; }; Meta.prototype['hasIn' + capitalized] = function (subkey) { return this._findInherited(key, subkey) !== undefined; }; }
javascript
{ "resource": "" }
q53557
inheritedMapOfMaps
train
function inheritedMapOfMaps(name, Meta) { var key = memberProperty(name); var capitalized = capitalize(name); Meta.prototype['write' + capitalized] = function (subkey, itemkey, value) { var outerMap = this._getOrCreateOwnMap(key); var innerMap = outerMap[subkey]; if (!innerMap) { innerMap = outerMap[subkey] = new _emberMetalEmpty_object.default(); } innerMap[itemkey] = value; }; Meta.prototype['peek' + capitalized] = function (subkey, itemkey) { var pointer = this; while (pointer !== undefined) { var map = pointer[key]; if (map) { var value = map[subkey]; if (value) { if (value[itemkey] !== undefined) { return value[itemkey]; } } } pointer = pointer.parent; } }; Meta.prototype['has' + capitalized] = function (subkey) { var pointer = this; while (pointer !== undefined) { if (pointer[key] && pointer[key][subkey]) { return true; } pointer = pointer.parent; } return false; }; Meta.prototype['forEachIn' + capitalized] = function (subkey, fn) { return this._forEachIn(key, subkey, fn); }; }
javascript
{ "resource": "" }
q53558
ownCustomObject
train
function ownCustomObject(name, Meta) { var key = memberProperty(name); var capitalized = capitalize(name); Meta.prototype['writable' + capitalized] = function (create) { var ret = this[key]; if (!ret) { ret = this[key] = create(this.source); } return ret; }; Meta.prototype['readable' + capitalized] = function () { return this[key]; }; }
javascript
{ "resource": "" }
q53559
train
function (obj, meta) { // if `null` already, just set it to the new value // otherwise define property first if (obj[META_FIELD] !== null) { if (obj.__defineNonEnumerable) { obj.__defineNonEnumerable(EMBER_META_PROPERTY); } else { Object.defineProperty(obj, META_FIELD, META_DESC); } } obj[META_FIELD] = meta; }
javascript
{ "resource": "" }
q53560
Mixin
train
function Mixin(args, properties) { this.properties = properties; var length = args && args.length; if (length > 0) { var m = new Array(length); for (var i = 0; i < length; i++) { var x = args[i]; if (x instanceof Mixin) { m[i] = x; } else { m[i] = new Mixin(undefined, x); } } this.mixins = m; } else { this.mixins = undefined; } this.ownerConstructor = undefined; this._without = undefined; this[_emberMetalUtils.GUID_KEY] = null; this[_emberMetalUtils.GUID_KEY + '_name'] = null; _emberMetalDebug.debugSeal(this); }
javascript
{ "resource": "" }
q53561
_immediateObserver
train
function _immediateObserver() { _emberMetalDebug.deprecate('Usage of `Ember.immediateObserver` is deprecated, use `Ember.observer` instead.', false, { id: 'ember-metal.immediate-observer', until: '3.0.0' }); for (var i = 0, l = arguments.length; i < l; i++) { var arg = arguments[i]; _emberMetalDebug.assert('Immediate observers must observe internal properties only, not properties on other objects.', typeof arg !== 'string' || arg.indexOf('.') === -1); } return observer.apply(this, arguments); }
javascript
{ "resource": "" }
q53562
_beforeObserver
train
function _beforeObserver() { for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { args[_key5] = arguments[_key5]; } var func = args.slice(-1)[0]; var paths; var addWatchedProperty = function (path) { paths.push(path); }; var _paths = args.slice(0, -1); if (typeof func !== 'function') { // revert to old, soft-deprecated argument ordering func = args[0]; _paths = args.slice(1); } paths = []; for (var i = 0; i < _paths.length; ++i) { _emberMetalExpand_properties.default(_paths[i], addWatchedProperty); } if (typeof func !== 'function') { throw new _emberMetalCore.default.Error('Ember.beforeObserver called without a function'); } func.__ember_observesBefore__ = paths; return func; }
javascript
{ "resource": "" }
q53563
changeProperties
train
function changeProperties(callback, binding) { beginPropertyChanges(); try { callback.call(binding); } finally { endPropertyChanges.call(binding); } }
javascript
{ "resource": "" }
q53564
chain
train
function chain(value, fn, label) { _emberMetalDebug.assert('Must call chain with a label', !!label); if (isStream(value)) { var stream = new _emberMetalStreamsStream.Stream(fn, function () { return label + '(' + labelFor(value) + ')'; }); stream.addDependency(value); return stream; } else { return fn(); } }
javascript
{ "resource": "" }
q53565
guidFor
train
function guidFor(obj) { if (obj && obj[GUID_KEY]) { return obj[GUID_KEY]; } // special cases where we don't want to add a key to object if (obj === undefined) { return '(undefined)'; } if (obj === null) { return '(null)'; } var ret; var type = typeof obj; // Don't allow prototype changes to String etc. to change the guidFor switch (type) { case 'number': ret = numberCache[obj]; if (!ret) { ret = numberCache[obj] = 'nu' + obj; } return ret; case 'string': ret = stringCache[obj]; if (!ret) { ret = stringCache[obj] = 'st' + uuid(); } return ret; case 'boolean': return obj ? '(true)' : '(false)'; default: if (obj === Object) { return '(Object)'; } if (obj === Array) { return '(Array)'; } ret = GUID_PREFIX + uuid(); if (obj[GUID_KEY] === null) { obj[GUID_KEY] = ret; } else { GUID_DESC.value = ret; if (obj.__defineNonEnumerable) { obj.__defineNonEnumerable(GUID_KEY_PROPERTY); } else { Object.defineProperty(obj, GUID_KEY, GUID_DESC); } } return ret; } }
javascript
{ "resource": "" }
q53566
tryInvoke
train
function tryInvoke(obj, methodName, args) { if (canInvoke(obj, methodName)) { return args ? applyStr(obj, methodName, args) : applyStr(obj, methodName); } }
javascript
{ "resource": "" }
q53567
apply
train
function apply(t, m, a) { var l = a && a.length; if (!a || !l) { return m.call(t); } switch (l) { case 1: return m.call(t, a[0]); case 2: return m.call(t, a[0], a[1]); case 3: return m.call(t, a[0], a[1], a[2]); case 4: return m.call(t, a[0], a[1], a[2], a[3]); case 5: return m.call(t, a[0], a[1], a[2], a[3], a[4]); default: return m.apply(t, a); } }
javascript
{ "resource": "" }
q53568
destroy
train
function destroy(obj) { var meta = _emberMetalMeta.peekMeta(obj); var node, nodes, key, nodeObject; if (meta) { _emberMetalMeta.deleteMeta(obj); // remove chainWatchers to remove circular references that would prevent GC node = meta.readableChains(); if (node) { NODE_STACK.push(node); // process tree while (NODE_STACK.length > 0) { node = NODE_STACK.pop(); // push children nodes = node._chains; if (nodes) { for (key in nodes) { if (nodes[key] !== undefined) { NODE_STACK.push(nodes[key]); } } } // remove chainWatcher in node object if (node._watching) { nodeObject = node._object; if (nodeObject) { _emberMetalChains.removeChainWatcher(nodeObject, node._key, node); } } } } } }
javascript
{ "resource": "" }
q53569
train
function (controller, _prop) { var prop = _prop.substr(0, _prop.length - 3); var delegate = controller._qpDelegate; var value = _emberMetalProperty_get.get(controller, prop); delegate(prop, value); }
javascript
{ "resource": "" }
q53570
train
function () { var rootURL = this.rootURL; _emberMetalDebug.assert('rootURL must end with a trailing forward slash e.g. "/app/"', rootURL.charAt(rootURL.length - 1) === '/'); var implementation = detectImplementation({ location: this.location, history: this.history, userAgent: this.userAgent, rootURL: rootURL, documentMode: this.documentMode, global: this.global }); if (implementation === false) { _emberMetalProperty_set.set(this, 'cancelRouterSetup', true); implementation = 'none'; } var concrete = _containerOwner.getOwner(this).lookup('location:' + implementation); _emberMetalProperty_set.set(concrete, 'rootURL', rootURL); _emberMetalDebug.assert('Could not find location \'' + implementation + '\'.', !!concrete); _emberMetalProperty_set.set(this, 'concreteImplementation', concrete); }
javascript
{ "resource": "" }
q53571
train
function () { var history = _emberMetalProperty_get.get(this, 'history') || window.history; _emberMetalProperty_set.set(this, 'history', history); if (history && 'state' in history) { this.supportsHistory = true; } this.replaceState(this.formatURL(this.getURL())); }
javascript
{ "resource": "" }
q53572
train
function () { var location = _emberMetalProperty_get.get(this, 'location'); var path = location.pathname; var rootURL = _emberMetalProperty_get.get(this, 'rootURL'); var baseURL = _emberMetalProperty_get.get(this, 'baseURL'); // remove trailing slashes if they exists rootURL = rootURL.replace(/\/$/, ''); baseURL = baseURL.replace(/\/$/, ''); // remove baseURL and rootURL from path var url = path.replace(baseURL, '').replace(rootURL, ''); var search = location.search || ''; url += search; url += this.getHash(); return url; }
javascript
{ "resource": "" }
q53573
train
function (path) { var state = this.getState(); path = this.formatURL(path); if (!state || state.path !== path) { this.pushState(path); } }
javascript
{ "resource": "" }
q53574
train
function (path) { var state = this.getState(); path = this.formatURL(path); if (!state || state.path !== path) { this.replaceState(path); } }
javascript
{ "resource": "" }
q53575
train
function (callback) { var _this = this; var guid = _emberMetalUtils.guidFor(this); _emberViewsSystemJquery.default(window).on('popstate.ember-location-' + guid, function (e) { // Ignore initial page load popstate event in Chrome if (!popstateFired) { popstateFired = true; if (_this.getURL() === _this._previousURL) { return; } } callback(_this.getURL()); }); }
javascript
{ "resource": "" }
q53576
generateController
train
function generateController(owner, controllerName, context) { generateControllerFactory(owner, controllerName, context); var fullName = 'controller:' + controllerName; var instance = owner.lookup(fullName); if (_emberMetalProperty_get.get(instance, 'namespace.LOG_ACTIVE_GENERATION')) { _emberMetalDebug.info('generated -> ' + fullName, { fullName: fullName }); } return instance; }
javascript
{ "resource": "" }
q53577
train
function (name) { var route = _containerOwner.getOwner(this).lookup('route:' + name); if (!route) { return {}; } var transition = this.router.router.activeTransition; var state = transition ? transition.state : this.router.router.state; var params = {}; _emberMetalAssign.default(params, state.params[name]); _emberMetalAssign.default(params, getQueryParamsFor(route, state)); return params; }
javascript
{ "resource": "" }
q53578
train
function (value, urlKey, defaultValueType) { // urlKey isn't used here, but anyone overriding // can use it to provide deserialization specific // to a certain query param. // Use the defaultValueType of the default value (the initial value assigned to a // controller query param property), to intelligently deserialize and cast. if (defaultValueType === 'boolean') { return value === 'true' ? true : false; } else if (defaultValueType === 'number') { return Number(value).valueOf(); } else if (defaultValueType === 'array') { return _emberRuntimeSystemNative_array.A(JSON.parse(value)); } return value; }
javascript
{ "resource": "" }
q53579
train
function (oldInfos, newInfos, transition) { _emberMetalRun_loop.default.once(this, this.trigger, 'willTransition', transition); if (_emberMetalProperty_get.get(this, 'namespace').LOG_TRANSITIONS) { _emberMetalLogger.default.log('Preparing to transition from \'' + EmberRouter._routePath(oldInfos) + '\' to \'' + EmberRouter._routePath(newInfos) + '\''); } }
javascript
{ "resource": "" }
q53580
train
function (leafRouteName) { if (this._qpCache[leafRouteName]) { return this._qpCache[leafRouteName]; } var map = {}; var qps = []; this._qpCache[leafRouteName] = { map: map, qps: qps }; var routerjs = this.router; var recogHandlerInfos = routerjs.recognizer.handlersFor(leafRouteName); for (var i = 0, len = recogHandlerInfos.length; i < len; ++i) { var recogHandler = recogHandlerInfos[i]; var route = routerjs.getHandler(recogHandler.handler); var qpMeta = _emberMetalProperty_get.get(route, '_qp'); if (!qpMeta) { continue; } _emberMetalAssign.default(map, qpMeta.map); qps.push.apply(qps, qpMeta.qps); } return { qps: qps, map: map }; }
javascript
{ "resource": "" }
q53581
queryParamsHelper
train
function queryParamsHelper(params, hash) { _emberMetalDebug.assert('The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName=\'foo\') as opposed to just (query-params \'foo\')', params.length === 0); return _emberRoutingSystemQuery_params.default.create({ values: hash }); }
javascript
{ "resource": "" }
q53582
max
train
function max(dependentKey) { return reduceMacro(dependentKey, function (max, item) { return Math.max(max, item); }, -Infinity); }
javascript
{ "resource": "" }
q53583
filterBy
train
function filterBy(dependentKey, propertyKey, value) { var callback; if (arguments.length === 2) { callback = function (item) { return _emberMetalProperty_get.get(item, propertyKey); }; } else { callback = function (item) { return _emberMetalProperty_get.get(item, propertyKey) === value; }; } return filter(dependentKey + '.@each.' + propertyKey, callback); }
javascript
{ "resource": "" }
q53584
setDiff
train
function setDiff(setAProperty, setBProperty) { if (arguments.length !== 2) { throw new _emberMetalError.default('setDiff requires exactly two dependent arrays.'); } return _emberMetalComputed.computed(setAProperty + '.[]', setBProperty + '.[]', function () { var setA = this.get(setAProperty); var setB = this.get(setBProperty); if (!_emberRuntimeUtils.isArray(setA)) { return _emberRuntimeSystemNative_array.A(); } if (!_emberRuntimeUtils.isArray(setB)) { return _emberRuntimeSystemNative_array.A(setA); } return setA.filter(function (x) { return setB.indexOf(x) === -1; }); }).readOnly(); }
javascript
{ "resource": "" }
q53585
collect
train
function collect() { for (var _len3 = arguments.length, dependentKeys = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { dependentKeys[_key3] = arguments[_key3]; } return multiArrayMacro(dependentKeys, function () { var properties = _emberMetalGet_properties.default(this, dependentKeys); var res = _emberRuntimeSystemNative_array.A(); for (var key in properties) { if (properties.hasOwnProperty(key)) { if (_emberMetalIs_none.default(properties[key])) { res.push(null); } else { res.push(properties[key]); } } } return res; }); }
javascript
{ "resource": "" }
q53586
copy
train
function copy(obj, deep) { // fast paths if ('object' !== typeof obj || obj === null) { return obj; // can't copy primitives } if (_emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj)) { return obj.copy(deep); } return _copy(obj, deep, deep ? [] : null, deep ? [] : null); }
javascript
{ "resource": "" }
q53587
createInjectionHelper
train
function createInjectionHelper(type, validator) { typeValidators[type] = validator; inject[type] = function (name) { return new _emberMetalInjected_property.default(type, name); }; }
javascript
{ "resource": "" }
q53588
validatePropertyInjections
train
function validatePropertyInjections(factory) { var proto = factory.proto(); var types = []; var key, desc, validator, i, l; for (key in proto) { desc = proto[key]; if (desc instanceof _emberMetalInjected_property.default && types.indexOf(desc.type) === -1) { types.push(desc.type); } } if (types.length) { for (i = 0, l = types.length; i < l; i++) { validator = typeValidators[types[i]]; if (typeof validator === 'function') { validator(factory); } } } return true; }
javascript
{ "resource": "" }
q53589
train
function () { _emberMetalDebug.deprecate('`frozenCopy` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.frozen-copy', until: '3.0.0' }); if (_emberRuntimeMixinsFreezable.Freezable && _emberRuntimeMixinsFreezable.Freezable.detect(this)) { return _emberMetalProperty_get.get(this, 'isFrozen') ? this : this.copy().freeze(); } else { throw new _emberMetalError.default(this + ' does not support freezing'); } }
javascript
{ "resource": "" }
q53590
train
function () { var sortKeys = arguments; return this.toArray().sort(function (a, b) { for (var i = 0; i < sortKeys.length; i++) { var key = sortKeys[i]; var propA = _emberMetalProperty_get.get(a, key); var propB = _emberMetalProperty_get.get(b, key); // return 1 or -1 else continue to the next sortKey var compareValue = _emberRuntimeCompare.default(propA, propB); if (compareValue) { return compareValue; } } return 0; }); }
javascript
{ "resource": "" }
q53591
train
function (objects) { var _this = this; _emberMetalProperty_events.beginPropertyChanges(this); objects.forEach(function (obj) { return _this.addObject(obj); }); _emberMetalProperty_events.endPropertyChanges(this); return this; }
javascript
{ "resource": "" }
q53592
train
function (key, value) { var ret; // = this.reducedProperty(key, value); if (value !== undefined && ret === undefined) { ret = this[key] = value; } return ret; }
javascript
{ "resource": "" }
q53593
typeOf
train
function typeOf(item) { if (item === null) { return 'null'; } if (item === undefined) { return 'undefined'; } var ret = TYPE_MAP[toString.call(item)] || 'object'; if (ret === 'function') { if (_emberRuntimeSystemObject.default.detect(item)) { ret = 'class'; } } else if (ret === 'object') { if (item instanceof Error) { ret = 'error'; } else if (item instanceof _emberRuntimeSystemObject.default) { ret = 'instance'; } else if (item instanceof Date) { ret = 'date'; } } return ret; }
javascript
{ "resource": "" }
q53594
train
function (context, callback) { if (!this.waiters) { return; } if (arguments.length === 1) { callback = context; context = null; } this.waiters = _emberRuntimeSystemNative_array.A(this.waiters.filter(function (elt) { return !(elt[0] === context && elt[1] === callback); })); }
javascript
{ "resource": "" }
q53595
protoWrap
train
function protoWrap(proto, name, callback, isAsync) { proto[name] = function () { for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } if (isAsync) { return callback.apply(this, args); } else { return this.then(function () { return callback.apply(this, args); }); } }; }
javascript
{ "resource": "" }
q53596
isolate
train
function isolate(fn, val) { var value, lastPromise; // Reset lastPromise for nested helpers Test.lastPromise = null; value = fn(val); lastPromise = Test.lastPromise; Test.lastPromise = null; // If the method returned a promise // return that promise. If not, // return the last async helper's promise if (value && value instanceof Test.Promise || !lastPromise) { return value; } else { return run(function () { return Test.resolve(lastPromise).then(function () { return value; }); }); } }
javascript
{ "resource": "" }
q53597
train
function (klass) { _emberMetalDebug.deprecate('nearestChildOf has been deprecated.', false, { id: 'ember-views.nearest-child-of', until: '3.0.0' }); var view = _emberMetalProperty_get.get(this, 'parentView'); while (view) { if (_emberMetalProperty_get.get(view, 'parentView') instanceof klass) { return view; } view = _emberMetalProperty_get.get(view, 'parentView'); } }
javascript
{ "resource": "" }
q53598
train
function (block, renderNode) { if (_renderView === undefined) { _renderView = require('ember-htmlbars/system/render-view'); } return _renderView.renderHTMLBarsBlock(this, block, renderNode); }
javascript
{ "resource": "" }
q53599
train
function (property) { var view = _emberMetalProperty_get.get(this, 'parentView'); while (view) { if (property in view) { return view; } view = _emberMetalProperty_get.get(view, 'parentView'); } }
javascript
{ "resource": "" }