repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
restify/errors
lib/helpers.js
errNameFromDesc
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
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; }
[ "function", "errNameFromDesc", "(", "desc", ")", "{", "assert", ".", "string", "(", "desc", ",", "'desc'", ")", ";", "var", "pieces", "=", "desc", ".", "split", "(", "/", "\\s+", "/", ")", ";", "var", "name", "=", "_", ".", "reduce", "(", "pieces", ",", "function", "(", "acc", ",", "piece", ")", "{", "var", "normalizedPiece", "=", "_", ".", "capitalize", "(", "piece", ".", "toLowerCase", "(", ")", ")", ";", "return", "acc", "+", "normalizedPiece", ";", "}", ",", "''", ")", ";", "name", "=", "name", ".", "replace", "(", "/", "\\W+", "/", "g", ",", "''", ")", ";", "if", "(", "!", "_", ".", "endsWith", "(", "name", ",", "'Error'", ")", ")", "{", "name", "+=", "'Error'", ";", "}", "return", "name", ";", "}" ]
used to programatically create http error code names, using the underlying status codes names exposed via the http module. @private @function errNameFromDesc @param {String} desc a description of the error, e.g., 'Not Found' @returns {String}
[ "used", "to", "programatically", "create", "http", "error", "code", "names", "using", "the", "underlying", "status", "codes", "names", "exposed", "via", "the", "http", "module", "." ]
af5cb0c1a72b7a47886b77a56f56d766806b3c1e
https://github.com/restify/errors/blob/af5cb0c1a72b7a47886b77a56f56d766806b3c1e/lib/helpers.js#L103-L127
train
restify/errors
lib/index.js
makeErrFromCode
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
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); }
[ "function", "makeErrFromCode", "(", "statusCode", ")", "{", "assert", ".", "number", "(", "statusCode", ",", "'statusCode'", ")", ";", "assert", ".", "equal", "(", "statusCode", ">=", "400", ",", "true", ")", ";", "var", "args", "=", "_", ".", "drop", "(", "_", ".", "toArray", "(", "arguments", ")", ")", ";", "var", "name", "=", "helpers", ".", "errNameFromCode", "(", "statusCode", ")", ";", "var", "ErrCtor", "=", "httpErrors", "[", "name", "]", ";", "assert", ".", "func", "(", "ErrCtor", ")", ";", "return", "makeInstance", "(", "ErrCtor", ",", "makeErrFromCode", ",", "args", ")", ";", "}" ]
create an error object from an http status code. first arg is status code, all subsequent args passed on to the constructor. only works for regular HttpErrors, not RestErrors. @public @function makeErrFromCode @param {Number} statusCode the http status code @returns {Error} an error instance
[ "create", "an", "error", "object", "from", "an", "http", "status", "code", ".", "first", "arg", "is", "status", "code", "all", "subsequent", "args", "passed", "on", "to", "the", "constructor", ".", "only", "works", "for", "regular", "HttpErrors", "not", "RestErrors", "." ]
af5cb0c1a72b7a47886b77a56f56d766806b3c1e
https://github.com/restify/errors/blob/af5cb0c1a72b7a47886b77a56f56d766806b3c1e/lib/index.js#L26-L42
train
restify/errors
lib/index.js
makeInstance
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
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; }
[ "function", "makeInstance", "(", "constructor", ",", "constructorOpt", ",", "args", ")", "{", "function", "F", "(", ")", "{", "return", "constructor", ".", "apply", "(", "this", ",", "args", ")", ";", "}", "F", ".", "prototype", "=", "constructor", ".", "prototype", ";", "var", "errInstance", "=", "new", "F", "(", ")", ";", "Error", ".", "captureStackTrace", "(", "errInstance", ",", "constructorOpt", ")", ";", "return", "errInstance", ";", "}" ]
helper function to dynamically apply args to a dynamic constructor. magicks. @private @function makeInstance @param {Function} constructor the constructor function @param {Function} constructorOpt where to start the error stack trace @param {Array} args array of arguments to apply to ctor @returns {Object} instance of the ctor
[ "helper", "function", "to", "dynamically", "apply", "args", "to", "a", "dynamic", "constructor", ".", "magicks", "." ]
af5cb0c1a72b7a47886b77a56f56d766806b3c1e
https://github.com/restify/errors/blob/af5cb0c1a72b7a47886b77a56f56d766806b3c1e/lib/index.js#L55-L69
train
restify/errors
lib/makeConstructor.js
makeConstructor
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
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; }
[ "function", "makeConstructor", "(", "name", ",", "defaults", ")", "{", "assert", ".", "string", "(", "name", ",", "'name'", ")", ";", "assert", ".", "optionalObject", "(", "defaults", ",", "'defaults'", ")", ";", "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", ".", "equal", "(", "typeof", "module", ".", "exports", "[", "name", "]", ",", "'undefined'", ",", "'Constructor already exists!'", ")", ";", "var", "ErrCtor", "=", "function", "(", ")", "{", "RestError", ".", "apply", "(", "this", ",", "arguments", ")", ";", "this", ".", "name", "=", "name", ";", "}", ";", "util", ".", "inherits", "(", "ErrCtor", ",", "RestError", ")", ";", "_", ".", "assign", "(", "ErrCtor", ".", "prototype", ",", "prototypeDefaults", ")", ";", "ErrCtor", ".", "displayName", "=", "name", ";", "return", "ErrCtor", ";", "}" ]
create RestError subclasses for users. takes a string, creates a constructor for them. magicks, again. @public @function makeConstructor @param {String} name the name of the error class to create @param {Number} defaults optional status code @return {Function} a constructor function
[ "create", "RestError", "subclasses", "for", "users", ".", "takes", "a", "string", "creates", "a", "constructor", "for", "them", ".", "magicks", "again", "." ]
af5cb0c1a72b7a47886b77a56f56d766806b3c1e
https://github.com/restify/errors/blob/af5cb0c1a72b7a47886b77a56f56d766806b3c1e/lib/makeConstructor.js#L24-L61
train
restify/errors
lib/serializer.js
factory
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
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; }
[ "function", "factory", "(", "options", ")", "{", "assert", ".", "optionalObject", "(", "options", ",", "'options'", ")", ";", "var", "opts", "=", "_", ".", "assign", "(", "{", "topLevelFields", ":", "false", "}", ",", "options", ")", ";", "var", "serializer", "=", "new", "ErrorSerializer", "(", "opts", ")", ";", "serializer", ".", "serialize", "=", "serializer", ".", "serialize", ".", "bind", "(", "serializer", ")", ";", "return", "serializer", ";", "}" ]
factory function to create customized serializers. @public @param {Object} options an options object @return {Function} serializer function
[ "factory", "function", "to", "create", "customized", "serializers", "." ]
af5cb0c1a72b7a47886b77a56f56d766806b3c1e
https://github.com/restify/errors/blob/af5cb0c1a72b7a47886b77a56f56d766806b3c1e/lib/serializer.js#L265-L278
train
camunda/camunda-bpm-sdk-js
lib/forms/camunda-form.js
CamundaForm
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
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); }
[ "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\\''", ")", ")", ";", "}", "\\'", "\\'", "\\'", "}" ]
A class to help handling embedded forms @class @memberof CamSDk.form @param {Object.<String,*>} options @param {Cam} options.client @param {String} [options.taskId] @param {String} [options.processDefinitionId] @param {String} [options.processDefinitionKey] @param {Element} [options.formContainer] @param {Element} [options.formElement] @param {Object} [options.urlParams] @param {String} [options.formUrl]
[ "A", "class", "to", "help", "handling", "embedded", "forms" ]
4ad43b41b501c31024ee017f5dc95a933258b0f0
https://github.com/camunda/camunda-bpm-sdk-js/blob/4ad43b41b501c31024ee017f5dc95a933258b0f0/lib/forms/camunda-form.js#L69-L136
train
camunda/camunda-bpm-sdk-js
lib/events.js
toArray
function toArray(obj) { var a, arr = []; for (a in obj) { arr.push(obj[a]); } return arr; }
javascript
function toArray(obj) { var a, arr = []; for (a in obj) { arr.push(obj[a]); } return arr; }
[ "function", "toArray", "(", "obj", ")", "{", "var", "a", ",", "arr", "=", "[", "]", ";", "for", "(", "a", "in", "obj", ")", "{", "arr", ".", "push", "(", "obj", "[", "a", "]", ")", ";", "}", "return", "arr", ";", "}" ]
Converts an object into array @param {*} obj @return {Array}
[ "Converts", "an", "object", "into", "array" ]
4ad43b41b501c31024ee017f5dc95a933258b0f0
https://github.com/camunda/camunda-bpm-sdk-js/blob/4ad43b41b501c31024ee017f5dc95a933258b0f0/lib/events.js#L45-L51
train
camunda/camunda-bpm-sdk-js
lib/events.js
ensureEvents
function ensureEvents(obj, name) { obj._events = obj._events || {}; obj._events[name] = obj._events[name] || []; }
javascript
function ensureEvents(obj, name) { obj._events = obj._events || {}; obj._events[name] = obj._events[name] || []; }
[ "function", "ensureEvents", "(", "obj", ",", "name", ")", "{", "obj", ".", "_events", "=", "obj", ".", "_events", "||", "{", "}", ";", "obj", ".", "_events", "[", "name", "]", "=", "obj", ".", "_events", "[", "name", "]", "||", "[", "]", ";", "}" ]
Ensure an object to have the needed _events property @param {*} obj @param {String} name
[ "Ensure", "an", "object", "to", "have", "the", "needed", "_events", "property" ]
4ad43b41b501c31024ee017f5dc95a933258b0f0
https://github.com/camunda/camunda-bpm-sdk-js/blob/4ad43b41b501c31024ee017f5dc95a933258b0f0/lib/events.js#L76-L79
train
camunda/camunda-bpm-sdk-js
lib/forms/controls/abstract-form-field.js
AbstractFormField
function AbstractFormField(element, variableManager) { this.element = $( element ); this.variableManager = variableManager; this.variableName = null; this.initialize(); }
javascript
function AbstractFormField(element, variableManager) { this.element = $( element ); this.variableManager = variableManager; this.variableName = null; this.initialize(); }
[ "function", "AbstractFormField", "(", "element", ",", "variableManager", ")", "{", "this", ".", "element", "=", "$", "(", "element", ")", ";", "this", ".", "variableManager", "=", "variableManager", ";", "this", ".", "variableName", "=", "null", ";", "this", ".", "initialize", "(", ")", ";", "}" ]
An abstract class for the form field controls @class AbstractFormField @abstract @memberof CamSDK.form
[ "An", "abstract", "class", "for", "the", "form", "field", "controls" ]
4ad43b41b501c31024ee017f5dc95a933258b0f0
https://github.com/camunda/camunda-bpm-sdk-js/blob/4ad43b41b501c31024ee017f5dc95a933258b0f0/lib/forms/controls/abstract-form-field.js#L33-L40
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (eventName, arg1, arg2) { var callbacks = this._eventCallbacks[eventName]; if (callbacks) { for (var i = 0; i < callbacks.length; i++) { callbacks[i](arg1, arg2); } } }
javascript
function (eventName, arg1, arg2) { var callbacks = this._eventCallbacks[eventName]; if (callbacks) { for (var i = 0; i < callbacks.length; i++) { callbacks[i](arg1, arg2); } } }
[ "function", "(", "eventName", ",", "arg1", ",", "arg2", ")", "{", "var", "callbacks", "=", "this", ".", "_eventCallbacks", "[", "eventName", "]", ";", "if", "(", "callbacks", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "callbacks", ".", "length", ";", "i", "++", ")", "{", "callbacks", "[", "i", "]", "(", "arg1", ",", "arg2", ")", ";", "}", "}", "}" ]
Trigger an event. Supports up to two arguments. Designed around triggering transition events from one run loop instance to the next, which requires an argument for the first instance and then an argument for the next instance. @private @method _trigger @param {String} eventName @param {any} arg1 @param {any} arg2
[ "Trigger", "an", "event", ".", "Supports", "up", "to", "two", "arguments", ".", "Designed", "around", "triggering", "transition", "events", "from", "one", "run", "loop", "instance", "to", "the", "next", "which", "requires", "an", "argument", "for", "the", "first", "instance", "and", "then", "an", "argument", "for", "the", "next", "instance", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L489-L496
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
Container
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
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; }
[ "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", ";", "}" ]
A container used to instantiate and cache objects. Every `Container` must be associated with a `Registry`, which is referenced to determine the factory and options that should be used to instantiate objects. The public API for `Container` is still in flux and should not be considered stable. @private @class Container
[ "A", "container", "used", "to", "instantiate", "and", "cache", "objects", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L1075-L1083
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
function (fullName, options) { _emberMetalDebug.assert('fullName must be a proper full name', this.registry.validateFullName(fullName)); return factoryFor(this, this.registry.normalize(fullName), options); }
[ "function", "(", "fullName", ",", "options", ")", "{", "_emberMetalDebug", ".", "assert", "(", "'fullName must be a proper full name'", ",", "this", ".", "registry", ".", "validateFullName", "(", "fullName", ")", ")", ";", "return", "factoryFor", "(", "this", ",", "this", ".", "registry", ".", "normalize", "(", "fullName", ")", ",", "options", ")", ";", "}" ]
Given a fullName, return the corresponding factory. @private @method lookupFactory @param {String} fullName @param {Object} [options] @param {String} [options.source] The fullname of the request source (used for local lookup) @return {any}
[ "Given", "a", "fullName", "return", "the", "corresponding", "factory", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L1168-L1171
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
Registry
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
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); }
[ "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", ")", ";", "}" ]
A registry used to store factory and option information keyed by type. A `Registry` stores the factory and option information needed by a `Container` to instantiate and cache objects. The API for `Registry` is still in flux and should not be considered stable. @private @class Registry @since 1.11.0
[ "A", "registry", "used", "to", "store", "factory", "and", "option", "information", "keyed", "by", "type", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L1592-L1617
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; } }
[ "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", ";", "}", "}" ]
A hook to enable custom fullName normalization behaviour @private @method normalizeFullName @param {String} fullName @return {string} normalized fullName
[ "A", "hook", "to", "enable", "custom", "fullName", "normalization", "behaviour" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L1838-L1846
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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); }
[ "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", ")", ";", "}" ]
Given a fullName check if the container is aware of its factory or singleton instance. @private @method has @param {String} fullName @param {Object} [options] @param {String} [options.source] the fullname of the request source (used for local lookups) @return {Boolean}
[ "Given", "a", "fullName", "check", "if", "the", "container", "is", "aware", "of", "its", "factory", "or", "singleton", "instance", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L1886-L1894
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "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", ";", "}" ]
Initialize the `Ember.ApplicationInstance` and return a promise that resolves with the instance itself when the boot process is complete. The primary task here is to run any registered instance initializers. See the documentation on `BootOptions` for the options it takes. @private @method boot @param options @return {Promise<Ember.ApplicationInstance,Error>}
[ "Initialize", "the", "Ember", ".", "ApplicationInstance", "and", "return", "a", "promise", "that", "resolves", "with", "the", "instance", "itself", "when", "the", "boot", "process", "is", "complete", ".", "The", "primary", "task", "here", "is", "to", "run", "any", "registered", "instance", "initializers", ".", "See", "the", "documentation", "on", "BootOptions", "for", "the", "options", "it", "takes", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L3758-L3772
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function () { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; options.base = this; options.application = this; return _emberApplicationSystemApplicationInstance.default.create(options); }
javascript
function () { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; options.base = this; options.application = this; return _emberApplicationSystemApplicationInstance.default.create(options); }
[ "function", "(", ")", "{", "var", "options", "=", "arguments", ".", "length", "<=", "0", "||", "arguments", "[", "0", "]", "===", "undefined", "?", "{", "}", ":", "arguments", "[", "0", "]", ";", "options", ".", "base", "=", "this", ";", "options", ".", "application", "=", "this", ";", "return", "_emberApplicationSystemApplicationInstance", ".", "default", ".", "create", "(", "options", ")", ";", "}" ]
Create an ApplicationInstance for this application. @private @method buildInstance @return {Ember.ApplicationInstance} the application instance
[ "Create", "an", "ApplicationInstance", "for", "this", "application", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L4500-L4506
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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(); } }
[ "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", "(", ")", ";", "}", "}" ]
This method must be moved to the application instance object
[ "This", "method", "must", "be", "moved", "to", "the", "application", "instance", "object" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L4863-L4877
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function () { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; options.base = this; return _emberApplicationSystemEngineInstance.default.create(options); }
javascript
function () { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; options.base = this; return _emberApplicationSystemEngineInstance.default.create(options); }
[ "function", "(", ")", "{", "var", "options", "=", "arguments", ".", "length", "<=", "0", "||", "arguments", "[", "0", "]", "===", "undefined", "?", "{", "}", ":", "arguments", "[", "0", "]", ";", "options", ".", "base", "=", "this", ";", "return", "_emberApplicationSystemEngineInstance", ".", "default", ".", "create", "(", "options", ")", ";", "}" ]
Create an EngineInstance for this application. @private @method buildInstance @return {Ember.EngineInstance} the application instance
[ "Create", "an", "EngineInstance", "for", "this", "application", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L5372-L5377
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function () { var _constructor$buildRegistry; var registry = this.__registry__ = this.constructor.buildRegistry(this, (_constructor$buildRegistry = {}, _constructor$buildRegistry[GLIMMER] = this[GLIMMER], _constructor$buildRegistry)); return registry; }
javascript
function () { var _constructor$buildRegistry; var registry = this.__registry__ = this.constructor.buildRegistry(this, (_constructor$buildRegistry = {}, _constructor$buildRegistry[GLIMMER] = this[GLIMMER], _constructor$buildRegistry)); return registry; }
[ "function", "(", ")", "{", "var", "_constructor$buildRegistry", ";", "var", "registry", "=", "this", ".", "__registry__", "=", "this", ".", "constructor", ".", "buildRegistry", "(", "this", ",", "(", "_constructor$buildRegistry", "=", "{", "}", ",", "_constructor$buildRegistry", "[", "GLIMMER", "]", "=", "this", "[", "GLIMMER", "]", ",", "_constructor$buildRegistry", ")", ")", ";", "return", "registry", ";", "}" ]
Build and configure the registry for the current application. @private @method buildRegistry @return {Ember.Registry} the configured registry
[ "Build", "and", "configure", "the", "registry", "for", "the", "current", "application", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L5385-L5391
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "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", ";", "}" ]
Returns a human-readable description for a fullName. Used by the Application namespace in assertions to describe the precise name of the class that Ember is looking for, rather than container keys. @protected @param {String} fullName the lookup string @method lookupDescription @public
[ "Returns", "a", "human", "-", "readable", "description", "for", "a", "fullName", ".", "Used", "by", "the", "Application", "namespace", "in", "assertions", "to", "describe", "the", "precise", "name", "of", "the", "class", "that", "Ember", "is", "looking", "for", "rather", "than", "container", "keys", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L5947-L5962
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (parsedName) { var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); return _emberHtmlbarsTemplate_registry.get(templateName) || _emberHtmlbarsTemplate_registry.get(_emberRuntimeSystemString.decamelize(templateName)); }
javascript
function (parsedName) { var templateName = parsedName.fullNameWithoutType.replace(/\./g, '/'); return _emberHtmlbarsTemplate_registry.get(templateName) || _emberHtmlbarsTemplate_registry.get(_emberRuntimeSystemString.decamelize(templateName)); }
[ "function", "(", "parsedName", ")", "{", "var", "templateName", "=", "parsedName", ".", "fullNameWithoutType", ".", "replace", "(", "/", "\\.", "/", "g", ",", "'/'", ")", ";", "return", "_emberHtmlbarsTemplate_registry", ".", "get", "(", "templateName", ")", "||", "_emberHtmlbarsTemplate_registry", ".", "get", "(", "_emberRuntimeSystemString", ".", "decamelize", "(", "templateName", ")", ")", ";", "}" ]
Look up the template in Ember.TEMPLATES @protected @param {Object} parsedName a parseName object with the parsed fullName lookup string @method resolveTemplate @public
[ "Look", "up", "the", "template", "in", "Ember", ".", "TEMPLATES" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L5991-L5995
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (parsedName) { var className = _emberRuntimeSystemString.classify(parsedName.name); var factory = _emberMetalProperty_get.get(parsedName.root, className); if (factory) { return factory; } }
javascript
function (parsedName) { var className = _emberRuntimeSystemString.classify(parsedName.name); var factory = _emberMetalProperty_get.get(parsedName.root, className); if (factory) { return factory; } }
[ "function", "(", "parsedName", ")", "{", "var", "className", "=", "_emberRuntimeSystemString", ".", "classify", "(", "parsedName", ".", "name", ")", ";", "var", "factory", "=", "_emberMetalProperty_get", ".", "get", "(", "parsedName", ".", "root", ",", "className", ")", ";", "if", "(", "factory", ")", "{", "return", "factory", ";", "}", "}" ]
Lookup the model on the Application namespace @protected @param {Object} parsedName a parseName object with the parsed fullName lookup string @method resolveModel @public
[ "Lookup", "the", "model", "on", "the", "Application", "namespace" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L6043-L6050
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "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", ";", "}" ]
Used to iterate all items of a given type. @method knownForType @param {String} type the type to search for @private
[ "Used", "to", "iterate", "all", "items", "of", "a", "given", "type", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L6115-L6133
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "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", ";", "}" ]
Fetch the model types and observe them for changes. @public @method watchModelTypes @param {Function} typesAdded Callback to call to add types. Takes an array of objects containing wrapped types (returned from `wrapModelType`). @param {Function} typesUpdated Callback to call when a type has changed. Takes an array of objects containing wrapped types. @return {Function} Method to call to remove all observers
[ "Fetch", "the", "model", "types", "and", "observe", "them", "for", "changes", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L7147-L7171
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "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", ";", "}" ]
Fetch the records of a given type and observe them for changes. @public @method watchRecords @param {String} modelName The model name. @param {Function} recordsAdded Callback to call to add records. Takes an array of objects containing wrapped records. The object should have the following properties: columnValues: {Object} The key and value of a table cell. object: {Object} The actual record object. @param {Function} recordsUpdated Callback to call when a record has changed. Takes an array of objects containing wrapped records. @param {Function} recordsRemoved Callback to call when a record has removed. Takes the following parameters: index: The array index where the records were removed. count: The number of records removed. @return {Function} Method to call to remove all observers.
[ "Fetch", "the", "records", "of", "a", "given", "type", "and", "observe", "them", "for", "changes", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L7198-L7245
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "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", ";", "}" ]
Adds observers to a model type class. @private @method observeModelType @param {String} modelName The model type name. @param {Function} typesUpdated Called when a type is modified. @return {Function} The function to call to remove observers.
[ "Adds", "observers", "to", "a", "model", "type", "class", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L7294-L7319
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "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", ";", "}", "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", ";", "}" ]
Loops over all namespaces and all objects attached to them. @private @method _getObjectsOnNamespaces @return {Array} Array of model type strings.
[ "Loops", "over", "all", "namespaces", "and", "all", "objects", "attached", "to", "them", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L7390-L7415
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "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", ";", "}" ]
Wraps a record and observers changes to it. @private @method wrapRecord @param {Object} record The record instance. @return {Object} The wrapped record. Format: columnValues: {Array} searchKeywords: {Array}
[ "Wraps", "a", "record", "and", "observers", "changes", "to", "it", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L7438-L7447
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
unlessHelper
function unlessHelper(params, hash, options) { return ifUnless(params, hash, options, !_emberViewsStreamsShould_display.default(params[0])); }
javascript
function unlessHelper(params, hash, options) { return ifUnless(params, hash, options, !_emberViewsStreamsShould_display.default(params[0])); }
[ "function", "unlessHelper", "(", "params", ",", "hash", ",", "options", ")", "{", "return", "ifUnless", "(", "params", ",", "hash", ",", "options", ",", "!", "_emberViewsStreamsShould_display", ".", "default", "(", "params", "[", "0", "]", ")", ")", ";", "}" ]
The `unless` helper is the inverse of the `if` helper. Its block will be rendered if the expression contains a falsey value. All forms of the `if` helper can also be used with `unless`. @method unless @for Ember.Templates.helpers @public
[ "The", "unless", "helper", "is", "the", "inverse", "of", "the", "if", "helper", ".", "Its", "block", "will", "be", "rendered", "if", "the", "expression", "contains", "a", "falsey", "value", ".", "All", "forms", "of", "the", "if", "helper", "can", "also", "be", "used", "with", "unless", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L10647-L10649
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
ComponentNodeManager
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
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; }
[ "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", ";", "}" ]
In theory this should come through the env, but it should be safe to import this until we make the hook system public and it gets actively used in addons or other downstream libraries.
[ "In", "theory", "this", "should", "come", "through", "the", "env", "but", "it", "should", "be", "safe", "to", "import", "this", "until", "we", "make", "the", "hook", "system", "public", "and", "it", "gets", "actively", "used", "in", "addons", "or", "other", "downstream", "libraries", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L13984-L13992
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
getArrayValues
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
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; }
[ "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", ";", "}" ]
We don't want to leak mutable cells into helpers, which are pure functions that can only work with values.
[ "We", "don", "t", "want", "to", "leak", "mutable", "cells", "into", "helpers", "which", "are", "pure", "functions", "that", "can", "only", "work", "with", "values", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L14628-L14637
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
instrument
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
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); } }
[ "function", "instrument", "(", "component", ",", "callback", ",", "context", ")", "{", "var", "instrumentName", ",", "val", ",", "details", ",", "end", ";", "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", ")", ";", "}", "}" ]
Provides instrumentation for node managers. Wrap your node manager's render and re-render methods with this function. @param {Object} component Component or View instance (optional). @param {Function} callback The function to instrument. @param {Object} context The context to call the function with. @return {Object} Return value from the invoked callback. @private
[ "Provides", "instrumentation", "for", "node", "managers", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L14818-L14842
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
makeBoundHelper
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
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); }
[ "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", ")", ";", "}" ]
Create a bound helper. Accepts a function that receives the ordered and hash parameters from the template. If a bound property was provided in the template, it will be resolved to its value and any changes to the bound property cause the helper function to be re-run with the updated values. `params` - An array of resolved ordered parameters. `hash` - An object containing the hash parameters. For example: With an unquoted ordered parameter: ```javascript {{x-capitalize foo}} ``` Assuming `foo` was set to `"bar"`, the bound helper would receive `["bar"]` as its first argument, and an empty hash as its second. With a quoted ordered parameter: ```javascript {{x-capitalize "foo"}} ``` The bound helper would receive `["foo"]` as its first argument, and an empty hash as its second. With an unquoted hash parameter: ```javascript {{x-repeat "foo" count=repeatCount}} ``` Assuming that `repeatCount` resolved to 2, the bound helper would receive `["foo"]` as its first argument, and { count: 2 } as its second. @private @method makeBoundHelper @for Ember.HTMLBars @param {Function} fn @since 1.10.0
[ "Create", "a", "bound", "helper", ".", "Accepts", "a", "function", "that", "receives", "the", "ordered", "and", "hash", "parameters", "from", "the", "template", ".", "If", "a", "bound", "property", "was", "provided", "in", "the", "template", "it", "will", "be", "resolved", "to", "its", "value", "and", "any", "changes", "to", "the", "bound", "property", "cause", "the", "helper", "function", "to", "be", "re", "-", "run", "with", "the", "updated", "values", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L15005-L15008
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
htmlSafe
function htmlSafe(str) { if (str === null || str === undefined) { str = ''; } else if (typeof str !== 'string') { str = '' + str; } return new _htmlbarsUtil.SafeString(str); }
javascript
function htmlSafe(str) { if (str === null || str === undefined) { str = ''; } else if (typeof str !== 'string') { str = '' + str; } return new _htmlbarsUtil.SafeString(str); }
[ "function", "htmlSafe", "(", "str", ")", "{", "if", "(", "str", "===", "null", "||", "str", "===", "undefined", ")", "{", "str", "=", "''", ";", "}", "else", "if", "(", "typeof", "str", "!==", "'string'", ")", "{", "str", "=", "''", "+", "str", ";", "}", "return", "new", "_htmlbarsUtil", ".", "SafeString", "(", "str", ")", ";", "}" ]
Mark a string as safe for unescaped output with Ember templates. If you return HTML from a helper, use this function to ensure Ember's rendering layer does not escape the HTML. ```javascript Ember.String.htmlSafe('<div>someString</div>') ``` @method htmlSafe @for Ember.String @static @return {Handlebars.SafeString} A string that will not be HTML escaped by Handlebars. @public
[ "Mark", "a", "string", "as", "safe", "for", "unescaped", "output", "with", "Ember", "templates", ".", "If", "you", "return", "HTML", "from", "a", "helper", "use", "this", "function", "to", "ensure", "Ember", "s", "rendering", "layer", "does", "not", "escape", "the", "HTML", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L15557-L15564
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "function", "(", ")", "{", "_emberMetalDebug", ".", "assert", "(", "'Must pass a valid object to Ember.Binding.disconnect()'", ",", "!", "!", "this", ".", "_toObj", ")", ";", "_emberMetalObserver", ".", "removeObserver", "(", "this", ".", "_fromObj", ",", "this", ".", "_fromPath", ",", "this", ",", "'fromDidChange'", ")", ";", "if", "(", "!", "this", ".", "_oneWay", ")", "{", "_emberMetalObserver", ".", "removeObserver", "(", "this", ".", "_toObj", ",", "this", ".", "_to", ",", "this", ",", "'toDidChange'", ")", ";", "}", "this", ".", "_readyToSync", "=", "false", ";", "return", "this", ";", "}" ]
Disconnects the binding instance. Changes will no longer be relayed. You will not usually need to call this method. @method disconnect @return {Ember.Binding} `this` @public
[ "Disconnects", "the", "binding", "instance", ".", "Changes", "will", "no", "longer", "be", "relayed", ".", "You", "will", "not", "usually", "need", "to", "call", "this", "method", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L15923-L15937
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
ChainNode
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
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); } } }
[ "function", "ChainNode", "(", "parent", ",", "key", ",", "value", ")", "{", "this", ".", "_parent", "=", "parent", ";", "this", ".", "_key", "=", "key", ";", "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", ")", ";", "}", "}", "}" ]
A ChainNode watches a single key on an object. If you provide a starting value for the key then the node won't actually watch it. For a root node pass null for parent and key and object for value.
[ "A", "ChainNode", "watches", "a", "single", "key", "on", "an", "object", ".", "If", "you", "provide", "a", "starting", "value", "for", "the", "key", "then", "the", "node", "won", "t", "actually", "watch", "it", ".", "For", "a", "root", "node", "pass", "null", "for", "parent", "and", "key", "and", "object", "for", "value", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L16395-L16419
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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); }
[ "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", ")", ";", "}" ]
called on the root node of a chain to setup watchers on the specified path.
[ "called", "on", "the", "root", "node", "of", "a", "chain", "to", "setup", "watchers", "on", "the", "specified", "path", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L16482-L16490
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
match
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
function match(dependentKey, regexp) { return _emberMetalComputed.computed(dependentKey, function () { var value = _emberMetalProperty_get.get(this, dependentKey); return typeof value === 'string' ? regexp.test(value) : false; }); }
[ "function", "match", "(", "dependentKey", ",", "regexp", ")", "{", "return", "_emberMetalComputed", ".", "computed", "(", "dependentKey", ",", "function", "(", ")", "{", "var", "value", "=", "_emberMetalProperty_get", ".", "get", "(", "this", ",", "dependentKey", ")", ";", "return", "typeof", "value", "===", "'string'", "?", "regexp", ".", "test", "(", "value", ")", ":", "false", ";", "}", ")", ";", "}" ]
A computed property which matches the original value for the dependent property against a given RegExp, returning `true` if the value matches the RegExp and `false` if it does not. Example ```javascript var User = Ember.Object.extend({ hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/) }); var user = User.create({loggedIn: false}); user.get('hasValidEmail'); // false user.set('email', ''); user.get('hasValidEmail'); // false user.set('email', '[email protected]'); user.get('hasValidEmail'); // true ``` @method match @for Ember.computed @param {String} dependentKey @param {RegExp} regexp @return {Ember.ComputedProperty} computed property which match the original value for property against a given RegExp @public
[ "A", "computed", "property", "which", "matches", "the", "original", "value", "for", "the", "dependent", "property", "against", "a", "given", "RegExp", "returning", "true", "if", "the", "value", "matches", "the", "RegExp", "and", "false", "if", "it", "does", "not", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L17455-L17461
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
equal
function equal(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) === value; }); }
javascript
function equal(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) === value; }); }
[ "function", "equal", "(", "dependentKey", ",", "value", ")", "{", "return", "_emberMetalComputed", ".", "computed", "(", "dependentKey", ",", "function", "(", ")", "{", "return", "_emberMetalProperty_get", ".", "get", "(", "this", ",", "dependentKey", ")", "===", "value", ";", "}", ")", ";", "}" ]
A computed property that returns true if the provided dependent property is equal to the given value. Example ```javascript var Hamster = Ember.Object.extend({ napTime: Ember.computed.equal('state', 'sleepy') }); var hamster = Hamster.create(); hamster.get('napTime'); // false hamster.set('state', 'sleepy'); hamster.get('napTime'); // true hamster.set('state', 'hungry'); hamster.get('napTime'); // false ``` @method equal @for Ember.computed @param {String} dependentKey @param {String|Number|Object} value @return {Ember.ComputedProperty} computed property which returns true if the original value for property is equal to the given value. @public
[ "A", "computed", "property", "that", "returns", "true", "if", "the", "provided", "dependent", "property", "is", "equal", "to", "the", "given", "value", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L17492-L17496
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
gt
function gt(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) > value; }); }
javascript
function gt(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) > value; }); }
[ "function", "gt", "(", "dependentKey", ",", "value", ")", "{", "return", "_emberMetalComputed", ".", "computed", "(", "dependentKey", ",", "function", "(", ")", "{", "return", "_emberMetalProperty_get", ".", "get", "(", "this", ",", "dependentKey", ")", ">", "value", ";", "}", ")", ";", "}" ]
A computed property that returns true if the provided dependent property is greater than the provided value. Example ```javascript var Hamster = Ember.Object.extend({ hasTooManyBananas: Ember.computed.gt('numBananas', 10) }); var hamster = Hamster.create(); hamster.get('hasTooManyBananas'); // false hamster.set('numBananas', 3); hamster.get('hasTooManyBananas'); // false hamster.set('numBananas', 11); hamster.get('hasTooManyBananas'); // true ``` @method gt @for Ember.computed @param {String} dependentKey @param {Number} value @return {Ember.ComputedProperty} computed property which returns true if the original value for property is greater than given value. @public
[ "A", "computed", "property", "that", "returns", "true", "if", "the", "provided", "dependent", "property", "is", "greater", "than", "the", "provided", "value", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L17527-L17531
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
gte
function gte(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) >= value; }); }
javascript
function gte(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) >= value; }); }
[ "function", "gte", "(", "dependentKey", ",", "value", ")", "{", "return", "_emberMetalComputed", ".", "computed", "(", "dependentKey", ",", "function", "(", ")", "{", "return", "_emberMetalProperty_get", ".", "get", "(", "this", ",", "dependentKey", ")", ">=", "value", ";", "}", ")", ";", "}" ]
A computed property that returns true if the provided dependent property is greater than or equal to the provided value. Example ```javascript var Hamster = Ember.Object.extend({ hasTooManyBananas: Ember.computed.gte('numBananas', 10) }); var hamster = Hamster.create(); hamster.get('hasTooManyBananas'); // false hamster.set('numBananas', 3); hamster.get('hasTooManyBananas'); // false hamster.set('numBananas', 10); hamster.get('hasTooManyBananas'); // true ``` @method gte @for Ember.computed @param {String} dependentKey @param {Number} value @return {Ember.ComputedProperty} computed property which returns true if the original value for property is greater or equal then given value. @public
[ "A", "computed", "property", "that", "returns", "true", "if", "the", "provided", "dependent", "property", "is", "greater", "than", "or", "equal", "to", "the", "provided", "value", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L17562-L17566
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
lt
function lt(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) < value; }); }
javascript
function lt(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) < value; }); }
[ "function", "lt", "(", "dependentKey", ",", "value", ")", "{", "return", "_emberMetalComputed", ".", "computed", "(", "dependentKey", ",", "function", "(", ")", "{", "return", "_emberMetalProperty_get", ".", "get", "(", "this", ",", "dependentKey", ")", "<", "value", ";", "}", ")", ";", "}" ]
A computed property that returns true if the provided dependent property is less than the provided value. Example ```javascript var Hamster = Ember.Object.extend({ needsMoreBananas: Ember.computed.lt('numBananas', 3) }); var hamster = Hamster.create(); hamster.get('needsMoreBananas'); // true hamster.set('numBananas', 3); hamster.get('needsMoreBananas'); // false hamster.set('numBananas', 2); hamster.get('needsMoreBananas'); // true ``` @method lt @for Ember.computed @param {String} dependentKey @param {Number} value @return {Ember.ComputedProperty} computed property which returns true if the original value for property is less then given value. @public
[ "A", "computed", "property", "that", "returns", "true", "if", "the", "provided", "dependent", "property", "is", "less", "than", "the", "provided", "value", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L17597-L17601
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
lte
function lte(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) <= value; }); }
javascript
function lte(dependentKey, value) { return _emberMetalComputed.computed(dependentKey, function () { return _emberMetalProperty_get.get(this, dependentKey) <= value; }); }
[ "function", "lte", "(", "dependentKey", ",", "value", ")", "{", "return", "_emberMetalComputed", ".", "computed", "(", "dependentKey", ",", "function", "(", ")", "{", "return", "_emberMetalProperty_get", ".", "get", "(", "this", ",", "dependentKey", ")", "<=", "value", ";", "}", ")", ";", "}" ]
A computed property that returns true if the provided dependent property is less than or equal to the provided value. Example ```javascript var Hamster = Ember.Object.extend({ needsMoreBananas: Ember.computed.lte('numBananas', 3) }); var hamster = Hamster.create(); hamster.get('needsMoreBananas'); // true hamster.set('numBananas', 5); hamster.get('needsMoreBananas'); // false hamster.set('numBananas', 3); hamster.get('needsMoreBananas'); // true ``` @method lte @for Ember.computed @param {String} dependentKey @param {Number} value @return {Ember.ComputedProperty} computed property which returns true if the original value for property is less or equal than given value. @public
[ "A", "computed", "property", "that", "returns", "true", "if", "the", "provided", "dependent", "property", "is", "less", "than", "or", "equal", "to", "the", "provided", "value", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L17632-L17636
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
deprecatingAlias
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
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; } }); }
[ "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", ";", "}", "}", ")", ";", "}" ]
Creates a new property that is an alias for another property on an object. Calls to `get` or `set` this property behave as though they were called on the original property, but also print a deprecation warning. @method deprecatingAlias @for Ember.computed @param {String} dependentKey @return {Ember.ComputedProperty} computed property which creates an alias with a deprecation to the original value for property. @since 1.7.0 @public
[ "Creates", "a", "new", "property", "that", "is", "an", "alias", "for", "another", "property", "on", "an", "object", ".", "Calls", "to", "get", "or", "set", "this", "property", "behave", "as", "though", "they", "were", "called", "on", "the", "original", "property", "but", "also", "print", "a", "deprecation", "warning", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L17867-L17879
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
suspendListener
function suspendListener(obj, eventName, target, method, callback) { return suspendListeners(obj, [eventName], target, method, callback); }
javascript
function suspendListener(obj, eventName, target, method, callback) { return suspendListeners(obj, [eventName], target, method, callback); }
[ "function", "suspendListener", "(", "obj", ",", "eventName", ",", "target", ",", "method", ",", "callback", ")", "{", "return", "suspendListeners", "(", "obj", ",", "[", "eventName", "]", ",", "target", ",", "method", ",", "callback", ")", ";", "}" ]
Suspend listener during callback. This should only be used by the target of the event listener when it is taking an action that would cause the event, e.g. an object might suspend its property change listener while it is setting that property. @method suspendListener @for Ember @private @param obj @param {String} eventName @param {Object|Function} target A target object or a function @param {Function|String} method A function or the name of a function to be called on `target` @param {Function} callback
[ "Suspend", "listener", "during", "callback", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L18380-L18382
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
sendEvent
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
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; }
[ "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", ")", "{", "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", ";", "}" ]
Send an event. The execution of suspended listeners is skipped, and once listeners are removed. A listener without a target is executed on the passed object. If an array of actions is not passed, the actions stored on the passed object are invoked. @method sendEvent @for Ember @param obj @param {String} eventName @param {Array} params Optional parameters for each listener. @param {Array} actions Optional array of actions (listeners). @return true @public
[ "Send", "an", "event", ".", "The", "execution", "of", "suspended", "listeners", "is", "skipped", "and", "once", "listeners", "are", "removed", ".", "A", "listener", "without", "a", "target", "is", "executed", "on", "the", "passed", "object", ".", "If", "an", "array", "of", "actions", "is", "not", "passed", "the", "actions", "stored", "on", "the", "passed", "object", "are", "invoked", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L18435-L18478
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
on
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
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; }
[ "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", ";", "}" ]
Define a property as a function that should be executed when a specified event or events are triggered. ``` javascript var Job = Ember.Object.extend({ logCompleted: Ember.on('completed', function() { console.log('Job completed!'); }) }); var job = Job.create(); Ember.sendEvent(job, 'completed'); // Logs 'Job completed!' ``` @method on @for Ember @param {String} eventNames* @param {Function} func @return func @public
[ "Define", "a", "property", "as", "a", "function", "that", "should", "be", "executed", "when", "a", "specified", "event", "or", "events", "are", "triggered", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L18547-L18556
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
expandProperties
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
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, '.[]')); } }
[ "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", ",", "'.[]'", ")", ")", ";", "}", "}" ]
Expands `pattern`, invoking `callback` for each expansion. The only pattern supported is brace-expansion, anything else will be passed once to `callback` directly. Example ```js function echo(arg){ console.log(arg); } Ember.expandProperties('foo.bar', echo); //=> 'foo.bar' Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar' Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz' Ember.expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz' Ember.expandProperties('foo.{bar,baz}.[]', echo) //=> 'foo.bar.[]', 'foo.baz.[]' Ember.expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs' Ember.expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' ``` @method expandProperties @for Ember @private @param {String} pattern The property pattern to expand. @param {Function} callback The callback to invoke. It is invoked once per expansion, and is passed the expansion.
[ "Expands", "pattern", "invoking", "callback", "for", "each", "expansion", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L18600-L18617
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
InjectedProperty
function InjectedProperty(type, name) { this.type = type; this.name = name; this._super$Constructor(injectedPropertyGet); AliasedPropertyPrototype.oneWay.call(this); }
javascript
function InjectedProperty(type, name) { this.type = type; this.name = name; this._super$Constructor(injectedPropertyGet); AliasedPropertyPrototype.oneWay.call(this); }
[ "function", "InjectedProperty", "(", "type", ",", "name", ")", "{", "this", ".", "type", "=", "type", ";", "this", ".", "name", "=", "name", ";", "this", ".", "_super$Constructor", "(", "injectedPropertyGet", ")", ";", "AliasedPropertyPrototype", ".", "oneWay", ".", "call", "(", "this", ")", ";", "}" ]
Read-only property that returns the result of a container lookup. @class InjectedProperty @namespace Ember @constructor @param {String} type The container type the property will lookup @param {String} name (optional) The name the property will lookup, defaults to the property's name @private
[ "Read", "-", "only", "property", "that", "returns", "the", "result", "of", "a", "container", "lookup", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L19032-L19038
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
_instrumentStart
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
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); } }; }
[ "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", ")", ";", "}", "}", ";", "}" ]
private for now
[ "private", "for", "now" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L19209-L19252
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
subscribe
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
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; }
[ "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", "}", ";", "}" ]
Subscribes to a particular event or instrumented block of code. @method subscribe @namespace Ember.Instrumentation @param {String} [pattern] Namespaced event name. @param {Object} [object] Before and After hooks. @return {Subscriber} @private
[ "Subscribes", "to", "a", "particular", "event", "or", "instrumented", "block", "of", "code", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L19267-L19294
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
unsubscribe
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
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 = {}; }
[ "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", "=", "{", "}", ";", "}" ]
Unsubscribes from a particular event or instrumented block of code. @method unsubscribe @namespace Ember.Instrumentation @param {Object} [subscriber] @private
[ "Unsubscribes", "from", "a", "particular", "event", "or", "instrumented", "block", "of", "code", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L19306-L19317
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (key) { if (this.size === 0) { return; } var values = this._values; var guid = _emberMetalUtils.guidFor(key); return values[guid]; }
javascript
function (key) { if (this.size === 0) { return; } var values = this._values; var guid = _emberMetalUtils.guidFor(key); return values[guid]; }
[ "function", "(", "key", ")", "{", "if", "(", "this", ".", "size", "===", "0", ")", "{", "return", ";", "}", "var", "values", "=", "this", ".", "_values", ";", "var", "guid", "=", "_emberMetalUtils", ".", "guidFor", "(", "key", ")", ";", "return", "values", "[", "guid", "]", ";", "}" ]
Retrieve the value associated with a given key. @method get @param {*} key @return {*} the value associated with the key, or `undefined` @private
[ "Retrieve", "the", "value", "associated", "with", "a", "given", "key", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L20011-L20020
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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); }
[ "function", "(", "callback", ")", "{", "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", ")", ";", "}" ]
Iterate over all the keys and values. Calls the function once for each key, passing in value, key, and the map being iterated over, in that order. The keys are guaranteed to be iterated over in insertion order. @method forEach @param {Function} callback @param {*} self if passed, the `this` value inside the callback. By default, `this` is the map. @private
[ "Iterate", "over", "all", "the", "keys", "and", "values", ".", "Calls", "the", "function", "once", "for", "each", "key", "passing", "in", "value", "key", "and", "the", "map", "being", "iterated", "over", "in", "that", "order", ".", "The", "keys", "are", "guaranteed", "to", "be", "iterated", "over", "in", "insertion", "order", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L20097-L20122
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
ownMap
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
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]; }; }
[ "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", "]", ";", "}", ";", "}" ]
Implements a member that is a lazily created, non-inheritable POJO.
[ "Implements", "a", "member", "that", "is", "a", "lazily", "created", "non", "-", "inheritable", "POJO", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L20345-L20354
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
inheritedMap
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
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; }; }
[ "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", ";", "}", ";", "}" ]
Implements a member that is a lazily created POJO with inheritable values.
[ "Implements", "a", "member", "that", "is", "a", "lazily", "created", "POJO", "with", "inheritable", "values", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L20366-L20407
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
inheritedMapOfMaps
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
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); }; }
[ "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", ")", ";", "}", ";", "}" ]
Implements a member that provides a lazily created map of maps, with inheritance at both levels.
[ "Implements", "a", "member", "that", "provides", "a", "lazily", "created", "map", "of", "maps", "with", "inheritance", "at", "both", "levels", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L20435-L20478
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
ownCustomObject
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
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]; }; }
[ "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", "]", ";", "}", ";", "}" ]
Implements a member that provides a non-heritable, lazily-created object using the method you provide.
[ "Implements", "a", "member", "that", "provides", "a", "non", "-", "heritable", "lazily", "-", "created", "object", "using", "the", "method", "you", "provide", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L20510-L20523
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "function", "(", "obj", ",", "meta", ")", "{", "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", ";", "}" ]
choose the one appropriate for given platform
[ "choose", "the", "one", "appropriate", "for", "given", "platform" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L20573-L20585
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
Mixin
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
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); }
[ "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", ")", ";", "}" ]
The `Ember.Mixin` class allows you to create mixins, whose properties can be added to other classes. For instance, ```javascript App.Editable = Ember.Mixin.create({ edit: function() { console.log('starting to edit'); this.set('isEditing', true); }, isEditing: false }); Mix mixins into classes by passing them as the first arguments to .extend. App.CommentView = Ember.View.extend(App.Editable, { template: Ember.Handlebars.compile('{{#if view.isEditing}}...{{else}}...{{/if}}') }); commentView = App.CommentView.create(); commentView.edit(); // outputs 'starting to edit' ``` Note that Mixins are created with `Ember.Mixin.create`, not `Ember.Mixin.extend`. Note that mixins extend a constructor's prototype so arrays and object literals defined as properties will be shared amongst objects that implement the mixin. If you want to define a property in a mixin that is not shared, you can define it either as a computed property or have it be created on initialization of the object. ```javascript filters array will be shared amongst any object implementing mixin App.Filterable = Ember.Mixin.create({ filters: Ember.A() }); filters will be a separate array for every object implementing the mixin App.Filterable = Ember.Mixin.create({ filters: Ember.computed(function() {return Ember.A();}) }); filters will be created as a separate array during the object's initialization App.Filterable = Ember.Mixin.create({ init: function() { this._super(...arguments); this.set("filters", Ember.A()); } }); ``` @class Mixin @namespace Ember @public
[ "The", "Ember", ".", "Mixin", "class", "allows", "you", "to", "create", "mixins", "whose", "properties", "can", "be", "added", "to", "other", "classes", ".", "For", "instance" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L21288-L21314
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
_immediateObserver
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
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); }
[ "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", ")", ";", "}" ]
Specify a method that observes property changes. ```javascript Ember.Object.extend({ valueObserver: Ember.immediateObserver('value', function() { Executes whenever the "value" property changes }) }); ``` In the future, `Ember.observer` may become asynchronous. In this event, `Ember.immediateObserver` will maintain the synchronous behavior. Also available as `Function.prototype.observesImmediately` if prototype extensions are enabled. @method _immediateObserver @for Ember @param {String} propertyNames* @param {Function} func @deprecated Use `Ember.observer` instead. @return func @private
[ "Specify", "a", "method", "that", "observes", "property", "changes", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L21640-L21649
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
_beforeObserver
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
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; }
[ "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'", ")", "{", "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", ";", "}" ]
When observers fire, they are called with the arguments `obj`, `keyName`. Note, `@each.property` observer is called per each add or replace of an element and it's not called with a specific enumeration item. A `_beforeObserver` fires before a property changes. A `_beforeObserver` is an alternative form of `.observesBefore()`. ```javascript App.PersonView = Ember.View.extend({ friends: [{ name: 'Tom' }, { name: 'Stefan' }, { name: 'Kris' }], valueDidChange: Ember.observer('content.value', function(obj, keyName) { only run if updating a value already in the DOM if (this.get('state') === 'inDOM') { var color = obj.get(keyName) > this.changingFrom ? 'green' : 'red'; logic } }), friendsDidChange: Ember.observer('[email protected]', function(obj, keyName) { some logic obj.get(keyName) returns friends array }) }); ``` Also available as `Function.prototype.observesBefore` if prototype extensions are enabled. @method beforeObserver @for Ember @param {String} propertyNames* @param {Function} func @return func @deprecated @private
[ "When", "observers", "fire", "they", "are", "called", "with", "the", "arguments", "obj", "keyName", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L21692-L21725
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
changeProperties
function changeProperties(callback, binding) { beginPropertyChanges(); try { callback.call(binding); } finally { endPropertyChanges.call(binding); } }
javascript
function changeProperties(callback, binding) { beginPropertyChanges(); try { callback.call(binding); } finally { endPropertyChanges.call(binding); } }
[ "function", "changeProperties", "(", "callback", ",", "binding", ")", "{", "beginPropertyChanges", "(", ")", ";", "try", "{", "callback", ".", "call", "(", "binding", ")", ";", "}", "finally", "{", "endPropertyChanges", ".", "call", "(", "binding", ")", ";", "}", "}" ]
Make a series of property changes together in an exception-safe way. ```javascript Ember.changeProperties(function() { obj1.set('foo', mayBlowUpWhenSet); obj2.set('bar', baz); }); ``` @method changeProperties @param {Function} callback @param [binding] @private
[ "Make", "a", "series", "of", "property", "changes", "together", "in", "an", "exception", "-", "safe", "way", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L22443-L22450
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
chain
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
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(); } }
[ "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", "(", ")", ";", "}", "}" ]
Generate a new stream by providing a source stream and a function that can be used to transform the stream's value. In the case of a non-stream object, returns the result of the function. The value to transform would typically be available to the function you pass to `chain()` via scope. For example: ```javascript var source = ...; // stream returning a number or a numeric (non-stream) object var result = chain(source, function() { var currentValue = read(source); return currentValue + 1; }); ``` In the example, result is a stream if source is a stream, or a number of source was numeric. @private @for Ember.stream @function chain @param {Object|Stream} value A stream or non-stream object. @param {Function} fn Function to be run when the stream value changes, or to be run once in the case of a non-stream object. @return {Object|Stream} In the case of a stream `value` parameter, a new stream that will be updated with the return value of the provided function `fn`. In the case of a non-stream object, the return value of the provided function `fn`.
[ "Generate", "a", "new", "stream", "by", "providing", "a", "source", "stream", "and", "a", "function", "that", "can", "be", "used", "to", "transform", "the", "stream", "s", "value", ".", "In", "the", "case", "of", "a", "non", "-", "stream", "object", "returns", "the", "result", "of", "the", "function", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L24510-L24521
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
guidFor
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
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; } }
[ "function", "guidFor", "(", "obj", ")", "{", "if", "(", "obj", "&&", "obj", "[", "GUID_KEY", "]", ")", "{", "return", "obj", "[", "GUID_KEY", "]", ";", "}", "if", "(", "obj", "===", "undefined", ")", "{", "return", "'(undefined)'", ";", "}", "if", "(", "obj", "===", "null", ")", "{", "return", "'(null)'", ";", "}", "var", "ret", ";", "var", "type", "=", "typeof", "obj", ";", "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", ";", "}", "}" ]
Returns a unique id for the object. If the object does not yet have a guid, one will be assigned to it. You can call this on any object, `Ember.Object`-based or not, but be aware that it will add a `_guid` property. You can also use this method on DOM Element objects. @public @method guidFor @for Ember @param {Object} obj any object, string, number, Element, or primitive @return {String} the unique guid for this instance.
[ "Returns", "a", "unique", "id", "for", "the", "object", ".", "If", "the", "object", "does", "not", "yet", "have", "a", "guid", "one", "will", "be", "assigned", "to", "it", ".", "You", "can", "call", "this", "on", "any", "object", "Ember", ".", "Object", "-", "based", "or", "not", "but", "be", "aware", "that", "it", "will", "add", "a", "_guid", "property", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L24791-L24855
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
tryInvoke
function tryInvoke(obj, methodName, args) { if (canInvoke(obj, methodName)) { return args ? applyStr(obj, methodName, args) : applyStr(obj, methodName); } }
javascript
function tryInvoke(obj, methodName, args) { if (canInvoke(obj, methodName)) { return args ? applyStr(obj, methodName, args) : applyStr(obj, methodName); } }
[ "function", "tryInvoke", "(", "obj", ",", "methodName", ",", "args", ")", "{", "if", "(", "canInvoke", "(", "obj", ",", "methodName", ")", ")", "{", "return", "args", "?", "applyStr", "(", "obj", ",", "methodName", ",", "args", ")", ":", "applyStr", "(", "obj", ",", "methodName", ")", ";", "}", "}" ]
Checks to see if the `methodName` exists on the `obj`, and if it does, invokes it with the arguments passed. ```javascript var d = new Date('03/15/2013'); Ember.tryInvoke(d, 'getTime'); // 1363320000000 Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined ``` @method tryInvoke @for Ember @param {Object} obj The object to check for the method @param {String} methodName The method name to check for @param {Array} [args] The arguments to pass to the method @return {*} the return value of the invoked method or undefined if it cannot be invoked @public
[ "Checks", "to", "see", "if", "the", "methodName", "exists", "on", "the", "obj", "and", "if", "it", "does", "invokes", "it", "with", "the", "arguments", "passed", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L24994-L24998
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
apply
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
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); } }
[ "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", ")", ";", "}", "}" ]
The following functions are intentionally minified to keep the functions below Chrome's function body size inlining limit of 600 chars. @param {Object} t target @param {Function} m method @param {Array} a args @private
[ "The", "following", "functions", "are", "intentionally", "minified", "to", "keep", "the", "functions", "below", "Chrome", "s", "function", "body", "size", "inlining", "limit", "of", "600", "chars", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L25104-L25123
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
destroy
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
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); } } } } } }
[ "function", "destroy", "(", "obj", ")", "{", "var", "meta", "=", "_emberMetalMeta", ".", "peekMeta", "(", "obj", ")", ";", "var", "node", ",", "nodes", ",", "key", ",", "nodeObject", ";", "if", "(", "meta", ")", "{", "_emberMetalMeta", ".", "deleteMeta", "(", "obj", ")", ";", "node", "=", "meta", ".", "readableChains", "(", ")", ";", "if", "(", "node", ")", "{", "NODE_STACK", ".", "push", "(", "node", ")", ";", "while", "(", "NODE_STACK", ".", "length", ">", "0", ")", "{", "node", "=", "NODE_STACK", ".", "pop", "(", ")", ";", "nodes", "=", "node", ".", "_chains", ";", "if", "(", "nodes", ")", "{", "for", "(", "key", "in", "nodes", ")", "{", "if", "(", "nodes", "[", "key", "]", "!==", "undefined", ")", "{", "NODE_STACK", ".", "push", "(", "nodes", "[", "key", "]", ")", ";", "}", "}", "}", "if", "(", "node", ".", "_watching", ")", "{", "nodeObject", "=", "node", ".", "_object", ";", "if", "(", "nodeObject", ")", "{", "_emberMetalChains", ".", "removeChainWatcher", "(", "nodeObject", ",", "node", ".", "_key", ",", "node", ")", ";", "}", "}", "}", "}", "}", "}" ]
Tears down the meta on an object so that it can be garbage collected. Multiple calls will have no effect. @method destroy @for Ember @param {Object} obj the object to destroy @return {void} @private
[ "Tears", "down", "the", "meta", "on", "an", "object", "so", "that", "it", "can", "be", "garbage", "collected", ".", "Multiple", "calls", "will", "have", "no", "effect", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L25427-L25459
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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); }
[ "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", ")", ";", "}" ]
set by route @method _qpChanged @private
[ "set", "by", "route" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L25915-L25921
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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); }
[ "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", ",", "'\\'.'", ")", ";", "\\'", "}" ]
Called by the router to instruct the location to do any feature detection necessary. In the case of AutoLocation, we detect whether to use history or hash concrete implementations. @private
[ "Called", "by", "the", "router", "to", "instruct", "the", "location", "to", "do", "any", "feature", "detection", "necessary", ".", "In", "the", "case", "of", "AutoLocation", "we", "detect", "whether", "to", "use", "history", "or", "hash", "concrete", "implementations", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L26344-L26369
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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())); }
[ "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", "(", ")", ")", ")", ";", "}" ]
Used to set state on first call to setURL @private @method initState
[ "Used", "to", "set", "state", "on", "first", "call", "to", "setURL" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L26706-L26715
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "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'", ")", ";", "rootURL", "=", "rootURL", ".", "replace", "(", "/", "\\/$", "/", ",", "''", ")", ";", "baseURL", "=", "baseURL", ".", "replace", "(", "/", "\\/$", "/", ",", "''", ")", ";", "var", "url", "=", "path", ".", "replace", "(", "baseURL", ",", "''", ")", ".", "replace", "(", "rootURL", ",", "''", ")", ";", "var", "search", "=", "location", ".", "search", "||", "''", ";", "url", "+=", "search", ";", "url", "+=", "this", ".", "getHash", "(", ")", ";", "return", "url", ";", "}" ]
Returns the current `location.pathname` without `rootURL` or `baseURL` @private @method getURL @return url {String}
[ "Returns", "the", "current", "location", ".", "pathname", "without", "rootURL", "or", "baseURL" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L26731-L26750
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (path) { var state = this.getState(); path = this.formatURL(path); if (!state || state.path !== path) { this.pushState(path); } }
javascript
function (path) { var state = this.getState(); path = this.formatURL(path); if (!state || state.path !== path) { this.pushState(path); } }
[ "function", "(", "path", ")", "{", "var", "state", "=", "this", ".", "getState", "(", ")", ";", "path", "=", "this", ".", "formatURL", "(", "path", ")", ";", "if", "(", "!", "state", "||", "state", ".", "path", "!==", "path", ")", "{", "this", ".", "pushState", "(", "path", ")", ";", "}", "}" ]
Uses `history.pushState` to update the url without a page reload. @private @method setURL @param path {String}
[ "Uses", "history", ".", "pushState", "to", "update", "the", "url", "without", "a", "page", "reload", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L26758-L26765
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (path) { var state = this.getState(); path = this.formatURL(path); if (!state || state.path !== path) { this.replaceState(path); } }
javascript
function (path) { var state = this.getState(); path = this.formatURL(path); if (!state || state.path !== path) { this.replaceState(path); } }
[ "function", "(", "path", ")", "{", "var", "state", "=", "this", ".", "getState", "(", ")", ";", "path", "=", "this", ".", "formatURL", "(", "path", ")", ";", "if", "(", "!", "state", "||", "state", ".", "path", "!==", "path", ")", "{", "this", ".", "replaceState", "(", "path", ")", ";", "}", "}" ]
Uses `history.replaceState` to update the url without a page reload or history modification. @private @method replaceURL @param path {String}
[ "Uses", "history", ".", "replaceState", "to", "update", "the", "url", "without", "a", "page", "reload", "or", "history", "modification", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L26774-L26781
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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()); }); }
[ "function", "(", "callback", ")", "{", "var", "_this", "=", "this", ";", "var", "guid", "=", "_emberMetalUtils", ".", "guidFor", "(", "this", ")", ";", "_emberViewsSystemJquery", ".", "default", "(", "window", ")", ".", "on", "(", "'popstate.ember-location-'", "+", "guid", ",", "function", "(", "e", ")", "{", "if", "(", "!", "popstateFired", ")", "{", "popstateFired", "=", "true", ";", "if", "(", "_this", ".", "getURL", "(", ")", "===", "_this", ".", "_previousURL", ")", "{", "return", ";", "}", "}", "callback", "(", "_this", ".", "getURL", "(", ")", ")", ";", "}", ")", ";", "}" ]
Register a callback to be invoked whenever the browser history changes, including using forward and back buttons. @private @method onUpdateURL @param callback {Function}
[ "Register", "a", "callback", "to", "be", "invoked", "whenever", "the", "browser", "history", "changes", "including", "using", "forward", "and", "back", "buttons", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L26840-L26855
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
generateController
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
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; }
[ "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", ";", "}" ]
Generates and instantiates a controller. The type of the generated controller factory is derived from the context. If the context is an array an array controller is generated, if an object, an object controller otherwise, a basic controller is generated. @for Ember @method generateController @private @since 1.3.0
[ "Generates", "and", "instantiates", "a", "controller", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L27460-L27471
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "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", ";", "}" ]
Retrieves parameters, for current route using the state.params variable and getQueryParamsFor, using the supplied routeName. @method paramsFor @param {String} name @public
[ "Retrieves", "parameters", "for", "current", "route", "using", "the", "state", ".", "params", "variable", "and", "getQueryParamsFor", "using", "the", "supplied", "routeName", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L27809-L27824
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }
[ "function", "(", "value", ",", "urlKey", ",", "defaultValueType", ")", "{", "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", ";", "}" ]
Deserializes value of the query parameter based on defaultValueType @method deserializeQueryParam @param {Object} value @param {String} urlKey @param {String} defaultValueType @private
[ "Deserializes", "value", "of", "the", "query", "parameter", "based", "on", "defaultValueType" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L27862-L27877
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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) + '\''); } }
[ "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 \\''", "+", "\\'", ")", ";", "}", "}" ]
Handles notifying any listeners of an impending URL change. Triggers the router level `willTransition` hook. @method willTransition @public @since 1.11.0
[ "Handles", "notifying", "any", "listeners", "of", "an", "impending", "URL", "change", ".", "Triggers", "the", "router", "level", "willTransition", "hook", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L29844-L29850
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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 }; }
[ "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", "}", ";", "}" ]
Returns a merged query params meta object for a given route. Useful for asking a route what its known query params are. @private
[ "Returns", "a", "merged", "query", "params", "meta", "object", "for", "a", "given", "route", ".", "Useful", "for", "asking", "a", "route", "what", "its", "known", "query", "params", "are", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L30228-L30260
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
queryParamsHelper
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
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 }); }
[ "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\\')'", ",", "\\'", ")", ";", "\\'", "}" ]
This is a helper to be used in conjunction with the link-to helper. It will supply url query parameters to the target route. Example ```handlebars {{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}} ``` @method query-params @for Ember.Templates.helpers @param {Object} hash takes a hash of query parameters @return {Object} A `QueryParams` object for `{{link-to}}` @public
[ "This", "is", "a", "helper", "to", "be", "used", "in", "conjunction", "with", "the", "link", "-", "to", "helper", ".", "It", "will", "supply", "url", "query", "parameters", "to", "the", "target", "route", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L31045-L31051
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
max
function max(dependentKey) { return reduceMacro(dependentKey, function (max, item) { return Math.max(max, item); }, -Infinity); }
javascript
function max(dependentKey) { return reduceMacro(dependentKey, function (max, item) { return Math.max(max, item); }, -Infinity); }
[ "function", "max", "(", "dependentKey", ")", "{", "return", "reduceMacro", "(", "dependentKey", ",", "function", "(", "max", ",", "item", ")", "{", "return", "Math", ".", "max", "(", "max", ",", "item", ")", ";", "}", ",", "-", "Infinity", ")", ";", "}" ]
A computed property that calculates the maximum value in the dependent array. This will return `-Infinity` when the dependent array is empty. ```javascript var Person = Ember.Object.extend({ childAges: Ember.computed.mapBy('children', 'age'), maxChildAge: Ember.computed.max('childAges') }); var lordByron = Person.create({ children: [] }); lordByron.get('maxChildAge'); // -Infinity lordByron.get('children').pushObject({ name: 'Augusta Ada Byron', age: 7 }); lordByron.get('maxChildAge'); // 7 lordByron.get('children').pushObjects([{ name: 'Allegra Byron', age: 5 }, { name: 'Elizabeth Medora Leigh', age: 8 }]); lordByron.get('maxChildAge'); // 8 ``` @method max @for Ember.computed @param {String} dependentKey @return {Ember.ComputedProperty} computes the largest value in the dependentKey's array @public
[ "A", "computed", "property", "that", "calculates", "the", "maximum", "value", "in", "the", "dependent", "array", ".", "This", "will", "return", "-", "Infinity", "when", "the", "dependent", "array", "is", "empty", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L33017-L33021
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
filterBy
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
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); }
[ "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", ")", ";", "}" ]
Filters the array by the property and value ```javascript var Hamster = Ember.Object.extend({ remainingChores: Ember.computed.filterBy('chores', 'done', false) }); var hamster = Hamster.create({ chores: [ { name: 'cook', done: true }, { name: 'clean', done: true }, { name: 'write more unit tests', done: false } ] }); hamster.get('remainingChores'); // [{ name: 'write more unit tests', done: false }] ``` @method filterBy @for Ember.computed @param {String} dependentKey @param {String} propertyKey @param {*} value @return {Ember.ComputedProperty} the filtered array @public
[ "Filters", "the", "array", "by", "the", "property", "and", "value" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L33216-L33230
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
setDiff
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
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(); }
[ "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", "(", ")", ";", "}" ]
A computed property which returns a new array with all the properties from the first dependent array that are not in the second dependent array. Example ```javascript var Hamster = Ember.Object.extend({ likes: ['banana', 'grape', 'kale'], wants: Ember.computed.setDiff('likes', 'fruits') }); var hamster = Hamster.create({ fruits: [ 'grape', 'kale', ] }); hamster.get('wants'); // ['banana'] ``` @method setDiff @for Ember.computed @param {String} setAProperty @param {String} setBProperty @return {Ember.ComputedProperty} computes a new array with all the items from the first dependent array that are not in the second dependent array @public
[ "A", "computed", "property", "which", "returns", "a", "new", "array", "with", "all", "the", "properties", "from", "the", "first", "dependent", "array", "that", "are", "not", "in", "the", "second", "dependent", "array", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L33441-L33461
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
collect
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
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; }); }
[ "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", ";", "}", ")", ";", "}" ]
A computed property that returns the array of values for the provided dependent properties. Example ```javascript var Hamster = Ember.Object.extend({ clothes: Ember.computed.collect('hat', 'shirt') }); var hamster = Hamster.create(); hamster.get('clothes'); // [null, null] hamster.set('hat', 'Camp Hat'); hamster.set('shirt', 'Camp Shirt'); hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt'] ``` @method collect @for Ember.computed @param {String} dependentKey* @return {Ember.ComputedProperty} computed property which maps values of all passed in properties to an array. @public
[ "A", "computed", "property", "that", "returns", "the", "array", "of", "values", "for", "the", "provided", "dependent", "properties", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L33490-L33509
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
copy
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
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); }
[ "function", "copy", "(", "obj", ",", "deep", ")", "{", "if", "(", "'object'", "!==", "typeof", "obj", "||", "obj", "===", "null", ")", "{", "return", "obj", ";", "}", "if", "(", "_emberRuntimeMixinsCopyable", ".", "default", "&&", "_emberRuntimeMixinsCopyable", ".", "default", ".", "detect", "(", "obj", ")", ")", "{", "return", "obj", ".", "copy", "(", "deep", ")", ";", "}", "return", "_copy", "(", "obj", ",", "deep", ",", "deep", "?", "[", "]", ":", "null", ",", "deep", "?", "[", "]", ":", "null", ")", ";", "}" ]
Creates a shallow copy of the passed object. A deep copy of the object is returned if the optional `deep` argument is `true`. If the passed object implements the `Ember.Copyable` interface, then this function will delegate to the object's `copy()` method and return the result. See `Ember.Copyable` for further details. For primitive values (which are immutable in JavaScript), the passed object is simply returned. @method copy @for Ember @param {Object} obj The object to clone @param {Boolean} [deep=false] If true, a deep copy of the object is made. @return {Object} The copied object @public
[ "Creates", "a", "shallow", "copy", "of", "the", "passed", "object", ".", "A", "deep", "copy", "of", "the", "object", "is", "returned", "if", "the", "optional", "deep", "argument", "is", "true", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L33824-L33835
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
createInjectionHelper
function createInjectionHelper(type, validator) { typeValidators[type] = validator; inject[type] = function (name) { return new _emberMetalInjected_property.default(type, name); }; }
javascript
function createInjectionHelper(type, validator) { typeValidators[type] = validator; inject[type] = function (name) { return new _emberMetalInjected_property.default(type, name); }; }
[ "function", "createInjectionHelper", "(", "type", ",", "validator", ")", "{", "typeValidators", "[", "type", "]", "=", "validator", ";", "inject", "[", "type", "]", "=", "function", "(", "name", ")", "{", "return", "new", "_emberMetalInjected_property", ".", "default", "(", "type", ",", "name", ")", ";", "}", ";", "}" ]
This method allows other Ember modules to register injection helpers for a given container type. Helpers are exported to the `inject` namespace as the container type itself. @private @method createInjectionHelper @since 1.10.0 @for Ember @param {String} type The container type the helper will inject @param {Function} validator A validation callback that is executed at mixin-time
[ "This", "method", "allows", "other", "Ember", "modules", "to", "register", "injection", "helpers", "for", "a", "given", "container", "type", ".", "Helpers", "are", "exported", "to", "the", "inject", "namespace", "as", "the", "container", "type", "itself", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L34357-L34363
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
validatePropertyInjections
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
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; }
[ "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", ";", "}" ]
Validation function that runs per-type validation functions once for each injected type encountered. @private @method validatePropertyInjections @since 1.10.0 @for Ember @param {Object} factory The factory object
[ "Validation", "function", "that", "runs", "per", "-", "type", "validation", "functions", "once", "for", "each", "injected", "type", "encountered", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L34376-L34399
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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'); } }
[ "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'", ")", ";", "}", "}" ]
If the object implements `Ember.Freezable`, then this will return a new copy if the object is not frozen and the receiver if the object is frozen. Raises an exception if you try to call this method on a object that does not support freezing. You should use this method whenever you want a copy of a freezable object since a freezable object can simply return itself without actually consuming more memory. @method frozenCopy @return {Object} copy of receiver or receiver @deprecated Use `Object.freeze` instead. @private
[ "If", "the", "object", "implements", "Ember", ".", "Freezable", "then", "this", "will", "return", "a", "new", "copy", "if", "the", "object", "is", "not", "frozen", "and", "the", "receiver", "if", "the", "object", "is", "frozen", ".", "Raises", "an", "exception", "if", "you", "try", "to", "call", "this", "method", "on", "a", "object", "that", "does", "not", "support", "freezing", ".", "You", "should", "use", "this", "method", "whenever", "you", "want", "a", "copy", "of", "a", "freezable", "object", "since", "a", "freezable", "object", "can", "simply", "return", "itself", "without", "actually", "consuming", "more", "memory", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L35560-L35567
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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; }); }
[ "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", ")", ";", "var", "compareValue", "=", "_emberRuntimeCompare", ".", "default", "(", "propA", ",", "propB", ")", ";", "if", "(", "compareValue", ")", "{", "return", "compareValue", ";", "}", "}", "return", "0", ";", "}", ")", ";", "}" ]
Converts the enumerable into an array and sorts by the keys specified in the argument. You may provide multiple arguments to sort by multiple properties. @method sortBy @param {String} property name(s) to sort on @return {Array} The sorted array. @since 1.2.0 @public
[ "Converts", "the", "enumerable", "into", "an", "array", "and", "sorts", "by", "the", "keys", "specified", "in", "the", "argument", ".", "You", "may", "provide", "multiple", "arguments", "to", "sort", "by", "multiple", "properties", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L36528-L36545
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (objects) { var _this = this; _emberMetalProperty_events.beginPropertyChanges(this); objects.forEach(function (obj) { return _this.addObject(obj); }); _emberMetalProperty_events.endPropertyChanges(this); return this; }
javascript
function (objects) { var _this = this; _emberMetalProperty_events.beginPropertyChanges(this); objects.forEach(function (obj) { return _this.addObject(obj); }); _emberMetalProperty_events.endPropertyChanges(this); return this; }
[ "function", "(", "objects", ")", "{", "var", "_this", "=", "this", ";", "_emberMetalProperty_events", ".", "beginPropertyChanges", "(", "this", ")", ";", "objects", ".", "forEach", "(", "function", "(", "obj", ")", "{", "return", "_this", ".", "addObject", "(", "obj", ")", ";", "}", ")", ";", "_emberMetalProperty_events", ".", "endPropertyChanges", "(", "this", ")", ";", "return", "this", ";", "}" ]
Adds each object in the passed enumerable to the receiver. @method addObjects @param {Ember.Enumerable} objects the objects to add. @return {Object} receiver @public
[ "Adds", "each", "object", "in", "the", "passed", "enumerable", "to", "the", "receiver", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L37256-L37265
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (key, value) { var ret; // = this.reducedProperty(key, value); if (value !== undefined && ret === undefined) { ret = this[key] = value; } return ret; }
javascript
function (key, value) { var ret; // = this.reducedProperty(key, value); if (value !== undefined && ret === undefined) { ret = this[key] = value; } return ret; }
[ "function", "(", "key", ",", "value", ")", "{", "var", "ret", ";", "if", "(", "value", "!==", "undefined", "&&", "ret", "===", "undefined", ")", "{", "ret", "=", "this", "[", "key", "]", "=", "value", ";", "}", "return", "ret", ";", "}" ]
If you ask for an unknown property, then try to collect the value from member items.
[ "If", "you", "ask", "for", "an", "unknown", "property", "then", "try", "to", "collect", "the", "value", "from", "member", "items", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L40058-L40064
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
typeOf
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
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; }
[ "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", ";", "}" ]
Returns a consistent type for the passed object. Use this instead of the built-in `typeof` to get the type of an item. It will return the same result across all browsers and includes a bit more detail. Here is what will be returned: | Return Value | Meaning | |---------------|------------------------------------------------------| | 'string' | String primitive or String object. | | 'number' | Number primitive or Number object. | | 'boolean' | Boolean primitive or Boolean object. | | 'null' | Null value | | 'undefined' | Undefined value | | 'function' | A function | | 'array' | An instance of Array | | 'regexp' | An instance of RegExp | | 'date' | An instance of Date | | 'class' | An Ember class (created using Ember.Object.extend()) | | 'instance' | An Ember object instance | | 'error' | An instance of the Error object | | 'object' | A JavaScript object not inheriting from Ember.Object | Examples: ```javascript Ember.typeOf(); // 'undefined' Ember.typeOf(null); // 'null' Ember.typeOf(undefined); // 'undefined' Ember.typeOf('michael'); // 'string' Ember.typeOf(new String('michael')); // 'string' Ember.typeOf(101); // 'number' Ember.typeOf(new Number(101)); // 'number' Ember.typeOf(true); // 'boolean' Ember.typeOf(new Boolean(true)); // 'boolean' Ember.typeOf(Ember.makeArray); // 'function' Ember.typeOf([1, 2, 90]); // 'array' Ember.typeOf(/abc/); // 'regexp' Ember.typeOf(new Date()); // 'date' Ember.typeOf(Ember.Object.extend()); // 'class' Ember.typeOf(Ember.Object.create()); // 'instance' Ember.typeOf(new Error('teamocil')); // 'error' 'normal' JavaScript object Ember.typeOf({ a: 'b' }); // 'object' ``` @method typeOf @for Ember @param {Object} item the item to check @return {String} the type @public
[ "Returns", "a", "consistent", "type", "for", "the", "passed", "object", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L40726-L40750
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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); })); }
[ "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", ")", ";", "}", ")", ")", ";", "}" ]
`unregisterWaiter` is used to unregister a callback that was registered with `registerWaiter`. @public @method unregisterWaiter @param {Object} context (optional) @param {Function} callback @since 1.2.0
[ "unregisterWaiter", "is", "used", "to", "unregister", "a", "callback", "that", "was", "registered", "with", "registerWaiter", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L43206-L43217
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
protoWrap
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
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); }); } }; }
[ "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", ")", ";", "}", ")", ";", "}", "}", ";", "}" ]
This method is no longer needed But still here for backwards compatibility of helper chaining
[ "This", "method", "is", "no", "longer", "needed", "But", "still", "here", "for", "backwards", "compatibility", "of", "helper", "chaining" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L43405-L43419
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
isolate
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
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; }); }); } }
[ "function", "isolate", "(", "fn", ",", "val", ")", "{", "var", "value", ",", "lastPromise", ";", "Test", ".", "lastPromise", "=", "null", ";", "value", "=", "fn", "(", "val", ")", ";", "lastPromise", "=", "Test", ".", "lastPromise", ";", "Test", ".", "lastPromise", "=", "null", ";", "if", "(", "value", "&&", "value", "instanceof", "Test", ".", "Promise", "||", "!", "lastPromise", ")", "{", "return", "value", ";", "}", "else", "{", "return", "run", "(", "function", "(", ")", "{", "return", "Test", ".", "resolve", "(", "lastPromise", ")", ".", "then", "(", "function", "(", ")", "{", "return", "value", ";", "}", ")", ";", "}", ")", ";", "}", "}" ]
This method isolates nested async methods so that they don't conflict with other last promises. 1. Set `Ember.Test.lastPromise` to null 2. Invoke method 3. Return the last promise created during method
[ "This", "method", "isolates", "nested", "async", "methods", "so", "that", "they", "don", "t", "conflict", "with", "other", "last", "promises", ".", "1", ".", "Set", "Ember", ".", "Test", ".", "lastPromise", "to", "null", "2", ".", "Invoke", "method", "3", ".", "Return", "the", "last", "promise", "created", "during", "method" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L43445-L43468
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
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
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'); } }
[ "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'", ")", ";", "}", "}" ]
Return the nearest ancestor whose parent is an instance of `klass`. @method nearestChildOf @param {Class} klass Subclass of Ember.View (or Ember.View itself) @return Ember.View @deprecated @private
[ "Return", "the", "nearest", "ancestor", "whose", "parent", "is", "an", "instance", "of", "klass", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L44394-L44405
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (block, renderNode) { if (_renderView === undefined) { _renderView = require('ember-htmlbars/system/render-view'); } return _renderView.renderHTMLBarsBlock(this, block, renderNode); }
javascript
function (block, renderNode) { if (_renderView === undefined) { _renderView = require('ember-htmlbars/system/render-view'); } return _renderView.renderHTMLBarsBlock(this, block, renderNode); }
[ "function", "(", "block", ",", "renderNode", ")", "{", "if", "(", "_renderView", "===", "undefined", ")", "{", "_renderView", "=", "require", "(", "'ember-htmlbars/system/render-view'", ")", ";", "}", "return", "_renderView", ".", "renderHTMLBarsBlock", "(", "this", ",", "block", ",", "renderNode", ")", ";", "}" ]
Called on your view when it should push strings of HTML into a `Ember.RenderBuffer`. Most users will want to override the `template` or `templateName` properties instead of this method. By default, `Ember.View` will look for a function in the `template` property and invoke it with the value of `context`. The value of `context` will be the view's controller unless you override it. @method renderBlock @param {Ember.RenderBuffer} buffer The render buffer @private
[ "Called", "on", "your", "view", "when", "it", "should", "push", "strings", "of", "HTML", "into", "a", "Ember", ".", "RenderBuffer", ".", "Most", "users", "will", "want", "to", "override", "the", "template", "or", "templateName", "properties", "instead", "of", "this", "method", ".", "By", "default", "Ember", ".", "View", "will", "look", "for", "a", "function", "in", "the", "template", "property", "and", "invoke", "it", "with", "the", "value", "of", "context", ".", "The", "value", "of", "context", "will", "be", "the", "view", "s", "controller", "unless", "you", "override", "it", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L44472-L44478
train
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (property) { var view = _emberMetalProperty_get.get(this, 'parentView'); while (view) { if (property in view) { return view; } view = _emberMetalProperty_get.get(view, 'parentView'); } }
javascript
function (property) { var view = _emberMetalProperty_get.get(this, 'parentView'); while (view) { if (property in view) { return view; } view = _emberMetalProperty_get.get(view, 'parentView'); } }
[ "function", "(", "property", ")", "{", "var", "view", "=", "_emberMetalProperty_get", ".", "get", "(", "this", ",", "'parentView'", ")", ";", "while", "(", "view", ")", "{", "if", "(", "property", "in", "view", ")", "{", "return", "view", ";", "}", "view", "=", "_emberMetalProperty_get", ".", "get", "(", "view", ",", "'parentView'", ")", ";", "}", "}" ]
Return the nearest ancestor that has a given property. @method nearestWithProperty @param {String} property A property name @return Ember.View @private
[ "Return", "the", "nearest", "ancestor", "that", "has", "a", "given", "property", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L45221-L45230
train