{"version":3,"file":"index-ffe3a8fe.js","sources":["../../../app/frontend/javascripts/lib/util/index.ts"],"sourcesContent":["\n// tslint:disable-next-line:interface-name\nexport interface Stringable {\n toString(): string\n}\n\n/**\n * Test whether the item exists (i.e. is not null or undefined).\n *\n * @example\n * const myArr: Array = ['a', null, undefined, 'b']\n * const filtered: string[] = myArr.filter(exists)\n */\nexport function exists(item: T | null | undefined | false): item is T {\n return !!item\n}\n\nexport function present(value: T): value is Exclude {\n if (typeof value == 'string') {\n return value.length > 0\n }\n\n return !!value\n}\n\nexport function assert(value: T, key?: string, msg?: string): asserts value is Exclude {\n if (!present(value)) {\n throw new Error(msg || 'assert failed! Value was not present')\n }\n}\n\n/**\n * Returns a new array where duplicate values have been removed\n */\nexport function uniq(arr: T[]): T[] {\n return arr.filter((item, index) => arr.indexOf(item) === index)\n}\n\nexport function uniqBy(arr: T[], keyOrFn: keyof T | ((item: T) => any)): T[] {\n const fn: (item: T) => any = typeof(keyOrFn) == 'function' ?\n keyOrFn :\n (i: T) => i[keyOrFn]\n\n return arr.filter((item, index) => {\n const search = fn(item)\n return arr.findIndex((i) => fn(i) == search) === index\n })\n}\n\ndeclare global {\n // tslint:disable-next-line: interface-name\n interface Array {\n /**\n * Returns a new array where duplicate values have been removed\n */\n uniq(): T[]\n\n /**\n * Returns a new array where duplicate values have been removed, as selected\n * by the key function\n */\n uniqBy(keyOrFn: keyof T | ((item: T) => any)): T[]\n }\n}\n\nArray.prototype.uniq = function() {\n return uniq(this)\n}\nArray.prototype.uniqBy = function(keyOrFn) {\n return uniqBy(this, keyOrFn)\n}\n"],"names":["present","value","assert","key","msg","uniq","arr","item","index","uniqBy","keyOrFn","fn","i","search"],"mappings":"kFAiBO,SAASA,EAAWC,EAA8D,CACnF,OAAA,OAAOA,GAAS,SACXA,EAAM,OAAS,EAGjB,CAAC,CAACA,CACX,CAEgB,SAAAC,EAAUD,EAAUE,EAAcC,EAA0E,CACtH,GAAA,CAACJ,EAAQC,CAAK,EACV,MAAA,IAAI,MAAMG,GAAO,sCAAsC,CAEjE,CAKO,SAASC,EAAQC,EAAe,CAC9B,OAAAA,EAAI,OAAO,CAACC,EAAMC,IAAUF,EAAI,QAAQC,CAAI,IAAMC,CAAK,CAChE,CAEgB,SAAAC,EAAUH,EAAUI,EAA4C,CACxE,MAAAC,EAAuB,OAAOD,GAAY,WAC9CA,EACCE,GAASA,EAAEF,CAAO,EAErB,OAAOJ,EAAI,OAAO,CAACC,EAAMC,IAAU,CAC3B,MAAAK,EAASF,EAAGJ,CAAI,EACf,OAAAD,EAAI,UAAWM,GAAMD,EAAGC,CAAC,GAAKC,CAAM,IAAML,CAAA,CAClD,CACH,CAkBA,MAAM,UAAU,KAAO,UAAW,CAChC,OAAOH,EAAK,IAAI,CAClB,EACA,MAAM,UAAU,OAAS,SAASK,EAAS,CAClC,OAAAD,EAAO,KAAMC,CAAO,CAC7B"}