An ng1-style injectable
This could be a (non-minified) function such as:
function injectableFunction(SomeDependency) {
}
or an explicitly annotated function (minify safe)
injectableFunction.$inject = [ 'SomeDependency' ];
function injectableFunction(SomeDependency) {
}
or an array style annotated function (minify safe)
['SomeDependency', function injectableFunction(SomeDependency) {
}];
Given a .map function, builds a .map function which throws an error if any mapped elements do not pass a truthyness test.
Given a .filter Predicate, builds a .filter Predicate which throws an error if any elements do not pass.
Given an array, returns true if the object is found in the array, (using indexOf)
Given an object, returns a new object, where each property is transformed by the callback function
pushes a values to an array and returns the value
Given an array, and an item, if the item is found in the array, it removes it (in-place). The same array is returned
Like Object.assign()
Like Object.assign()
Naive forEach implementation works with Objects or Arrays
Naive forEach implementation works with Objects or Arrays
Reduce function that returns true if all of the values are truthy.
Reduce function that returns true if all of the values are truthy.
Finds the common ancestor path between two states.
Finds the common ancestor path between two states.
The first state.
The second state.
Returns an array of state names in descending order, not including the root.
Reduce function that returns true if any of the values are truthy.
Reduce function that returns true if any of the values are truthy.
let vals = [ 0, null, undefined ]; vals.reduce(anyTrueR, true); // false
vals.push("hello world"); vals.reduce(anyTrueR, true); // true ```
Reduce function which builds an object from an array of [key, value] pairs.
Reduce function which builds an object from an array of [key, value] pairs.
Each iteration sets the key/val pair on the memo object, then returns the memo for the next iteration.
Each keyValueTuple should be an array with values [ key: string, value: any ]
var pairs = [ ["fookey", "fooval"], ["barkey", "barval"] ]
var pairsToObj = pairs.reduce((memo, pair) => applyPairs(memo, pair), {})
// pairsToObj == { fookey: "fooval", barkey: "barval" }
// Or, more simply:
var pairsToObj = pairs.reduce(applyPairs, {})
// pairsToObj == { fookey: "fooval", barkey: "barval" }
Given two or more parallel arrays, returns an array of tuples where each tuple is composed of [ a[i], b[i], ... z[i] ]
Given two or more parallel arrays, returns an array of tuples where each tuple is composed of [ a[i], b[i], ... z[i] ]
let foo = [ 0, 2, 4, 6 ];
let bar = [ 1, 3, 5, 7 ];
let baz = [ 10, 30, 50, 70 ];
arrayTuples(foo, bar); // [ [0, 1], [2, 3], [4, 5], [6, 7] ]
arrayTuples(foo, bar, baz); // [ [0, 1, 10], [2, 3, 30], [4, 5, 50], [6, 7, 70] ]
shallow copy from src to dest
Builds proxy functions on the to
object which pass through to the from
object.
Builds proxy functions on the to
object which pass through to the from
object.
For each key in fnNames
, creates a proxy function on the to
object.
The proxy function calls the real function on the from
object.
This example creates an new class instance whose functions are prebound to the new'd object.
class Foo {
constructor(data) {
// Binds all functions from Foo.prototype to 'this',
// then copies them to 'this'
bindFunctions(Foo.prototype, this, this);
this.data = data;
}
log() {
console.log(this.data);
}
}
let myFoo = new Foo([1,2,3]);
var logit = myFoo.log;
logit(); // logs [1, 2, 3] from the myFoo 'this' instance
This example creates a bound version of a service function, and copies it to another object
var SomeService = {
this.data = [3, 4, 5];
this.log = function() {
console.log(this.data);
}
}
// Constructor fn
function OtherThing() {
// Binds all functions from SomeService to SomeService,
// then copies them to 'this'
bindFunctions(SomeService, this, SomeService);
}
let myOtherThing = new OtherThing();
myOtherThing.log(); // logs [3, 4, 5] from SomeService's 'this'
A function that returns the source object which contains the original functions to be bound
A function that returns the target object which will receive the bound functions
A function that returns the object which the functions will be bound to
The function names which will be bound (Defaults to all the functions found on the 'from' object)
If true, the binding of the function is delayed until the first time it's invoked
Applies a set of defaults to an options object. The options object is filtered to only those properties of the objects in the defaultsList. Earlier objects in the defaultsList take precedence when applying defaults.
Applies a set of defaults to an options object. The options object is filtered to only those properties of the objects in the defaultsList. Earlier objects in the defaultsList take precedence when applying defaults.
Given an array of (deregistration) functions, calls all functions and removes each one from the source array
Given an array of (deregistration) functions, calls all functions and removes each one from the source array
Given an array of objects, returns a new array containing only the elements which passed the callback predicate
Given an object, returns a new object with only those properties that passed the callback predicate
Given an array of objects, returns a new array containing only the elements which passed the callback predicate
Given an object, returns a new object with only those properties that passed the callback predicate
Given an object, return the first property of that object which passed the callback predicate
Given an array of objects, returns the first object which passed the callback predicate
Given an object, return the first property of that object which passed the callback predicate
Given an array of objects, returns the first object which passed the callback predicate
Return a completely flattened version of an array.
Return a completely flattened version of an array.
Reduce function which recursively un-nests all arrays
Reduce function which recursively un-nests all arrays
prototypal inheritance helper.
Creates a new object which has parent
object as its prototype, and then copies the properties from extra
onto it
Given an array, returns a new array, where each element is transformed by the callback function
Maps an array or object properties using a callback function
Given an array, returns a new array, where each element is transformed by the callback function
Maps an array or object properties using a callback function
Reduce function that merges each element of the list into a single object, using extend
Return a copy of the object omitting the blacklisted properties.
Like _.pairs: Given an object, returns an array of key/value pairs
Like _.pairs: Given an object, returns an array of key/value pairs
Return a copy of the object only containing the whitelisted properties.
Given an array of objects, maps each element to a named property of the element.
Given an object, maps each property of the object to a named property of the property.
Given an array of objects, maps each element to a named property of the element.
Given an object, maps each property of the object to a named property of the property.
Reduce function that pushes an object to an array, then returns the array. Mostly just for flattenR and uniqR
Get the last element of an array
Get the last element of an array
Reduce function that filters out duplicates
Reduce function that filters out duplicates
Return a new array with a single level of arrays unnested.
Return a new array with a single level of arrays unnested.
Reduce function which un-nests a single level of arrays
Reduce function which un-nests a single level of arrays
Given an object, return its enumerable property values
Given an object, return its enumerable property values
Generated using TypeDoc
Random utility functions used in the UI-Router code
These functions are exported, but are subject to change without notice.