id int32 0 58k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
31,600 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function() {
if (this.isDestroyed) { return; }
// At this point, the App.Router must already be assigned
if (this.Router) {
var container = this.__container__;
container.unregister('router:main');
container.register('router:main', this.Router);
}
this.runInitializers();
runLoadHooks('application', this);
// At this point, any initializers or load hooks that would have wanted
// to defer readiness have fired. In general, advancing readiness here
// will proceed to didBecomeReady.
this.advanceReadiness();
return this;
} | javascript | function() {
if (this.isDestroyed) { return; }
// At this point, the App.Router must already be assigned
if (this.Router) {
var container = this.__container__;
container.unregister('router:main');
container.register('router:main', this.Router);
}
this.runInitializers();
runLoadHooks('application', this);
// At this point, any initializers or load hooks that would have wanted
// to defer readiness have fired. In general, advancing readiness here
// will proceed to didBecomeReady.
this.advanceReadiness();
return this;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isDestroyed",
")",
"{",
"return",
";",
"}",
"// At this point, the App.Router must already be assigned",
"if",
"(",
"this",
".",
"Router",
")",
"{",
"var",
"container",
"=",
"this",
".",
"__container__",
";",... | Initialize the application. This happens automatically.
Run any initializers and run the application load hook. These hooks may
choose to defer readiness. For example, an authentication hook might want
to defer readiness until the auth token has been retrieved.
@private
@method _initialize | [
"Initialize",
"the",
"application",
".",
"This",
"happens",
"automatically",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L2733-L2752 | |
31,601 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(namespace) {
var container = new Container();
container.set = set;
container.resolver = resolverFor(namespace);
container.normalizeFullName = container.resolver.normalize;
container.describe = container.resolver.describe;
container.makeToString = container.resolver.makeToString;
container.optionsForType('component', { singleton: false });
container.optionsForType('view', { singleton: false });
container.optionsForType('template', { instantiate: false });
container.optionsForType('helper', { instantiate: false });
container.register('application:main', namespace, { instantiate: false });
container.register('controller:basic', Controller, { instantiate: false });
container.register('controller:object', ObjectController, { instantiate: false });
container.register('controller:array', ArrayController, { instantiate: false });
container.register('view:select', SelectView);
container.register('route:basic', Route, { instantiate: false });
container.register('event_dispatcher:main', EventDispatcher);
container.register('router:main', Router);
container.injection('router:main', 'namespace', 'application:main');
container.register('location:auto', AutoLocation);
container.register('location:hash', HashLocation);
container.register('location:history', HistoryLocation);
container.register('location:none', NoneLocation);
container.injection('controller', 'target', 'router:main');
container.injection('controller', 'namespace', 'application:main');
container.register('-bucket-cache:main', BucketCache);
container.injection('router', '_bucketCache', '-bucket-cache:main');
container.injection('route', '_bucketCache', '-bucket-cache:main');
container.injection('controller', '_bucketCache', '-bucket-cache:main');
container.injection('route', 'router', 'router:main');
container.injection('location', 'rootURL', '-location-setting:root-url');
// DEBUGGING
container.register('resolver-for-debugging:main', container.resolver.__resolver__, { instantiate: false });
container.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main');
container.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main');
// Custom resolver authors may want to register their own ContainerDebugAdapter with this key
// ES6TODO: resolve this via import once ember-application package is ES6'ed
if (!ContainerDebugAdapter) { ContainerDebugAdapter = requireModule('ember-extension-support/container_debug_adapter')['default']; }
container.register('container-debug-adapter:main', ContainerDebugAdapter);
return container;
} | javascript | function(namespace) {
var container = new Container();
container.set = set;
container.resolver = resolverFor(namespace);
container.normalizeFullName = container.resolver.normalize;
container.describe = container.resolver.describe;
container.makeToString = container.resolver.makeToString;
container.optionsForType('component', { singleton: false });
container.optionsForType('view', { singleton: false });
container.optionsForType('template', { instantiate: false });
container.optionsForType('helper', { instantiate: false });
container.register('application:main', namespace, { instantiate: false });
container.register('controller:basic', Controller, { instantiate: false });
container.register('controller:object', ObjectController, { instantiate: false });
container.register('controller:array', ArrayController, { instantiate: false });
container.register('view:select', SelectView);
container.register('route:basic', Route, { instantiate: false });
container.register('event_dispatcher:main', EventDispatcher);
container.register('router:main', Router);
container.injection('router:main', 'namespace', 'application:main');
container.register('location:auto', AutoLocation);
container.register('location:hash', HashLocation);
container.register('location:history', HistoryLocation);
container.register('location:none', NoneLocation);
container.injection('controller', 'target', 'router:main');
container.injection('controller', 'namespace', 'application:main');
container.register('-bucket-cache:main', BucketCache);
container.injection('router', '_bucketCache', '-bucket-cache:main');
container.injection('route', '_bucketCache', '-bucket-cache:main');
container.injection('controller', '_bucketCache', '-bucket-cache:main');
container.injection('route', 'router', 'router:main');
container.injection('location', 'rootURL', '-location-setting:root-url');
// DEBUGGING
container.register('resolver-for-debugging:main', container.resolver.__resolver__, { instantiate: false });
container.injection('container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main');
container.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main');
// Custom resolver authors may want to register their own ContainerDebugAdapter with this key
// ES6TODO: resolve this via import once ember-application package is ES6'ed
if (!ContainerDebugAdapter) { ContainerDebugAdapter = requireModule('ember-extension-support/container_debug_adapter')['default']; }
container.register('container-debug-adapter:main', ContainerDebugAdapter);
return container;
} | [
"function",
"(",
"namespace",
")",
"{",
"var",
"container",
"=",
"new",
"Container",
"(",
")",
";",
"container",
".",
"set",
"=",
"set",
";",
"container",
".",
"resolver",
"=",
"resolverFor",
"(",
"namespace",
")",
";",
"container",
".",
"normalizeFullName... | This creates a container with the default Ember naming conventions.
It also configures the container:
registered views are created every time they are looked up (they are
not singletons)
registered templates are not factories; the registered value is
returned directly.
the router receives the application as its `namespace` property
all controllers receive the router as their `target` and `controllers`
properties
all controllers receive the application as their `namespace` property
the application view receives the application controller as its
`controller` property
the application view receives the application template as its
`defaultTemplate` property
@private
@method buildContainer
@static
@param {Ember.Application} namespace the application to build the
container for.
@return {Ember.Container} the built container | [
"This",
"creates",
"a",
"container",
"with",
"the",
"default",
"Ember",
"naming",
"conventions",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L3135-L3190 | |
31,602 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function() {
var namespaces = emberA(Namespace.NAMESPACES);
var types = emberA();
var self = this;
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 `lookupContainer` on non-models
// (especially when `Ember.MODEL_FACTORY_INJECTIONS` is `true`)
if (!self.detect(namespace[key])) { continue; }
var name = dasherize(key);
if (!(namespace instanceof Application) && namespace.toString()) {
name = namespace + '/' + name;
}
types.push(name);
}
});
return types;
} | javascript | function() {
var namespaces = emberA(Namespace.NAMESPACES);
var types = emberA();
var self = this;
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 `lookupContainer` on non-models
// (especially when `Ember.MODEL_FACTORY_INJECTIONS` is `true`)
if (!self.detect(namespace[key])) { continue; }
var name = dasherize(key);
if (!(namespace instanceof Application) && namespace.toString()) {
name = namespace + '/' + name;
}
types.push(name);
}
});
return types;
} | [
"function",
"(",
")",
"{",
"var",
"namespaces",
"=",
"emberA",
"(",
"Namespace",
".",
"NAMESPACES",
")",
";",
"var",
"types",
"=",
"emberA",
"(",
")",
";",
"var",
"self",
"=",
"this",
";",
"namespaces",
".",
"forEach",
"(",
"function",
"(",
"namespace"... | 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"
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L4527-L4547 | |
31,603 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | handlebarsGet | function handlebarsGet(root, path, options) {
var data = options && options.data;
var normalizedPath = normalizePath(root, path, data);
var value;
// In cases where the path begins with a keyword, change the
// root to the value represented by that keyword, and ensure
// the path is relative to it.
root = normalizedPath.root;
path = normalizedPath.path;
// Ember.get with a null root and GlobalPath will fall back to
// Ember.lookup, which is no longer allowed in templates.
//
// But when outputting a primitive, root will be the primitive
// and path a blank string. These primitives should pass through
// to `get`.
if (root || path === '') {
value = get(root, path);
}
if (detectIsGlobal(path)) {
if (value === undefined && root !== Ember.lookup) {
root = Ember.lookup;
value = get(root, path);
}
if (root === Ember.lookup || root === null) {
Ember.deprecate("Global lookup of "+path+" from a Handlebars template is deprecated.");
}
}
return value;
} | javascript | function handlebarsGet(root, path, options) {
var data = options && options.data;
var normalizedPath = normalizePath(root, path, data);
var value;
// In cases where the path begins with a keyword, change the
// root to the value represented by that keyword, and ensure
// the path is relative to it.
root = normalizedPath.root;
path = normalizedPath.path;
// Ember.get with a null root and GlobalPath will fall back to
// Ember.lookup, which is no longer allowed in templates.
//
// But when outputting a primitive, root will be the primitive
// and path a blank string. These primitives should pass through
// to `get`.
if (root || path === '') {
value = get(root, path);
}
if (detectIsGlobal(path)) {
if (value === undefined && root !== Ember.lookup) {
root = Ember.lookup;
value = get(root, path);
}
if (root === Ember.lookup || root === null) {
Ember.deprecate("Global lookup of "+path+" from a Handlebars template is deprecated.");
}
}
return value;
} | [
"function",
"handlebarsGet",
"(",
"root",
",",
"path",
",",
"options",
")",
"{",
"var",
"data",
"=",
"options",
"&&",
"options",
".",
"data",
";",
"var",
"normalizedPath",
"=",
"normalizePath",
"(",
"root",
",",
"path",
",",
"data",
")",
";",
"var",
"v... | Lookup both on root and on window. If the path starts with
a keyword, the corresponding object will be looked up in the
template's data hash and used to resolve the path.
@method get
@for Ember.Handlebars
@param {Object} root The object to look up the property on
@param {String} path The path to be lookedup
@param {Object} options The template's option hash | [
"Lookup",
"both",
"on",
"root",
"and",
"on",
"window",
".",
"If",
"the",
"path",
"starts",
"with",
"a",
"keyword",
"the",
"corresponding",
"object",
"will",
"be",
"looked",
"up",
"in",
"the",
"template",
"s",
"data",
"hash",
"and",
"used",
"to",
"resolve... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L6797-L6829 |
31,604 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | registerBoundHelper | function registerBoundHelper(name, fn) {
var boundHelperArgs = slice.call(arguments, 1);
var boundFn = makeBoundHelper.apply(this, boundHelperArgs);
EmberHandlebars.registerHelper(name, boundFn);
} | javascript | function registerBoundHelper(name, fn) {
var boundHelperArgs = slice.call(arguments, 1);
var boundFn = makeBoundHelper.apply(this, boundHelperArgs);
EmberHandlebars.registerHelper(name, boundFn);
} | [
"function",
"registerBoundHelper",
"(",
"name",
",",
"fn",
")",
"{",
"var",
"boundHelperArgs",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"var",
"boundFn",
"=",
"makeBoundHelper",
".",
"apply",
"(",
"this",
",",
"boundHelperArgs",
")"... | Register a bound handlebars helper. Bound helpers behave similarly to regular
handlebars helpers, with the added ability to re-render when the underlying data
changes.
## Simple example
```javascript
Ember.Handlebars.registerBoundHelper('capitalize', function(value) {
return Ember.String.capitalize(value);
});
```
The above bound helper can be used inside of templates as follows:
```handlebars
{{capitalize name}}
```
In this case, when the `name` property of the template's context changes,
the rendered value of the helper will update to reflect this change.
## Example with options
Like normal handlebars helpers, bound helpers have access to the options
passed into the helper call.
```javascript
Ember.Handlebars.registerBoundHelper('repeat', function(value, options) {
var count = options.hash.count;
var a = [];
while(a.length < count) {
a.push(value);
}
return a.join('');
});
```
This helper could be used in a template as follows:
```handlebars
{{repeat text count=3}}
```
## Example with bound options
Bound hash options are also supported. Example:
```handlebars
{{repeat text count=numRepeats}}
```
In this example, count will be bound to the value of
the `numRepeats` property on the context. If that property
changes, the helper will be re-rendered.
## Example with extra dependencies
The `Ember.Handlebars.registerBoundHelper` method takes a variable length
third parameter which indicates extra dependencies on the passed in value.
This allows the handlebars helper to update when these dependencies change.
```javascript
Ember.Handlebars.registerBoundHelper('capitalizeName', function(value) {
return value.get('name').toUpperCase();
}, 'name');
```
## Example with multiple bound properties
`Ember.Handlebars.registerBoundHelper` supports binding to
multiple properties, e.g.:
```javascript
Ember.Handlebars.registerBoundHelper('concatenate', function() {
var values = Array.prototype.slice.call(arguments, 0, -1);
return values.join('||');
});
```
Which allows for template syntax such as `{{concatenate prop1 prop2}}` or
`{{concatenate prop1 prop2 prop3}}`. If any of the properties change,
the helper will re-render. Note that dependency keys cannot be
using in conjunction with multi-property helpers, since it is ambiguous
which property the dependent keys would belong to.
## Use with unbound helper
The `{{unbound}}` helper can be used with bound helper invocations
to render them in their unbound form, e.g.
```handlebars
{{unbound capitalize name}}
```
In this example, if the name property changes, the helper
will not re-render.
## Use with blocks not supported
Bound helpers do not support use with Handlebars blocks or
the addition of child views of any kind.
@method registerBoundHelper
@for Ember.Handlebars
@param {String} name
@param {Function} function
@param {String} dependentKeys* | [
"Register",
"a",
"bound",
"handlebars",
"helper",
".",
"Bound",
"helpers",
"behave",
"similarly",
"to",
"regular",
"handlebars",
"helpers",
"with",
"the",
"added",
"ability",
"to",
"re",
"-",
"render",
"when",
"the",
"underlying",
"data",
"changes",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L7167-L7171 |
31,605 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | _triageMustacheHelper | function _triageMustacheHelper(property, options) {
Ember.assert("You cannot pass more than one argument to the _triageMustache helper", arguments.length <= 2);
var helper = EmberHandlebars.resolveHelper(options.data.view.container, property);
if (helper) {
return helper.call(this, options);
}
return helpers.bind.call(this, property, options);
} | javascript | function _triageMustacheHelper(property, options) {
Ember.assert("You cannot pass more than one argument to the _triageMustache helper", arguments.length <= 2);
var helper = EmberHandlebars.resolveHelper(options.data.view.container, property);
if (helper) {
return helper.call(this, options);
}
return helpers.bind.call(this, property, options);
} | [
"function",
"_triageMustacheHelper",
"(",
"property",
",",
"options",
")",
"{",
"Ember",
".",
"assert",
"(",
"\"You cannot pass more than one argument to the _triageMustache helper\"",
",",
"arguments",
".",
"length",
"<=",
"2",
")",
";",
"var",
"helper",
"=",
"EmberH... | '_triageMustache' is used internally select between a binding, helper, or component for
the given context. Until this point, it would be hard to determine if the
mustache is a property reference or a regular helper reference. This triage
helper resolves that.
This would not be typically invoked by directly.
@private
@method _triageMustache
@for Ember.Handlebars.helpers
@param {String} property Property/helperID to triage
@param {Object} options hash of template/rendering options
@return {String} HTML string | [
"_triageMustache",
"is",
"used",
"internally",
"select",
"between",
"a",
"binding",
"helper",
"or",
"component",
"for",
"the",
"given",
"context",
".",
"Until",
"this",
"point",
"it",
"would",
"be",
"hard",
"to",
"determine",
"if",
"the",
"mustache",
"is",
"... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L7641-L7650 |
31,606 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | bindClasses | function bindClasses(context, classBindings, view, bindAttrId, options) {
var ret = [];
var newClass, value, elem;
// Helper method to retrieve the property from the context and
// determine which class string to return, based on whether it is
// a Boolean or not.
var classStringForPath = function(root, parsedPath, options) {
var val;
var path = parsedPath.path;
if (path === 'this') {
val = root;
} else if (path === '') {
val = true;
} else {
val = handlebarsGet(root, path, options);
}
return View._classStringForValue(path, val, parsedPath.className, parsedPath.falsyClassName);
};
// For each property passed, loop through and setup
// an observer.
forEach.call(classBindings.split(' '), function(binding) {
// Variable in which the old class value is saved. The observer function
// closes over this variable, so it knows which string to remove when
// the property changes.
var oldClass;
var observer;
var parsedPath = View._parsePropertyPath(binding);
var path = parsedPath.path;
var pathRoot = context;
var normalized;
if (path !== '' && path !== 'this') {
normalized = normalizePath(context, path, options.data);
pathRoot = normalized.root;
path = normalized.path;
}
// Set up an observer on the context. If the property changes, toggle the
// class name.
observer = function() {
// Get the current value of the property
newClass = classStringForPath(context, parsedPath, options);
elem = bindAttrId ? view.$("[data-bindattr-" + bindAttrId + "='" + bindAttrId + "']") : view.$();
// If we can't find the element anymore, a parent template has been
// re-rendered and we've been nuked. Remove the observer.
if (!elem || elem.length === 0) {
removeObserver(pathRoot, path, observer);
} else {
// If we had previously added a class to the element, remove it.
if (oldClass) {
elem.removeClass(oldClass);
}
// If necessary, add a new class. Make sure we keep track of it so
// it can be removed in the future.
if (newClass) {
elem.addClass(newClass);
oldClass = newClass;
} else {
oldClass = null;
}
}
};
if (path !== '' && path !== 'this') {
view.registerObserver(pathRoot, path, observer);
}
// We've already setup the observer; now we just need to figure out the
// correct behavior right now on the first pass through.
value = classStringForPath(context, parsedPath, options);
if (value) {
ret.push(value);
// Make sure we save the current value so that it can be removed if the
// observer fires.
oldClass = value;
}
});
return ret;
} | javascript | function bindClasses(context, classBindings, view, bindAttrId, options) {
var ret = [];
var newClass, value, elem;
// Helper method to retrieve the property from the context and
// determine which class string to return, based on whether it is
// a Boolean or not.
var classStringForPath = function(root, parsedPath, options) {
var val;
var path = parsedPath.path;
if (path === 'this') {
val = root;
} else if (path === '') {
val = true;
} else {
val = handlebarsGet(root, path, options);
}
return View._classStringForValue(path, val, parsedPath.className, parsedPath.falsyClassName);
};
// For each property passed, loop through and setup
// an observer.
forEach.call(classBindings.split(' '), function(binding) {
// Variable in which the old class value is saved. The observer function
// closes over this variable, so it knows which string to remove when
// the property changes.
var oldClass;
var observer;
var parsedPath = View._parsePropertyPath(binding);
var path = parsedPath.path;
var pathRoot = context;
var normalized;
if (path !== '' && path !== 'this') {
normalized = normalizePath(context, path, options.data);
pathRoot = normalized.root;
path = normalized.path;
}
// Set up an observer on the context. If the property changes, toggle the
// class name.
observer = function() {
// Get the current value of the property
newClass = classStringForPath(context, parsedPath, options);
elem = bindAttrId ? view.$("[data-bindattr-" + bindAttrId + "='" + bindAttrId + "']") : view.$();
// If we can't find the element anymore, a parent template has been
// re-rendered and we've been nuked. Remove the observer.
if (!elem || elem.length === 0) {
removeObserver(pathRoot, path, observer);
} else {
// If we had previously added a class to the element, remove it.
if (oldClass) {
elem.removeClass(oldClass);
}
// If necessary, add a new class. Make sure we keep track of it so
// it can be removed in the future.
if (newClass) {
elem.addClass(newClass);
oldClass = newClass;
} else {
oldClass = null;
}
}
};
if (path !== '' && path !== 'this') {
view.registerObserver(pathRoot, path, observer);
}
// We've already setup the observer; now we just need to figure out the
// correct behavior right now on the first pass through.
value = classStringForPath(context, parsedPath, options);
if (value) {
ret.push(value);
// Make sure we save the current value so that it can be removed if the
// observer fires.
oldClass = value;
}
});
return ret;
} | [
"function",
"bindClasses",
"(",
"context",
",",
"classBindings",
",",
"view",
",",
"bindAttrId",
",",
"options",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"var",
"newClass",
",",
"value",
",",
"elem",
";",
"// Helper method to retrieve the property from the co... | Helper that, given a space-separated string of property paths and a context,
returns an array of class names. Calling this method also has the side
effect of setting up observers at those property paths, such that if they
change, the correct class name will be reapplied to the DOM element.
For example, if you pass the string "fooBar", it will first look up the
"fooBar" value of the context. If that value is true, it will add the
"foo-bar" class to the current element (i.e., the dasherized form of
"fooBar"). If the value is a string, it will add that string as the class.
Otherwise, it will not add any new class name.
@private
@method bindClasses
@for Ember.Handlebars
@param {Ember.Object} context The context from which to lookup properties
@param {String} classBindings A string, space-separated, of class bindings
to use
@param {View} view The view in which observers should look for the
element to update
@param {Srting} bindAttrId Optional bindAttr id used to lookup elements
@return {Array} An array of class names to add | [
"Helper",
"that",
"given",
"a",
"space",
"-",
"separated",
"string",
"of",
"property",
"paths",
"and",
"a",
"context",
"returns",
"an",
"array",
"of",
"class",
"names",
".",
"Calling",
"this",
"method",
"also",
"has",
"the",
"side",
"effect",
"of",
"settin... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L8234-L8323 |
31,607 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(buffer) {
// If not invoked via a triple-mustache ({{{foo}}}), escape
// the content of the template.
var escape = get(this, 'isEscaped');
var shouldDisplay = get(this, 'shouldDisplayFunc');
var preserveContext = get(this, 'preserveContext');
var context = get(this, 'previousContext');
var inverseTemplate = get(this, 'inverseTemplate');
var displayTemplate = get(this, 'displayTemplate');
var result = this.normalizedValue();
this._lastNormalizedValue = result;
// First, test the conditional to see if we should
// render the template or not.
if (shouldDisplay(result)) {
set(this, 'template', displayTemplate);
// If we are preserving the context (for example, if this
// is an #if block, call the template with the same object.
if (preserveContext) {
set(this, '_context', context);
} else {
// Otherwise, determine if this is a block bind or not.
// If so, pass the specified object to the template
if (displayTemplate) {
set(this, '_context', result);
} else {
// This is not a bind block, just push the result of the
// expression to the render context and return.
if (result === null || result === undefined) {
result = "";
} else if (!(result instanceof SafeString)) {
result = String(result);
}
if (escape) { result = Handlebars.Utils.escapeExpression(result); }
buffer.push(result);
return;
}
}
} else if (inverseTemplate) {
set(this, 'template', inverseTemplate);
if (preserveContext) {
set(this, '_context', context);
} else {
set(this, '_context', result);
}
} else {
set(this, 'template', function() { return ''; });
}
return this._super(buffer);
} | javascript | function(buffer) {
// If not invoked via a triple-mustache ({{{foo}}}), escape
// the content of the template.
var escape = get(this, 'isEscaped');
var shouldDisplay = get(this, 'shouldDisplayFunc');
var preserveContext = get(this, 'preserveContext');
var context = get(this, 'previousContext');
var inverseTemplate = get(this, 'inverseTemplate');
var displayTemplate = get(this, 'displayTemplate');
var result = this.normalizedValue();
this._lastNormalizedValue = result;
// First, test the conditional to see if we should
// render the template or not.
if (shouldDisplay(result)) {
set(this, 'template', displayTemplate);
// If we are preserving the context (for example, if this
// is an #if block, call the template with the same object.
if (preserveContext) {
set(this, '_context', context);
} else {
// Otherwise, determine if this is a block bind or not.
// If so, pass the specified object to the template
if (displayTemplate) {
set(this, '_context', result);
} else {
// This is not a bind block, just push the result of the
// expression to the render context and return.
if (result === null || result === undefined) {
result = "";
} else if (!(result instanceof SafeString)) {
result = String(result);
}
if (escape) { result = Handlebars.Utils.escapeExpression(result); }
buffer.push(result);
return;
}
}
} else if (inverseTemplate) {
set(this, 'template', inverseTemplate);
if (preserveContext) {
set(this, '_context', context);
} else {
set(this, '_context', result);
}
} else {
set(this, 'template', function() { return ''; });
}
return this._super(buffer);
} | [
"function",
"(",
"buffer",
")",
"{",
"// If not invoked via a triple-mustache ({{{foo}}}), escape",
"// the content of the template.",
"var",
"escape",
"=",
"get",
"(",
"this",
",",
"'isEscaped'",
")",
";",
"var",
"shouldDisplay",
"=",
"get",
"(",
"this",
",",
"'shoul... | Determines which template to invoke, sets up the correct state based on
that logic, then invokes the default `Ember.View` `render` implementation.
This method will first look up the `path` key on `pathRoot`,
then pass that value to the `shouldDisplayFunc` function. If that returns
`true,` the `displayTemplate` function will be rendered to DOM. Otherwise,
`inverseTemplate`, if specified, will be rendered.
For example, if this `Ember._HandlebarsBoundView` represented the `{{#with
foo}}` helper, it would look up the `foo` property of its context, and
`shouldDisplayFunc` would always return true. The object found by looking
up `foo` would be passed to `displayTemplate`.
@method render
@param {Ember.RenderBuffer} buffer | [
"Determines",
"which",
"template",
"to",
"invoke",
"sets",
"up",
"the",
"correct",
"state",
"based",
"on",
"that",
"logic",
"then",
"invokes",
"the",
"default",
"Ember",
".",
"View",
"render",
"implementation",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L10427-L10484 | |
31,608 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | flushPendingChains | function flushPendingChains() {
if (pendingQueue.length === 0) { return; } // nothing to do
var queue = pendingQueue;
pendingQueue = [];
forEach.call(queue, function(q) { q[0].add(q[1]); });
warn('Watching an undefined global, Ember expects watched globals to be setup by the time the run loop is flushed, check for typos', pendingQueue.length === 0);
} | javascript | function flushPendingChains() {
if (pendingQueue.length === 0) { return; } // nothing to do
var queue = pendingQueue;
pendingQueue = [];
forEach.call(queue, function(q) { q[0].add(q[1]); });
warn('Watching an undefined global, Ember expects watched globals to be setup by the time the run loop is flushed, check for typos', pendingQueue.length === 0);
} | [
"function",
"flushPendingChains",
"(",
")",
"{",
"if",
"(",
"pendingQueue",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"// nothing to do",
"var",
"queue",
"=",
"pendingQueue",
";",
"pendingQueue",
"=",
"[",
"]",
";",
"forEach",
".",
"call",
... | attempts to add the pendingQueue chains again. If some of them end up back in the queue and reschedule is true, schedules a timeout to try again. | [
"attempts",
"to",
"add",
"the",
"pendingQueue",
"chains",
"again",
".",
"If",
"some",
"of",
"them",
"end",
"up",
"back",
"in",
"the",
"queue",
"and",
"reschedule",
"is",
"true",
"schedules",
"a",
"timeout",
"to",
"try",
"again",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L11972-L11981 |
31,609 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | deprecateProperty | function deprecateProperty(object, deprecatedKey, newKey) {
function deprecate() {
Ember.deprecate('Usage of `' + deprecatedKey + '` is deprecated, use `' + newKey + '` instead.');
}
if (hasPropertyAccessors) {
defineProperty(object, deprecatedKey, {
configurable: true,
enumerable: false,
set: function(value) { deprecate(); set(this, newKey, value); },
get: function() { deprecate(); return get(this, newKey); }
});
}
} | javascript | function deprecateProperty(object, deprecatedKey, newKey) {
function deprecate() {
Ember.deprecate('Usage of `' + deprecatedKey + '` is deprecated, use `' + newKey + '` instead.');
}
if (hasPropertyAccessors) {
defineProperty(object, deprecatedKey, {
configurable: true,
enumerable: false,
set: function(value) { deprecate(); set(this, newKey, value); },
get: function() { deprecate(); return get(this, newKey); }
});
}
} | [
"function",
"deprecateProperty",
"(",
"object",
",",
"deprecatedKey",
",",
"newKey",
")",
"{",
"function",
"deprecate",
"(",
")",
"{",
"Ember",
".",
"deprecate",
"(",
"'Usage of `'",
"+",
"deprecatedKey",
"+",
"'` is deprecated, use `'",
"+",
"newKey",
"+",
"'` ... | Used internally to allow changing properties in a backwards compatible way, and print a helpful
deprecation warning.
@method deprecateProperty
@param {Object} object The object to add the deprecated property to.
@param {String} deprecatedKey The property to add (and print deprecation warnings upon accessing).
@param {String} newKey The property that will be aliased.
@private
@since 1.7.0 | [
"Used",
"internally",
"to",
"allow",
"changing",
"properties",
"in",
"a",
"backwards",
"compatible",
"way",
"and",
"print",
"a",
"helpful",
"deprecation",
"warning",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L13951-L13964 |
31,610 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | indexOf | function indexOf(obj, element, index) {
return obj.indexOf ? obj.indexOf(element, index) : _indexOf.call(obj, element, index);
} | javascript | function indexOf(obj, element, index) {
return obj.indexOf ? obj.indexOf(element, index) : _indexOf.call(obj, element, index);
} | [
"function",
"indexOf",
"(",
"obj",
",",
"element",
",",
"index",
")",
"{",
"return",
"obj",
".",
"indexOf",
"?",
"obj",
".",
"indexOf",
"(",
"element",
",",
"index",
")",
":",
"_indexOf",
".",
"call",
"(",
"obj",
",",
"element",
",",
"index",
")",
... | Calls the indexOf function on the passed object with a specified callback. This
uses `Ember.ArrayPolyfill`'s-indexOf method when necessary.
@method indexOf
@param {Object} obj The object to call indexOn on
@param {Function} callback The callback to execute
@param {Object} index The index to start searching from | [
"Calls",
"the",
"indexOf",
"function",
"on",
"the",
"passed",
"object",
"with",
"a",
"specified",
"callback",
".",
"This",
"uses",
"Ember",
".",
"ArrayPolyfill",
"s",
"-",
"indexOf",
"method",
"when",
"necessary",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L14061-L14063 |
31,611 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | indexesOf | function indexesOf(obj, elements) {
return elements === undefined ? [] : map(elements, function(item) {
return indexOf(obj, item);
});
} | javascript | function indexesOf(obj, elements) {
return elements === undefined ? [] : map(elements, function(item) {
return indexOf(obj, item);
});
} | [
"function",
"indexesOf",
"(",
"obj",
",",
"elements",
")",
"{",
"return",
"elements",
"===",
"undefined",
"?",
"[",
"]",
":",
"map",
"(",
"elements",
",",
"function",
"(",
"item",
")",
"{",
"return",
"indexOf",
"(",
"obj",
",",
"item",
")",
";",
"}",... | Returns an array of indexes of the first occurrences of the passed elements
on the passed object.
```javascript
var array = [1, 2, 3, 4, 5];
Ember.EnumerableUtils.indexesOf(array, [2, 5]); // [1, 4]
var fubar = "Fubarr";
Ember.EnumerableUtils.indexesOf(fubar, ['b', 'r']); // [2, 4]
```
@method indexesOf
@param {Object} obj The object to check for element indexes
@param {Array} elements The elements to search for on *obj*
@return {Array} An array of indexes. | [
"Returns",
"an",
"array",
"of",
"indexes",
"of",
"the",
"first",
"occurrences",
"of",
"the",
"passed",
"elements",
"on",
"the",
"passed",
"object",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L14084-L14088 |
31,612 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | addObject | function addObject(array, item) {
var index = indexOf(array, item);
if (index === -1) { array.push(item); }
} | javascript | function addObject(array, item) {
var index = indexOf(array, item);
if (index === -1) { array.push(item); }
} | [
"function",
"addObject",
"(",
"array",
",",
"item",
")",
"{",
"var",
"index",
"=",
"indexOf",
"(",
"array",
",",
"item",
")",
";",
"if",
"(",
"index",
"===",
"-",
"1",
")",
"{",
"array",
".",
"push",
"(",
"item",
")",
";",
"}",
"}"
] | Adds an object to an array. If the array already includes the object this
method has no effect.
@method addObject
@param {Array} array The array the passed item should be added to
@param {Object} item The item to add to the passed array
@return 'undefined' | [
"Adds",
"an",
"object",
"to",
"an",
"array",
".",
"If",
"the",
"array",
"already",
"includes",
"the",
"object",
"this",
"method",
"has",
"no",
"effect",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L14100-L14103 |
31,613 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | intersection | function intersection(array1, array2) {
var result = [];
forEach(array1, function(element) {
if (indexOf(array2, element) >= 0) {
result.push(element);
}
});
return result;
} | javascript | function intersection(array1, array2) {
var result = [];
forEach(array1, function(element) {
if (indexOf(array2, element) >= 0) {
result.push(element);
}
});
return result;
} | [
"function",
"intersection",
"(",
"array1",
",",
"array2",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"forEach",
"(",
"array1",
",",
"function",
"(",
"element",
")",
"{",
"if",
"(",
"indexOf",
"(",
"array2",
",",
"element",
")",
">=",
"0",
")",
... | Calculates the intersection of two arrays. This method returns a new array
filled with the records that the two passed arrays share with each other.
If there is no intersection, an empty array will be returned.
```javascript
var array1 = [1, 2, 3, 4, 5];
var array2 = [1, 3, 5, 6, 7];
Ember.EnumerableUtils.intersection(array1, array2); // [1, 3, 5]
var array1 = [1, 2, 3];
var array2 = [4, 5, 6];
Ember.EnumerableUtils.intersection(array1, array2); // []
```
@method intersection
@param {Array} array1 The first array
@param {Array} array2 The second array
@return {Array} The intersection of the two passed arrays. | [
"Calculates",
"the",
"intersection",
"of",
"two",
"arrays",
".",
"This",
"method",
"returns",
"a",
"new",
"array",
"filled",
"with",
"the",
"records",
"that",
"the",
"two",
"passed",
"arrays",
"share",
"with",
"each",
"other",
".",
"If",
"there",
"is",
"no... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L14200-L14209 |
31,614 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | watchedEvents | function watchedEvents(obj) {
var listeners = obj['__ember_meta__'].listeners, ret = [];
if (listeners) {
for(var eventName in listeners) {
if (listeners[eventName]) { ret.push(eventName); }
}
}
return ret;
} | javascript | function watchedEvents(obj) {
var listeners = obj['__ember_meta__'].listeners, ret = [];
if (listeners) {
for(var eventName in listeners) {
if (listeners[eventName]) { ret.push(eventName); }
}
}
return ret;
} | [
"function",
"watchedEvents",
"(",
"obj",
")",
"{",
"var",
"listeners",
"=",
"obj",
"[",
"'__ember_meta__'",
"]",
".",
"listeners",
",",
"ret",
"=",
"[",
"]",
";",
"if",
"(",
"listeners",
")",
"{",
"for",
"(",
"var",
"eventName",
"in",
"listeners",
")",... | Return a list of currently watched events
@private
@method watchedEvents
@for Ember
@param obj | [
"Return",
"a",
"list",
"of",
"currently",
"watched",
"events"
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L14564-L14573 |
31,615 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | isEmpty | function isEmpty(obj) {
var none = isNone(obj);
if (none) {
return none;
}
if (typeof obj.size === 'number') {
return !obj.size;
}
var objectType = typeof obj;
if (objectType === 'object') {
var size = get(obj, 'size');
if (typeof size === 'number') {
return !size;
}
}
if (typeof obj.length === 'number' && objectType !== 'function') {
return !obj.length;
}
if (objectType === 'object') {
var length = get(obj, 'length');
if (typeof length === 'number') {
return !length;
}
}
return false;
} | javascript | function isEmpty(obj) {
var none = isNone(obj);
if (none) {
return none;
}
if (typeof obj.size === 'number') {
return !obj.size;
}
var objectType = typeof obj;
if (objectType === 'object') {
var size = get(obj, 'size');
if (typeof size === 'number') {
return !size;
}
}
if (typeof obj.length === 'number' && objectType !== 'function') {
return !obj.length;
}
if (objectType === 'object') {
var length = get(obj, 'length');
if (typeof length === 'number') {
return !length;
}
}
return false;
} | [
"function",
"isEmpty",
"(",
"obj",
")",
"{",
"var",
"none",
"=",
"isNone",
"(",
"obj",
")",
";",
"if",
"(",
"none",
")",
"{",
"return",
"none",
";",
"}",
"if",
"(",
"typeof",
"obj",
".",
"size",
"===",
"'number'",
")",
"{",
"return",
"!",
"obj",
... | Verifies that a value is `null` or an empty string, empty array,
or empty function.
Constrains the rules on `Ember.isNone` by returning true for empty
string and empty arrays.
```javascript
Ember.isEmpty(); // true
Ember.isEmpty(null); // true
Ember.isEmpty(undefined); // true
Ember.isEmpty(''); // true
Ember.isEmpty([]); // true
Ember.isEmpty('Adam Hawkins'); // false
Ember.isEmpty([0,1,2]); // false
```
@method isEmpty
@for Ember
@param {Object} obj Value to test
@return {Boolean} | [
"Verifies",
"that",
"a",
"value",
"is",
"null",
"or",
"an",
"empty",
"string",
"empty",
"array",
"or",
"empty",
"function",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L15128-L15159 |
31,616 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | _suspendBeforeObserver | function _suspendBeforeObserver(obj, path, target, method, callback) {
return suspendListener(obj, beforeEvent(path), target, method, callback);
} | javascript | function _suspendBeforeObserver(obj, path, target, method, callback) {
return suspendListener(obj, beforeEvent(path), target, method, callback);
} | [
"function",
"_suspendBeforeObserver",
"(",
"obj",
",",
"path",
",",
"target",
",",
"method",
",",
"callback",
")",
"{",
"return",
"suspendListener",
"(",
"obj",
",",
"beforeEvent",
"(",
"path",
")",
",",
"target",
",",
"method",
",",
"callback",
")",
";",
... | Suspend observer during callback. This should only be used by the target of the observer while it is setting the observed path. | [
"Suspend",
"observer",
"during",
"callback",
".",
"This",
"should",
"only",
"be",
"used",
"by",
"the",
"target",
"of",
"the",
"observer",
"while",
"it",
"is",
"setting",
"the",
"observed",
"path",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L16977-L16979 |
31,617 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | set | function set(obj, keyName, value, tolerant) {
if (typeof obj === 'string') {
Ember.assert("Path '" + obj + "' must be global if no obj is given.", IS_GLOBAL.test(obj));
value = keyName;
keyName = obj;
obj = null;
}
Ember.assert("Cannot call set with "+ keyName +" key.", !!keyName);
if (!obj) {
return setPath(obj, keyName, value, tolerant);
}
var meta = obj['__ember_meta__'];
var desc = meta && meta.descs[keyName];
var isUnknown, currentValue;
if (desc === undefined && isPath(keyName)) {
return setPath(obj, keyName, value, tolerant);
}
Ember.assert("You need to provide an object and key to `set`.", !!obj && keyName !== undefined);
Ember.assert('calling set on destroyed object', !obj.isDestroyed);
if (desc !== undefined) {
desc.set(obj, keyName, value);
} else {
if (typeof obj === 'object' && obj !== null && value !== undefined && obj[keyName] === value) {
return value;
}
isUnknown = 'object' === typeof obj && !(keyName in obj);
// setUnknownProperty is called if `obj` is an object,
// the property does not already exist, and the
// `setUnknownProperty` method exists on the object
if (isUnknown && 'function' === typeof obj.setUnknownProperty) {
obj.setUnknownProperty(keyName, value);
} else if (meta && meta.watching[keyName] > 0) {
if (hasPropertyAccessors) {
currentValue = meta.values[keyName];
} else {
currentValue = obj[keyName];
}
// only trigger a change if the value has changed
if (value !== currentValue) {
propertyWillChange(obj, keyName);
if (hasPropertyAccessors) {
if (
(currentValue === undefined && !(keyName in obj)) ||
!Object.prototype.propertyIsEnumerable.call(obj, keyName)
) {
defineProperty(obj, keyName, null, value); // setup mandatory setter
} else {
meta.values[keyName] = value;
}
} else {
obj[keyName] = value;
}
propertyDidChange(obj, keyName);
}
} else {
obj[keyName] = value;
}
}
return value;
} | javascript | function set(obj, keyName, value, tolerant) {
if (typeof obj === 'string') {
Ember.assert("Path '" + obj + "' must be global if no obj is given.", IS_GLOBAL.test(obj));
value = keyName;
keyName = obj;
obj = null;
}
Ember.assert("Cannot call set with "+ keyName +" key.", !!keyName);
if (!obj) {
return setPath(obj, keyName, value, tolerant);
}
var meta = obj['__ember_meta__'];
var desc = meta && meta.descs[keyName];
var isUnknown, currentValue;
if (desc === undefined && isPath(keyName)) {
return setPath(obj, keyName, value, tolerant);
}
Ember.assert("You need to provide an object and key to `set`.", !!obj && keyName !== undefined);
Ember.assert('calling set on destroyed object', !obj.isDestroyed);
if (desc !== undefined) {
desc.set(obj, keyName, value);
} else {
if (typeof obj === 'object' && obj !== null && value !== undefined && obj[keyName] === value) {
return value;
}
isUnknown = 'object' === typeof obj && !(keyName in obj);
// setUnknownProperty is called if `obj` is an object,
// the property does not already exist, and the
// `setUnknownProperty` method exists on the object
if (isUnknown && 'function' === typeof obj.setUnknownProperty) {
obj.setUnknownProperty(keyName, value);
} else if (meta && meta.watching[keyName] > 0) {
if (hasPropertyAccessors) {
currentValue = meta.values[keyName];
} else {
currentValue = obj[keyName];
}
// only trigger a change if the value has changed
if (value !== currentValue) {
propertyWillChange(obj, keyName);
if (hasPropertyAccessors) {
if (
(currentValue === undefined && !(keyName in obj)) ||
!Object.prototype.propertyIsEnumerable.call(obj, keyName)
) {
defineProperty(obj, keyName, null, value); // setup mandatory setter
} else {
meta.values[keyName] = value;
}
} else {
obj[keyName] = value;
}
propertyDidChange(obj, keyName);
}
} else {
obj[keyName] = value;
}
}
return value;
} | [
"function",
"set",
"(",
"obj",
",",
"keyName",
",",
"value",
",",
"tolerant",
")",
"{",
"if",
"(",
"typeof",
"obj",
"===",
"'string'",
")",
"{",
"Ember",
".",
"assert",
"(",
"\"Path '\"",
"+",
"obj",
"+",
"\"' must be global if no obj is given.\"",
",",
"I... | Sets the value of a property on an object, respecting computed properties
and notifying observers and other listeners of the change. If the
property is not defined but the object implements the `setUnknownProperty`
method then that will be invoked as well.
@method set
@for Ember
@param {Object} obj The object to modify.
@param {String} keyName The property key to set
@param {Object} value The value to set
@return {Object} the passed value. | [
"Sets",
"the",
"value",
"of",
"a",
"property",
"on",
"an",
"object",
"respecting",
"computed",
"properties",
"and",
"notifying",
"observers",
"and",
"other",
"listeners",
"of",
"the",
"change",
".",
"If",
"the",
"property",
"is",
"not",
"defined",
"but",
"th... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L18028-L18098 |
31,618 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | intern | function intern(str) {
var obj = {};
obj[str] = 1;
for (var key in obj) {
if (key === str) return key;
}
return str;
} | javascript | function intern(str) {
var obj = {};
obj[str] = 1;
for (var key in obj) {
if (key === str) return key;
}
return str;
} | [
"function",
"intern",
"(",
"str",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
";",
"obj",
"[",
"str",
"]",
"=",
"1",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"key",
"===",
"str",
")",
"return",
"key",
";",
"}",
"return",
... | Strongly hint runtimes to intern the provided string.
When do I need to use this function?
For the most part, never. Pre-mature optimization is bad, and often the
runtime does exactly what you need it to, and more often the trade-off isn't
worth it.
Why?
Runtimes store strings in at least 2 different representations:
Ropes and Symbols (interned strings). The Rope provides a memory efficient
data-structure for strings created from concatenation or some other string
manipulation like splitting.
Unfortunately checking equality of different ropes can be quite costly as
runtimes must resort to clever string comparison algorithims. These
algorithims typically cost in proportion to the length of the string.
Luckily, this is where the Symbols (interned strings) shine. As Symbols are
unique by their string content, equality checks can be done by pointer
comparision.
How do I know if my string is a rope or symbol?
Typically (warning general sweeping statement, but truthy in runtimes at
present) static strings created as part of the JS source are interned.
Strings often used for comparisions can be interned at runtime if some
criteria are met. One of these criteria can be the size of the entire rope.
For example, in chrome 38 a rope longer then 12 characters will not
intern, nor will segments of that rope.
Some numbers: http://jsperf.com/eval-vs-keys/8
Known Trick™
@private
@return {String} interned version of the provided string | [
"Strongly",
"hint",
"runtimes",
"to",
"intern",
"the",
"provided",
"string",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L18923-L18930 |
31,619 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | makeArray | function makeArray(obj) {
if (obj === null || obj === undefined) { return []; }
return isArray(obj) ? obj : [obj];
} | javascript | function makeArray(obj) {
if (obj === null || obj === undefined) { return []; }
return isArray(obj) ? obj : [obj];
} | [
"function",
"makeArray",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
"===",
"null",
"||",
"obj",
"===",
"undefined",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"isArray",
"(",
"obj",
")",
"?",
"obj",
":",
"[",
"obj",
"]",
";",
"}"
] | Forces the passed object to be part of an array. If the object is already
an array or array-like, returns the object. Otherwise adds the object to
an array. If obj is `null` or `undefined`, returns an empty array.
```javascript
Ember.makeArray(); // []
Ember.makeArray(null); // []
Ember.makeArray(undefined); // []
Ember.makeArray('lindsay'); // ['lindsay']
Ember.makeArray([1, 2, 42]); // [1, 2, 42]
var controller = Ember.ArrayProxy.create({ content: [] });
Ember.makeArray(controller) === controller; // true
```
@method makeArray
@for Ember
@param {Object} obj the object
@return {Array} | [
"Forces",
"the",
"passed",
"object",
"to",
"be",
"part",
"of",
"an",
"array",
".",
"If",
"the",
"object",
"is",
"already",
"an",
"array",
"or",
"array",
"-",
"like",
"returns",
"the",
"object",
".",
"Otherwise",
"adds",
"the",
"object",
"to",
"an",
"ar... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L19327-L19330 |
31,620 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | typeOf | function typeOf(item) {
var ret, modulePath;
// ES6TODO: Depends on Ember.Object which is defined in runtime.
if (typeof EmberObject === "undefined") {
modulePath = 'ember-runtime/system/object';
if (Ember.__loader.registry[modulePath]) {
EmberObject = Ember.__loader.require(modulePath)['default'];
}
}
ret = (item === null || item === undefined) ? String(item) : TYPE_MAP[toString.call(item)] || 'object';
if (ret === 'function') {
if (EmberObject && EmberObject.detect(item)) ret = 'class';
} else if (ret === 'object') {
if (item instanceof Error) ret = 'error';
else if (EmberObject && item instanceof EmberObject) ret = 'instance';
else if (item instanceof Date) ret = 'date';
}
return ret;
} | javascript | function typeOf(item) {
var ret, modulePath;
// ES6TODO: Depends on Ember.Object which is defined in runtime.
if (typeof EmberObject === "undefined") {
modulePath = 'ember-runtime/system/object';
if (Ember.__loader.registry[modulePath]) {
EmberObject = Ember.__loader.require(modulePath)['default'];
}
}
ret = (item === null || item === undefined) ? String(item) : TYPE_MAP[toString.call(item)] || 'object';
if (ret === 'function') {
if (EmberObject && EmberObject.detect(item)) ret = 'class';
} else if (ret === 'object') {
if (item instanceof Error) ret = 'error';
else if (EmberObject && item instanceof EmberObject) ret = 'instance';
else if (item instanceof Date) ret = 'date';
}
return ret;
} | [
"function",
"typeOf",
"(",
"item",
")",
"{",
"var",
"ret",
",",
"modulePath",
";",
"// ES6TODO: Depends on Ember.Object which is defined in runtime.",
"if",
"(",
"typeof",
"EmberObject",
"===",
"\"undefined\"",
")",
"{",
"modulePath",
"=",
"'ember-runtime/system/object'",... | Returns a consistent type for the passed item.
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 | [
"Returns",
"a",
"consistent",
"type",
"for",
"the",
"passed",
"item",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L19602-L19624 |
31,621 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | watchKey | function watchKey(obj, keyName, meta) {
// can't watch length on Array - it is special...
if (keyName === 'length' && typeOf(obj) === 'array') { return; }
var m = meta || metaFor(obj), watching = m.watching;
// activate watching first time
if (!watching[keyName]) {
watching[keyName] = 1;
var desc = m.descs[keyName];
if (desc && desc.willWatch) { desc.willWatch(obj, keyName); }
if ('function' === typeof obj.willWatchProperty) {
obj.willWatchProperty(keyName);
}
if (hasPropertyAccessors) {
handleMandatorySetter(m, obj, keyName);
}
} else {
watching[keyName] = (watching[keyName] || 0) + 1;
}
} | javascript | function watchKey(obj, keyName, meta) {
// can't watch length on Array - it is special...
if (keyName === 'length' && typeOf(obj) === 'array') { return; }
var m = meta || metaFor(obj), watching = m.watching;
// activate watching first time
if (!watching[keyName]) {
watching[keyName] = 1;
var desc = m.descs[keyName];
if (desc && desc.willWatch) { desc.willWatch(obj, keyName); }
if ('function' === typeof obj.willWatchProperty) {
obj.willWatchProperty(keyName);
}
if (hasPropertyAccessors) {
handleMandatorySetter(m, obj, keyName);
}
} else {
watching[keyName] = (watching[keyName] || 0) + 1;
}
} | [
"function",
"watchKey",
"(",
"obj",
",",
"keyName",
",",
"meta",
")",
"{",
"// can't watch length on Array - it is special...",
"if",
"(",
"keyName",
"===",
"'length'",
"&&",
"typeOf",
"(",
"obj",
")",
"===",
"'array'",
")",
"{",
"return",
";",
"}",
"var",
"... | utils.js | [
"utils",
".",
"js"
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L19720-L19745 |
31,622 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function() {
this._super.apply(this, arguments);
Ember.deprecate('Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.', !this.currentWhen);
// Map desired event name to invoke function
var eventName = get(this, 'eventName');
this.on(eventName, this, this._invoke);
} | javascript | function() {
this._super.apply(this, arguments);
Ember.deprecate('Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.', !this.currentWhen);
// Map desired event name to invoke function
var eventName = get(this, 'eventName');
this.on(eventName, this, this._invoke);
} | [
"function",
"(",
")",
"{",
"this",
".",
"_super",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"Ember",
".",
"deprecate",
"(",
"'Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.'",
",",
"!",
"this",
".",
"currentWhen",
")",
";... | this is doc'ed here so it shows up in the events section of the API documentation, which is where people will likely go looking for it.
Triggers the `LinkView`'s routing behavior. If
`eventName` is changed to a value other than `click`
the routing behavior will trigger on that custom event
instead.
@event click
An overridable method called when LinkView objects are instantiated.
Example:
```javascript
App.MyLinkView = Ember.LinkView.extend({
init: function() {
this._super();
Ember.Logger.log('Event is ' + this.get('eventName'));
}
});
```
NOTE: If you do override `init` for a framework class like `Ember.View` or
`Ember.ArrayController`, be sure to call `this._super()` in your
`init` declaration! If you don't, Ember may not have an opportunity to
do important setup work, and you'll see strange behavior in your
application.
@method init | [
"this",
"is",
"doc",
"ed",
"here",
"so",
"it",
"shows",
"up",
"in",
"the",
"events",
"section",
"of",
"the",
"API",
"documentation",
"which",
"is",
"where",
"people",
"will",
"likely",
"go",
"looking",
"for",
"it",
".",
"Triggers",
"the",
"LinkView",
"s"... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L20594-L20602 | |
31,623 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(){
var helperParameters = this.parameters;
var linkTextPath = helperParameters.options.linkTextPath;
var paths = getResolvedPaths(helperParameters);
var length = paths.length;
var path, i, normalizedPath;
if (linkTextPath) {
normalizedPath = getNormalizedPath(linkTextPath, helperParameters);
this.registerObserver(normalizedPath.root, normalizedPath.path, this, this.rerender);
}
for(i=0; i < length; i++) {
path = paths[i];
if (null === path) {
// A literal value was provided, not a path, so nothing to observe.
continue;
}
normalizedPath = getNormalizedPath(path, helperParameters);
this.registerObserver(normalizedPath.root, normalizedPath.path, this, this._paramsChanged);
}
var queryParamsObject = this.queryParamsObject;
if (queryParamsObject) {
var values = queryParamsObject.values;
// Install observers for all of the hash options
// provided in the (query-params) subexpression.
for (var k in values) {
if (!values.hasOwnProperty(k)) { continue; }
if (queryParamsObject.types[k] === 'ID') {
normalizedPath = getNormalizedPath(values[k], helperParameters);
this.registerObserver(normalizedPath.root, normalizedPath.path, this, this._paramsChanged);
}
}
}
} | javascript | function(){
var helperParameters = this.parameters;
var linkTextPath = helperParameters.options.linkTextPath;
var paths = getResolvedPaths(helperParameters);
var length = paths.length;
var path, i, normalizedPath;
if (linkTextPath) {
normalizedPath = getNormalizedPath(linkTextPath, helperParameters);
this.registerObserver(normalizedPath.root, normalizedPath.path, this, this.rerender);
}
for(i=0; i < length; i++) {
path = paths[i];
if (null === path) {
// A literal value was provided, not a path, so nothing to observe.
continue;
}
normalizedPath = getNormalizedPath(path, helperParameters);
this.registerObserver(normalizedPath.root, normalizedPath.path, this, this._paramsChanged);
}
var queryParamsObject = this.queryParamsObject;
if (queryParamsObject) {
var values = queryParamsObject.values;
// Install observers for all of the hash options
// provided in the (query-params) subexpression.
for (var k in values) {
if (!values.hasOwnProperty(k)) { continue; }
if (queryParamsObject.types[k] === 'ID') {
normalizedPath = getNormalizedPath(values[k], helperParameters);
this.registerObserver(normalizedPath.root, normalizedPath.path, this, this._paramsChanged);
}
}
}
} | [
"function",
"(",
")",
"{",
"var",
"helperParameters",
"=",
"this",
".",
"parameters",
";",
"var",
"linkTextPath",
"=",
"helperParameters",
".",
"options",
".",
"linkTextPath",
";",
"var",
"paths",
"=",
"getResolvedPaths",
"(",
"helperParameters",
")",
";",
"va... | This is called to setup observers that will trigger a rerender.
@private
@method _setupPathObservers
@since 1.3.0 | [
"This",
"is",
"called",
"to",
"setup",
"observers",
"that",
"will",
"trigger",
"a",
"rerender",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L20623-L20661 | |
31,624 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(params, transition) {
var match, name, sawParams, value;
var queryParams = get(this, '_qp.map');
for (var prop in params) {
if (prop === 'queryParams' || (queryParams && prop in queryParams)) {
continue;
}
if (match = prop.match(/^(.*)_id$/)) {
name = match[1];
value = params[prop];
}
sawParams = true;
}
if (!name && sawParams) { return copy(params); }
else if (!name) {
if (transition.resolveIndex < 1) { return; }
var parentModel = transition.state.handlerInfos[transition.resolveIndex-1].context;
return parentModel;
}
return this.findModel(name, value);
} | javascript | function(params, transition) {
var match, name, sawParams, value;
var queryParams = get(this, '_qp.map');
for (var prop in params) {
if (prop === 'queryParams' || (queryParams && prop in queryParams)) {
continue;
}
if (match = prop.match(/^(.*)_id$/)) {
name = match[1];
value = params[prop];
}
sawParams = true;
}
if (!name && sawParams) { return copy(params); }
else if (!name) {
if (transition.resolveIndex < 1) { return; }
var parentModel = transition.state.handlerInfos[transition.resolveIndex-1].context;
return parentModel;
}
return this.findModel(name, value);
} | [
"function",
"(",
"params",
",",
"transition",
")",
"{",
"var",
"match",
",",
"name",
",",
"sawParams",
",",
"value",
";",
"var",
"queryParams",
"=",
"get",
"(",
"this",
",",
"'_qp.map'",
")",
";",
"for",
"(",
"var",
"prop",
"in",
"params",
")",
"{",
... | A hook you can implement to convert the URL into the model for
this route.
```js
App.Router.map(function() {
this.resource('post', {path: '/posts/:post_id'});
});
```
The model for the `post` route is `store.find('post', params.post_id)`.
By default, if your route has a dynamic segment ending in `_id`:
The model class is determined from the segment (`post_id`'s
class is `App.Post`)
The find method is called on the model class with the value of
the dynamic segment.
Note that for routes with dynamic segments, this hook is not always
executed. If the route is entered through a transition (e.g. when
using the `link-to` Handlebars helper or the `transitionTo` method
of routes), and a model context is already provided this hook
is not called.
A model context does not include a primitive string or number,
which does cause the model hook to be called.
Routes without dynamic segments will always execute the model hook.
```js
no dynamic segment, model hook always called
this.transitionTo('posts');
model passed in, so model hook not called
thePost = store.find('post', 1);
this.transitionTo('post', thePost);
integer passed in, model hook is called
this.transitionTo('post', 1);
```
This hook follows the asynchronous/promise semantics
described in the documentation for `beforeModel`. In particular,
if a promise returned from `model` fails, the error will be
handled by the `error` hook on `Ember.Route`.
Example
```js
App.PostRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('post', params.post_id);
}
});
```
@method model
@param {Object} params the parameters extracted from the URL
@param {Transition} transition
@param {Object} queryParams the query params for this route
@return {Object|Promise} the model for this route. If
a promise is returned, the transition will pause until
the promise resolves, and the resolved value of the promise
will be used as the model for this route. | [
"A",
"hook",
"you",
"can",
"implement",
"to",
"convert",
"the",
"URL",
"into",
"the",
"model",
"for",
"this",
"route",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L24873-L24900 | |
31,625 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(name, model) {
var container = this.container;
model = model || this.modelFor(name);
return generateController(container, name, model);
} | javascript | function(name, model) {
var container = this.container;
model = model || this.modelFor(name);
return generateController(container, name, model);
} | [
"function",
"(",
"name",
",",
"model",
")",
"{",
"var",
"container",
"=",
"this",
".",
"container",
";",
"model",
"=",
"model",
"||",
"this",
".",
"modelFor",
"(",
"name",
")",
";",
"return",
"generateController",
"(",
"container",
",",
"name",
",",
"m... | Generates a controller for a route.
If the optional model is passed then the controller type is determined automatically,
e.g., an ArrayController for arrays.
Example
```js
App.PostRoute = Ember.Route.extend({
setupController: function(controller, post) {
this._super(controller, post);
this.generateController('posts', post);
}
});
```
@method generateController
@param {String} name the name of the controller
@param {Object} model the model to infer the type of the controller (optional) | [
"Generates",
"a",
"controller",
"for",
"a",
"route",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L25150-L25156 | |
31,626 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(infos) {
updatePaths(this);
this._cancelLoadingEvent();
this.notifyPropertyChange('url');
// Put this in the runloop so url will be accurate. Seems
// less surprising than didTransition being out of sync.
run.once(this, this.trigger, 'didTransition');
if (get(this, 'namespace').LOG_TRANSITIONS) {
Ember.Logger.log("Transitioned into '" + EmberRouter._routePath(infos) + "'");
}
} | javascript | function(infos) {
updatePaths(this);
this._cancelLoadingEvent();
this.notifyPropertyChange('url');
// Put this in the runloop so url will be accurate. Seems
// less surprising than didTransition being out of sync.
run.once(this, this.trigger, 'didTransition');
if (get(this, 'namespace').LOG_TRANSITIONS) {
Ember.Logger.log("Transitioned into '" + EmberRouter._routePath(infos) + "'");
}
} | [
"function",
"(",
"infos",
")",
"{",
"updatePaths",
"(",
"this",
")",
";",
"this",
".",
"_cancelLoadingEvent",
"(",
")",
";",
"this",
".",
"notifyPropertyChange",
"(",
"'url'",
")",
";",
"// Put this in the runloop so url will be accurate. Seems",
"// less surprising t... | Handles updating the paths and notifying any listeners of the URL
change.
Triggers the router level `didTransition` hook.
@method didTransition
@private
@since 1.2.0 | [
"Handles",
"updating",
"the",
"paths",
"and",
"notifying",
"any",
"listeners",
"of",
"the",
"URL",
"change",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L25804-L25818 | |
31,627 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(routeName, models, queryParams) {
var router = this.router;
return router.isActive.apply(router, arguments);
} | javascript | function(routeName, models, queryParams) {
var router = this.router;
return router.isActive.apply(router, arguments);
} | [
"function",
"(",
"routeName",
",",
"models",
",",
"queryParams",
")",
"{",
"var",
"router",
"=",
"this",
".",
"router",
";",
"return",
"router",
".",
"isActive",
".",
"apply",
"(",
"router",
",",
"arguments",
")",
";",
"}"
] | An alternative form of `isActive` that doesn't require
manual concatenation of the arguments into a single
array.
@method isActiveIntent
@param routeName
@param models
@param queryParams
@return {Boolean}
@private
@since 1.7.0 | [
"An",
"alternative",
"form",
"of",
"isActive",
"that",
"doesn",
"t",
"require",
"manual",
"concatenation",
"of",
"the",
"arguments",
"into",
"a",
"single",
"array",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L25893-L25896 | |
31,628 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(callback) {
var router = this.router;
if (!router) {
router = new Router();
router._triggerWillChangeContext = Ember.K;
router._triggerWillLeave = Ember.K;
router.callbacks = [];
router.triggerEvent = triggerEvent;
this.reopenClass({ router: router });
}
var dsl = EmberRouterDSL.map(function() {
this.resource('application', { path: "/" }, function() {
for (var i=0; i < router.callbacks.length; i++) {
router.callbacks[i].call(this);
}
callback.call(this);
});
});
router.callbacks.push(callback);
router.map(dsl.generate());
return router;
} | javascript | function(callback) {
var router = this.router;
if (!router) {
router = new Router();
router._triggerWillChangeContext = Ember.K;
router._triggerWillLeave = Ember.K;
router.callbacks = [];
router.triggerEvent = triggerEvent;
this.reopenClass({ router: router });
}
var dsl = EmberRouterDSL.map(function() {
this.resource('application', { path: "/" }, function() {
for (var i=0; i < router.callbacks.length; i++) {
router.callbacks[i].call(this);
}
callback.call(this);
});
});
router.callbacks.push(callback);
router.map(dsl.generate());
return router;
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"router",
"=",
"this",
".",
"router",
";",
"if",
"(",
"!",
"router",
")",
"{",
"router",
"=",
"new",
"Router",
"(",
")",
";",
"router",
".",
"_triggerWillChangeContext",
"=",
"Ember",
".",
"K",
";",
"rout... | The `Router.map` function allows you to define mappings from URLs to routes
and resources in your application. These mappings are defined within the
supplied callback function using `this.resource` and `this.route`.
```javascript
App.Router.map(function({
this.route('about');
this.resource('article');
}));
```
For more detailed examples please see
[the guides](http://emberjs.com/guides/routing/defining-your-routes/).
@method map
@param callback | [
"The",
"Router",
".",
"map",
"function",
"allows",
"you",
"to",
"define",
"mappings",
"from",
"URLs",
"to",
"routes",
"and",
"resources",
"in",
"your",
"application",
".",
"These",
"mappings",
"are",
"defined",
"within",
"the",
"supplied",
"callback",
"functio... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L26432-L26459 | |
31,629 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | map | function map(dependentKey, callback) {
var options = {
addedItem: function(array, item, changeMeta, instanceMeta) {
var mapped = callback.call(this, item, changeMeta.index);
array.insertAt(changeMeta.index, mapped);
return array;
},
removedItem: function(array, item, changeMeta, instanceMeta) {
array.removeAt(changeMeta.index, 1);
return array;
}
};
return arrayComputed(dependentKey, options);
} | javascript | function map(dependentKey, callback) {
var options = {
addedItem: function(array, item, changeMeta, instanceMeta) {
var mapped = callback.call(this, item, changeMeta.index);
array.insertAt(changeMeta.index, mapped);
return array;
},
removedItem: function(array, item, changeMeta, instanceMeta) {
array.removeAt(changeMeta.index, 1);
return array;
}
};
return arrayComputed(dependentKey, options);
} | [
"function",
"map",
"(",
"dependentKey",
",",
"callback",
")",
"{",
"var",
"options",
"=",
"{",
"addedItem",
":",
"function",
"(",
"array",
",",
"item",
",",
"changeMeta",
",",
"instanceMeta",
")",
"{",
"var",
"mapped",
"=",
"callback",
".",
"call",
"(",
... | Returns an array mapped via the callback
The callback method you provide should have the following signature.
`item` is the current item in the iteration.
`index` is the integer index of the current item in the iteration.
```javascript
function(item, index);
```
Example
```javascript
var Hamster = Ember.Object.extend({
excitingChores: Ember.computed.map('chores', function(chore, index) {
return chore.toUpperCase() + '!';
})
});
var hamster = Hamster.create({
chores: ['clean', 'write more unit tests']
});
hamster.get('excitingChores'); // ['CLEAN!', 'WRITE MORE UNIT TESTS!']
```
@method computed.map
@for Ember
@param {String} dependentKey
@param {Function} callback
@return {Ember.ComputedProperty} an array mapped via the callback | [
"Returns",
"an",
"array",
"mapped",
"via",
"the",
"callback"
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L28050-L28064 |
31,630 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | sort | function sort(itemsKey, sortDefinition) {
Ember.assert('Ember.computed.sort requires two arguments: an array key to sort and ' +
'either a sort properties key or sort function', arguments.length === 2);
if (typeof sortDefinition === 'function') {
return customSort(itemsKey, sortDefinition);
} else {
return propertySort(itemsKey, sortDefinition);
}
} | javascript | function sort(itemsKey, sortDefinition) {
Ember.assert('Ember.computed.sort requires two arguments: an array key to sort and ' +
'either a sort properties key or sort function', arguments.length === 2);
if (typeof sortDefinition === 'function') {
return customSort(itemsKey, sortDefinition);
} else {
return propertySort(itemsKey, sortDefinition);
}
} | [
"function",
"sort",
"(",
"itemsKey",
",",
"sortDefinition",
")",
"{",
"Ember",
".",
"assert",
"(",
"'Ember.computed.sort requires two arguments: an array key to sort and '",
"+",
"'either a sort properties key or sort function'",
",",
"arguments",
".",
"length",
"===",
"2",
... | A computed property which returns a new array with all the
properties from the first dependent array sorted based on a property
or sort function.
The callback method you provide should have the following signature:
```javascript
function(itemA, itemB);
```
- `itemA` the first item to compare.
- `itemB` the second item to compare.
This function should return negative number (e.g. `-1`) when `itemA` should come before
`itemB`. It should return positive number (e.g. `1`) when `itemA` should come after
`itemB`. If the `itemA` and `itemB` are equal this function should return `0`.
Therefore, if this function is comparing some numeric values, simple `itemA - itemB` or
`itemA.get( 'foo' ) - itemB.get( 'foo' )` can be used instead of series of `if`.
Example
```javascript
var ToDoList = Ember.Object.extend({
using standard ascending sort
todosSorting: ['name'],
sortedTodos: Ember.computed.sort('todos', 'todosSorting'),
using descending sort
todosSortingDesc: ['name:desc'],
sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'),
using a custom sort function
priorityTodos: Ember.computed.sort('todos', function(a, b){
if (a.priority > b.priority) {
return 1;
} else if (a.priority < b.priority) {
return -1;
}
return 0;
})
});
var todoList = ToDoList.create({todos: [
{ name: 'Unit Test', priority: 2 },
{ name: 'Documentation', priority: 3 },
{ name: 'Release', priority: 1 }
]});
todoList.get('sortedTodos'); // [{ name:'Documentation', priority:3 }, { name:'Release', priority:1 }, { name:'Unit Test', priority:2 }]
todoList.get('sortedTodosDesc'); // [{ name:'Unit Test', priority:2 }, { name:'Release', priority:1 }, { name:'Documentation', priority:3 }]
todoList.get('priorityTodos'); // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }]
```
@method computed.sort
@for Ember
@param {String} dependentKey
@param {String or Function} sortDefinition a dependent key to an
array of sort properties (add `:desc` to the arrays sort properties to sort descending) or a function to use when sorting
@return {Ember.ComputedProperty} computes a new sorted array based
on the sort property array or callback function | [
"A",
"computed",
"property",
"which",
"returns",
"a",
"new",
"array",
"with",
"all",
"the",
"properties",
"from",
"the",
"first",
"dependent",
"array",
"sorted",
"based",
"on",
"a",
"property",
"or",
"sort",
"function",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L28558-L28567 |
31,631 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(actionName) {
var args = [].slice.call(arguments, 1);
var target;
if (this._actions && this._actions[actionName]) {
if (this._actions[actionName].apply(this, args) === true) {
// handler returned true, so this action will bubble
} else {
return;
}
}
if (target = get(this, 'target')) {
Ember.assert("The `target` for " + this + " (" + target + ") does not have a `send` method", typeof target.send === 'function');
target.send.apply(target, arguments);
}
} | javascript | function(actionName) {
var args = [].slice.call(arguments, 1);
var target;
if (this._actions && this._actions[actionName]) {
if (this._actions[actionName].apply(this, args) === true) {
// handler returned true, so this action will bubble
} else {
return;
}
}
if (target = get(this, 'target')) {
Ember.assert("The `target` for " + this + " (" + target + ") does not have a `send` method", typeof target.send === 'function');
target.send.apply(target, arguments);
}
} | [
"function",
"(",
"actionName",
")",
"{",
"var",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"var",
"target",
";",
"if",
"(",
"this",
".",
"_actions",
"&&",
"this",
".",
"_actions",
"[",
"actionName",
"]",... | Triggers a named action on the `ActionHandler`. Any parameters
supplied after the `actionName` string will be passed as arguments
to the action target function.
If the `ActionHandler` has its `target` property set, actions may
bubble to the `target`. Bubbling happens when an `actionName` can
not be found in the `ActionHandler`'s `actions` hash or if the
action target function returns `true`.
Example
```js
App.WelcomeRoute = Ember.Route.extend({
actions: {
playTheme: function() {
this.send('playMusic', 'theme.mp3');
},
playMusic: function(track) {
...
}
}
});
```
@method send
@param {String} actionName The action to trigger
@param {*} context a context to send with the action | [
"Triggers",
"a",
"named",
"action",
"on",
"the",
"ActionHandler",
".",
"Any",
"parameters",
"supplied",
"after",
"the",
"actionName",
"string",
"will",
"be",
"passed",
"as",
"arguments",
"to",
"the",
"action",
"target",
"function",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L29893-L29909 | |
31,632 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(removing, adding) {
var removeCnt, addCnt, hasDelta;
if ('number' === typeof removing) removeCnt = removing;
else if (removing) removeCnt = get(removing, 'length');
else removeCnt = removing = -1;
if ('number' === typeof adding) addCnt = adding;
else if (adding) addCnt = get(adding,'length');
else addCnt = adding = -1;
hasDelta = addCnt<0 || removeCnt<0 || addCnt-removeCnt!==0;
if (removing === -1) removing = null;
if (adding === -1) adding = null;
propertyWillChange(this, '[]');
if (hasDelta) propertyWillChange(this, 'length');
sendEvent(this, '@enumerable:before', [this, removing, adding]);
return this;
} | javascript | function(removing, adding) {
var removeCnt, addCnt, hasDelta;
if ('number' === typeof removing) removeCnt = removing;
else if (removing) removeCnt = get(removing, 'length');
else removeCnt = removing = -1;
if ('number' === typeof adding) addCnt = adding;
else if (adding) addCnt = get(adding,'length');
else addCnt = adding = -1;
hasDelta = addCnt<0 || removeCnt<0 || addCnt-removeCnt!==0;
if (removing === -1) removing = null;
if (adding === -1) adding = null;
propertyWillChange(this, '[]');
if (hasDelta) propertyWillChange(this, 'length');
sendEvent(this, '@enumerable:before', [this, removing, adding]);
return this;
} | [
"function",
"(",
"removing",
",",
"adding",
")",
"{",
"var",
"removeCnt",
",",
"addCnt",
",",
"hasDelta",
";",
"if",
"(",
"'number'",
"===",
"typeof",
"removing",
")",
"removeCnt",
"=",
"removing",
";",
"else",
"if",
"(",
"removing",
")",
"removeCnt",
"=... | Invoke this method just before the contents of your enumerable will
change. You can either omit the parameters completely or pass the objects
to be removed or added if available or just a count.
@method enumerableContentWillChange
@param {Ember.Enumerable|Number} removing An enumerable of the objects to
be removed or the number of items to be removed.
@param {Ember.Enumerable|Number} adding An enumerable of the objects to be
added or the number of items to be added.
@chainable | [
"Invoke",
"this",
"method",
"just",
"before",
"the",
"contents",
"of",
"your",
"enumerable",
"will",
"change",
".",
"You",
"can",
"either",
"omit",
"the",
"parameters",
"completely",
"or",
"pass",
"the",
"objects",
"to",
"be",
"removed",
"or",
"added",
"if",... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L31705-L31727 | |
31,633 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(name, target, method) {
if (!method) {
method = target;
target = null;
}
addListener(this, name, target, method, true);
return this;
} | javascript | function(name, target, method) {
if (!method) {
method = target;
target = null;
}
addListener(this, name, target, method, true);
return this;
} | [
"function",
"(",
"name",
",",
"target",
",",
"method",
")",
"{",
"if",
"(",
"!",
"method",
")",
"{",
"method",
"=",
"target",
";",
"target",
"=",
"null",
";",
"}",
"addListener",
"(",
"this",
",",
"name",
",",
"target",
",",
"method",
",",
"true",
... | Subscribes a function to a named event and then cancels the subscription
after the first time the event is triggered. It is good to use ``one`` when
you only care about the first time an event has taken place.
This function takes an optional 2nd argument that will become the "this"
value for the callback. If this argument is passed then the 3rd argument
becomes the function.
@method one
@param {String} name The name of the event
@param {Object} [target] The "this" binding for the callback
@param {Function} method The callback to execute
@return this | [
"Subscribes",
"a",
"function",
"to",
"a",
"named",
"event",
"and",
"then",
"cancels",
"the",
"subscription",
"after",
"the",
"first",
"time",
"the",
"event",
"is",
"triggered",
".",
"It",
"is",
"good",
"to",
"use",
"one",
"when",
"you",
"only",
"care",
"... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L31885-L31893 | |
31,634 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(name) {
var length = arguments.length;
var args = new Array(length - 1);
for (var i = 1; i < length; i++) {
args[i - 1] = arguments[i];
}
sendEvent(this, name, args);
} | javascript | function(name) {
var length = arguments.length;
var args = new Array(length - 1);
for (var i = 1; i < length; i++) {
args[i - 1] = arguments[i];
}
sendEvent(this, name, args);
} | [
"function",
"(",
"name",
")",
"{",
"var",
"length",
"=",
"arguments",
".",
"length",
";",
"var",
"args",
"=",
"new",
"Array",
"(",
"length",
"-",
"1",
")",
";",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"... | Triggers a named event for the object. Any additional arguments
will be passed as parameters to the functions that are subscribed to the
event.
```javascript
person.on('didEat', function(food) {
console.log('person ate some ' + food);
});
person.trigger('didEat', 'broccoli');
outputs: person ate some broccoli
```
@method trigger
@param {String} name The name of the event
@param {Object...} args Optional arguments to pass on | [
"Triggers",
"a",
"named",
"event",
"for",
"the",
"object",
".",
"Any",
"additional",
"arguments",
"will",
"be",
"passed",
"as",
"parameters",
"to",
"the",
"functions",
"that",
"are",
"subscribed",
"to",
"the",
"event",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L31913-L31922 | |
31,635 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(objects) {
if (!(Enumerable.detect(objects) || isArray(objects))) {
throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects");
}
this.replace(get(this, 'length'), 0, objects);
return this;
} | javascript | function(objects) {
if (!(Enumerable.detect(objects) || isArray(objects))) {
throw new TypeError("Must pass Ember.Enumerable to Ember.MutableArray#pushObjects");
}
this.replace(get(this, 'length'), 0, objects);
return this;
} | [
"function",
"(",
"objects",
")",
"{",
"if",
"(",
"!",
"(",
"Enumerable",
".",
"detect",
"(",
"objects",
")",
"||",
"isArray",
"(",
"objects",
")",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"\"Must pass Ember.Enumerable to Ember.MutableArray#pushObjects\""... | Add the objects in the passed numerable to the end of the array. Defers
notifying observers of the change until all objects are added.
```javascript
var colors = ["red"];
colors.pushObjects(["yellow", "orange"]); // ["red", "yellow", "orange"]
```
@method pushObjects
@param {Ember.Enumerable} objects the objects to add
@return {Ember.Array} receiver | [
"Add",
"the",
"objects",
"in",
"the",
"passed",
"numerable",
"to",
"the",
"end",
"of",
"the",
"array",
".",
"Defers",
"notifying",
"observers",
"of",
"the",
"change",
"until",
"all",
"objects",
"are",
"added",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L32228-L32234 | |
31,636 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(objects) {
beginPropertyChanges(this);
for (var i = objects.length - 1; i >= 0; i--) {
this.removeObject(objects[i]);
}
endPropertyChanges(this);
return this;
} | javascript | function(objects) {
beginPropertyChanges(this);
for (var i = objects.length - 1; i >= 0; i--) {
this.removeObject(objects[i]);
}
endPropertyChanges(this);
return this;
} | [
"function",
"(",
"objects",
")",
"{",
"beginPropertyChanges",
"(",
"this",
")",
";",
"for",
"(",
"var",
"i",
"=",
"objects",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"this",
".",
"removeObject",
"(",
"objects",
"[",
... | Removes each object in the passed enumerable from the receiver.
@method removeObjects
@param {Ember.Enumerable} objects the objects to remove
@return {Object} receiver | [
"Removes",
"each",
"object",
"in",
"the",
"passed",
"enumerable",
"from",
"the",
"receiver",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L32513-L32520 | |
31,637 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function() {
var C = this;
var l = arguments.length;
if (l > 0) {
var args = new Array(l);
for (var i = 0; i < l; i++) {
args[i] = arguments[i];
}
this._initProperties(args);
}
return new C();
} | javascript | function() {
var C = this;
var l = arguments.length;
if (l > 0) {
var args = new Array(l);
for (var i = 0; i < l; i++) {
args[i] = arguments[i];
}
this._initProperties(args);
}
return new C();
} | [
"function",
"(",
")",
"{",
"var",
"C",
"=",
"this",
";",
"var",
"l",
"=",
"arguments",
".",
"length",
";",
"if",
"(",
"l",
">",
"0",
")",
"{",
"var",
"args",
"=",
"new",
"Array",
"(",
"l",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
... | Creates an instance of a class. Accepts either no arguments, or an object
containing values to initialize the newly instantiated object with.
```javascript
App.Person = Ember.Object.extend({
helloWorld: function() {
alert("Hi, my name is " + this.get('name'));
}
});
var tom = App.Person.create({
name: 'Tom Dale'
});
tom.helloWorld(); // alerts "Hi, my name is Tom Dale".
```
`create` will call the `init` function if defined during
`Ember.AnyObject.extend`
If no arguments are passed to `create`, it will not set values to the new
instance during initialization:
```javascript
var noName = App.Person.create();
noName.helloWorld(); // alerts undefined
```
NOTE: For performance reasons, you cannot declare methods or computed
properties during `create`. You should instead declare methods and computed
properties when using `extend` or use the `createWithMixins` shorthand.
@method create
@static
@param [arguments]* | [
"Creates",
"an",
"instance",
"of",
"a",
"class",
".",
"Accepts",
"either",
"no",
"arguments",
"or",
"an",
"object",
"containing",
"values",
"to",
"initialize",
"the",
"newly",
"instantiated",
"object",
"with",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L34719-L34730 | |
31,638 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(obj) {
// fail fast
if (!Enumerable.detect(obj)) return false;
var loc = get(this, 'length');
if (get(obj, 'length') !== loc) return false;
while(--loc >= 0) {
if (!obj.contains(this[loc])) return false;
}
return true;
} | javascript | function(obj) {
// fail fast
if (!Enumerable.detect(obj)) return false;
var loc = get(this, 'length');
if (get(obj, 'length') !== loc) return false;
while(--loc >= 0) {
if (!obj.contains(this[loc])) return false;
}
return true;
} | [
"function",
"(",
"obj",
")",
"{",
"// fail fast",
"if",
"(",
"!",
"Enumerable",
".",
"detect",
"(",
"obj",
")",
")",
"return",
"false",
";",
"var",
"loc",
"=",
"get",
"(",
"this",
",",
"'length'",
")",
";",
"if",
"(",
"get",
"(",
"obj",
",",
"'le... | Returns true if the passed object is also an enumerable that contains the
same objects as the receiver.
```javascript
var colors = ["red", "green", "blue"],
same_colors = new Ember.Set(colors);
same_colors.isEqual(colors); // true
same_colors.isEqual(["purple", "brown"]); // false
```
@method isEqual
@param {Ember.Set} obj the other object.
@return {Boolean} | [
"Returns",
"true",
"if",
"the",
"passed",
"object",
"is",
"also",
"an",
"enumerable",
"that",
"contains",
"the",
"same",
"objects",
"as",
"the",
"receiver",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L35999-L36011 | |
31,639 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function() {
if (get(this, 'isFrozen')) throw new EmberError(FROZEN_ERROR);
var obj = this.length > 0 ? this[this.length-1] : null;
this.remove(obj);
return obj;
} | javascript | function() {
if (get(this, 'isFrozen')) throw new EmberError(FROZEN_ERROR);
var obj = this.length > 0 ? this[this.length-1] : null;
this.remove(obj);
return obj;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"get",
"(",
"this",
",",
"'isFrozen'",
")",
")",
"throw",
"new",
"EmberError",
"(",
"FROZEN_ERROR",
")",
";",
"var",
"obj",
"=",
"this",
".",
"length",
">",
"0",
"?",
"this",
"[",
"this",
".",
"length",
"-",
... | Removes the last element from the set and returns it, or `null` if it's empty.
```javascript
var colors = new Ember.Set(["green", "blue"]);
colors.pop(); // "blue"
colors.pop(); // "green"
colors.pop(); // null
```
@method pop
@return {Object} The removed object from the set or null. | [
"Removes",
"the",
"last",
"element",
"from",
"the",
"set",
"and",
"returns",
"it",
"or",
"null",
"if",
"it",
"s",
"empty",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L36066-L36071 | |
31,640 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function (index) {
var split = false;
var arrayOperationIndex, arrayOperation,
arrayOperationRangeStart, arrayOperationRangeEnd,
len;
// OPTIMIZE: we could search these faster if we kept a balanced tree.
// find leftmost arrayOperation to the right of `index`
for (arrayOperationIndex = arrayOperationRangeStart = 0, len = this._operations.length; arrayOperationIndex < len; ++arrayOperationIndex) {
arrayOperation = this._operations[arrayOperationIndex];
if (arrayOperation.type === DELETE) { continue; }
arrayOperationRangeEnd = arrayOperationRangeStart + arrayOperation.count - 1;
if (index === arrayOperationRangeStart) {
break;
} else if (index > arrayOperationRangeStart && index <= arrayOperationRangeEnd) {
split = true;
break;
} else {
arrayOperationRangeStart = arrayOperationRangeEnd + 1;
}
}
return new ArrayOperationMatch(arrayOperation, arrayOperationIndex, split, arrayOperationRangeStart);
} | javascript | function (index) {
var split = false;
var arrayOperationIndex, arrayOperation,
arrayOperationRangeStart, arrayOperationRangeEnd,
len;
// OPTIMIZE: we could search these faster if we kept a balanced tree.
// find leftmost arrayOperation to the right of `index`
for (arrayOperationIndex = arrayOperationRangeStart = 0, len = this._operations.length; arrayOperationIndex < len; ++arrayOperationIndex) {
arrayOperation = this._operations[arrayOperationIndex];
if (arrayOperation.type === DELETE) { continue; }
arrayOperationRangeEnd = arrayOperationRangeStart + arrayOperation.count - 1;
if (index === arrayOperationRangeStart) {
break;
} else if (index > arrayOperationRangeStart && index <= arrayOperationRangeEnd) {
split = true;
break;
} else {
arrayOperationRangeStart = arrayOperationRangeEnd + 1;
}
}
return new ArrayOperationMatch(arrayOperation, arrayOperationIndex, split, arrayOperationRangeStart);
} | [
"function",
"(",
"index",
")",
"{",
"var",
"split",
"=",
"false",
";",
"var",
"arrayOperationIndex",
",",
"arrayOperation",
",",
"arrayOperationRangeStart",
",",
"arrayOperationRangeEnd",
",",
"len",
";",
"// OPTIMIZE: we could search these faster if we kept a balanced tree... | Return an `ArrayOperationMatch` for the operation that contains the item at `index`.
@method _findArrayOperation
@param {Number} index the index of the item whose operation information
should be returned.
@private | [
"Return",
"an",
"ArrayOperationMatch",
"for",
"the",
"operation",
"that",
"contains",
"the",
"item",
"at",
"index",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L36918-L36944 | |
31,641 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(rootElement, event, eventName) {
var self = this;
rootElement.on(event + '.ember', '.ember-view', function(evt, triggeringManager) {
var view = View.views[this.id];
var result = true;
var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null;
if (manager && manager !== triggeringManager) {
result = self._dispatchEvent(manager, evt, eventName, view);
} else if (view) {
result = self._bubbleEvent(view, evt, eventName);
}
return result;
});
rootElement.on(event + '.ember', '[data-ember-action]', function(evt) {
var actionId = jQuery(evt.currentTarget).attr('data-ember-action');
var action = ActionManager.registeredActions[actionId];
// We have to check for action here since in some cases, jQuery will trigger
// an event on `removeChild` (i.e. focusout) after we've already torn down the
// action handlers for the view.
if (action && action.eventName === eventName) {
return action.handler(evt);
}
});
} | javascript | function(rootElement, event, eventName) {
var self = this;
rootElement.on(event + '.ember', '.ember-view', function(evt, triggeringManager) {
var view = View.views[this.id];
var result = true;
var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null;
if (manager && manager !== triggeringManager) {
result = self._dispatchEvent(manager, evt, eventName, view);
} else if (view) {
result = self._bubbleEvent(view, evt, eventName);
}
return result;
});
rootElement.on(event + '.ember', '[data-ember-action]', function(evt) {
var actionId = jQuery(evt.currentTarget).attr('data-ember-action');
var action = ActionManager.registeredActions[actionId];
// We have to check for action here since in some cases, jQuery will trigger
// an event on `removeChild` (i.e. focusout) after we've already torn down the
// action handlers for the view.
if (action && action.eventName === eventName) {
return action.handler(evt);
}
});
} | [
"function",
"(",
"rootElement",
",",
"event",
",",
"eventName",
")",
"{",
"var",
"self",
"=",
"this",
";",
"rootElement",
".",
"on",
"(",
"event",
"+",
"'.ember'",
",",
"'.ember-view'",
",",
"function",
"(",
"evt",
",",
"triggeringManager",
")",
"{",
"va... | Registers an event listener on the rootElement. If the given event is
triggered, the provided event handler will be triggered on the target view.
If the target view does not implement the event handler, or if the handler
returns `false`, the parent view will be called. The event will continue to
bubble to each successive parent view until it reaches the top.
@private
@method setupHandler
@param {Element} rootElement
@param {String} event the browser-originated event to listen to
@param {String} eventName the name of the method to call on the view | [
"Registers",
"an",
"event",
"listener",
"on",
"the",
"rootElement",
".",
"If",
"the",
"given",
"event",
"is",
"triggered",
"the",
"provided",
"event",
"handler",
"will",
"be",
"triggered",
"on",
"the",
"target",
"view",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L38698-L38727 | |
31,642 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(content, start, removedCount) {
// If the contents were empty before and this template collection has an
// empty view remove it now.
var emptyView = get(this, 'emptyView');
if (emptyView && emptyView instanceof View) {
emptyView.removeFromParent();
}
// Loop through child views that correspond with the removed items.
// Note that we loop from the end of the array to the beginning because
// we are mutating it as we go.
var childViews = this._childViews;
var childView, idx;
for (idx = start + removedCount - 1; idx >= start; idx--) {
childView = childViews[idx];
childView.destroy();
}
} | javascript | function(content, start, removedCount) {
// If the contents were empty before and this template collection has an
// empty view remove it now.
var emptyView = get(this, 'emptyView');
if (emptyView && emptyView instanceof View) {
emptyView.removeFromParent();
}
// Loop through child views that correspond with the removed items.
// Note that we loop from the end of the array to the beginning because
// we are mutating it as we go.
var childViews = this._childViews;
var childView, idx;
for (idx = start + removedCount - 1; idx >= start; idx--) {
childView = childViews[idx];
childView.destroy();
}
} | [
"function",
"(",
"content",
",",
"start",
",",
"removedCount",
")",
"{",
"// If the contents were empty before and this template collection has an",
"// empty view remove it now.",
"var",
"emptyView",
"=",
"get",
"(",
"this",
",",
"'emptyView'",
")",
";",
"if",
"(",
"em... | Called when a mutation to the underlying content array will occur.
This method will remove any views that are no longer in the underlying
content array.
Invokes whenever the content array itself will change.
@method arrayWillChange
@param {Array} content the managed collection of objects
@param {Number} start the index at which the changes will occurr
@param {Number} removed number of object to be removed from content | [
"Called",
"when",
"a",
"mutation",
"to",
"the",
"underlying",
"content",
"array",
"will",
"occur",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L39935-L39953 | |
31,643 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(content, start, removed, added) {
var addedViews = [];
var view, item, idx, len, itemViewClass, emptyView;
len = content ? get(content, 'length') : 0;
if (len) {
itemViewClass = get(this, 'itemViewClass');
itemViewClass = handlebarsGetView(content, itemViewClass, this.container);
for (idx = start; idx < start+added; idx++) {
item = content.objectAt(idx);
view = this.createChildView(itemViewClass, {
content: item,
contentIndex: idx
});
addedViews.push(view);
}
} else {
emptyView = get(this, 'emptyView');
if (!emptyView) { return; }
if ('string' === typeof emptyView && isGlobalPath(emptyView)) {
emptyView = get(emptyView) || emptyView;
}
emptyView = this.createChildView(emptyView);
addedViews.push(emptyView);
set(this, 'emptyView', emptyView);
if (CoreView.detect(emptyView)) {
this._createdEmptyView = emptyView;
}
}
this.replace(start, 0, addedViews);
} | javascript | function(content, start, removed, added) {
var addedViews = [];
var view, item, idx, len, itemViewClass, emptyView;
len = content ? get(content, 'length') : 0;
if (len) {
itemViewClass = get(this, 'itemViewClass');
itemViewClass = handlebarsGetView(content, itemViewClass, this.container);
for (idx = start; idx < start+added; idx++) {
item = content.objectAt(idx);
view = this.createChildView(itemViewClass, {
content: item,
contentIndex: idx
});
addedViews.push(view);
}
} else {
emptyView = get(this, 'emptyView');
if (!emptyView) { return; }
if ('string' === typeof emptyView && isGlobalPath(emptyView)) {
emptyView = get(emptyView) || emptyView;
}
emptyView = this.createChildView(emptyView);
addedViews.push(emptyView);
set(this, 'emptyView', emptyView);
if (CoreView.detect(emptyView)) {
this._createdEmptyView = emptyView;
}
}
this.replace(start, 0, addedViews);
} | [
"function",
"(",
"content",
",",
"start",
",",
"removed",
",",
"added",
")",
"{",
"var",
"addedViews",
"=",
"[",
"]",
";",
"var",
"view",
",",
"item",
",",
"idx",
",",
"len",
",",
"itemViewClass",
",",
"emptyView",
";",
"len",
"=",
"content",
"?",
... | Called when a mutation to the underlying content array occurs.
This method will replay that mutation against the views that compose the
`Ember.CollectionView`, ensuring that the view reflects the model.
This array observer is added in `contentDidChange`.
@method arrayDidChange
@param {Array} content the managed collection of objects
@param {Number} start the index at which the changes occurred
@param {Number} removed number of object removed from content
@param {Number} added number of object added to content | [
"Called",
"when",
"a",
"mutation",
"to",
"the",
"underlying",
"content",
"array",
"occurs",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L39969-L40008 | |
31,644 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(classBindings) {
var classNames = this.classNames;
var elem, newClass, dasherizedClass;
// Loop through all of the configured bindings. These will be either
// property names ('isUrgent') or property paths relative to the view
// ('content.isUrgent')
forEach(classBindings, function(binding) {
Ember.assert("classNameBindings must not have spaces in them. Multiple class name bindings can be provided as elements of an array, e.g. ['foo', ':bar']", binding.indexOf(' ') === -1);
// Variable in which the old class value is saved. The observer function
// closes over this variable, so it knows which string to remove when
// the property changes.
var oldClass;
// Extract just the property name from bindings like 'foo:bar'
var parsedPath = View._parsePropertyPath(binding);
// Set up an observer on the context. If the property changes, toggle the
// class name.
var observer = function() {
// Get the current value of the property
newClass = this._classStringForProperty(binding);
elem = this.$();
// If we had previously added a class to the element, remove it.
if (oldClass) {
elem.removeClass(oldClass);
// Also remove from classNames so that if the view gets rerendered,
// the class doesn't get added back to the DOM.
classNames.removeObject(oldClass);
}
// If necessary, add a new class. Make sure we keep track of it so
// it can be removed in the future.
if (newClass) {
elem.addClass(newClass);
oldClass = newClass;
} else {
oldClass = null;
}
};
// Get the class name for the property at its current value
dasherizedClass = this._classStringForProperty(binding);
if (dasherizedClass) {
// Ensure that it gets into the classNames array
// so it is displayed when we render.
addObject(classNames, dasherizedClass);
// Save a reference to the class name so we can remove it
// if the observer fires. Remember that this variable has
// been closed over by the observer.
oldClass = dasherizedClass;
}
this.registerObserver(this, parsedPath.path, observer);
// Remove className so when the view is rerendered,
// the className is added based on binding reevaluation
this.one('willClearRender', function() {
if (oldClass) {
classNames.removeObject(oldClass);
oldClass = null;
}
});
}, this);
} | javascript | function(classBindings) {
var classNames = this.classNames;
var elem, newClass, dasherizedClass;
// Loop through all of the configured bindings. These will be either
// property names ('isUrgent') or property paths relative to the view
// ('content.isUrgent')
forEach(classBindings, function(binding) {
Ember.assert("classNameBindings must not have spaces in them. Multiple class name bindings can be provided as elements of an array, e.g. ['foo', ':bar']", binding.indexOf(' ') === -1);
// Variable in which the old class value is saved. The observer function
// closes over this variable, so it knows which string to remove when
// the property changes.
var oldClass;
// Extract just the property name from bindings like 'foo:bar'
var parsedPath = View._parsePropertyPath(binding);
// Set up an observer on the context. If the property changes, toggle the
// class name.
var observer = function() {
// Get the current value of the property
newClass = this._classStringForProperty(binding);
elem = this.$();
// If we had previously added a class to the element, remove it.
if (oldClass) {
elem.removeClass(oldClass);
// Also remove from classNames so that if the view gets rerendered,
// the class doesn't get added back to the DOM.
classNames.removeObject(oldClass);
}
// If necessary, add a new class. Make sure we keep track of it so
// it can be removed in the future.
if (newClass) {
elem.addClass(newClass);
oldClass = newClass;
} else {
oldClass = null;
}
};
// Get the class name for the property at its current value
dasherizedClass = this._classStringForProperty(binding);
if (dasherizedClass) {
// Ensure that it gets into the classNames array
// so it is displayed when we render.
addObject(classNames, dasherizedClass);
// Save a reference to the class name so we can remove it
// if the observer fires. Remember that this variable has
// been closed over by the observer.
oldClass = dasherizedClass;
}
this.registerObserver(this, parsedPath.path, observer);
// Remove className so when the view is rerendered,
// the className is added based on binding reevaluation
this.one('willClearRender', function() {
if (oldClass) {
classNames.removeObject(oldClass);
oldClass = null;
}
});
}, this);
} | [
"function",
"(",
"classBindings",
")",
"{",
"var",
"classNames",
"=",
"this",
".",
"classNames",
";",
"var",
"elem",
",",
"newClass",
",",
"dasherizedClass",
";",
"// Loop through all of the configured bindings. These will be either",
"// property names ('isUrgent') or proper... | Iterates over the view's `classNameBindings` array, inserts the value
of the specified property into the `classNames` array, then creates an
observer to update the view's element if the bound property ever changes
in the future.
@method _applyClassNameBindings
@private | [
"Iterates",
"over",
"the",
"view",
"s",
"classNameBindings",
"array",
"inserts",
"the",
"value",
"of",
"the",
"specified",
"property",
"into",
"the",
"classNames",
"array",
"then",
"creates",
"an",
"observer",
"to",
"update",
"the",
"view",
"s",
"element",
"if... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L42336-L42404 | |
31,645 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | function(property) {
var parsedPath = View._parsePropertyPath(property);
var path = parsedPath.path;
var val = get(this, path);
if (val === undefined && isGlobalPath(path)) {
val = get(Ember.lookup, path);
}
return View._classStringForValue(path, val, parsedPath.className, parsedPath.falsyClassName);
} | javascript | function(property) {
var parsedPath = View._parsePropertyPath(property);
var path = parsedPath.path;
var val = get(this, path);
if (val === undefined && isGlobalPath(path)) {
val = get(Ember.lookup, path);
}
return View._classStringForValue(path, val, parsedPath.className, parsedPath.falsyClassName);
} | [
"function",
"(",
"property",
")",
"{",
"var",
"parsedPath",
"=",
"View",
".",
"_parsePropertyPath",
"(",
"property",
")",
";",
"var",
"path",
"=",
"parsedPath",
".",
"path",
";",
"var",
"val",
"=",
"get",
"(",
"this",
",",
"path",
")",
";",
"if",
"("... | Given a property name, returns a dasherized version of that
property name if the property evaluates to a non-falsy value.
For example, if the view has property `isUrgent` that evaluates to true,
passing `isUrgent` to this method will return `"is-urgent"`.
@method _classStringForProperty
@param property
@private | [
"Given",
"a",
"property",
"name",
"returns",
"a",
"dasherized",
"version",
"of",
"that",
"property",
"name",
"if",
"the",
"property",
"evaluates",
"to",
"a",
"non",
"-",
"falsy",
"value",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L42493-L42503 | |
31,646 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | interiorNamespace | function interiorNamespace(element){
if (
element &&
element.namespaceURI === svgNamespace &&
!svgHTMLIntegrationPoints[element.tagName]
) {
return svgNamespace;
} else {
return null;
}
} | javascript | function interiorNamespace(element){
if (
element &&
element.namespaceURI === svgNamespace &&
!svgHTMLIntegrationPoints[element.tagName]
) {
return svgNamespace;
} else {
return null;
}
} | [
"function",
"interiorNamespace",
"(",
"element",
")",
"{",
"if",
"(",
"element",
"&&",
"element",
".",
"namespaceURI",
"===",
"svgNamespace",
"&&",
"!",
"svgHTMLIntegrationPoints",
"[",
"element",
".",
"tagName",
"]",
")",
"{",
"return",
"svgNamespace",
";",
"... | This is not the namespace of the element, but of the elements inside that elements. | [
"This",
"is",
"not",
"the",
"namespace",
"of",
"the",
"element",
"but",
"of",
"the",
"elements",
"inside",
"that",
"elements",
"."
] | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L43484-L43494 |
31,647 | appiphony/appiphony-lightning-js | public/lib/emberjs/ember.js | buildSafeDOM | function buildSafeDOM(html, contextualElement, dom) {
var childNodes = buildIESafeDOM(html, contextualElement, dom);
if (contextualElement.tagName === 'SELECT') {
// Walk child nodes
for (var i = 0; childNodes[i]; i++) {
// Find and process the first option child node
if (childNodes[i].tagName === 'OPTION') {
if (detectAutoSelectedOption(childNodes[i].parentNode, childNodes[i], html)) {
// If the first node is selected but does not have an attribute,
// presume it is not really selected.
childNodes[i].parentNode.selectedIndex = -1;
}
break;
}
}
}
return childNodes;
} | javascript | function buildSafeDOM(html, contextualElement, dom) {
var childNodes = buildIESafeDOM(html, contextualElement, dom);
if (contextualElement.tagName === 'SELECT') {
// Walk child nodes
for (var i = 0; childNodes[i]; i++) {
// Find and process the first option child node
if (childNodes[i].tagName === 'OPTION') {
if (detectAutoSelectedOption(childNodes[i].parentNode, childNodes[i], html)) {
// If the first node is selected but does not have an attribute,
// presume it is not really selected.
childNodes[i].parentNode.selectedIndex = -1;
}
break;
}
}
}
return childNodes;
} | [
"function",
"buildSafeDOM",
"(",
"html",
",",
"contextualElement",
",",
"dom",
")",
"{",
"var",
"childNodes",
"=",
"buildIESafeDOM",
"(",
"html",
",",
"contextualElement",
",",
"dom",
")",
";",
"if",
"(",
"contextualElement",
".",
"tagName",
"===",
"'SELECT'",... | When parsing innerHTML, the browser may set up DOM with some things not desired. For example, with a select element context and option innerHTML the first option will be marked selected. This method cleans up some of that, resetting those values back to their defaults. | [
"When",
"parsing",
"innerHTML",
"the",
"browser",
"may",
"set",
"up",
"DOM",
"with",
"some",
"things",
"not",
"desired",
".",
"For",
"example",
"with",
"a",
"select",
"element",
"context",
"and",
"option",
"innerHTML",
"the",
"first",
"option",
"will",
"be",... | 704953fdc60b62d3073fc5cace716a201d38b36c | https://github.com/appiphony/appiphony-lightning-js/blob/704953fdc60b62d3073fc5cace716a201d38b36c/public/lib/emberjs/ember.js#L43949-L43968 |
31,648 | yahoo/kobold | lib/cli.js | filterArguments | function filterArguments(args, params, inject) {
var newArgs = ['node', '_mocha'].concat(inject || []),
param, i, len,
type;
for (i = 2, len = args.length; i < len; i++) {
if ((i < args.length - 1) && (args[i].length > 2) && (args[i].substr(0, 2) === '--')) {
// Get parameter without '--'
param = args[i].substr(2);
// Is parameter used?
if (params.hasOwnProperty(param)) {
// Remember what the type was
type = typeof params[param];
// Overwrite value with next value in arguments
if (type === 'boolean') {
params[param] = true;
} else {
params[param] = args[i + 1];
i++;
// Convert back to boolean if needed
if (type === 'number') {
params[param] = parseFloat(params[param]);
}
}
} else {
newArgs.push(args[i]);
}
} else {
newArgs.push(args[i]);
}
}
// Set test-path with last argument if none given
if (!params['test-path']) {
params['test-path'] = args.pop();
}
newArgs.push(path.join(__dirname, '..', 'resource', 'run.js'));
return newArgs;
} | javascript | function filterArguments(args, params, inject) {
var newArgs = ['node', '_mocha'].concat(inject || []),
param, i, len,
type;
for (i = 2, len = args.length; i < len; i++) {
if ((i < args.length - 1) && (args[i].length > 2) && (args[i].substr(0, 2) === '--')) {
// Get parameter without '--'
param = args[i].substr(2);
// Is parameter used?
if (params.hasOwnProperty(param)) {
// Remember what the type was
type = typeof params[param];
// Overwrite value with next value in arguments
if (type === 'boolean') {
params[param] = true;
} else {
params[param] = args[i + 1];
i++;
// Convert back to boolean if needed
if (type === 'number') {
params[param] = parseFloat(params[param]);
}
}
} else {
newArgs.push(args[i]);
}
} else {
newArgs.push(args[i]);
}
}
// Set test-path with last argument if none given
if (!params['test-path']) {
params['test-path'] = args.pop();
}
newArgs.push(path.join(__dirname, '..', 'resource', 'run.js'));
return newArgs;
} | [
"function",
"filterArguments",
"(",
"args",
",",
"params",
",",
"inject",
")",
"{",
"var",
"newArgs",
"=",
"[",
"'node'",
",",
"'_mocha'",
"]",
".",
"concat",
"(",
"inject",
"||",
"[",
"]",
")",
",",
"param",
",",
"i",
",",
"len",
",",
"type",
";",... | Filters arguments given and sets them to parameters
@method filterArguments
@param {string[]} args
@param {object} params
@param {string[]} [inject]
@return {string[]}
@private | [
"Filters",
"arguments",
"given",
"and",
"sets",
"them",
"to",
"parameters"
] | c43adea98046a7cc4101a27f0448675b2f589601 | https://github.com/yahoo/kobold/blob/c43adea98046a7cc4101a27f0448675b2f589601/lib/cli.js#L14-L63 |
31,649 | yahoo/kobold | lib/cli.js | prepareEnvironment | function prepareEnvironment (argv) {
var params, args;
// Define default values
params = {
'approved-folder': 'approved',
'build-folder': 'build',
'highlight-folder': 'highlight',
'config-folder': 'config',
'fail-orphans': false,
'fail-additions': false,
'test-path': null,
'config': null
};
// Filter arguments
args = filterArguments(argv, params, [
'--slow', '5000',
'--no-timeouts'
]);
if (!fs.existsSync(params['test-path'])) {
throw new Error('Cannot find path to ' + params['test-path']);
} else {
params['test-path'] = path.resolve(params['test-path']);
}
// Load global config
if (typeof params['config'] === 'string') {
params['config'] = require(path.resolve(params['config']));
} else {
params['config'] = params['config'] || {};
}
// Set global variable for test-runner
global.koboldOptions = {
"verbose": false,
"failForOrphans": params['fail-orphans'],
"failOnAdditions": params['fail-additions'],
"build": params['build'],
"comparison": params['config'],
"storage": {
"type": 'File',
"options": {
"path": params['test-path'],
"approvedFolderName": params['approved-folder'],
"buildFolderName": params['build-folder'],
"highlightFolderName": params['highlight-folder'],
"configFolderName": params['config-folder']
}
}
};
return args;
} | javascript | function prepareEnvironment (argv) {
var params, args;
// Define default values
params = {
'approved-folder': 'approved',
'build-folder': 'build',
'highlight-folder': 'highlight',
'config-folder': 'config',
'fail-orphans': false,
'fail-additions': false,
'test-path': null,
'config': null
};
// Filter arguments
args = filterArguments(argv, params, [
'--slow', '5000',
'--no-timeouts'
]);
if (!fs.existsSync(params['test-path'])) {
throw new Error('Cannot find path to ' + params['test-path']);
} else {
params['test-path'] = path.resolve(params['test-path']);
}
// Load global config
if (typeof params['config'] === 'string') {
params['config'] = require(path.resolve(params['config']));
} else {
params['config'] = params['config'] || {};
}
// Set global variable for test-runner
global.koboldOptions = {
"verbose": false,
"failForOrphans": params['fail-orphans'],
"failOnAdditions": params['fail-additions'],
"build": params['build'],
"comparison": params['config'],
"storage": {
"type": 'File',
"options": {
"path": params['test-path'],
"approvedFolderName": params['approved-folder'],
"buildFolderName": params['build-folder'],
"highlightFolderName": params['highlight-folder'],
"configFolderName": params['config-folder']
}
}
};
return args;
} | [
"function",
"prepareEnvironment",
"(",
"argv",
")",
"{",
"var",
"params",
",",
"args",
";",
"// Define default values",
"params",
"=",
"{",
"'approved-folder'",
":",
"'approved'",
",",
"'build-folder'",
":",
"'build'",
",",
"'highlight-folder'",
":",
"'highlight'",
... | Prepares the environment for kobold
@method prepareEnvironment
@param {string[]} argv
@return {string[]}
@private | [
"Prepares",
"the",
"environment",
"for",
"kobold"
] | c43adea98046a7cc4101a27f0448675b2f589601 | https://github.com/yahoo/kobold/blob/c43adea98046a7cc4101a27f0448675b2f589601/lib/cli.js#L73-L133 |
31,650 | redpandatronicsuk/arty-charty | arty-charty/util.js | makeBarsChartPath | function makeBarsChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, paddingLeft, isRange) {
let heightScaler = (chartHeight-markerRadius)/maxValue;
let xSpacing = width / pointsOnScreen;
let barWidth = xSpacing - paddingLeft;
let fullWidth = paddingLeft/2 + (paddingLeft+barWidth) * (chart.data.length-1) + barWidth;
let pathStr = []
let barCords = [];
let x1, y1, y2;
chart.data.some((d, idx) => {
x1 = paddingLeft/2 + (paddingLeft+barWidth) * idx;
if (x1 > fullWidth * t && chart.drawChart) {
return true;
}
if (chart.stretchChart) {
x1 = x1 * t;
}
y1 = (chartHeight+chartHeightOffset) - d.value * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1);
y2 = isRange ? (chartHeight+chartHeightOffset) - d.valueLow * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1) : (chartHeight+chartHeightOffset);
pathStr.push('M');
pathStr.push(x1);
pathStr.push(y2);
pathStr.push('H');
pathStr.push(x1 + barWidth);
pathStr.push('V');
pathStr.push(y1);
pathStr.push('H');
pathStr.push(x1);
pathStr.push('V');
pathStr.push(y2);
barCords.push({x1: x1, x2: x1+barWidth, y1: y1, y2: y2});
});
return {
path: pathStr.join(' '),
width: fullWidth,
maxScroll: fullWidth - width,
barCords: barCords
};
} | javascript | function makeBarsChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, paddingLeft, isRange) {
let heightScaler = (chartHeight-markerRadius)/maxValue;
let xSpacing = width / pointsOnScreen;
let barWidth = xSpacing - paddingLeft;
let fullWidth = paddingLeft/2 + (paddingLeft+barWidth) * (chart.data.length-1) + barWidth;
let pathStr = []
let barCords = [];
let x1, y1, y2;
chart.data.some((d, idx) => {
x1 = paddingLeft/2 + (paddingLeft+barWidth) * idx;
if (x1 > fullWidth * t && chart.drawChart) {
return true;
}
if (chart.stretchChart) {
x1 = x1 * t;
}
y1 = (chartHeight+chartHeightOffset) - d.value * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1);
y2 = isRange ? (chartHeight+chartHeightOffset) - d.valueLow * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1) : (chartHeight+chartHeightOffset);
pathStr.push('M');
pathStr.push(x1);
pathStr.push(y2);
pathStr.push('H');
pathStr.push(x1 + barWidth);
pathStr.push('V');
pathStr.push(y1);
pathStr.push('H');
pathStr.push(x1);
pathStr.push('V');
pathStr.push(y2);
barCords.push({x1: x1, x2: x1+barWidth, y1: y1, y2: y2});
});
return {
path: pathStr.join(' '),
width: fullWidth,
maxScroll: fullWidth - width,
barCords: barCords
};
} | [
"function",
"makeBarsChartPath",
"(",
"chart",
",",
"width",
",",
"t",
",",
"maxValue",
",",
"chartHeight",
",",
"chartHeightOffset",
",",
"markerRadius",
",",
"pointsOnScreen",
",",
"paddingLeft",
",",
"isRange",
")",
"{",
"let",
"heightScaler",
"=",
"(",
"ch... | Generate the SVG path for a bar chart.
@param {object} chart The chart object
@param {number} width Width of the chart in pixels
@param {number} t Scale parameter (range: 0-1), used for
animating the graph
@param {number} maxValue The maximum value of chart data
@param {number} chartHeight Height of the chart in pixels
@param {number} chartHeightOffset By how much to offset the chart height.
Note: The negation of this number is as
the marginTop for the component.
This is done so when the graph is
animated, overflow is not cut off.
@param {number} markerRadius Radius of the markers on the line (only needed to calcualte the height scaler and keep it consistent with the line/area chart, refactor for better name!!!)
@param {number} pointsOnScreen The number of points to show on the screen
without having to scroll. Used to calculate
the horizontal spacing between points. (maybe find better name????) | [
"Generate",
"the",
"SVG",
"path",
"for",
"a",
"bar",
"chart",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L276-L313 |
31,651 | redpandatronicsuk/arty-charty | arty-charty/util.js | makeStackedBarsChartPath | function makeStackedBarsChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, paddingLeft, yAxisWidth, isRange) {
let heightScaler = (chartHeight-markerRadius)/maxValue;
width = width - yAxisWidth;
let xSpacing = width / pointsOnScreen;
let barWidth = xSpacing - paddingLeft;
let fullWidth = paddingLeft/2 + (paddingLeft+barWidth) * (chart.data.length-1) + barWidth;
let paths = []
let barCords = [];
let x1, y1, y2;
chart.data.some((d, idx) => {
x1 = paddingLeft/2 + (paddingLeft+barWidth) * idx + yAxisWidth;
if (x1 > fullWidth * t && chart.drawChart) {
return true;
}
if (chart.stretchChart) {
x1 = x1 * t;
}
let prevY = 0;
d.forEach((stack) => {
y1 = (chartHeight+chartHeightOffset) - (stack.value+prevY) * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1);
//y2 = isRange ? (chartHeight+chartHeightOffset) - prevY * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1) : (chartHeight+chartHeightOffset);
y2 = isRange ? (chartHeight+chartHeightOffset) - prevY * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1) : (chartHeight+chartHeightOffset);
prevY += stack.value;
paths.push({path: makeBarPath(x1, y1, y2, barWidth), color: stack.color});
barCords.push({x1: x1, x2: x1+barWidth, y1: y1, y2: y2});
});
});
return {
//path: pathStr.join(' '),
path: paths,
width: fullWidth,
maxScroll: fullWidth - width,
barCords: barCords
};
} | javascript | function makeStackedBarsChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, paddingLeft, yAxisWidth, isRange) {
let heightScaler = (chartHeight-markerRadius)/maxValue;
width = width - yAxisWidth;
let xSpacing = width / pointsOnScreen;
let barWidth = xSpacing - paddingLeft;
let fullWidth = paddingLeft/2 + (paddingLeft+barWidth) * (chart.data.length-1) + barWidth;
let paths = []
let barCords = [];
let x1, y1, y2;
chart.data.some((d, idx) => {
x1 = paddingLeft/2 + (paddingLeft+barWidth) * idx + yAxisWidth;
if (x1 > fullWidth * t && chart.drawChart) {
return true;
}
if (chart.stretchChart) {
x1 = x1 * t;
}
let prevY = 0;
d.forEach((stack) => {
y1 = (chartHeight+chartHeightOffset) - (stack.value+prevY) * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1);
//y2 = isRange ? (chartHeight+chartHeightOffset) - prevY * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1) : (chartHeight+chartHeightOffset);
y2 = isRange ? (chartHeight+chartHeightOffset) - prevY * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1) : (chartHeight+chartHeightOffset);
prevY += stack.value;
paths.push({path: makeBarPath(x1, y1, y2, barWidth), color: stack.color});
barCords.push({x1: x1, x2: x1+barWidth, y1: y1, y2: y2});
});
});
return {
//path: pathStr.join(' '),
path: paths,
width: fullWidth,
maxScroll: fullWidth - width,
barCords: barCords
};
} | [
"function",
"makeStackedBarsChartPath",
"(",
"chart",
",",
"width",
",",
"t",
",",
"maxValue",
",",
"chartHeight",
",",
"chartHeightOffset",
",",
"markerRadius",
",",
"pointsOnScreen",
",",
"paddingLeft",
",",
"yAxisWidth",
",",
"isRange",
")",
"{",
"let",
"heig... | Make like candle-stick, where each stck is its own Shape | [
"Make",
"like",
"candle",
"-",
"stick",
"where",
"each",
"stck",
"is",
"its",
"own",
"Shape"
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L316-L350 |
31,652 | redpandatronicsuk/arty-charty | arty-charty/util.js | makeAreaChartPath | function makeAreaChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen) {
return makeLineOrAreaChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, true, false);
} | javascript | function makeAreaChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen) {
return makeLineOrAreaChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, true, false);
} | [
"function",
"makeAreaChartPath",
"(",
"chart",
",",
"width",
",",
"t",
",",
"maxValue",
",",
"chartHeight",
",",
"chartHeightOffset",
",",
"markerRadius",
",",
"pointsOnScreen",
")",
"{",
"return",
"makeLineOrAreaChartPath",
"(",
"chart",
",",
"width",
",",
"t",... | Wrapper function for makeLineOrAreaChartPath to make a line chart. | [
"Wrapper",
"function",
"for",
"makeLineOrAreaChartPath",
"to",
"make",
"a",
"line",
"chart",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L479-L481 |
31,653 | redpandatronicsuk/arty-charty | arty-charty/util.js | makeLineChartPath | function makeLineChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen) {
return makeLineOrAreaChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, false, false);
} | javascript | function makeLineChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen) {
return makeLineOrAreaChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, false, false);
} | [
"function",
"makeLineChartPath",
"(",
"chart",
",",
"width",
",",
"t",
",",
"maxValue",
",",
"chartHeight",
",",
"chartHeightOffset",
",",
"markerRadius",
",",
"pointsOnScreen",
")",
"{",
"return",
"makeLineOrAreaChartPath",
"(",
"chart",
",",
"width",
",",
"t",... | Wrapper function for makeLineOrAreaChartPath to make an area chart. | [
"Wrapper",
"function",
"for",
"makeLineOrAreaChartPath",
"to",
"make",
"an",
"area",
"chart",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L490-L492 |
31,654 | redpandatronicsuk/arty-charty | arty-charty/util.js | makeLineOrAreaChartPath | function makeLineOrAreaChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, makeArea, isRange) {
let heightScaler = (chartHeight-markerRadius)/maxValue;
let xSpacing = width / pointsOnScreen;
let centeriser = xSpacing / 2 - markerRadius;
let fullWidth = xSpacing*(chart.data.length-1) + markerRadius + centeriser;
let lineStrArray = makeArea && !isRange ? ['M' + markerRadius, chartHeight+chartHeightOffset] : [];
if (isRange) {
lineStrArray.push('M');
lineStrArray.push(makeXcord(chart, fullWidth, t, centeriser, markerRadius));
lineStrArray.push((chartHeight+chartHeightOffset) - chart.data[0].value * heightScaler * (chart.timingFunctions ? chart.timingFunctions[0 % chart.timingFunctions.length](t) : 1));
}
let xCord;
let lowCords = [];
chart.data.some((d, idx) => {
let spacing = idx*xSpacing + centeriser;
if (spacing > fullWidth * t && chart.drawChart) {
return true;
}
xCord = makeXcord(chart, fullWidth, t, spacing, markerRadius);
// Move line to to next x-coordinate:
lineStrArray.push((idx > 0 || makeArea ? 'L' : 'M') + xCord);
// And y-cordinate:
let yCord = (chartHeight+chartHeightOffset) - d.value * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1);
lineStrArray.push(yCord);
if (isRange) {
let yCordLow = (chartHeight+chartHeightOffset) - d.valueLow * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1);
lowCords.unshift({xCord, yCordLow});
}
});
if (makeArea) {
if (isRange) {
lowCords.forEach((d) => {
lineStrArray.push('L' + d.xCord);
lineStrArray.push(d.yCordLow);
});
// lineStrArray.push('L' + makeXcord(chart, fullWidth, t, xSpacing + centeriser, markerRadius));
// lineStrArray.push(d.yCordLow);
} else {
lineStrArray.push('L' + xCord);
lineStrArray.push(chartHeight + chartHeightOffset);
}
lineStrArray.push('Z');
}
return {
path: lineStrArray.join(' '),
width: xCord + markerRadius,
maxScroll: fullWidth - xSpacing + markerRadius
};
} | javascript | function makeLineOrAreaChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, makeArea, isRange) {
let heightScaler = (chartHeight-markerRadius)/maxValue;
let xSpacing = width / pointsOnScreen;
let centeriser = xSpacing / 2 - markerRadius;
let fullWidth = xSpacing*(chart.data.length-1) + markerRadius + centeriser;
let lineStrArray = makeArea && !isRange ? ['M' + markerRadius, chartHeight+chartHeightOffset] : [];
if (isRange) {
lineStrArray.push('M');
lineStrArray.push(makeXcord(chart, fullWidth, t, centeriser, markerRadius));
lineStrArray.push((chartHeight+chartHeightOffset) - chart.data[0].value * heightScaler * (chart.timingFunctions ? chart.timingFunctions[0 % chart.timingFunctions.length](t) : 1));
}
let xCord;
let lowCords = [];
chart.data.some((d, idx) => {
let spacing = idx*xSpacing + centeriser;
if (spacing > fullWidth * t && chart.drawChart) {
return true;
}
xCord = makeXcord(chart, fullWidth, t, spacing, markerRadius);
// Move line to to next x-coordinate:
lineStrArray.push((idx > 0 || makeArea ? 'L' : 'M') + xCord);
// And y-cordinate:
let yCord = (chartHeight+chartHeightOffset) - d.value * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1);
lineStrArray.push(yCord);
if (isRange) {
let yCordLow = (chartHeight+chartHeightOffset) - d.valueLow * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1);
lowCords.unshift({xCord, yCordLow});
}
});
if (makeArea) {
if (isRange) {
lowCords.forEach((d) => {
lineStrArray.push('L' + d.xCord);
lineStrArray.push(d.yCordLow);
});
// lineStrArray.push('L' + makeXcord(chart, fullWidth, t, xSpacing + centeriser, markerRadius));
// lineStrArray.push(d.yCordLow);
} else {
lineStrArray.push('L' + xCord);
lineStrArray.push(chartHeight + chartHeightOffset);
}
lineStrArray.push('Z');
}
return {
path: lineStrArray.join(' '),
width: xCord + markerRadius,
maxScroll: fullWidth - xSpacing + markerRadius
};
} | [
"function",
"makeLineOrAreaChartPath",
"(",
"chart",
",",
"width",
",",
"t",
",",
"maxValue",
",",
"chartHeight",
",",
"chartHeightOffset",
",",
"markerRadius",
",",
"pointsOnScreen",
",",
"makeArea",
",",
"isRange",
")",
"{",
"let",
"heightScaler",
"=",
"(",
... | Generate the SVG path for a line or area chart.
@param {object} chart The chart object
@param {number} width Width of the chart in pixels
@param {number} t Scale parameter (range: 0-1), used for
animating the graph
@param {number} maxValue The maximum value of chart data
@param {number} chartHeight Height of the chart in pixels
@param {number} chartHeightOffset By how much to offset the chart height.
Note: The negation of this number is as
the marginTop for the component.
This is done so when the graph is
animated, overflow is not cut off.
@param {number} markerRadius Radius of the markers on the line (needed here so we can add it to the width of the chart element, maybe change name to something better such as padding!!!!)
@param {number} pointsOnScreen The number of points to show on the screen
without having to scroll. Used to calculate
the horizontal spacing between points. (maybe find better name????)
@param {boolean} makeArea Wether to close the line (make it an
area chart) or not. | [
"Generate",
"the",
"SVG",
"path",
"for",
"a",
"line",
"or",
"area",
"chart",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L515-L564 |
31,655 | redpandatronicsuk/arty-charty | arty-charty/util.js | makeSplineChartPath | function makeSplineChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, closePath) {
let heightScaler = (chartHeight-markerRadius)/maxValue;
let xSpacing = width / pointsOnScreen;
let centeriser = xSpacing / 2 - markerRadius;
let fullWidth = xSpacing*(chart.data.length-1) + markerRadius + centeriser;
let xCord;
let xCords = [];
let yCords = [];
chart.data.forEach((d, idx) => {
let spacing = idx*xSpacing + centeriser;
if (spacing > fullWidth * t && chart.drawChart) {
return true;
}
xCord = makeXcord(chart, fullWidth, t, spacing, markerRadius);
xCords.push(xCord);
yCords.push((chartHeight+chartHeightOffset) - d.value * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1));
});
let px = computeSplineControlPoints(xCords);
let py = computeSplineControlPoints(yCords);
let splines = [`M ${xCords[0]} ${yCords[0]}`];
for (i=0;i<xCords.length-1;i++) {
splines.push(makeSpline(xCords[i],yCords[i],px.p1[i],py.p1[i],px.p2[i],py.p2[i],xCords[i+1],yCords[i+1]));
}
if (closePath) { // close for area spline graph
splines.push(`V ${chartHeight+chartHeightOffset} H ${xCords[0]} Z`);
}
return {
path: splines.join(','),
width: xCords.slice(-1) + markerRadius,
maxScroll: fullWidth - xSpacing + markerRadius
};
} | javascript | function makeSplineChartPath(chart, width, t, maxValue, chartHeight, chartHeightOffset, markerRadius, pointsOnScreen, closePath) {
let heightScaler = (chartHeight-markerRadius)/maxValue;
let xSpacing = width / pointsOnScreen;
let centeriser = xSpacing / 2 - markerRadius;
let fullWidth = xSpacing*(chart.data.length-1) + markerRadius + centeriser;
let xCord;
let xCords = [];
let yCords = [];
chart.data.forEach((d, idx) => {
let spacing = idx*xSpacing + centeriser;
if (spacing > fullWidth * t && chart.drawChart) {
return true;
}
xCord = makeXcord(chart, fullWidth, t, spacing, markerRadius);
xCords.push(xCord);
yCords.push((chartHeight+chartHeightOffset) - d.value * heightScaler * (chart.timingFunctions ? chart.timingFunctions[idx % chart.timingFunctions.length](t) : 1));
});
let px = computeSplineControlPoints(xCords);
let py = computeSplineControlPoints(yCords);
let splines = [`M ${xCords[0]} ${yCords[0]}`];
for (i=0;i<xCords.length-1;i++) {
splines.push(makeSpline(xCords[i],yCords[i],px.p1[i],py.p1[i],px.p2[i],py.p2[i],xCords[i+1],yCords[i+1]));
}
if (closePath) { // close for area spline graph
splines.push(`V ${chartHeight+chartHeightOffset} H ${xCords[0]} Z`);
}
return {
path: splines.join(','),
width: xCords.slice(-1) + markerRadius,
maxScroll: fullWidth - xSpacing + markerRadius
};
} | [
"function",
"makeSplineChartPath",
"(",
"chart",
",",
"width",
",",
"t",
",",
"maxValue",
",",
"chartHeight",
",",
"chartHeightOffset",
",",
"markerRadius",
",",
"pointsOnScreen",
",",
"closePath",
")",
"{",
"let",
"heightScaler",
"=",
"(",
"chartHeight",
"-",
... | Generate the SVG path for a spline or spline-area chart.
@param {object} chart The chart object
@param {number} width Width of the chart in pixels
@param {number} t Scale parameter (range: 0-1), used for
animating the graph
@param {number} maxValue The maximum value of chart data
@param {number} chartHeight Height of the chart in pixels
@param {number} chartHeightOffset By how much to offset the chart height.
Note: The negation of this number is as
the marginTop for the component.
This is done so when the graph is
animated, overflow is not cut off.
@param {number} markerRadius Radius of the markers on the line (needed here so we can add it to the width of the chart element, maybe change name to something better such as padding!!!!)
@param {number} pointsOnScreen The number of points to show on the screen
without having to scroll. Used to calculate
the horizontal spacing between points. (maybe find better name????)
@param {boolean} closePath Wether to close the spline (make it an
area chart) or not. | [
"Generate",
"the",
"SVG",
"path",
"for",
"a",
"spline",
"or",
"spline",
"-",
"area",
"chart",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L613-L645 |
31,656 | redpandatronicsuk/arty-charty | arty-charty/util.js | rgbaToHsla | function rgbaToHsla(h, s, l, a) {
return [...rgbToHsl(h,s,l), a];
} | javascript | function rgbaToHsla(h, s, l, a) {
return [...rgbToHsl(h,s,l), a];
} | [
"function",
"rgbaToHsla",
"(",
"h",
",",
"s",
",",
"l",
",",
"a",
")",
"{",
"return",
"[",
"...",
"rgbToHsl",
"(",
"h",
",",
"s",
",",
"l",
")",
",",
"a",
"]",
";",
"}"
] | Converts a RGBA colour to HSLA. | [
"Converts",
"a",
"RGBA",
"colour",
"to",
"HSLA",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L739-L741 |
31,657 | redpandatronicsuk/arty-charty | arty-charty/util.js | inerpolateColorsFixedAlpha | function inerpolateColorsFixedAlpha(col1, col2, amount, alpha) {
let col1rgb = parseColor(col1);
let col2rgb = parseColor(col2);
return RGBobj2string({
r: Math.min(255, col1rgb.r * amount + col2rgb.r * Math.max(0,1-amount)),
g: Math.min(255, col1rgb.g * amount + col2rgb.g * Math.max(0,1-amount)),
b: Math.min(255, col1rgb.b * amount + col2rgb.b * Math.max(0,1-amount)),
a: alpha
});
} | javascript | function inerpolateColorsFixedAlpha(col1, col2, amount, alpha) {
let col1rgb = parseColor(col1);
let col2rgb = parseColor(col2);
return RGBobj2string({
r: Math.min(255, col1rgb.r * amount + col2rgb.r * Math.max(0,1-amount)),
g: Math.min(255, col1rgb.g * amount + col2rgb.g * Math.max(0,1-amount)),
b: Math.min(255, col1rgb.b * amount + col2rgb.b * Math.max(0,1-amount)),
a: alpha
});
} | [
"function",
"inerpolateColorsFixedAlpha",
"(",
"col1",
",",
"col2",
",",
"amount",
",",
"alpha",
")",
"{",
"let",
"col1rgb",
"=",
"parseColor",
"(",
"col1",
")",
";",
"let",
"col2rgb",
"=",
"parseColor",
"(",
"col2",
")",
";",
"return",
"RGBobj2string",
"(... | Interpolate two colours and set the alpha value. | [
"Interpolate",
"two",
"colours",
"and",
"set",
"the",
"alpha",
"value",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L863-L872 |
31,658 | redpandatronicsuk/arty-charty | arty-charty/util.js | shadeColor | function shadeColor(col, amount) {
let col1rgb = parseColor(col);
return RGBobj2string({
r: Math.min(255, col1rgb.r * amount + 0 * Math.max(0,1-amount)),
g: Math.min(255, col1rgb.g * amount + 0 * Math.max(0,1-amount)),
b: Math.min(255, col1rgb.b * amount + 0 * Math.max(0,1-amount)),
a: col1rgb.a
});
} | javascript | function shadeColor(col, amount) {
let col1rgb = parseColor(col);
return RGBobj2string({
r: Math.min(255, col1rgb.r * amount + 0 * Math.max(0,1-amount)),
g: Math.min(255, col1rgb.g * amount + 0 * Math.max(0,1-amount)),
b: Math.min(255, col1rgb.b * amount + 0 * Math.max(0,1-amount)),
a: col1rgb.a
});
} | [
"function",
"shadeColor",
"(",
"col",
",",
"amount",
")",
"{",
"let",
"col1rgb",
"=",
"parseColor",
"(",
"col",
")",
";",
"return",
"RGBobj2string",
"(",
"{",
"r",
":",
"Math",
".",
"min",
"(",
"255",
",",
"col1rgb",
".",
"r",
"*",
"amount",
"+",
"... | Shade the colour by the given amount. | [
"Shade",
"the",
"colour",
"by",
"the",
"given",
"amount",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L877-L885 |
31,659 | redpandatronicsuk/arty-charty | arty-charty/util.js | lightenColor | function lightenColor(col, amount) {
let colRgba = parseColor(col);
let colHsla = rgbaToHsla(colRgba.r, colRgba.g, colRgba.b, colRgba.a);
colRgba = hslaToRgba(colHsla[0],colHsla[1],Math.min(Math.max(colHsla[2]+amount, 0), 1),colHsla[3]);
return RGBobj2string({
r: colRgba[0],
g: colRgba[1],
b: colRgba[2],
a: colRgba[3]
});
} | javascript | function lightenColor(col, amount) {
let colRgba = parseColor(col);
let colHsla = rgbaToHsla(colRgba.r, colRgba.g, colRgba.b, colRgba.a);
colRgba = hslaToRgba(colHsla[0],colHsla[1],Math.min(Math.max(colHsla[2]+amount, 0), 1),colHsla[3]);
return RGBobj2string({
r: colRgba[0],
g: colRgba[1],
b: colRgba[2],
a: colRgba[3]
});
} | [
"function",
"lightenColor",
"(",
"col",
",",
"amount",
")",
"{",
"let",
"colRgba",
"=",
"parseColor",
"(",
"col",
")",
";",
"let",
"colHsla",
"=",
"rgbaToHsla",
"(",
"colRgba",
".",
"r",
",",
"colRgba",
".",
"g",
",",
"colRgba",
".",
"b",
",",
"colRg... | Increase colour lightness by the given amount. | [
"Increase",
"colour",
"lightness",
"by",
"the",
"given",
"amount",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L903-L913 |
31,660 | redpandatronicsuk/arty-charty | arty-charty/util.js | hueshiftColor | function hueshiftColor(col, amount) {
let colRgba = parseColor(col);
let colHsla = rgbaToHsla(colRgba.r, colRgba.g, colRgba.b, colRgba.a);
colRgba = hslaToRgba((hsl[0] + amount) % 1, colHsla[1], colHsla[2],colHsla[3]);
return RGBobj2string({
r: colRgba[0],
g: colRgba[1],
b: colRgba[2],
a: colRgba[3]
});
} | javascript | function hueshiftColor(col, amount) {
let colRgba = parseColor(col);
let colHsla = rgbaToHsla(colRgba.r, colRgba.g, colRgba.b, colRgba.a);
colRgba = hslaToRgba((hsl[0] + amount) % 1, colHsla[1], colHsla[2],colHsla[3]);
return RGBobj2string({
r: colRgba[0],
g: colRgba[1],
b: colRgba[2],
a: colRgba[3]
});
} | [
"function",
"hueshiftColor",
"(",
"col",
",",
"amount",
")",
"{",
"let",
"colRgba",
"=",
"parseColor",
"(",
"col",
")",
";",
"let",
"colHsla",
"=",
"rgbaToHsla",
"(",
"colRgba",
".",
"r",
",",
"colRgba",
".",
"g",
",",
"colRgba",
".",
"b",
",",
"colR... | Hue shift colour by a given amount. | [
"Hue",
"shift",
"colour",
"by",
"a",
"given",
"amount",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L933-L943 |
31,661 | redpandatronicsuk/arty-charty | arty-charty/util.js | getMaxSumStack | function getMaxSumStack(arr) { //here!!!
let maxValue = Number.MIN_VALUE;
arr
.forEach((d) => {
let stackSum = computeArrayValueSum(d);
if (stackSum > maxValue) {
maxValue = stackSum;
}
});
return maxValue;
} | javascript | function getMaxSumStack(arr) { //here!!!
let maxValue = Number.MIN_VALUE;
arr
.forEach((d) => {
let stackSum = computeArrayValueSum(d);
if (stackSum > maxValue) {
maxValue = stackSum;
}
});
return maxValue;
} | [
"function",
"getMaxSumStack",
"(",
"arr",
")",
"{",
"//here!!!",
"let",
"maxValue",
"=",
"Number",
".",
"MIN_VALUE",
";",
"arr",
".",
"forEach",
"(",
"(",
"d",
")",
"=>",
"{",
"let",
"stackSum",
"=",
"computeArrayValueSum",
"(",
"d",
")",
";",
"if",
"(... | Find maximum stacksum | [
"Find",
"maximum",
"stacksum"
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L999-L1009 |
31,662 | redpandatronicsuk/arty-charty | arty-charty/util.js | getMinMaxValuesXY | function getMinMaxValuesXY(arr) {
let maxValueX = Number.MIN_VALUE;
let maxValueY = Number.MIN_VALUE;
let minValueX = Number.MAX_VALUE;
let minValueY = Number.MAX_VALUE;
arr
.forEach((d) => {
if (d.x > maxValueX) {
maxValueX = d.x;
}
if (d.x < minValueX) {
minValueX = d.x;
}
if (d.y > maxValueY) {
maxValueY = d.y;
}
if (d.y < minValueY) {
minValueY = d.y;
}
});
return {maxValueX, minValueX, maxValueY, minValueY};
} | javascript | function getMinMaxValuesXY(arr) {
let maxValueX = Number.MIN_VALUE;
let maxValueY = Number.MIN_VALUE;
let minValueX = Number.MAX_VALUE;
let minValueY = Number.MAX_VALUE;
arr
.forEach((d) => {
if (d.x > maxValueX) {
maxValueX = d.x;
}
if (d.x < minValueX) {
minValueX = d.x;
}
if (d.y > maxValueY) {
maxValueY = d.y;
}
if (d.y < minValueY) {
minValueY = d.y;
}
});
return {maxValueX, minValueX, maxValueY, minValueY};
} | [
"function",
"getMinMaxValuesXY",
"(",
"arr",
")",
"{",
"let",
"maxValueX",
"=",
"Number",
".",
"MIN_VALUE",
";",
"let",
"maxValueY",
"=",
"Number",
".",
"MIN_VALUE",
";",
"let",
"minValueX",
"=",
"Number",
".",
"MAX_VALUE",
";",
"let",
"minValueY",
"=",
"N... | Find minimum and maximum X and Y values in an array of
XY coordinate objects | [
"Find",
"minimum",
"and",
"maximum",
"X",
"and",
"Y",
"values",
"in",
"an",
"array",
"of",
"XY",
"coordinate",
"objects"
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L1027-L1048 |
31,663 | redpandatronicsuk/arty-charty | arty-charty/util.js | getMinMaxValuesCandlestick | function getMinMaxValuesCandlestick(arr) {
let maxValue = Number.MIN_VALUE;
let minValue = Number.MAX_VALUE;
arr
.forEach((d) => {
if (d.high > maxValue) {
maxValue = d.high;
}
if (d.low < minValue) {
minValue = d.low;
}
});
return {maxValue, minValue};
} | javascript | function getMinMaxValuesCandlestick(arr) {
let maxValue = Number.MIN_VALUE;
let minValue = Number.MAX_VALUE;
arr
.forEach((d) => {
if (d.high > maxValue) {
maxValue = d.high;
}
if (d.low < minValue) {
minValue = d.low;
}
});
return {maxValue, minValue};
} | [
"function",
"getMinMaxValuesCandlestick",
"(",
"arr",
")",
"{",
"let",
"maxValue",
"=",
"Number",
".",
"MIN_VALUE",
";",
"let",
"minValue",
"=",
"Number",
".",
"MAX_VALUE",
";",
"arr",
".",
"forEach",
"(",
"(",
"d",
")",
"=>",
"{",
"if",
"(",
"d",
".",... | Find minimum and maximum value in an array of candlestick objects | [
"Find",
"minimum",
"and",
"maximum",
"value",
"in",
"an",
"array",
"of",
"candlestick",
"objects"
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L1053-L1066 |
31,664 | redpandatronicsuk/arty-charty | arty-charty/util.js | findRectangleIndexContainingPoint | function findRectangleIndexContainingPoint(rectangles, x, y) {
let closestIdx;
rectangles.some((d, idx) => {
if ((d.x1 <= x && x <= d.x2) && (d.y1 <= y && y <= d.y2)) {
closestIdx = idx;
return true;
}
return false;
});
return closestIdx;
} | javascript | function findRectangleIndexContainingPoint(rectangles, x, y) {
let closestIdx;
rectangles.some((d, idx) => {
if ((d.x1 <= x && x <= d.x2) && (d.y1 <= y && y <= d.y2)) {
closestIdx = idx;
return true;
}
return false;
});
return closestIdx;
} | [
"function",
"findRectangleIndexContainingPoint",
"(",
"rectangles",
",",
"x",
",",
"y",
")",
"{",
"let",
"closestIdx",
";",
"rectangles",
".",
"some",
"(",
"(",
"d",
",",
"idx",
")",
"=>",
"{",
"if",
"(",
"(",
"d",
".",
"x1",
"<=",
"x",
"&&",
"x",
... | Find the index of the rectangle that contains a given
coordinate.
@param {array} points - Array of rectangles, each rectangle is of the form
{x1: number, x2: number, y1: number, y2: number},
where x1 and x2 are the minimum and maximum x coordinates
and y1 and y3 are the minimum and maximum x coordinates.
@param {number} x - The x coordinate
@param {number} y - The y coordinate | [
"Find",
"the",
"index",
"of",
"the",
"rectangle",
"that",
"contains",
"a",
"given",
"coordinate",
"."
] | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L1091-L1101 |
31,665 | redpandatronicsuk/arty-charty | arty-charty/util.js | findClosestPointIndexWithinRadius | function findClosestPointIndexWithinRadius(points, x, y, radiusThreshold) {
let closestIdx;
let closestDist = Number.MAX_VALUE;
points.forEach((d, idx) => {
let distSqrd = Math.pow(d.x - x, 2) + Math.pow(d.y - y, 2); // changeto: (d.x - x)**2 + (d.y - y)**2;
if (distSqrd < closestDist && distSqrd < radiusThreshold) {
closestIdx = idx;
closestDist = distSqrd;
}
});
return closestIdx;
} | javascript | function findClosestPointIndexWithinRadius(points, x, y, radiusThreshold) {
let closestIdx;
let closestDist = Number.MAX_VALUE;
points.forEach((d, idx) => {
let distSqrd = Math.pow(d.x - x, 2) + Math.pow(d.y - y, 2); // changeto: (d.x - x)**2 + (d.y - y)**2;
if (distSqrd < closestDist && distSqrd < radiusThreshold) {
closestIdx = idx;
closestDist = distSqrd;
}
});
return closestIdx;
} | [
"function",
"findClosestPointIndexWithinRadius",
"(",
"points",
",",
"x",
",",
"y",
",",
"radiusThreshold",
")",
"{",
"let",
"closestIdx",
";",
"let",
"closestDist",
"=",
"Number",
".",
"MAX_VALUE",
";",
"points",
".",
"forEach",
"(",
"(",
"d",
",",
"idx",
... | Find the index of the closest coordinate to a
reference coordinate in an array of coordinates.
If no point is found within the threshold distance
undefined is returned. | [
"Find",
"the",
"index",
"of",
"the",
"closest",
"coordinate",
"to",
"a",
"reference",
"coordinate",
"in",
"an",
"array",
"of",
"coordinates",
".",
"If",
"no",
"point",
"is",
"found",
"within",
"the",
"threshold",
"distance",
"undefined",
"is",
"returned",
".... | d0b90b42de9f4360343e25e918358e9b331f080d | https://github.com/redpandatronicsuk/arty-charty/blob/d0b90b42de9f4360343e25e918358e9b331f080d/arty-charty/util.js#L1109-L1120 |
31,666 | Kronos-Integration/kronos-interceptor-object-data-processor-row | lib/util/property-helper.js | function (fieldDefinition) {
let type = fieldDefinition.fieldType;
if (typeof type === 'object') {
type = fieldDefinition.fieldType.type;
}
return type;
} | javascript | function (fieldDefinition) {
let type = fieldDefinition.fieldType;
if (typeof type === 'object') {
type = fieldDefinition.fieldType.type;
}
return type;
} | [
"function",
"(",
"fieldDefinition",
")",
"{",
"let",
"type",
"=",
"fieldDefinition",
".",
"fieldType",
";",
"if",
"(",
"typeof",
"type",
"===",
"'object'",
")",
"{",
"type",
"=",
"fieldDefinition",
".",
"fieldType",
".",
"type",
";",
"}",
"return",
"type",... | Returns the severity for a check property. The severity may be defined globaly
for the complete field, but also may be defined on a per check basis
@param fieldDefinition The field_definition | [
"Returns",
"the",
"severity",
"for",
"a",
"check",
"property",
".",
"The",
"severity",
"may",
"be",
"defined",
"globaly",
"for",
"the",
"complete",
"field",
"but",
"also",
"may",
"be",
"defined",
"on",
"a",
"per",
"check",
"basis"
] | 678a59b84dab4a9082377c90849a0d62d97a1ea4 | https://github.com/Kronos-Integration/kronos-interceptor-object-data-processor-row/blob/678a59b84dab4a9082377c90849a0d62d97a1ea4/lib/util/property-helper.js#L87-L93 | |
31,667 | sociomantic-tsunami/lochness | webpack.config.js | buildConfig | function buildConfig( wantedEnv )
{
const isValid = wantedEnv &&
wantedEnv.length > 0 && allowedEnvs.indexOf( wantedEnv ) !== -1;
const validEnv = isValid ? wantedEnv : 'dev';
return configs[ validEnv ];
} | javascript | function buildConfig( wantedEnv )
{
const isValid = wantedEnv &&
wantedEnv.length > 0 && allowedEnvs.indexOf( wantedEnv ) !== -1;
const validEnv = isValid ? wantedEnv : 'dev';
return configs[ validEnv ];
} | [
"function",
"buildConfig",
"(",
"wantedEnv",
")",
"{",
"const",
"isValid",
"=",
"wantedEnv",
"&&",
"wantedEnv",
".",
"length",
">",
"0",
"&&",
"allowedEnvs",
".",
"indexOf",
"(",
"wantedEnv",
")",
"!==",
"-",
"1",
";",
"const",
"validEnv",
"=",
"isValid",
... | Build the webpack configuration
@param {String} wantedEnv The wanted environment
@return {Object} Webpack config | [
"Build",
"the",
"webpack",
"configuration"
] | cf71d6608ce2cdc6d745195a90c815304b8f0f6f | https://github.com/sociomantic-tsunami/lochness/blob/cf71d6608ce2cdc6d745195a90c815304b8f0f6f/webpack.config.js#L37-L45 |
31,668 | yhtml5/yhtml5-cli | packages/yhtml5-cli/lib/generate.js | generate | function generate (projectPatch, source, done) {
shell.mkdir('-p', projectPatch)
shell.cp('-Rf', source, projectPatch)
done()
} | javascript | function generate (projectPatch, source, done) {
shell.mkdir('-p', projectPatch)
shell.cp('-Rf', source, projectPatch)
done()
} | [
"function",
"generate",
"(",
"projectPatch",
",",
"source",
",",
"done",
")",
"{",
"shell",
".",
"mkdir",
"(",
"'-p'",
",",
"projectPatch",
")",
"shell",
".",
"cp",
"(",
"'-Rf'",
",",
"source",
",",
"projectPatch",
")",
"done",
"(",
")",
"}"
] | Generate a template given a `src` and `dest`.
@param {String} projectPatch
@param {String} source
@param {Function} done | [
"Generate",
"a",
"template",
"given",
"a",
"src",
"and",
"dest",
"."
] | 521a8ad160058e453dff87c7cc9bfb16215715c6 | https://github.com/yhtml5/yhtml5-cli/blob/521a8ad160058e453dff87c7cc9bfb16215715c6/packages/yhtml5-cli/lib/generate.js#L12-L16 |
31,669 | feedhenry/fh-mbaas-express | lib/common/authenticate.js | getCacheRefreshInterval | function getCacheRefreshInterval() {
var value = parseInt(process.env[CACHE_REFRESH_KEY]);
// Should we 0 here to invalidate the cache immediately?
if (value && !isNaN(value) && value > 0) {
return value;
}
return DEFAULT_CACHE_REFRESH_SECONDS;
} | javascript | function getCacheRefreshInterval() {
var value = parseInt(process.env[CACHE_REFRESH_KEY]);
// Should we 0 here to invalidate the cache immediately?
if (value && !isNaN(value) && value > 0) {
return value;
}
return DEFAULT_CACHE_REFRESH_SECONDS;
} | [
"function",
"getCacheRefreshInterval",
"(",
")",
"{",
"var",
"value",
"=",
"parseInt",
"(",
"process",
".",
"env",
"[",
"CACHE_REFRESH_KEY",
"]",
")",
";",
"// Should we 0 here to invalidate the cache immediately?",
"if",
"(",
"value",
"&&",
"!",
"isNaN",
"(",
"va... | The refresh interval of the authentication cache should be configurable. Since
this is running inside a cloud app the best option is th use an environment
variable.
@returns {*} | [
"The",
"refresh",
"interval",
"of",
"the",
"authentication",
"cache",
"should",
"be",
"configurable",
".",
"Since",
"this",
"is",
"running",
"inside",
"a",
"cloud",
"app",
"the",
"best",
"option",
"is",
"th",
"use",
"an",
"environment",
"variable",
"."
] | 381c2a5842b49a4cbc4519d55b9a3c870b364d3c | https://github.com/feedhenry/fh-mbaas-express/blob/381c2a5842b49a4cbc4519d55b9a3c870b364d3c/lib/common/authenticate.js#L357-L366 |
31,670 | scijs/cwise-parser | index.js | createLocal | function createLocal(id) {
var nstr = prefix + id.replace(/\_/g, "__")
localVars.push(nstr)
return nstr
} | javascript | function createLocal(id) {
var nstr = prefix + id.replace(/\_/g, "__")
localVars.push(nstr)
return nstr
} | [
"function",
"createLocal",
"(",
"id",
")",
"{",
"var",
"nstr",
"=",
"prefix",
"+",
"id",
".",
"replace",
"(",
"/",
"\\_",
"/",
"g",
",",
"\"__\"",
")",
"localVars",
".",
"push",
"(",
"nstr",
")",
"return",
"nstr",
"}"
] | Retrieves a local variable | [
"Retrieves",
"a",
"local",
"variable"
] | 6b9cbce6ebb6b66051226df75627f740b7ecdcc8 | https://github.com/scijs/cwise-parser/blob/6b9cbce6ebb6b66051226df75627f740b7ecdcc8/index.js#L72-L76 |
31,671 | scijs/cwise-parser | index.js | createThisVar | function createThisVar(id) {
var nstr = "this_" + id.replace(/\_/g, "__")
thisVars.push(nstr)
return nstr
} | javascript | function createThisVar(id) {
var nstr = "this_" + id.replace(/\_/g, "__")
thisVars.push(nstr)
return nstr
} | [
"function",
"createThisVar",
"(",
"id",
")",
"{",
"var",
"nstr",
"=",
"\"this_\"",
"+",
"id",
".",
"replace",
"(",
"/",
"\\_",
"/",
"g",
",",
"\"__\"",
")",
"thisVars",
".",
"push",
"(",
"nstr",
")",
"return",
"nstr",
"}"
] | Creates a this variable | [
"Creates",
"a",
"this",
"variable"
] | 6b9cbce6ebb6b66051226df75627f740b7ecdcc8 | https://github.com/scijs/cwise-parser/blob/6b9cbce6ebb6b66051226df75627f740b7ecdcc8/index.js#L79-L83 |
31,672 | scijs/cwise-parser | index.js | rewrite | function rewrite(node, nstr) {
var lo = node.range[0], hi = node.range[1]
for(var i=lo+1; i<hi; ++i) {
exploded[i] = ""
}
exploded[lo] = nstr
} | javascript | function rewrite(node, nstr) {
var lo = node.range[0], hi = node.range[1]
for(var i=lo+1; i<hi; ++i) {
exploded[i] = ""
}
exploded[lo] = nstr
} | [
"function",
"rewrite",
"(",
"node",
",",
"nstr",
")",
"{",
"var",
"lo",
"=",
"node",
".",
"range",
"[",
"0",
"]",
",",
"hi",
"=",
"node",
".",
"range",
"[",
"1",
"]",
"for",
"(",
"var",
"i",
"=",
"lo",
"+",
"1",
";",
"i",
"<",
"hi",
";",
... | Rewrites an ast node | [
"Rewrites",
"an",
"ast",
"node"
] | 6b9cbce6ebb6b66051226df75627f740b7ecdcc8 | https://github.com/scijs/cwise-parser/blob/6b9cbce6ebb6b66051226df75627f740b7ecdcc8/index.js#L86-L92 |
31,673 | dowjones/distribucache | lib/CacheClient.js | CacheClient | function CacheClient(store, config) {
EventEmitter.call(this);
this._store = store;
this._config = config || {};
util.propagateEvent(this._store, this, 'error');
this.on('error', unhandledErrorListener);
} | javascript | function CacheClient(store, config) {
EventEmitter.call(this);
this._store = store;
this._config = config || {};
util.propagateEvent(this._store, this, 'error');
this.on('error', unhandledErrorListener);
} | [
"function",
"CacheClient",
"(",
"store",
",",
"config",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_store",
"=",
"store",
";",
"this",
".",
"_config",
"=",
"config",
"||",
"{",
"}",
";",
"util",
".",
"propagateEvent",
... | Create a new cache client,
decorated with the desired features,
based on the provided config.
@constructor
@param {Store} store
@param {Object} [config]
@param {Boolean} [config.isPreconfigured] defaults to false
@param {String} [config.host] defaults to 'localhost'
@param {Number} [config.port] defaults to 6379
@param {String} [config.password]
@param {String} [config.namespace]
@param {Boolean} [config.optimizeForSmallValues] defaults to false
@param {Boolean} [config.optimizeForBuffers] defaults to false
@param {String} [config.expiresIn] in ms
@param {String} [config.staleIn] in ms
@param {Function} [config.populate]
@param {Number} [config.populateIn] in ms, defaults to 30sec
@param {Number} [config.populateInAttempts] defaults to 5
@param {Number} [config.pausePopulateIn] in ms
@param {Number} [config.leaseExpiresIn] in ms
@param {Number} [config.timeoutPopulateIn] in ms
@param {Number} [config.accessedAtThrottle] in ms
@param {Number} [config.namespace] | [
"Create",
"a",
"new",
"cache",
"client",
"decorated",
"with",
"the",
"desired",
"features",
"based",
"on",
"the",
"provided",
"config",
"."
] | ad79caee277771a6e49ee4a98c4983480cd89945 | https://github.com/dowjones/distribucache/blob/ad79caee277771a6e49ee4a98c4983480cd89945/lib/CacheClient.js#L46-L54 |
31,674 | macrat/AsyncMark | src/timer.js | timeit | async function timeit(fun, context={}, args=[]) {
const start = now();
await fun.call(context, ...args);
const end = now();
return end - start;
} | javascript | async function timeit(fun, context={}, args=[]) {
const start = now();
await fun.call(context, ...args);
const end = now();
return end - start;
} | [
"async",
"function",
"timeit",
"(",
"fun",
",",
"context",
"=",
"{",
"}",
",",
"args",
"=",
"[",
"]",
")",
"{",
"const",
"start",
"=",
"now",
"(",
")",
";",
"await",
"fun",
".",
"call",
"(",
"context",
",",
"...",
"args",
")",
";",
"const",
"en... | Measure tiem to execute a function.
wait for done if the target function returns a thenable object. so you can use async function.
NOTE: this function will execute target function only once.
@param {function(): ?Promise} fun - the target function.
@param {Object} [context={}] - the `this` for target function.
@param {Object[]} [args=[]] - arguments to passing to target function.
@return {Promise<Number>} milliseconds taked executing.
@example
const msec = await timeit(function() {
# do something heavy.
});
@example
console.log(await timeit(axios.get, args=['http://example.com']));
@since 0.2.4 | [
"Measure",
"tiem",
"to",
"execute",
"a",
"function",
"."
] | 84ae4130034c47857d0df0e64d43900a18b8b285 | https://github.com/macrat/AsyncMark/blob/84ae4130034c47857d0df0e64d43900a18b8b285/src/timer.js#L79-L85 |
31,675 | SandJS/http | lib/middleware/ai.js | getCache | function getCache() {
return new Promise(function(resolve, reject) {
// create and fetch the cache key
get(getKey(), function(err, data) {
if (err) {
return reject(err);
}
resolve(data);
});
});
} | javascript | function getCache() {
return new Promise(function(resolve, reject) {
// create and fetch the cache key
get(getKey(), function(err, data) {
if (err) {
return reject(err);
}
resolve(data);
});
});
} | [
"function",
"getCache",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// create and fetch the cache key",
"get",
"(",
"getKey",
"(",
")",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(... | Fetches an image buffer from the cache
@returns {Promise} | [
"Fetches",
"an",
"image",
"buffer",
"from",
"the",
"cache"
] | 8f8b4d23eb5f59d802c9537e0ccd67b47fa79d2f | https://github.com/SandJS/http/blob/8f8b4d23eb5f59d802c9537e0ccd67b47fa79d2f/lib/middleware/ai.js#L323-L333 |
31,676 | SandJS/http | lib/middleware/ai.js | putCache | function putCache() {
return new Promise(function(resolve, reject) {
// make the cache key
let key = getKey();
// adapt the image
adapt(function(err, stdout, stderr) {
if (err) {
return reject(err);
}
// convert the new image stream to buffer
stream2buffer(stdout, function(err, buffer) {
if (err) {
return reject(err);
}
if (!buffer || !buffer.length) {
return resolve(buffer);
}
// put the buffer in the cache
put(key, buffer, function(err, data) {
if (err) {
log(`Cache set failure: ${err instanceof Error ? err.message : err}`);
}
// return the buffer
resolve(buffer);
});
});
});
});
} | javascript | function putCache() {
return new Promise(function(resolve, reject) {
// make the cache key
let key = getKey();
// adapt the image
adapt(function(err, stdout, stderr) {
if (err) {
return reject(err);
}
// convert the new image stream to buffer
stream2buffer(stdout, function(err, buffer) {
if (err) {
return reject(err);
}
if (!buffer || !buffer.length) {
return resolve(buffer);
}
// put the buffer in the cache
put(key, buffer, function(err, data) {
if (err) {
log(`Cache set failure: ${err instanceof Error ? err.message : err}`);
}
// return the buffer
resolve(buffer);
});
});
});
});
} | [
"function",
"putCache",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// make the cache key",
"let",
"key",
"=",
"getKey",
"(",
")",
";",
"// adapt the image",
"adapt",
"(",
"function",
"(",
"err",
",... | Creates an adapted image buffer | puts it in the cache | returns the buffer
@returns {Promise} | [
"Creates",
"an",
"adapted",
"image",
"buffer",
"|",
"puts",
"it",
"in",
"the",
"cache",
"|",
"returns",
"the",
"buffer"
] | 8f8b4d23eb5f59d802c9537e0ccd67b47fa79d2f | https://github.com/SandJS/http/blob/8f8b4d23eb5f59d802c9537e0ccd67b47fa79d2f/lib/middleware/ai.js#L340-L373 |
31,677 | SandJS/http | lib/middleware/ai.js | getKey | function getKey() {
let paramString =
width + 'x' + height + '-'
+ path
+ (is2x ? '-@2x' : '')
+ (bg ? `_${bg}` : '')
+ (crop ? '_crop' : '')
+ (mode ? `_${mode}` : '')
+ (trim ? '_trim' : '');
return paramString + '-' + crypto.createHash('sha1').update(paramString).digest('hex');
} | javascript | function getKey() {
let paramString =
width + 'x' + height + '-'
+ path
+ (is2x ? '-@2x' : '')
+ (bg ? `_${bg}` : '')
+ (crop ? '_crop' : '')
+ (mode ? `_${mode}` : '')
+ (trim ? '_trim' : '');
return paramString + '-' + crypto.createHash('sha1').update(paramString).digest('hex');
} | [
"function",
"getKey",
"(",
")",
"{",
"let",
"paramString",
"=",
"width",
"+",
"'x'",
"+",
"height",
"+",
"'-'",
"+",
"path",
"+",
"(",
"is2x",
"?",
"'-@2x'",
":",
"''",
")",
"+",
"(",
"bg",
"?",
"`",
"${",
"bg",
"}",
"`",
":",
"''",
")",
"+",... | Builds a cache key for the adapted image
@returns {string} | [
"Builds",
"a",
"cache",
"key",
"for",
"the",
"adapted",
"image"
] | 8f8b4d23eb5f59d802c9537e0ccd67b47fa79d2f | https://github.com/SandJS/http/blob/8f8b4d23eb5f59d802c9537e0ccd67b47fa79d2f/lib/middleware/ai.js#L380-L391 |
31,678 | Rhinostone/gina | core/controller/controller.js | function(type, resStr, resArr, resObj) {
switch(type){
case 'css':
var css = resObj;
for (var res in resArr) {
//means that you will find options.
if (typeof(resArr[res]) == "object") {
//console.info('found object ', resArr[res]);
css.media = (resArr[res].options.media) ? resArr[res].options.media : css.media;
css.rel = (resArr[res].options.rel) ? resArr[res].options.rel : css.rel;
css.type = (resArr[res].options.type) ? resArr[res].options.type : css.type;
if (!css.content[resArr[res]._]) {
css.content[resArr[res]._] = '<link href="'+ resArr[res]._ +'" media="'+ css.media +'" rel="'+ css.rel +'" type="'+ css.type +'">';
resStr += '\n\t' + css.content[resArr[res]._]
}
} else {
css.content[resArr[res]] = '<link href="'+ resArr[res] +'" media="screen" rel="'+ css.rel +'" type="'+ css.type +'">';
resStr += '\n\t' + css.content[resArr[res]]
}
}
return { css : css, cssStr : resStr }
break;
case 'js':
var js = resObj;
for (var res in resArr) {
//means that you will find options
if ( typeof(resArr[res]) == "object" ) {
js.type = (resArr[res].options.type) ? resArr[res].options.type : js.type;
if (!js.content[resArr[res]._]) {
js.content[resArr[res]._] = '<script type="'+ js.type +'" src="'+ resArr[res]._ +'"></script>';
resStr += '\n' + js.content[resArr[res]._];
}
} else {
js.content[resArr[res]] = '<script type="'+ js.type +'" src="'+ resArr[res] +'"></script>';
resStr += '\n' + js.content[resArr[res]]
}
}
return { js : js, jsStr : resStr }
break;
}
} | javascript | function(type, resStr, resArr, resObj) {
switch(type){
case 'css':
var css = resObj;
for (var res in resArr) {
//means that you will find options.
if (typeof(resArr[res]) == "object") {
//console.info('found object ', resArr[res]);
css.media = (resArr[res].options.media) ? resArr[res].options.media : css.media;
css.rel = (resArr[res].options.rel) ? resArr[res].options.rel : css.rel;
css.type = (resArr[res].options.type) ? resArr[res].options.type : css.type;
if (!css.content[resArr[res]._]) {
css.content[resArr[res]._] = '<link href="'+ resArr[res]._ +'" media="'+ css.media +'" rel="'+ css.rel +'" type="'+ css.type +'">';
resStr += '\n\t' + css.content[resArr[res]._]
}
} else {
css.content[resArr[res]] = '<link href="'+ resArr[res] +'" media="screen" rel="'+ css.rel +'" type="'+ css.type +'">';
resStr += '\n\t' + css.content[resArr[res]]
}
}
return { css : css, cssStr : resStr }
break;
case 'js':
var js = resObj;
for (var res in resArr) {
//means that you will find options
if ( typeof(resArr[res]) == "object" ) {
js.type = (resArr[res].options.type) ? resArr[res].options.type : js.type;
if (!js.content[resArr[res]._]) {
js.content[resArr[res]._] = '<script type="'+ js.type +'" src="'+ resArr[res]._ +'"></script>';
resStr += '\n' + js.content[resArr[res]._];
}
} else {
js.content[resArr[res]] = '<script type="'+ js.type +'" src="'+ resArr[res] +'"></script>';
resStr += '\n' + js.content[resArr[res]]
}
}
return { js : js, jsStr : resStr }
break;
}
} | [
"function",
"(",
"type",
",",
"resStr",
",",
"resArr",
",",
"resObj",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"'css'",
":",
"var",
"css",
"=",
"resObj",
";",
"for",
"(",
"var",
"res",
"in",
"resArr",
")",
"{",
"//means that you will find opt... | Get node resources
@param {string} type
@param {string} resStr
@param {array} resArr
@param {object} resObj
@return {object} content
@private | [
"Get",
"node",
"resources"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/controller/controller.js#L942-L989 | |
31,679 | Rhinostone/gina | core/controller/controller.js | function (i, res, files, cb) {
if (!files.length || files.length == 0) {
cb(false)
} else {
if ( fs.existsSync(files[i].target) ) new _(files[i].target).rmSync();
var sourceStream = fs.createReadStream(files[i].source);
var destinationStream = fs.createWriteStream(files[i].target);
sourceStream
.pipe(destinationStream)
.on('error', function () {
var err = 'Error on SuperController::copyFile(...): Not found ' + files[i].source + ' or ' + files[i].target;
cb(err)
})
.on('close', function () {
try {
fs.unlinkSync(files[i].source);
files.splice(i, 1);
} catch (err) {
cb(err)
}
movefiles(i, res, files, cb)
})
}
} | javascript | function (i, res, files, cb) {
if (!files.length || files.length == 0) {
cb(false)
} else {
if ( fs.existsSync(files[i].target) ) new _(files[i].target).rmSync();
var sourceStream = fs.createReadStream(files[i].source);
var destinationStream = fs.createWriteStream(files[i].target);
sourceStream
.pipe(destinationStream)
.on('error', function () {
var err = 'Error on SuperController::copyFile(...): Not found ' + files[i].source + ' or ' + files[i].target;
cb(err)
})
.on('close', function () {
try {
fs.unlinkSync(files[i].source);
files.splice(i, 1);
} catch (err) {
cb(err)
}
movefiles(i, res, files, cb)
})
}
} | [
"function",
"(",
"i",
",",
"res",
",",
"files",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"files",
".",
"length",
"||",
"files",
".",
"length",
"==",
"0",
")",
"{",
"cb",
"(",
"false",
")",
"}",
"else",
"{",
"if",
"(",
"fs",
".",
"existsSync",
"("... | Move files to assets dir
@param {object} res
@param {collection} files
@callback cb
@param {object} [err] | [
"Move",
"files",
"to",
"assets",
"dir"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/controller/controller.js#L1165-L1192 | |
31,680 | Rhinostone/gina | core/controller/controller.js | function(req) {
req.getParams = function() {
// copy
var params = JSON.parse(JSON.stringify(req.params));
switch( req.method.toLowerCase() ) {
case 'get':
params = merge(params, req.get, true);
break;
case 'post':
params = merge(params, req.post, true);
break;
case 'put':
params = merge(params, req.put, true);
break;
case 'delete':
params = merge(params, req.delete, true);
break;
}
return params
}
req.getParam = function(name) {
// copy
var param = null, params = JSON.parse(JSON.stringify(req.params));
switch( req.method.toLowerCase() ) {
case 'get':
param = req.get[name];
break;
case 'post':
param = req.post[name];
break;
case 'put':
param= req.put[name];
break;
case 'delete':
param = req.delete[name];
break;
}
return param
}
} | javascript | function(req) {
req.getParams = function() {
// copy
var params = JSON.parse(JSON.stringify(req.params));
switch( req.method.toLowerCase() ) {
case 'get':
params = merge(params, req.get, true);
break;
case 'post':
params = merge(params, req.post, true);
break;
case 'put':
params = merge(params, req.put, true);
break;
case 'delete':
params = merge(params, req.delete, true);
break;
}
return params
}
req.getParam = function(name) {
// copy
var param = null, params = JSON.parse(JSON.stringify(req.params));
switch( req.method.toLowerCase() ) {
case 'get':
param = req.get[name];
break;
case 'post':
param = req.post[name];
break;
case 'put':
param= req.put[name];
break;
case 'delete':
param = req.delete[name];
break;
}
return param
}
} | [
"function",
"(",
"req",
")",
"{",
"req",
".",
"getParams",
"=",
"function",
"(",
")",
"{",
"// copy",
"var",
"params",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"req",
".",
"params",
")",
")",
";",
"switch",
"(",
"req",
".",
... | Get all Params | [
"Get",
"all",
"Params"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/controller/controller.js#L1542-L1591 | |
31,681 | Rhinostone/gina | core/controller/controller.js | function (code) {
var list = {}, cde = 'short', name = null;
if ( typeof(code) != 'undefined' && typeof(userLocales[0][code]) == 'string' ) {
cde = code
} else if ( typeof(code) != 'undefined' ) (
console.warn('`'+ code +'` not supported : sticking with `short` code')
)
for ( var i = 0, len = userLocales.length; i< len; ++i ) {
if (userLocales[i][cde]) {
name = userLocales[i].full || userLocales[i].officialName.short;
if ( name )
list[ userLocales[i][cde] ] = name;
}
}
return list
} | javascript | function (code) {
var list = {}, cde = 'short', name = null;
if ( typeof(code) != 'undefined' && typeof(userLocales[0][code]) == 'string' ) {
cde = code
} else if ( typeof(code) != 'undefined' ) (
console.warn('`'+ code +'` not supported : sticking with `short` code')
)
for ( var i = 0, len = userLocales.length; i< len; ++i ) {
if (userLocales[i][cde]) {
name = userLocales[i].full || userLocales[i].officialName.short;
if ( name )
list[ userLocales[i][cde] ] = name;
}
}
return list
} | [
"function",
"(",
"code",
")",
"{",
"var",
"list",
"=",
"{",
"}",
",",
"cde",
"=",
"'short'",
",",
"name",
"=",
"null",
";",
"if",
"(",
"typeof",
"(",
"code",
")",
"!=",
"'undefined'",
"&&",
"typeof",
"(",
"userLocales",
"[",
"0",
"]",
"[",
"code"... | Get countries list
@param {string} [code] - e.g.: short, long, fifa, m49
@return {object} countries - countries code & value list | [
"Get",
"countries",
"list"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/controller/controller.js#L1649-L1670 | |
31,682 | Rhinostone/gina | core/controller/controller.js | function (arr){
var tmp = null,
curObj = {},
obj = {},
count = 0,
data = {},
last = null;
for (var r in arr) {
tmp = r.split(".");
//Creating structure - Adding sub levels
for (var o in tmp) {
count++;
if (last && typeof(obj[last]) == "undefined") {
curObj[last] = {};
if (count >= tmp.length) {
// assigning.
// !!! if null or undefined, it will be ignored while extending.
curObj[last][tmp[o]] = (arr[r]) ? arr[r] : "undefined";
last = null;
count = 0;
break
} else {
curObj[last][tmp[o]] = {}
}
} else if (tmp.length === 1) { //Just one root var
curObj[tmp[o]] = (arr[r]) ? arr[r] : "undefined";
obj = curObj;
break
}
obj = curObj;
last = tmp[o]
}
//data = merge(data, obj, true);
data = merge(obj, data);
obj = {};
curObj = {}
}
return data
} | javascript | function (arr){
var tmp = null,
curObj = {},
obj = {},
count = 0,
data = {},
last = null;
for (var r in arr) {
tmp = r.split(".");
//Creating structure - Adding sub levels
for (var o in tmp) {
count++;
if (last && typeof(obj[last]) == "undefined") {
curObj[last] = {};
if (count >= tmp.length) {
// assigning.
// !!! if null or undefined, it will be ignored while extending.
curObj[last][tmp[o]] = (arr[r]) ? arr[r] : "undefined";
last = null;
count = 0;
break
} else {
curObj[last][tmp[o]] = {}
}
} else if (tmp.length === 1) { //Just one root var
curObj[tmp[o]] = (arr[r]) ? arr[r] : "undefined";
obj = curObj;
break
}
obj = curObj;
last = tmp[o]
}
//data = merge(data, obj, true);
data = merge(obj, data);
obj = {};
curObj = {}
}
return data
} | [
"function",
"(",
"arr",
")",
"{",
"var",
"tmp",
"=",
"null",
",",
"curObj",
"=",
"{",
"}",
",",
"obj",
"=",
"{",
"}",
",",
"count",
"=",
"0",
",",
"data",
"=",
"{",
"}",
",",
"last",
"=",
"null",
";",
"for",
"(",
"var",
"r",
"in",
"arr",
... | converting references to objects | [
"converting",
"references",
"to",
"objects"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/controller/controller.js#L1816-L1854 | |
31,683 | invisible-tech/mongoose-extras | customAsserts/documentAssertions.js | assertSameObjectIdArray | function assertSameObjectIdArray(actual, expected, msg) {
assert(Array.isArray(actual), 'assertSameObjectIdArray: First argument is not an Array.')
assert(Array.isArray(expected), 'assertSameObjectIdArray: Second argument is not an Array.')
assert(size(actual) > 0 || size(expected) > 0, 'assertSameObjectIdArray: Received two empty Arrays.')
assert.strictEqual(size(actual), size(expected), 'assertSameObjectIdArray: arrays different sizes')
const parseIds = flow(map(stringifyObjectId), sortBy(identity))
try { parseIds(actual) } catch (err) { throw Error(`assertSameObjectIdArray 1st argument: ${err.message}`) }
try { parseIds(expected) } catch (err) { throw Error(`assertSameObjectIdArray 2nd argument: ${err.message}`) }
assert.deepStrictEqual(parseIds(actual), parseIds(expected), msg)
} | javascript | function assertSameObjectIdArray(actual, expected, msg) {
assert(Array.isArray(actual), 'assertSameObjectIdArray: First argument is not an Array.')
assert(Array.isArray(expected), 'assertSameObjectIdArray: Second argument is not an Array.')
assert(size(actual) > 0 || size(expected) > 0, 'assertSameObjectIdArray: Received two empty Arrays.')
assert.strictEqual(size(actual), size(expected), 'assertSameObjectIdArray: arrays different sizes')
const parseIds = flow(map(stringifyObjectId), sortBy(identity))
try { parseIds(actual) } catch (err) { throw Error(`assertSameObjectIdArray 1st argument: ${err.message}`) }
try { parseIds(expected) } catch (err) { throw Error(`assertSameObjectIdArray 2nd argument: ${err.message}`) }
assert.deepStrictEqual(parseIds(actual), parseIds(expected), msg)
} | [
"function",
"assertSameObjectIdArray",
"(",
"actual",
",",
"expected",
",",
"msg",
")",
"{",
"assert",
"(",
"Array",
".",
"isArray",
"(",
"actual",
")",
",",
"'assertSameObjectIdArray: First argument is not an Array.'",
")",
"assert",
"(",
"Array",
".",
"isArray",
... | Throws if the given actual and expected arrays of ObjectIds don't match.
@method assertSameDocumentIdArray
@param {ObjectId[]} actual - Array of ObjectId
@param {ObjectId[]} expected - Array of ObjectId
@param {String} msg - Optional custom error message
@return {undefined} - Throws if assertions fail | [
"Throws",
"if",
"the",
"given",
"actual",
"and",
"expected",
"arrays",
"of",
"ObjectIds",
"don",
"t",
"match",
"."
] | 9b572554a292ead1644b0afa3fc5a5b382d5dec9 | https://github.com/invisible-tech/mongoose-extras/blob/9b572554a292ead1644b0afa3fc5a5b382d5dec9/customAsserts/documentAssertions.js#L73-L82 |
31,684 | Rhinostone/gina | script/pre_install.js | PreInstall | function PreInstall() {
var self = this;
var init = function() {
self.isWin32 = ( os.platform() == 'win32' ) ? true : false;
self.path = __dirname.substring(0, (__dirname.length - 'script'.length));
console.debug('paths -> '+ self.path);
if ( hasNodeModulesSync() ) { // cleaining old
var target = new _(self.path + '/node_modules');
console.debug('replacing: ', target.toString() );
var err = target.rmSync();
if (err instanceof Error) {
throw err;
process.exit(1)
}
fs.mkdirSync(_(self.path) + '/node_modules');
}
}
var hasNodeModulesSync = function() {
return fs.existsSync( _(self.path + '/node_modules') )
}
// compare with post_install.js if you want to use this
//var filename = _(self.path + '/SUCCESS');
//var installed = fs.existsSync( filename );
//if (installed && /node_modules\/gina/.test( new _(process.cwd()).toUnixStyle() ) ) {
// process.exit(0)
//} else {
// fs.writeFileSync(filename, true );
//}
// ...
init()
} | javascript | function PreInstall() {
var self = this;
var init = function() {
self.isWin32 = ( os.platform() == 'win32' ) ? true : false;
self.path = __dirname.substring(0, (__dirname.length - 'script'.length));
console.debug('paths -> '+ self.path);
if ( hasNodeModulesSync() ) { // cleaining old
var target = new _(self.path + '/node_modules');
console.debug('replacing: ', target.toString() );
var err = target.rmSync();
if (err instanceof Error) {
throw err;
process.exit(1)
}
fs.mkdirSync(_(self.path) + '/node_modules');
}
}
var hasNodeModulesSync = function() {
return fs.existsSync( _(self.path + '/node_modules') )
}
// compare with post_install.js if you want to use this
//var filename = _(self.path + '/SUCCESS');
//var installed = fs.existsSync( filename );
//if (installed && /node_modules\/gina/.test( new _(process.cwd()).toUnixStyle() ) ) {
// process.exit(0)
//} else {
// fs.writeFileSync(filename, true );
//}
// ...
init()
} | [
"function",
"PreInstall",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"init",
"=",
"function",
"(",
")",
"{",
"self",
".",
"isWin32",
"=",
"(",
"os",
".",
"platform",
"(",
")",
"==",
"'win32'",
")",
"?",
"true",
":",
"false",
";",
"sel... | Pre install constructor
@constructor | [
"Pre",
"install",
"constructor"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/script/pre_install.js#L24-L61 |
31,685 | Rhinostone/gina | core/plugins/lib/validator/src/main.js | function($form) {
var $form = $form, _id = null;
if ( typeof($form) == 'undefined' ) {
if ( typeof(this.target) != 'undefined' ) {
_id = this.target.getAttribute('id');
} else {
_id = this.getAttribute('id');
}
$form = instance.$forms[_id]
} else if ( typeof($form) == 'string' ) {
_id = $form;
_id = _id.replace(/\#/, '');
if ( typeof(instance.$forms[_id]) == 'undefined') {
throw new Error('[ FormValidator::resetErrorsDisplay([formId]) ] `'+$form+'` not found')
}
$form = instance.$forms[_id]
}
//reseting error display
handleErrorsDisplay($form['target'], []);
return $form
} | javascript | function($form) {
var $form = $form, _id = null;
if ( typeof($form) == 'undefined' ) {
if ( typeof(this.target) != 'undefined' ) {
_id = this.target.getAttribute('id');
} else {
_id = this.getAttribute('id');
}
$form = instance.$forms[_id]
} else if ( typeof($form) == 'string' ) {
_id = $form;
_id = _id.replace(/\#/, '');
if ( typeof(instance.$forms[_id]) == 'undefined') {
throw new Error('[ FormValidator::resetErrorsDisplay([formId]) ] `'+$form+'` not found')
}
$form = instance.$forms[_id]
}
//reseting error display
handleErrorsDisplay($form['target'], []);
return $form
} | [
"function",
"(",
"$form",
")",
"{",
"var",
"$form",
"=",
"$form",
",",
"_id",
"=",
"null",
";",
"if",
"(",
"typeof",
"(",
"$form",
")",
"==",
"'undefined'",
")",
"{",
"if",
"(",
"typeof",
"(",
"this",
".",
"target",
")",
"!=",
"'undefined'",
")",
... | Reset errors display
@param {object|string} [$form|formId] | [
"Reset",
"errors",
"display"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/plugins/lib/validator/src/main.js#L392-L416 | |
31,686 | Rhinostone/gina | core/plugins/lib/validator/src/main.js | function(rules, tmp) {
var _r = null;
for (var r in rules) {
if ( typeof(rules[r]) == 'object' && typeof(instance.rules[tmp + r]) == 'undefined' ) {
_r = r;
if (/\[|\]/.test(r) ) { // must be a real path
_r = r.replace(/\[/g, '.').replace(/\]/g, '');
}
instance.rules[tmp + _r] = rules[r];
//delete instance.rules[r];
parseRules(rules[r], tmp + _r +'.');
}
}
} | javascript | function(rules, tmp) {
var _r = null;
for (var r in rules) {
if ( typeof(rules[r]) == 'object' && typeof(instance.rules[tmp + r]) == 'undefined' ) {
_r = r;
if (/\[|\]/.test(r) ) { // must be a real path
_r = r.replace(/\[/g, '.').replace(/\]/g, '');
}
instance.rules[tmp + _r] = rules[r];
//delete instance.rules[r];
parseRules(rules[r], tmp + _r +'.');
}
}
} | [
"function",
"(",
"rules",
",",
"tmp",
")",
"{",
"var",
"_r",
"=",
"null",
";",
"for",
"(",
"var",
"r",
"in",
"rules",
")",
"{",
"if",
"(",
"typeof",
"(",
"rules",
"[",
"r",
"]",
")",
"==",
"'object'",
"&&",
"typeof",
"(",
"instance",
".",
"rule... | parseRules - Preparing rules paths
@param {object} rules
@param {string} tmp - path | [
"parseRules",
"-",
"Preparing",
"rules",
"paths"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/plugins/lib/validator/src/main.js#L1103-L1119 | |
31,687 | Kronos-Integration/kronos-interceptor-object-data-processor-row | lib/converter/data-field-splitter.js | createSplitterForField | function createSplitterForField(multiFieldDefinitionPart, fieldName) {
if (multiFieldDefinitionPart === undefined) {
throw ("'multiFieldDefinitionPart' must not be undefined");
}
if (fieldName === undefined) {
throw ("'fieldName' must not be undefined");
}
const delimiter = multiFieldDefinitionPart.delimiter;
let escapeChar = multiFieldDefinitionPart.escapeChar;
let removeWhiteSpace = true;
let uniqueFields = true;
let sortFields = true;
let removeEmpty = true;
// set default values
if (multiFieldDefinitionPart.removeWhiteSpace !== undefined) {
// remove leading and trailing whitespaces
removeWhiteSpace = multiFieldDefinitionPart.removeWhiteSpace;
}
if (multiFieldDefinitionPart.uniqueFields !== undefined) {
// remove duplicates from the list
uniqueFields = multiFieldDefinitionPart.uniqueFields;
}
if (multiFieldDefinitionPart.sortFields !== undefined) {
// sort the fields
sortFields = multiFieldDefinitionPart.sortFields;
}
if (multiFieldDefinitionPart.removeEmpty !== undefined) {
// Empty fields will be deleted
removeEmpty = multiFieldDefinitionPart.removeEmpty;
}
return function (content) {
if (content.hasOwnProperty(fieldName)) {
// the field exists in the content record
let fieldValue = content[fieldName];
if (fieldValue) {
// ------------------------------------------------
// escape delimiter
// ------------------------------------------------
if (escapeChar) {
escapeChar = escapeChar.replace(/\\/, "\\\\");
escapeChar = escapeChar.replace(/\//, "\\/");
// The escaped delimiter will be replaced by the string '<--DIVIDER-->'
let re = new RegExp(escapeChar + delimiter, 'g');
fieldValue = fieldValue.replace(re, TMP_DEVIDER);
}
// ------------------------------------------------
// split the string
// ------------------------------------------------
let values = fieldValue.split(delimiter);
if (escapeChar) {
// remove the escape char
let re = new RegExp(TMP_DEVIDER, 'g');
for (let i = 0; i < values.length; i++) {
values[i] = values[i].replace(re, delimiter);
}
}
// ------------------------------------------------
// remove the leading and trailing whiteSpaces
// ------------------------------------------------
if (removeWhiteSpace) {
for (let i = 0; i < values.length; i++) {
values[i] = values[i].trim();
}
}
// ------------------------------------------------
// remove empty fields
// ------------------------------------------------
if (removeEmpty) {
let i = 0;
let j = 0;
for (i = 0; i < values.length; i++) {
if (values[i]) {
values[j] = values[i];
j++;
}
}
values.splice(j, i);
}
// ------------------------------------------------
// sort fields
// ------------------------------------------------
if (sortFields) {
values.sort();
}
// ------------------------------------------------
// remove duplicates
// ------------------------------------------------
if (uniqueFields) {
values = values.filter(function (elem, pos) {
return values.indexOf(elem) == pos;
});
}
// ------------------------------------------------
// store the splited fields back to the content
// ------------------------------------------------
content[fieldName] = values;
}
}
return null;
};
} | javascript | function createSplitterForField(multiFieldDefinitionPart, fieldName) {
if (multiFieldDefinitionPart === undefined) {
throw ("'multiFieldDefinitionPart' must not be undefined");
}
if (fieldName === undefined) {
throw ("'fieldName' must not be undefined");
}
const delimiter = multiFieldDefinitionPart.delimiter;
let escapeChar = multiFieldDefinitionPart.escapeChar;
let removeWhiteSpace = true;
let uniqueFields = true;
let sortFields = true;
let removeEmpty = true;
// set default values
if (multiFieldDefinitionPart.removeWhiteSpace !== undefined) {
// remove leading and trailing whitespaces
removeWhiteSpace = multiFieldDefinitionPart.removeWhiteSpace;
}
if (multiFieldDefinitionPart.uniqueFields !== undefined) {
// remove duplicates from the list
uniqueFields = multiFieldDefinitionPart.uniqueFields;
}
if (multiFieldDefinitionPart.sortFields !== undefined) {
// sort the fields
sortFields = multiFieldDefinitionPart.sortFields;
}
if (multiFieldDefinitionPart.removeEmpty !== undefined) {
// Empty fields will be deleted
removeEmpty = multiFieldDefinitionPart.removeEmpty;
}
return function (content) {
if (content.hasOwnProperty(fieldName)) {
// the field exists in the content record
let fieldValue = content[fieldName];
if (fieldValue) {
// ------------------------------------------------
// escape delimiter
// ------------------------------------------------
if (escapeChar) {
escapeChar = escapeChar.replace(/\\/, "\\\\");
escapeChar = escapeChar.replace(/\//, "\\/");
// The escaped delimiter will be replaced by the string '<--DIVIDER-->'
let re = new RegExp(escapeChar + delimiter, 'g');
fieldValue = fieldValue.replace(re, TMP_DEVIDER);
}
// ------------------------------------------------
// split the string
// ------------------------------------------------
let values = fieldValue.split(delimiter);
if (escapeChar) {
// remove the escape char
let re = new RegExp(TMP_DEVIDER, 'g');
for (let i = 0; i < values.length; i++) {
values[i] = values[i].replace(re, delimiter);
}
}
// ------------------------------------------------
// remove the leading and trailing whiteSpaces
// ------------------------------------------------
if (removeWhiteSpace) {
for (let i = 0; i < values.length; i++) {
values[i] = values[i].trim();
}
}
// ------------------------------------------------
// remove empty fields
// ------------------------------------------------
if (removeEmpty) {
let i = 0;
let j = 0;
for (i = 0; i < values.length; i++) {
if (values[i]) {
values[j] = values[i];
j++;
}
}
values.splice(j, i);
}
// ------------------------------------------------
// sort fields
// ------------------------------------------------
if (sortFields) {
values.sort();
}
// ------------------------------------------------
// remove duplicates
// ------------------------------------------------
if (uniqueFields) {
values = values.filter(function (elem, pos) {
return values.indexOf(elem) == pos;
});
}
// ------------------------------------------------
// store the splited fields back to the content
// ------------------------------------------------
content[fieldName] = values;
}
}
return null;
};
} | [
"function",
"createSplitterForField",
"(",
"multiFieldDefinitionPart",
",",
"fieldName",
")",
"{",
"if",
"(",
"multiFieldDefinitionPart",
"===",
"undefined",
")",
"{",
"throw",
"(",
"\"'multiFieldDefinitionPart' must not be undefined\"",
")",
";",
"}",
"if",
"(",
"field... | Create the field spliter for a given field definition
The field must be a multiField.
@param multiFieldDefinitionPart The multiField part of aa field definition for one field.
@param fieldName The name of the current multiField | [
"Create",
"the",
"field",
"spliter",
"for",
"a",
"given",
"field",
"definition",
"The",
"field",
"must",
"be",
"a",
"multiField",
"."
] | 678a59b84dab4a9082377c90849a0d62d97a1ea4 | https://github.com/Kronos-Integration/kronos-interceptor-object-data-processor-row/blob/678a59b84dab4a9082377c90849a0d62d97a1ea4/lib/converter/data-field-splitter.js#L28-L146 |
31,688 | AlCalzone/shared-utils | build/sorted-list/index.js | findPrevNode | function findPrevNode(firstNode, item, comparer) {
let ret;
let prevNode = firstNode;
// while item > prevNode.value
while (prevNode != undefined && comparer(prevNode.value, item) > 0) {
ret = prevNode;
prevNode = prevNode.next;
}
return ret;
} | javascript | function findPrevNode(firstNode, item, comparer) {
let ret;
let prevNode = firstNode;
// while item > prevNode.value
while (prevNode != undefined && comparer(prevNode.value, item) > 0) {
ret = prevNode;
prevNode = prevNode.next;
}
return ret;
} | [
"function",
"findPrevNode",
"(",
"firstNode",
",",
"item",
",",
"comparer",
")",
"{",
"let",
"ret",
";",
"let",
"prevNode",
"=",
"firstNode",
";",
"// while item > prevNode.value",
"while",
"(",
"prevNode",
"!=",
"undefined",
"&&",
"comparer",
"(",
"prevNode",
... | Seeks the list from the beginning and finds the position to add the new item | [
"Seeks",
"the",
"list",
"from",
"the",
"beginning",
"and",
"finds",
"the",
"position",
"to",
"add",
"the",
"new",
"item"
] | 9048e1f8793909fae7acb503984a4d8aadad4f3b | https://github.com/AlCalzone/shared-utils/blob/9048e1f8793909fae7acb503984a4d8aadad4f3b/build/sorted-list/index.js#L8-L17 |
31,689 | AlCalzone/shared-utils | build/sorted-list/index.js | findNode | function findNode(firstNode, predicate) {
let curNode = firstNode;
while (curNode != null) {
if (predicate(curNode.value))
return curNode;
curNode = curNode.next;
}
} | javascript | function findNode(firstNode, predicate) {
let curNode = firstNode;
while (curNode != null) {
if (predicate(curNode.value))
return curNode;
curNode = curNode.next;
}
} | [
"function",
"findNode",
"(",
"firstNode",
",",
"predicate",
")",
"{",
"let",
"curNode",
"=",
"firstNode",
";",
"while",
"(",
"curNode",
"!=",
"null",
")",
"{",
"if",
"(",
"predicate",
"(",
"curNode",
".",
"value",
")",
")",
"return",
"curNode",
";",
"c... | Seeks the list from the beginning and returns the first item matching the given predicate | [
"Seeks",
"the",
"list",
"from",
"the",
"beginning",
"and",
"returns",
"the",
"first",
"item",
"matching",
"the",
"given",
"predicate"
] | 9048e1f8793909fae7acb503984a4d8aadad4f3b | https://github.com/AlCalzone/shared-utils/blob/9048e1f8793909fae7acb503984a4d8aadad4f3b/build/sorted-list/index.js#L21-L28 |
31,690 | Kronos-Integration/kronos-interceptor-object-data-processor-row | lib/recordCheck/data-check-string-email.js | createCheckEmail | function createCheckEmail(fieldDefinition, fieldName) {
const severity = propertyHelper.getSeverity(fieldDefinition);
// return getIteratorFunction: function (fieldName, defaultValue, checkProperties, checkFunction, getErrorFunction,
// getValueIfErrorFunction, getValueIfOkFunction) {
let errorInfo = {
severity: severity,
errorCode: 'NOT_EMAIL'
};
return functionHelper.getParserCheck(errorInfo, getEmailIfValid, fieldName, undefined);
} | javascript | function createCheckEmail(fieldDefinition, fieldName) {
const severity = propertyHelper.getSeverity(fieldDefinition);
// return getIteratorFunction: function (fieldName, defaultValue, checkProperties, checkFunction, getErrorFunction,
// getValueIfErrorFunction, getValueIfOkFunction) {
let errorInfo = {
severity: severity,
errorCode: 'NOT_EMAIL'
};
return functionHelper.getParserCheck(errorInfo, getEmailIfValid, fieldName, undefined);
} | [
"function",
"createCheckEmail",
"(",
"fieldDefinition",
",",
"fieldName",
")",
"{",
"const",
"severity",
"=",
"propertyHelper",
".",
"getSeverity",
"(",
"fieldDefinition",
")",
";",
"// return getIteratorFunction: function (fieldName, defaultValue, checkProperties, checkFunction,... | Checks if a given string looks like a valid email.
@param fieldDefinition The field_definition for this field.
@param fieldName The name of the current field
@return The check | [
"Checks",
"if",
"a",
"given",
"string",
"looks",
"like",
"a",
"valid",
"email",
"."
] | 678a59b84dab4a9082377c90849a0d62d97a1ea4 | https://github.com/Kronos-Integration/kronos-interceptor-object-data-processor-row/blob/678a59b84dab4a9082377c90849a0d62d97a1ea4/lib/recordCheck/data-check-string-email.js#L45-L58 |
31,691 | Kronos-Integration/kronos-interceptor-object-data-processor-row | lib/recordCheck/data-check-string-email.js | createCheckDefaultValue | function createCheckDefaultValue(fieldDefinition, fieldName) {
const defaultValue = fieldDefinition.defaultValue;
// -----------------------------------------------------------------------
// Set default value
// -----------------------------------------------------------------------
return function (content) {
const valueToCheck = content[fieldName];
// If the value is defined, we need to check it
if (valueToCheck === undefined || valueToCheck === null) {
if (defaultValue !== undefined) {
content[fieldName] = defaultValue;
}
} else {
if (Array.isArray(valueToCheck)) {
valueToCheck.forEach(function (item, idx, arr) {
if (item === undefined || item === null) {
arr[idx] = defaultValue;
}
});
}
}
};
} | javascript | function createCheckDefaultValue(fieldDefinition, fieldName) {
const defaultValue = fieldDefinition.defaultValue;
// -----------------------------------------------------------------------
// Set default value
// -----------------------------------------------------------------------
return function (content) {
const valueToCheck = content[fieldName];
// If the value is defined, we need to check it
if (valueToCheck === undefined || valueToCheck === null) {
if (defaultValue !== undefined) {
content[fieldName] = defaultValue;
}
} else {
if (Array.isArray(valueToCheck)) {
valueToCheck.forEach(function (item, idx, arr) {
if (item === undefined || item === null) {
arr[idx] = defaultValue;
}
});
}
}
};
} | [
"function",
"createCheckDefaultValue",
"(",
"fieldDefinition",
",",
"fieldName",
")",
"{",
"const",
"defaultValue",
"=",
"fieldDefinition",
".",
"defaultValue",
";",
"// -----------------------------------------------------------------------",
"// Set default value",
"// ----------... | Set the default value if no value is there
@param fieldDefinition The field_definition for this field.
@param fieldName The name of the current field
@return checks A list of checks to be perfomred | [
"Set",
"the",
"default",
"value",
"if",
"no",
"value",
"is",
"there"
] | 678a59b84dab4a9082377c90849a0d62d97a1ea4 | https://github.com/Kronos-Integration/kronos-interceptor-object-data-processor-row/blob/678a59b84dab4a9082377c90849a0d62d97a1ea4/lib/recordCheck/data-check-string-email.js#L66-L90 |
31,692 | Rhinostone/gina | core/utils/helpers/dateFormat.js | function (format) {
var name = "default";
for (var f in self.masks) {
if ( self.masks[f] === format )
return f
}
return name
} | javascript | function (format) {
var name = "default";
for (var f in self.masks) {
if ( self.masks[f] === format )
return f
}
return name
} | [
"function",
"(",
"format",
")",
"{",
"var",
"name",
"=",
"\"default\"",
";",
"for",
"(",
"var",
"f",
"in",
"self",
".",
"masks",
")",
"{",
"if",
"(",
"self",
".",
"masks",
"[",
"f",
"]",
"===",
"format",
")",
"return",
"f",
"}",
"return",
"name",... | Get mask name from a given format
@param {string} format
@return {string} maskName | [
"Get",
"mask",
"name",
"from",
"a",
"given",
"format"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/utils/helpers/dateFormat.js#L143-L153 | |
31,693 | Rhinostone/gina | core/utils/helpers/dateFormat.js | function(date, dateTo) {
if ( dateTo instanceof Date) {
// The number of milliseconds in one day
var oneDay = 1000 * 60 * 60 * 24
// Convert both dates to milliseconds
var date1Ms = date.getTime()
var date2Ms = dateTo.getTime()
// Calculate the difference in milliseconds
var count = Math.abs(date1Ms - date2Ms)
// Convert back to days and return
return Math.round(count/oneDay);
} else {
throw new Error('dateTo is not instance of Date() !')
}
} | javascript | function(date, dateTo) {
if ( dateTo instanceof Date) {
// The number of milliseconds in one day
var oneDay = 1000 * 60 * 60 * 24
// Convert both dates to milliseconds
var date1Ms = date.getTime()
var date2Ms = dateTo.getTime()
// Calculate the difference in milliseconds
var count = Math.abs(date1Ms - date2Ms)
// Convert back to days and return
return Math.round(count/oneDay);
} else {
throw new Error('dateTo is not instance of Date() !')
}
} | [
"function",
"(",
"date",
",",
"dateTo",
")",
"{",
"if",
"(",
"dateTo",
"instanceof",
"Date",
")",
"{",
"// The number of milliseconds in one day",
"var",
"oneDay",
"=",
"1000",
"*",
"60",
"*",
"60",
"*",
"24",
"// Convert both dates to milliseconds",
"var",
"dat... | Count days from the current date to another
TODO - add a closure to `ignoreWeekend()` based on Utils::Validator
TODO - add a closure to `ignoreFromList(array)` based on Utils::Validator
@param {object} dateTo
@return {number} count | [
"Count",
"days",
"from",
"the",
"current",
"date",
"to",
"another"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/utils/helpers/dateFormat.js#L165-L183 | |
31,694 | Rhinostone/gina | core/utils/helpers/dateFormat.js | function(date, dateTo, mask) {
if ( dateTo instanceof Date) {
var count = countDaysTo(date, dateTo)
, month = date.getMonth()
, year = date.getFullYear()
, day = date.getDate() + 1
, dateObj = new Date(year, month, day)
, days = []
, i = 0;
for (; i < count; ++i) {
if ( typeof(mask) != 'undefined' ) {
days.push(new Date(dateObj).format(mask));
} else {
days.push(new Date(dateObj));
}
dateObj.setDate(dateObj.getDate() + 1);
}
return days || [];
} else {
throw new Error('dateTo is not instance of Date() !')
}
} | javascript | function(date, dateTo, mask) {
if ( dateTo instanceof Date) {
var count = countDaysTo(date, dateTo)
, month = date.getMonth()
, year = date.getFullYear()
, day = date.getDate() + 1
, dateObj = new Date(year, month, day)
, days = []
, i = 0;
for (; i < count; ++i) {
if ( typeof(mask) != 'undefined' ) {
days.push(new Date(dateObj).format(mask));
} else {
days.push(new Date(dateObj));
}
dateObj.setDate(dateObj.getDate() + 1);
}
return days || [];
} else {
throw new Error('dateTo is not instance of Date() !')
}
} | [
"function",
"(",
"date",
",",
"dateTo",
",",
"mask",
")",
"{",
"if",
"(",
"dateTo",
"instanceof",
"Date",
")",
"{",
"var",
"count",
"=",
"countDaysTo",
"(",
"date",
",",
"dateTo",
")",
",",
"month",
"=",
"date",
".",
"getMonth",
"(",
")",
",",
"yea... | Will give an array of dates between the current date to a targeted date
TODO - add a closure to `ignoreWeekend()` based on Utils::Validator
TODO - add a closure to `ignoreFromList(array)` based on Utils::Validator
@param {object} dateTo
@param {string} [ mask ]
@return {array} dates | [
"Will",
"give",
"an",
"array",
"of",
"dates",
"between",
"the",
"current",
"date",
"to",
"a",
"targeted",
"date"
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/utils/helpers/dateFormat.js#L196-L221 | |
31,695 | dowjones/distribucache | lib/decorators/BaseDecorator.js | BaseDecorator | function BaseDecorator(cache, config, configSchema) {
this._cache = cache;
if (config) {
this._configSchema = configSchema;
this._config = this._humanTimeIntervalToMs(config);
this._config = this._validateConfig(configSchema, this._config);
}
// substitute cb, for cases
// when you don't need a callback, but
// don't want to loose the error.
this._emitError = function (err) {
if (err) this.emit('error', err);
}.bind(this);
} | javascript | function BaseDecorator(cache, config, configSchema) {
this._cache = cache;
if (config) {
this._configSchema = configSchema;
this._config = this._humanTimeIntervalToMs(config);
this._config = this._validateConfig(configSchema, this._config);
}
// substitute cb, for cases
// when you don't need a callback, but
// don't want to loose the error.
this._emitError = function (err) {
if (err) this.emit('error', err);
}.bind(this);
} | [
"function",
"BaseDecorator",
"(",
"cache",
",",
"config",
",",
"configSchema",
")",
"{",
"this",
".",
"_cache",
"=",
"cache",
";",
"if",
"(",
"config",
")",
"{",
"this",
".",
"_configSchema",
"=",
"configSchema",
";",
"this",
".",
"_config",
"=",
"this",... | The root of the Decorator tree
@constructor | [
"The",
"root",
"of",
"the",
"Decorator",
"tree"
] | ad79caee277771a6e49ee4a98c4983480cd89945 | https://github.com/dowjones/distribucache/blob/ad79caee277771a6e49ee4a98c4983480cd89945/lib/decorators/BaseDecorator.js#L12-L27 |
31,696 | Rhinostone/gina | core/utils/lib/merge/src/main.js | function (obj) {
if (
!obj
|| {}.toString.call(obj) !== '[object Object]'
|| obj.nodeType
|| obj.setInterval
) {
return false
}
var hasOwn = {}.hasOwnProperty;
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
// added test for node > v6
var hasMethodPrototyped = ( typeof(obj.constructor) != 'undefined' ) ? hasOwn.call(obj.constructor.prototype, 'isPrototypeOf') : false;
if (
obj.constructor && !hasOwnConstructor && !hasMethodPrototyped
) {
return false
}
//Own properties are enumerated firstly, so to speed up,
//if last one is own, then all properties are own.
var key;
return key === undefined || hasOwn.call(obj, key)
} | javascript | function (obj) {
if (
!obj
|| {}.toString.call(obj) !== '[object Object]'
|| obj.nodeType
|| obj.setInterval
) {
return false
}
var hasOwn = {}.hasOwnProperty;
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
// added test for node > v6
var hasMethodPrototyped = ( typeof(obj.constructor) != 'undefined' ) ? hasOwn.call(obj.constructor.prototype, 'isPrototypeOf') : false;
if (
obj.constructor && !hasOwnConstructor && !hasMethodPrototyped
) {
return false
}
//Own properties are enumerated firstly, so to speed up,
//if last one is own, then all properties are own.
var key;
return key === undefined || hasOwn.call(obj, key)
} | [
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
"||",
"{",
"}",
".",
"toString",
".",
"call",
"(",
"obj",
")",
"!==",
"'[object Object]'",
"||",
"obj",
".",
"nodeType",
"||",
"obj",
".",
"setInterval",
")",
"{",
"return",
"false",
"}",
"va... | Check if object before merging. | [
"Check",
"if",
"object",
"before",
"merging",
"."
] | c6ba13d3255a43734c54880ff12d3a50df53ebea | https://github.com/Rhinostone/gina/blob/c6ba13d3255a43734c54880ff12d3a50df53ebea/core/utils/lib/merge/src/main.js#L307-L333 | |
31,697 | kevinoid/promise-nodeify | index.js | doCallback | function doCallback(callback, reason, value) {
// Note: Could delay callback call until later, as When.js does, but this
// loses the stack (particularly for bluebird long traces) and causes
// unnecessary delay in the non-exception (common) case.
try {
// Match argument length to resolve/reject in case callback cares.
// Note: bluebird has argument length 1 if value === undefined due to
// https://github.com/petkaantonov/bluebird/issues/170
// If you are reading this and want similar behavior, I'll consider it.
if (reason) {
callback(reason);
} else {
callback(null, value);
}
} catch (err) {
later(() => { throw err; });
}
} | javascript | function doCallback(callback, reason, value) {
// Note: Could delay callback call until later, as When.js does, but this
// loses the stack (particularly for bluebird long traces) and causes
// unnecessary delay in the non-exception (common) case.
try {
// Match argument length to resolve/reject in case callback cares.
// Note: bluebird has argument length 1 if value === undefined due to
// https://github.com/petkaantonov/bluebird/issues/170
// If you are reading this and want similar behavior, I'll consider it.
if (reason) {
callback(reason);
} else {
callback(null, value);
}
} catch (err) {
later(() => { throw err; });
}
} | [
"function",
"doCallback",
"(",
"callback",
",",
"reason",
",",
"value",
")",
"{",
"// Note: Could delay callback call until later, as When.js does, but this",
"// loses the stack (particularly for bluebird long traces) and causes",
"// unnecessary delay in the non-exception (common) case.",... | Invokes callback and ensures any exceptions thrown are uncaught.
@private | [
"Invokes",
"callback",
"and",
"ensures",
"any",
"exceptions",
"thrown",
"are",
"uncaught",
"."
] | 1542cb7824c1b5e0e19e925dfb9650bfe8c7cdbd | https://github.com/kevinoid/promise-nodeify/blob/1542cb7824c1b5e0e19e925dfb9650bfe8c7cdbd/index.js#L20-L37 |
31,698 | kevinoid/promise-nodeify | index.js | promiseNodeify | function promiseNodeify(promise, callback) {
if (typeof callback !== 'function') {
return promise;
}
function onRejected(reason) {
// callback is unlikely to recognize or expect a falsey error.
// (we also rely on truthyness for arguments.length in doCallback)
// Convert it to something truthy
let truthyReason = reason;
if (!truthyReason) {
// Note: unthenify converts falsey rejections to TypeError:
// https://github.com/blakeembrey/unthenify/blob/v1.0.0/src/index.ts#L32
// We use bluebird convention for Error, message, and .cause property
truthyReason = new Error(String(reason));
truthyReason.cause = reason;
}
doCallback(callback, truthyReason);
}
function onResolved(value) {
doCallback(callback, null, value);
}
promise.then(onResolved, onRejected);
return undefined;
} | javascript | function promiseNodeify(promise, callback) {
if (typeof callback !== 'function') {
return promise;
}
function onRejected(reason) {
// callback is unlikely to recognize or expect a falsey error.
// (we also rely on truthyness for arguments.length in doCallback)
// Convert it to something truthy
let truthyReason = reason;
if (!truthyReason) {
// Note: unthenify converts falsey rejections to TypeError:
// https://github.com/blakeembrey/unthenify/blob/v1.0.0/src/index.ts#L32
// We use bluebird convention for Error, message, and .cause property
truthyReason = new Error(String(reason));
truthyReason.cause = reason;
}
doCallback(callback, truthyReason);
}
function onResolved(value) {
doCallback(callback, null, value);
}
promise.then(onResolved, onRejected);
return undefined;
} | [
"function",
"promiseNodeify",
"(",
"promise",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"callback",
"!==",
"'function'",
")",
"{",
"return",
"promise",
";",
"}",
"function",
"onRejected",
"(",
"reason",
")",
"{",
"// callback is unlikely to recognize or expe... | Calls a node-style callback when a Promise is resolved or rejected.
This function provides the behavior of
{@link https://github.com/then/nodeify then <code>nodeify</code>},
{@link
https://github.com/cujojs/when/blob/master/docs/api.md#nodebindcallback
when.js <code>node.bindCallback</code>},
or {@link http://bluebirdjs.com/docs/api/ascallback.html bluebird
<code>Promise.prototype.nodeify</code> (now
<code>Promise.prototype.asCallback</code>)} (without options).
@ template ValueType
@param {!Promise<ValueType>} promise Promise to monitor.
@param {?function(*, ValueType=)=} callback Node-style callback to be
called when <code>promise</code> is resolved or rejected. If
<code>promise</code> is rejected with a falsey value the first argument
will be an instance of <code>Error</code> with a <code>.cause</code>
property with the rejected value.
@return {Promise<ValueType>|undefined} <code>undefined</code> if
<code>callback</code> is a function, otherwise a <code>Promise</code>
which behaves like <code>promise</code> (currently is <code>promise</code>,
but is not guaranteed to remain so).
@alias module:promise-nodeify | [
"Calls",
"a",
"node",
"-",
"style",
"callback",
"when",
"a",
"Promise",
"is",
"resolved",
"or",
"rejected",
"."
] | 1542cb7824c1b5e0e19e925dfb9650bfe8c7cdbd | https://github.com/kevinoid/promise-nodeify/blob/1542cb7824c1b5e0e19e925dfb9650bfe8c7cdbd/index.js#L63-L90 |
31,699 | Gi60s/binary-case | index.js | getBinaryCase | function getBinaryCase (str, val) {
let res = '';
for (let i = 0; i < str.length; i++) {
const code = str.charCodeAt(i);
if (code >= 65 && code <= 90) {
res += val & 1 ? String.fromCharCode(code + 32) : String.fromCharCode(code);
val >>>= 1;
} else if (code >= 97 && code <= 122) {
res += val & 1 ? String.fromCharCode(code - 32) : String.fromCharCode(code);
val >>>= 1;
} else {
res += String.fromCharCode(code);
}
if (val === 0) {
return res + str.substr(i + 1);
}
}
return res;
} | javascript | function getBinaryCase (str, val) {
let res = '';
for (let i = 0; i < str.length; i++) {
const code = str.charCodeAt(i);
if (code >= 65 && code <= 90) {
res += val & 1 ? String.fromCharCode(code + 32) : String.fromCharCode(code);
val >>>= 1;
} else if (code >= 97 && code <= 122) {
res += val & 1 ? String.fromCharCode(code - 32) : String.fromCharCode(code);
val >>>= 1;
} else {
res += String.fromCharCode(code);
}
if (val === 0) {
return res + str.substr(i + 1);
}
}
return res;
} | [
"function",
"getBinaryCase",
"(",
"str",
",",
"val",
")",
"{",
"let",
"res",
"=",
"''",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
";",
"i",
"++",
")",
"{",
"const",
"code",
"=",
"str",
".",
"charCodeAt",
"(",
... | A performance improved method for acquiring the binary case, provided by Blake Embrey with very minor modification by James Speirs.
@author Blake Embrey | https://github.com/blakeembrey
@author James Speirs | https://github.com/gi60s
@param {string} str
@param {number} val
@returns {string} | [
"A",
"performance",
"improved",
"method",
"for",
"acquiring",
"the",
"binary",
"case",
"provided",
"by",
"Blake",
"Embrey",
"with",
"very",
"minor",
"modification",
"by",
"James",
"Speirs",
"."
] | a53af5c542b936d6c1329895dd9b93556024d132 | https://github.com/Gi60s/binary-case/blob/a53af5c542b936d6c1329895dd9b93556024d132/index.js#L86-L108 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.