@uirouter/core
Version:
UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps
13 lines • 3.81 kB
Source Map (JSON)
{
"version": 3,
"file": "predicates.js",
"sourceRoot": "",
"sources": [
"@uirouter/core/common/predicates.ts"
],
"names": [],
"mappings": "AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIjD,IAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;AACxC,IAAM,GAAG,GAAG,UAAC,CAAS,IAAK,OAAA,UAAC,CAAM,IAAK,OAAA,OAAO,CAAC,KAAK,CAAC,EAAd,CAAc,EAA1B,CAA0B,CAAC;AACtD,MAAM,CAAC,IAAM,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC;AAC5C,MAAM,CAAC,IAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC;AAC1C,MAAM,CAAC,IAAM,MAAM,GAAG,UAAC,CAAM,IAAK,OAAA,CAAC,KAAK,IAAI,EAAV,CAAU,CAAC;AAC7C,MAAM,CAAC,IAAM,iBAAiB,GAAG,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACzD,MAAM,CAAC,IAAM,UAAU,GAAmC,GAAG,CAAC,UAAU,CAAC,CAAC;AAC1E,MAAM,CAAC,IAAM,QAAQ,GAAiC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACpE,MAAM,CAAC,IAAM,QAAQ,GAA4B,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC/D,MAAM,CAAC,IAAM,QAAQ,GAAG,UAAC,CAAM,IAAK,OAAA,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAnC,CAAmC,CAAC;AACxE,MAAM,CAAC,IAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AACrC,MAAM,CAAC,IAAM,MAAM,GAA+B,CAAC,UAAC,CAAM,IAAK,OAAA,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,eAAe,EAAjC,CAAiC,CAAC,CAAC;AAClG,MAAM,CAAC,IAAM,QAAQ,GAAiC,CAAC,UAAC,CAAM,IAAK,OAAA,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,EAAnC,CAAmC,CAAC,CAAC;AAExG;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,GAAQ;IACnC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE;QAC9B,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC3B,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;KACpF;IACD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,IAAM,SAAS,GAAkC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC",
"sourcesContent": [
"/**\n * Predicates\n *\n * These predicates return true/false based on the input.\n * Although these functions are exported, they are subject to change without notice.\n *\n * @packageDocumentation\n */\nimport { and, not, pipe, prop, or } from './hof';\nimport { Predicate } from './common'; // has or is using\nimport { StateObject } from '../state/stateObject';\n\nconst toStr = Object.prototype.toString;\nconst tis = (t: string) => (x: any) => typeof x === t;\nexport const isUndefined = tis('undefined');\nexport const isDefined = not(isUndefined);\nexport const isNull = (o: any) => o === null;\nexport const isNullOrUndefined = or(isNull, isUndefined);\nexport const isFunction: (x: any) => x is Function = <any>tis('function');\nexport const isNumber: (x: any) => x is number = <any>tis('number');\nexport const isString = <(x: any) => x is string>tis('string');\nexport const isObject = (x: any) => x !== null && typeof x === 'object';\nexport const isArray = Array.isArray;\nexport const isDate: (x: any) => x is Date = <any>((x: any) => toStr.call(x) === '[object Date]');\nexport const isRegExp: (x: any) => x is RegExp = <any>((x: any) => toStr.call(x) === '[object RegExp]');\n\n/**\n * Predicate which checks if a value is injectable\n *\n * A value is \"injectable\" if it is a function, or if it is an ng1 array-notation-style array\n * where all the elements in the array are Strings, except the last one, which is a Function\n */\nexport function isInjectable(val: any) {\n if (isArray(val) && val.length) {\n const head = val.slice(0, -1),\n tail = val.slice(-1);\n return !(head.filter(not(isString)).length || tail.filter(not(isFunction)).length);\n }\n return isFunction(val);\n}\n\n/**\n * Predicate which checks if a value looks like a Promise\n *\n * It is probably a Promise if it's an object, and it has a `then` property which is a Function\n */\nexport const isPromise = <(x: any) => x is Promise<any>>and(isObject, pipe(prop('then'), isFunction));\n"
]
}