Random utility functions used in the UI-Router code

These functions are exported, but are subject to change without notice.

## Index

### Classes

- Queue

### Interfaces

- $InjectorLike
- $QLike
- $QLikeDeferred
- CoreServices
- LocationConfig
- LocationServices
- Obj
- TypedMap

### Type aliases

- IInjectable
- Mapper
- Predicate

### Variables

- angular
- assertMap
- assertPredicate
- equals
- extend
- forEach
- fromJson
- global
- inArray
- mapObj
- pushTo
- removeFrom
- root
- toJson

### Functions

- _arraysEq
- _equals
- _extend
- _forEach
- _inArray
- _pushTo
- _removeFrom
- allTrueR
- ancestors
- anyTrueR
- applyPairs
- arrayTuples
- assertFn
- copy
- createProxyFunctions
- defaults
- deregAll
- filter
- find
- flatten
- flattenR
- identity
- inherit
- map
- mergeR
- noop
- notImplemented
- omit
- pairs
- pick
- pluck
- pushR
- silenceUncaughtInPromise
- silentRejection
- tail
- uniqR
- unnest
- unnestR
- values

### Object literals

- services

## Type aliases

IInjectable: Function | any[]

An ng1-style injectable

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) {

    }];

publicapi

- Defined in common/common.ts:58

Mapper: function

#### Type declaration

- - (x: X, key?: string | number): T

  - #### Parameters

    - ##### x X

    - ##### key: Optional string | number

    #### Returns T

- Defined in common/common.ts:28

Predicate: function

#### Type declaration

- - (x?: X): boolean

  - #### Parameters

    - ##### x: Optional X

    #### Returns boolean

- Defined in common/common.ts:30

## Variables

angular: any = root.angular || {}

- Defined in common/common.ts:18

assertMap: function = assertFn

Given a .map function, builds a .map function which throws an error if any mapped elements do not pass a truthyness test.

Given a .map function, builds a .map function which throws an error if any mapped elements do not pass a truthyness test.

example

      var data = { foo: 1, bar: 2 };

      let keys = [ 'foo', 'bar' ]
      let values = keys.map(assertMap(key => data[key], "Key not found"));
      // values is [1, 2]

      let keys = [ 'foo', 'bar', 'baz' ]
      let values = keys.map(assertMap(key => data[key], "Key not found"));
      // throws Error("Key not found")

#### Type declaration

- - <T, U>(mapFn: function, errMsg: string | Function): function

  - #### Type parameters

    - #### T

    - #### U

    #### Parameters

    - ##### mapFn function

      - - (t: T): U

        - #### Parameters

          - ##### t T

          #### Returns U

    - ##### errMsg string | Function

    #### Returns function

    - - (t: T): U

      - #### Parameters

        - ##### t T

        #### Returns U

- Defined in common/common.ts:439

assertPredicate: function = assertFn

Given a .filter Predicate, builds a .filter Predicate which throws an error if any elements do not pass.

Given a .filter Predicate, builds a .filter Predicate which throws an error if any elements do not pass.

example

      let isNumber = (obj) => typeof(obj) === 'number';
      let allNumbers = [ 1, 2, 3, 4, 5 ];
      allNumbers.filter(assertPredicate(isNumber)); //OK

      let oneString = [ 1, 2, 3, 4, "5" ];
      oneString.filter(assertPredicate(isNumber, "Not all numbers")); // throws Error(""Not all numbers"");

#### Type declaration

- - <T>(predicate: Predicate<T>, errMsg: string | Function): Predicate<T>

  - #### Type parameters

    - #### T

    #### Parameters

    - ##### predicate Predicate<T>

    - ##### errMsg string | Function

    #### Returns Predicate<T>

- Defined in common/common.ts:422

equals: any = angular.equals || _equals

- Defined in common/common.ts:24

extend: assign = Object.assign || _extend

- Defined in common/common.ts:23

forEach: any = angular.forEach || _forEach

- Defined in common/common.ts:22

fromJson: any = angular.fromJson || JSON.parse.bind(JSON)

- Defined in common/common.ts:20

global: any

- Defined in common/common.ts:15

inArray: _inArray = curry(_inArray) as any

Given an array, returns true if the object is found in the array, (using indexOf)

Given an array, returns true if the object is found in the array, (using indexOf)

- Defined in common/common.ts:146

mapObj: function = map

Given an object, returns a new object, where each property is transformed by the callback function

Given an object, returns a new object, where each property is transformed by the callback function

#### Type declaration

- - <T, U>(collection: object, callback: Mapper<T, U>, target?: object): object

  - #### Type parameters

    - #### T

    - #### U

    #### Parameters

    - ##### collection object

      - ##### [key: string]: T

    - ##### callback Mapper<T, U>

    - ##### target: Optional object

      - ##### [key: string]: T

    #### Returns object

    - ##### [key: string]: U

- Defined in common/common.ts:295

pushTo: _pushTo = curry(_pushTo) as any

pushes a values to an array and returns the value

pushes a values to an array and returns the value

- Defined in common/common.ts:167

removeFrom: _removeFrom = curry(_removeFrom) as any

Given an array, and an item, if the item is found in the array, it removes it (in-place). The same array is returned

Given an array, and an item, if the item is found in the array, it removes it (in-place). The same array is returned

- Defined in common/common.ts:157

root: any = (typeof self === 'object' && self.self === self && self) ||(typeof global === 'object' && global.global === global && global) || this

- Defined in common/common.ts:16

toJson: any = angular.toJson || JSON.stringify.bind(JSON)

- Defined in common/common.ts:21

## Functions

- _arraysEq(a1: any[], a2: any[]): any

- #### Parameters

  - ##### a1 any[]

  - ##### a2 any[]

  #### Returns any

  - Defined in common/common.ts:589

- _equals(o1: any, o2: any): boolean

- #### Parameters

  - ##### o1 any

  - ##### o2 any

  #### Returns boolean

  - Defined in common/common.ts:561

- _extend(toObj: Obj, ...fromObjs: Obj[]): any

- Like Object.assign()

- Like Object.assign()

  #### Parameters

  - ##### toObj Obj

  - ##### ...fromObjs: Rest Obj[]

  #### Returns any

  - Defined in common/common.ts:546

- _forEach(obj: any, cb: function, _this: Obj): void

- Naive forEach implementation works with Objects or Arrays

- Naive forEach implementation works with Objects or Arrays

  #### Parameters

  - ##### obj any

  - ##### cb function

    - - (el: any, idx?: any): void

      - #### Parameters

        - ##### el any

        - ##### idx: Optional any

        #### Returns void

  - ##### _this Obj

  #### Returns void

  - Defined in common/common.ts:540

- _inArray(array: any[], obj: any): boolean
- _inArray(array: any[]): function

- #### Parameters

  - ##### array any[]

  - ##### obj any

  #### Returns boolean

  - Defined in common/common.ts:147

- #### Parameters

  - ##### array any[]

  #### Returns function

  - - (obj: any): boolean

    - #### Parameters

      - ##### obj any

      #### Returns boolean

  - Defined in common/common.ts:148

- _pushTo<T>(arr: T[], val: T): T
- _pushTo<T>(arr: T[]): function

- #### Type parameters

  - #### T

  #### Parameters

  - ##### arr T[]

  - ##### val T

  #### Returns T

  - Defined in common/common.ts:168

- #### Type parameters

  - #### T

  #### Parameters

  - ##### arr T[]

  #### Returns function

  - - (val: T): T

    - #### Parameters

      - ##### val T

      #### Returns T

  - Defined in common/common.ts:169

- _removeFrom<T>(array: T[], obj: T): T[]
- _removeFrom<T>(array: T[]): function

- #### Type parameters

  - #### T

  #### Parameters

  - ##### array T[]

  - ##### obj T

  #### Returns T[]

  - Defined in common/common.ts:158

- #### Type parameters

  - #### T

  #### Parameters

  - ##### array T[]

  #### Returns function

  - - (obj: T): T[]

    - #### Parameters

      - ##### obj T

      #### Returns T[]

  - Defined in common/common.ts:159

- allTrueR(memo: boolean, elem: any): any

- Reduce function that returns true if all of the values are truthy.

- Reduce function that returns true if all of the values are truthy.

  #### Parameters

  - ##### memo boolean

  - ##### elem any

  #### Returns any

  - Defined in common/common.ts:332

- ancestors(first: StateObject, second: StateObject): StateObject[]

- Finds the common ancestor path between two states.

- Finds the common ancestor path between two states.

  #### Parameters

  - ##### first StateObject

    :

    The first state.

  - ##### second StateObject

    :

    The second state.

  #### Returns StateObject[]

  :

  Returns an array of state names in descending order, not including the root.

  - Defined in common/common.ts:201

- anyTrueR(memo: boolean, elem: any): any

- Reduce function that returns true if any of the values are truthy.

- Reduce function that returns true if any of the values are truthy.

  - @example ```

  let vals = [ 0, null, undefined ]; vals.reduce(anyTrueR, true); // false

  vals.push("hello world"); vals.reduce(anyTrueR, true); // true ```

  #### Parameters

  - ##### memo boolean

  - ##### elem any

  #### Returns any

  - Defined in common/common.ts:347

- applyPairs(memo: TypedMap<any>, keyValTuple: any[]): TypedMap<any>

- 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 ]

  example

        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" }

  #### Parameters

  - ##### memo TypedMap<any>

  - ##### keyValTuple any[]

  #### Returns TypedMap<any>

  - Defined in common/common.ts:517

- arrayTuples(...args: any[]): any[]

- 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] ]

  example

        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] ]

  #### Parameters

  - ##### ...args: Rest any[]

  #### Returns any[]

  - Defined in common/common.ts:476

- assertFn(predicateOrMap: Function, errMsg?: string | Function): any

- #### Parameters

  - ##### predicateOrMap Function

  - ##### errMsg: Default value string | Function = "assert failure"

  #### Returns any

  - Defined in common/common.ts:440

- copy(src: Obj, dest?: Obj): Obj

- shallow copy from src to dest

- shallow copy from src to dest

  #### Parameters

  - ##### src Obj

  - ##### dest: Optional Obj

  #### Returns Obj

  - Defined in common/common.ts:533

- createProxyFunctions(source: Function, target: Obj, bind: Function, fnNames?: string[], latebind?: boolean): Obj

- 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.

  #### Example:

  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

  #### Example:

  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'

  #### Parameters

  - ##### source Function

    :

    A function that returns the source object which contains the original functions to be bound

  - ##### target Obj

    :

    A function that returns the target object which will receive the bound functions

  - ##### bind Function

    :

    A function that returns the object which the functions will be bound to

  - ##### fnNames: Optional string[]

    :

    The function names which will be bound (Defaults to all the functions found on the 'from' object)

  - ##### latebind: Default value boolean = false

    :

    If true, the binding of the function is delayed until the first time it's invoked

  #### Returns Obj

  - Defined in common/common.ts:120

- defaults(opts: any, ...defaultsList: Obj[]): any

- 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.

  #### Parameters

  - ##### opts any

  - ##### ...defaultsList: Rest Obj[]

  #### Returns any

  - Defined in common/common.ts:185

- deregAll(functions: Function[]): void

- 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

  #### Parameters

  - ##### functions Function[]

  #### Returns void

  - Defined in common/common.ts:175

- filter<T>(collection: T[], callback: function): T[]

- Given an array of objects, returns a new array containing only the elements which passed the callback predicate

- filter<T>(collection: TypedMap<T>, callback: function): TypedMap<T>

- 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

  #### Type parameters

  - #### T

  #### Parameters

  - ##### collection T[]

  - ##### callback function

    - - (t: T, key?: number): boolean

      - #### Parameters

        - ##### t T

        - ##### key: Optional number

        #### Returns boolean

  #### Returns T[]

  - Defined in common/common.ts:264

- Given an object, returns a new object with only those properties that passed the callback predicate

  #### Type parameters

  - #### T

  #### Parameters

  - ##### collection TypedMap<T>

  - ##### callback function

    - - (t: T, key?: string): boolean

      - #### Parameters

        - ##### t T

        - ##### key: Optional string

        #### Returns boolean

  #### Returns TypedMap<T>

  - Defined in common/common.ts:266

- find<T>(collection: TypedMap<T>, callback: Predicate<T>): T

- Given an object, return the first property of that object which passed the callback predicate

- find<T>(collection: T[], callback: Predicate<T>): T

- 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

  #### Type parameters

  - #### T

  #### Parameters

  - ##### collection TypedMap<T>

  - ##### callback Predicate<T>

  #### Returns T

  - Defined in common/common.ts:279

- Given an array of objects, returns the first object which passed the callback predicate

  #### Type parameters

  - #### T

  #### Parameters

  - ##### collection T[]

  - ##### callback Predicate<T>

  #### Returns T

  - Defined in common/common.ts:281

- flatten(arr: any[]): any

- Return a completely flattened version of an array.

- Return a completely flattened version of an array.

  #### Parameters

  - ##### arr any[]

  #### Returns any

  - Defined in common/common.ts:407

- flattenR(memo: any[], elem: any): any

- Reduce function which recursively un-nests all arrays

- Reduce function which recursively un-nests all arrays

  #### Parameters

  - ##### memo any[]

  - ##### elem any

  #### Returns any

  - Defined in common/common.ts:370

- identity(x: any): any

- #### Parameters

  - ##### x any

  #### Returns any

  - Defined in common/common.ts:25

- inherit(parent: Obj, extra?: Obj): any

- prototypal inheritance helper. Creates a new object which has `parent` object as its prototype, and then copies the properties from `extra` onto it

- prototypal inheritance helper. Creates a new object which has `parent` object as its prototype, and then copies the properties from `extra` onto it

  #### Parameters

  - ##### parent Obj

  - ##### extra: Optional Obj

  #### Returns any

  - Defined in common/common.ts:142

- map<T, U>(collection: T[], callback: Mapper<T, U>, target?: Array): U[]

- Given an array, returns a new array, where each element is transformed by the callback function

- map<T, U>(collection: object, callback: Mapper<T, U>, target?: object): object

- 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

  #### Type parameters

  - #### T

  - #### U

  #### Parameters

  - ##### collection T[]

  - ##### callback Mapper<T, U>

  - ##### target: Optional Array

  #### Returns U[]

  - Defined in common/common.ts:297

- Maps an array or object properties using a callback function

  #### Type parameters

  - #### T

  - #### U

  #### Parameters

  - ##### collection object

    - ##### [key: string]: T

  - ##### callback Mapper<T, U>

  - ##### target: Optional object

    - ##### [key: string]: T

  #### Returns object

  - ##### [key: string]: U

  - Defined in common/common.ts:298

- mergeR(memo: Obj, item: Obj): Obj

- Reduce function that merges each element of the list into a single object, using extend

- Reduce function that merges each element of the list into a single object, using extend

  #### Parameters

  - ##### memo Obj

  - ##### item Obj

  #### Returns Obj

  - Defined in common/common.ts:192

- noop(): any

- #### Returns any

  - Defined in common/common.ts:26

- notImplemented(fnname: string): (Anonymous function)

- #### Parameters

  - ##### fnname string

  #### Returns (Anonymous function)

  - Defined in common/coreservices.ts:12

- omit(obj: Obj, propNames: string[]): Obj

- Return a copy of the object omitting the blacklisted properties.

- Return a copy of the object omitting the blacklisted properties.

  example

        var foo = { a: 1, b: 2, c: 3 };
        var ab = omit(foo, ['a', 'b']); // { c: 3 }

  #### Parameters

  - ##### obj Obj

    :

    the source object

  - ##### propNames string[]

    :

    an Array of strings, which are the blacklisted property names

  #### Returns Obj

  - Defined in common/common.ts:244

- pairs(obj: Obj): any[][]

- Like _.pairs: Given an object, returns an array of key/value pairs

- Like _.pairs: Given an object, returns an array of key/value pairs

  #### Parameters

  - ##### obj Obj

  #### Returns any[][]

  - Defined in common/common.ts:459

- pick(obj: Obj, propNames: string[]): Obj

- Return a copy of the object only containing the whitelisted properties.

- Return a copy of the object only containing the whitelisted properties.

  #### Example:

      var foo = { a: 1, b: 2, c: 3 };
      var ab = pick(foo, ['a', 'b']); // { a: 1, b: 2 }

  #### Parameters

  - ##### obj Obj

    :

    the source object

  - ##### propNames string[]

    :

    an Array of strings, which are the whitelisted property names

  #### Returns Obj

  - Defined in common/common.ts:222

- pluck<T>(collection: Obj[], propName: string): T[]

- Given an array of objects, maps each element to a named property of the element.

- pluck(collection: object, propName: string): object

- 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.

  #### Type parameters

  - #### T

  #### Parameters

  - ##### collection Obj[]

  - ##### propName string

  #### Returns T[]

  - Defined in common/common.ts:252

- Given an object, maps each property of the object to a named property of the property.

  #### Parameters

  - ##### collection object

    - ##### [key: string]: any

  - ##### propName string

  #### Returns object

  - ##### [key: string]: any

  - Defined in common/common.ts:254

- pushR(arr: any[], obj: any): any[]

- Reduce function that pushes an object to an array, then returns the array. Mostly just for flattenR and uniqR

- Reduce function that pushes an object to an array, then returns the array. Mostly just for flattenR and uniqR

  #### Parameters

  - ##### arr any[]

  - ##### obj any

  #### Returns any[]

  - Defined in common/common.ts:377

- silenceUncaughtInPromise(promise: Promise<any>): Promise<any>

- #### Parameters

  - ##### promise Promise<any>

  #### Returns Promise<any>

  - Defined in common/common.ts:595

- silentRejection(error: any): Promise<any>

- #### Parameters

  - ##### error any

  #### Returns Promise<any>

  - Defined in common/common.ts:597

- tail<T>(arr: T[]): T

- Get the last element of an array

- Get the last element of an array

  #### Type parameters

  - #### T

  #### Parameters

  - ##### arr T[]

  #### Returns T

  - Defined in common/common.ts:526

- uniqR<T>(acc: T[], token: T): T[]

- Reduce function that filters out duplicates

- Reduce function that filters out duplicates

  #### Type parameters

  - #### T

  #### Parameters

  - ##### acc T[]

  - ##### token T

  #### Returns T[]

  - Defined in common/common.ts:383

- unnest(arr: any[]): any

- Return a new array with a single level of arrays unnested.

- Return a new array with a single level of arrays unnested.

  #### Parameters

  - ##### arr any[]

  #### Returns any

  - Defined in common/common.ts:396

- unnestR(memo: any[], elem: any[]): any[]

- Reduce function which un-nests a single level of arrays

- Reduce function which un-nests a single level of arrays

  #### Parameters

  - ##### memo any[]

  - ##### elem any[]

  #### Returns any[]

  - Defined in common/common.ts:358

- values(obj: Obj): any[]

- Given an object, return its enumerable property values

- Given an object, return its enumerable property values

  #### Parameters

  - ##### obj Obj

  #### Returns any[]

  - Defined in common/common.ts:316

## Object literals

services: object

- Defined in common/coreservices.ts:16

$injector: undefined = undefined

- Defined in common/coreservices.ts:18

$q: undefined = undefined

- Defined in common/coreservices.ts:17

Generated using TypeDoc