# Variable assertMap`Const`

assertMap: (predicateOrMap: any, errMsg?: string) => (obj: any) => any = assertFn

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

#### Type declaration

- - (predicateOrMap: any, errMsg?: string): (obj: any) => any

  - #### Parameters

    - predicateOrMap: any
    - errMsg: string = "assert failure"

    #### Returns (obj: any) => any

#### 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")

- Defined in src/shared/common.js:356