index.es.js.map 10 KB

1
  1. {"version":3,"file":"index.es.js","sources":["../src/array.js","../src/function.js","../src/index.js"],"sourcesContent":["/** @license MIT License (c) copyright 2010-2016 original author or authors */\n\n// Non-mutating array operations\n\n// cons :: a -> [a] -> [a]\n// a with x prepended\nexport function cons (x, a) {\n const l = a.length\n const b = new Array(l + 1)\n b[0] = x\n for (let i = 0; i < l; ++i) {\n b[i + 1] = a[i]\n }\n return b\n}\n\n// append :: a -> [a] -> [a]\n// a with x appended\nexport function append (x, a) {\n const l = a.length\n const b = new Array(l + 1)\n for (let i = 0; i < l; ++i) {\n b[i] = a[i]\n }\n\n b[l] = x\n return b\n}\n\n// drop :: Int -> [a] -> [a]\n// drop first n elements\nexport function drop (n, a) { // eslint-disable-line complexity\n if (n < 0) {\n throw new TypeError('n must be >= 0')\n }\n\n const l = a.length\n if (n === 0 || l === 0) {\n return a\n }\n\n if (n >= l) {\n return []\n }\n\n return unsafeDrop(n, a, l - n)\n}\n\n// unsafeDrop :: Int -> [a] -> Int -> [a]\n// Internal helper for drop\nfunction unsafeDrop (n, a, l) {\n const b = new Array(l)\n for (let i = 0; i < l; ++i) {\n b[i] = a[n + i]\n }\n return b\n}\n\n// tail :: [a] -> [a]\n// drop head element\nexport function tail (a) {\n return drop(1, a)\n}\n\n// copy :: [a] -> [a]\n// duplicate a (shallow duplication)\nexport function copy (a) {\n const l = a.length\n const b = new Array(l)\n for (let i = 0; i < l; ++i) {\n b[i] = a[i]\n }\n return b\n}\n\n// map :: (a -> b) -> [a] -> [b]\n// transform each element with f\nexport function map (f, a) {\n const l = a.length\n const b = new Array(l)\n for (let i = 0; i < l; ++i) {\n b[i] = f(a[i])\n }\n return b\n}\n\n// reduce :: (a -> b -> a) -> a -> [b] -> a\n// accumulate via left-fold\nexport function reduce (f, z, a) {\n let r = z\n for (let i = 0, l = a.length; i < l; ++i) {\n r = f(r, a[i], i)\n }\n return r\n}\n\n// replace :: a -> Int -> [a]\n// replace element at index\nexport function replace (x, i, a) { // eslint-disable-line complexity\n if (i < 0) {\n throw new TypeError('i must be >= 0')\n }\n\n const l = a.length\n const b = new Array(l)\n for (let j = 0; j < l; ++j) {\n b[j] = i === j ? x : a[j]\n }\n return b\n}\n\n// remove :: Int -> [a] -> [a]\n// remove element at index\nexport function remove (i, a) { // eslint-disable-line complexity\n if (i < 0) {\n throw new TypeError('i must be >= 0')\n }\n\n const l = a.length\n if (l === 0 || i >= l) { // exit early if index beyond end of array\n return a\n }\n\n if (l === 1) { // exit early if index in bounds and length === 1\n return []\n }\n\n return unsafeRemove(i, a, l - 1)\n}\n\n// unsafeRemove :: Int -> [a] -> Int -> [a]\n// Internal helper to remove element at index\nfunction unsafeRemove (i, a, l) {\n const b = new Array(l)\n let j\n for (j = 0; j < i; ++j) {\n b[j] = a[j]\n }\n for (j = i; j < l; ++j) {\n b[j] = a[j + 1]\n }\n\n return b\n}\n\n// removeAll :: (a -> boolean) -> [a] -> [a]\n// remove all elements matching a predicate\n// @deprecated\nexport function removeAll (f, a) {\n const l = a.length\n const b = new Array(l)\n let j = 0\n for (let x, i = 0; i < l; ++i) {\n x = a[i]\n if (!f(x)) {\n b[j] = x\n ++j\n }\n }\n\n b.length = j\n return b\n}\n\n// findIndex :: a -> [a] -> Int\n// find index of x in a, from the left\nexport function findIndex (x, a) {\n for (let i = 0, l = a.length; i < l; ++i) {\n if (x === a[i]) {\n return i\n }\n }\n return -1\n}\n\n// isArrayLike :: * -> boolean\n// Return true iff x is array-like\nexport function isArrayLike (x) {\n return x != null && typeof x.length === 'number' && typeof x !== 'function'\n}\n","/** @license MIT License (c) copyright 2010-2016 original author or authors */\n\n// id :: a -> a\nexport const id = x => x\n\n// compose :: (b -> c) -> (a -> b) -> (a -> c)\nexport const compose = (f, g) => x => f(g(x))\n\n// apply :: (a -> b) -> a -> b\nexport const apply = (f, x) => f(x)\n\n// curry2 :: ((a, b) -> c) -> (a -> b -> c)\nexport function curry2 (f) {\n function curried (a, b) {\n switch (arguments.length) {\n case 0: return curried\n case 1: return b => f(a, b)\n default: return f(a, b)\n }\n }\n return curried\n}\n\n// curry3 :: ((a, b, c) -> d) -> (a -> b -> c -> d)\nexport function curry3 (f) {\n function curried (a, b, c) { // eslint-disable-line complexity\n switch (arguments.length) {\n case 0: return curried\n case 1: return curry2((b, c) => f(a, b, c))\n case 2: return c => f(a, b, c)\n default:return f(a, b, c)\n }\n }\n return curried\n}\n\n// curry4 :: ((a, b, c, d) -> e) -> (a -> b -> c -> d -> e)\nexport function curry4 (f) {\n function curried (a, b, c, d) { // eslint-disable-line complexity\n switch (arguments.length) {\n case 0: return curried\n case 1: return curry3((b, c, d) => f(a, b, c, d))\n case 2: return curry2((c, d) => f(a, b, c, d))\n case 3: return d => f(a, b, c, d)\n default:return f(a, b, c, d)\n }\n }\n return curried\n}\n","/** @license MIT License (c) copyright 2016 original author or authors */\n\nexport * from './array'\nexport * from './function'\n"],"names":["cons","x","a","l","length","b","Array","i","append","drop","n","TypeError","unsafeDrop","tail","copy","map","f","reduce","z","r","replace","j","remove","unsafeRemove","removeAll","findIndex","isArrayLike","id","compose","g","apply","curry2","curried","arguments","curry3","c","curry4","d"],"mappings":"AAAA;;;;;;AAMA,AAAO,SAASA,IAAT,CAAeC,CAAf,EAAkBC,CAAlB,EAAqB;MACpBC,IAAID,EAAEE,MAAZ;MACMC,IAAI,IAAIC,KAAJ,CAAUH,IAAI,CAAd,CAAV;IACE,CAAF,IAAOF,CAAP;OACK,IAAIM,IAAI,CAAb,EAAgBA,IAAIJ,CAApB,EAAuB,EAAEI,CAAzB,EAA4B;MACxBA,IAAI,CAAN,IAAWL,EAAEK,CAAF,CAAX;;SAEKF,CAAP;;;;;AAKF,AAAO,SAASG,MAAT,CAAiBP,CAAjB,EAAoBC,CAApB,EAAuB;MACtBC,IAAID,EAAEE,MAAZ;MACMC,IAAI,IAAIC,KAAJ,CAAUH,IAAI,CAAd,CAAV;OACK,IAAII,IAAI,CAAb,EAAgBA,IAAIJ,CAApB,EAAuB,EAAEI,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