{"version":3,"sources":["Honeywell.ClientModel.Functional.ts"],"names":["exports","compose2","g","f","a","compose3","h","compose4","k","curry2","source","b","curry3","c","curry4","d","map","callback","collection","_","filter","condition","reverseCurry2","applyAll","arg","fork","lastly","functions","groupBy","criteria","pair","key","data","pairs"],"mappings":"oHAcaA,EAAAC,SAAW,SAAUC,EAAgBC,GAAgC,MAAA,UAAAC,GAAK,MAAAF,GAAEC,EAAEC,MAS9EJ,EAAAK,SAAW,SAAaC,EAAgBJ,EAAgBC,GAAgC,MAAAH,GAAAC,SAASK,EAAGN,EAAAC,SAASC,EAAGC,KAUhHH,EAAAO,SAAW,SAAgBC,EAAgBF,EAAgBJ,EAAgBC,GAAgC,MAAAH,GAAAC,SAASO,EAAGR,EAAAK,SAASC,EAAGJ,EAAGC,KAOtIH,EAAAS,OAAS,SAAUC,GAA8B,MAAA,UAACN,GAAS,MAAA,UAACO,GAAS,MAAAD,GAAON,EAAGO,MAO/EX,EAAAY,OAAS,SAAaF,GAAoC,MAAA,UAACN,GAAS,MAAAJ,GAAAS,OAAO,SAACE,EAAME,GAAS,MAAAH,GAAON,EAAGO,EAAGE,OAOxGb,EAAAc,OAAS,SAAgBJ,GAA0C,MAAA,UAACN,GAAS,MAAAJ,GAAAY,OAAO,SAACD,EAAME,EAAME,GAAS,MAAAL,GAAON,EAAGO,EAAGE,EAAGE,OAO1Hf,EAAAgB,IAAM,SAAaC,GAAgC,MAAA,UAACC,GAAoB,MAAWC,GAAEH,IAAIE,EAAYD,KAOrGjB,EAAAoB,OAAS,SAAIC,GAAmC,MAAA,UAACH,GAAoB,MAAAC,GAAEC,OAAOF,EAAYG,KAO1FrB,EAAAsB,cAAgB,SAAUZ,GAA8B,MAAA,UAACC,GAAS,MAAA,UAACP,GAAS,MAAAM,GAAON,EAAGO,MAQtFX,EAAAuB,SAAW,SAAOC,GAAW,MAAAxB,GAAAgB,IAAI,SAACb,GAAmB,MAAAA,GAAEqB,MAGvDxB,EAAAyB,KAAO,SAAUC,GAA2B,MAAA,UAACC,GAA+B,MAAA,UAACH,GACtF,MAAAE,GAAO1B,EAAAuB,SAAeC,GAAKG,OAOlB3B,EAAA4B,QAAU,SAAIC,GAAa,MAAA7B,GAAAK,SAASL,EAAAgB,IAAI,SAACc,GAClD,OAASC,IAAKD,EAAK,GAAIE,KAAMF,EAAK,MAClCX,EAAEc,MAAO,SAACvB,GAAgB,MAAAS,GAAES,QAAQlB,EAAQmB","file":"Honeywell.ClientModel.Functional.js","sourcesContent":["///\r\n// Below are some utility functins we can use for functional programing techniques.\r\n// Lodash has compose() and curry() functions, but they are not strongly typed, \r\n// so you will lose all type information after applyint them.\r\n// Hence I had to write custom functins\r\n\r\nimport * as _ from \"lodash\";\r\n\r\n/**\r\n * Compose funciton that takes two arguments\r\n * @param g first function\r\n * @param f second function\r\n * @returns {} resulting function\r\n */\r\nexport const compose2 = (g: (b: B) => C, f: (a: A) => B): (a: A) => C => a => g(f(a));\r\n\r\n/**\r\n * Compose funciton that takes three arguments\r\n * @param h : first function\r\n * @param g : second function\r\n * @param f : third function\r\n * @returns {}: resulting function\r\n */\r\nexport const compose3 = (h: (c: C) => D, g: (b: B) => C, f: (a: A) => B): (a: A) => D => compose2(h, compose2(g, f));\r\n\r\n/**\r\n * Compose that takes four arguments\r\n * @param k first function\r\n * @param h second function\r\n * @param g third function\r\n * @param f fourth function\r\n * @returns {} resulting function\r\n */\r\nexport const compose4 = (k: (d: D) => E, h: (c: C) => D, g: (b: B) => C, f: (a: A) => B): (a: A) => E => compose2(k, compose3(h, g, f));\r\n\r\n/**\r\n * Curry on a function of two arguments\r\n * @param source \r\n * @returns {} \r\n */\r\nexport const curry2 = (source: (a: A, b: B) => R) => (a: A) => (b: B) => source(a, b);\r\n\r\n/**\r\n * Curry on a function of three arguments\r\n * @param source \r\n * @returns {} \r\n */\r\nexport const curry3 = (source: (a: A, b: B, c: C) => R) => (a: A) => curry2((b: B, c: C) => source(a, b, c));\r\n\r\n/**\r\n * Curry on a function of four arguments\r\n * @param source \r\n * @returns {} \r\n */\r\nexport const curry4 = (source: (a: A, b: B, c: C, d: D) => R) => (a: A) => curry3((b: B, c: C, d: D) => source(a, b, c, d));\r\n\r\n/**\r\n * Curried version of underscore map\r\n * @param callback \r\n * @returns {} \r\n */\r\nexport const map = (callback: (t: T) => TResult) => (collection: T[]) => _.map(collection, callback);\r\n\r\n/**\r\n * Curried version of underscore filter\r\n * @param condition \r\n * @returns {} Filtered collection\r\n */\r\nexport const filter = (condition: (element: T) => any) => (collection: T[]) => _.filter(collection, condition);\r\n\r\n/**\r\n * Curry on a function of two arguments, but reversing the order\r\n * @param source \r\n * @returns {} \r\n */\r\nexport const reverseCurry2 = (source: (a: A, b: B) => R) => (b: B) => (a: A) => source(a, b);\r\n\r\n/**\r\n * Applies an array of functions to a value, returns an array of values\r\n * @param arg \r\n * @returns {} \r\n */\r\n//export var applyAll: (arg: A) => (functions: ((a: A) => B)[]) => B[] = (arg: A) => (functions: ((a: A) => B)[]) => _.map<(a: A) => B, B>(functions, (f: (a: A) => B) => f(arg));\r\nexport const applyAll = (arg: A) => map((f: (a: A) => B) => f(arg));\r\n\r\n//Applies an array of functions to a value, but then apply the function lastly() to this array to derive a final value\r\nexport const fork = (lastly: (bs: B[]) => A) => (functions: ((c: C) => B)[]) => (arg: C) =>\r\n lastly(applyAll(arg)(functions));\r\n\r\n/**\r\n * Group By method. Does the same thing as groupBy by lodash, but returns an array instead of object\r\n * @param criteria \r\n * @returns {} \r\n */\r\nexport const groupBy = (criteria) => compose3(map((pair: [string, T[]]) => {\r\n return { key: pair[0], data: pair[1] };\r\n}), _.pairs, (source: T[]) => _.groupBy(source, criteria));"]}