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Delivr using Terser v5.39.0.\n * Original file: /npm/@yagni-js/yagni@0.7.1/dist/yagni.cjs.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n *\n * @module @yagni-js/yagni\n * @version 0.7.1\n * @author Yuri Egorov <ysegorov at gmail dot com>\n * @license Unlicense http://unlicense.org\n *\n */\n\n'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\n/**\n * Takes three functions `predicate`, `fnIf` and `fnElse` as an arguments\n * and returns **a new function**, which then takes `smth` as an argument\n * and returns **the result of calling either `fnIf` or `fnElse`** function\n * depending on the result of calling `predicate` function.\n *\n * @category Logic\n *\n * @param {Function} predicate function to check a condition\n * @param {Function} fnIf function to call if `predicate` evaluates to true\n * @param {Function} fnElse function to call if `predicate` evaluates to false\n * @returns {Function} a new function to take `smth` as an argument and return\n * the result of calling either `fnIf(smth)` or `fnElse(smth)` function\n * depending on the `predicate(smth)` call result\n *\n * @example\n *\n *     import {ifElse} from '@yagni-js/yagni';\n *\n *     function isNil(smth) { return smth === void 0 || smth === null; }\n *     function ifDefined(smth) { return smth; }\n *     function ifUndefined(smth) { return 'foo'; }\n *\n *     const valueOrFoo = ifElse(isNil, ifUndefined, ifDefined);\n *\n *     const res0 = valueOrFoo(null);   // => 'foo'\n *     const res1 = valueOrFoo('baz');  // => 'baz'\n *     const res2 = valueOrFoo('bar');  // => 'bar'\n *\n *     // same thing using only `@yagni-js/yagni` functions\n *\n *     import {isNil, identity, always, ifElse} from '@yagni-js/yagni';\n *\n *     const valueOrFoo = ifElse(isNil, always('foo'), identity);\n *\n *     const res0 = valueOrFoo(null);   // => 'foo'\n *     const res1 = valueOrFoo('baz');  // => 'baz'\n *     const res2 = valueOrFoo('bar');  // => 'bar'\n *\n */\nfunction ifElse(predicate, fnIf, fnElse) {\n  return function _ifElse(smth) {\n    return predicate(smth) ? fnIf(smth) : fnElse(smth);\n  };\n}\n\n\n/**\n * Takes two functions `left` and `right` as arguments and returns\n * **a new function**, which then takes some value `smth` as an argument\n * and returns **boolean** - `true` if both `left(smth)` and `right(smth)`\n * calls return true and `false` otherwise\n *\n * @category Logic\n *\n * @param {Function} left predicate function to calculate left side value\n * @param {Function} right predicate function to calculate right side value\n * @returns {Function} a new function to take `smth` as an argument and\n * return true if both `left(smth)` and `right(smth)` evaluate to true and\n * false otherwise\n *\n * @example\n *\n *     import {and} from '@yagni-js/yagni';\n *\n *     function above0(smth) { return smth > 0; }\n *     function below100(smth) { return smth < 100; }\n *\n *     const test = and(above0, below100);\n *\n *     const res0 = test(42);   // => true\n *     const res1 = test(-1);   // => false\n *     const res2 = test(101);  // => false\n *\n */\nfunction and(left, right) {\n  return function _and(smth) {\n    return left(smth) && right(smth);\n  };\n}\n\n\n/**\n * Takes two functions `left` and `right` as arguments and returns\n * **a new function**, which then takes some value `smth` as an argument\n * and returns **boolean** - `true` if `left(smth)` or `right(smth)`\n * calls return true and `false` otherwise\n *\n * @category Logic\n *\n * @param {Function} left predicate function to calculate left side value\n * @param {Function} right predicate function to calculate right side value\n * @returns {Function} a new function to take `smth` as an argument and\n * return true if `left(smth)` or `right(smth)` evaluates to true and\n * false otherwise\n *\n * @example\n *\n *     import {or} from '@yagni-js/yagni';\n *\n *     function below0(smth) { return smth < 0; }\n *     function above100(smth) { return smth > 100; }\n *\n *     const test = or(below0, above100);\n *\n *     const res0 = test(42);   // => false\n *     const res1 = test(-1);   // => true\n *     const res2 = test(101);  // => true\n *\n */\nfunction or(left, right) {\n  return function _or(smth) {\n    return left(smth) || right(smth);\n  };\n}\n\n\n/**\n * Takes a function `test` and returns **a new function**, which then\n * takes some value `smth` as an argument and returns **negated result** of the\n * call `test(smth)`.\n *\n * @category Logic\n *\n * @param {Function} test predicate function\n * @returns {Function} a new function to take `smth` as an argument and return\n * `!` of the call `test(smth)`\n *\n * @example\n *\n *     import {not} from '@yagni-js/yagni';\n *\n *     function equalsFoo(smth) { return smth === 'foo'; }\n *\n *     const notEqualsFoo = not(equalsFoo);\n *\n *     const res0 = notEqualsFoo('foo');  // => false\n *     const res1 = notEqualsFoo('baz');  // => true\n *     const res2 = notEqualsFoo('bar');  // => true\n *\n */\nfunction not(test) {\n  return function _not(smth) {\n    return !test(smth);\n  };\n}\n\n/**\n * Takes some value `smth` as an argument and returns **boolean** -\n * `true` if `smth` is `null` or `undefined`, `false` otherwise.\n *\n * @category Test\n *\n * @param {*} smth value to test\n * @returns {Boolean} true if `smth` is `null` or `undefined`, `false` otherwise\n *\n * @example\n *\n *     import {isNil} from '@yagni-js/yagni';\n *\n *     var a;\n *\n *     const res0 = isNil(null);   // => true\n *     const res1 = isNil(a);      // => true\n *     const res2 = isNil('foo');  // => false\n *     const res3 = isNil(42);     // => false\n *     const res4 = isNil({});     // => false\n *     const res5 = isNil([]);     // => false\n *\n */\nfunction isNil(smth) {\n  return (smth === null) || (smth === void 0);\n}\n\n\n/**\n * Takes some value `smth` as an argument and returns **boolean** -\n * `true` if `smth` is not `null` and not `undefined`, `false` otherwise.\n *\n * @category Test\n *\n * @param {*} smth value to test\n * @returns {Boolean} true if `smth` is not `null` and not `undefined`,\n * `false` otherwise\n *\n * @example\n *\n *     import {isDefined} from '@yagni-js/yagni';\n *\n *     var a;\n *\n *     const res0 = isDefined(null);   // => false\n *     const res1 = isDefined(a);      // => false\n *     const res2 = isDefined('foo');  // => true\n *     const res3 = isDefined(42);     // => true\n *     const res4 = isDefined({});     // => true\n *     const res5 = isDefined([]);     // => true\n *\n */\nfunction isDefined(smth) {\n  return !isNil(smth);\n}\n\n\n/**\n * Takes some value `smth` as an argument and returns **boolean** -\n * `true` if `smth` is an array, `false` otherwise.\n *\n * Delegates to `Array.isArray` method.\n *\n * @category Test\n *\n * @param {*} smth value to test\n * @returns {Boolean} true if `smth` is an array, false otherwise\n *\n * @example\n *\n *     import {isArray} from '@yagni-js/yagni';\n *\n *     const res0 = isArray([]);   // => true\n *     const res1 = isArray({});   // => false\n *     const res2 = isArray(42);   // => false\n *\n */\nfunction isArray(smth) {\n  return Array.isArray(smth);\n}\n\n\n/**\n * Takes some value `smth` as an argument and returns **boolean** -\n * `true` if `smth` is an instance of Object, `false` otherwise.\n *\n * @category Test\n *\n * @param {*} smth value to test\n * @returns {Boolean} true if `smth` is an instance of Object, false otherwise\n *\n * @example\n *\n *     import {isObject} from '@yagni-js/yagni';\n *\n *     const res0 = isObject({});   // => true\n *     const res1 = isObject([]);   // => false\n *     const res2 = isObject(42);   // => false\n *\n */\nfunction isObject(smth) {\n  return Object.prototype.toString.call(smth) === '[object Object]';\n}\n\n\n/**\n * Takes some value `smth` as an argument and returns **boolean** -\n * `true` if `smth` is a string, `false` otherwise.\n *\n * @category Test\n *\n * @param {*} smth value to test\n * @returns {Boolean} true if `smth` is a string, false otherwise\n *\n * @example\n *\n *     import {isString} from '@yagni-js/yagni';\n *\n *     const res0 = isString('foo');   // => true\n *     const res1 = isString([]);      // => false\n *     const res2 = isString(42);      // => false\n *\n */\nfunction isString(smth) {\n  return Object.prototype.toString.call(smth) === '[object String]';\n}\n\n\n/**\n * Takes some value `smth` as an argument and returns **boolean** -\n * `true` if `smth` is a function, `false` otherwise.\n *\n * @category Test\n *\n * @param {*} smth value to test\n * @returns {Boolean} true if `smth` is a function, false otherwise\n *\n * @example\n *\n *     import {isFunction} from '@yagni-js/yagni';\n *\n *     function foo() { return 'baz'; }\n *\n *     const res0 = isFunction(foo);   // => true\n *     const res1 = isFunction([]);    // => false\n *     const res2 = isFunction(42);    // => false\n *\n */\nfunction isFunction(smth) {\n  return Object.prototype.toString.call(smth) === '[object Function]';\n}\n\n\n/**\n * Takes some value `smth` as an argument and returns **boolean**\n * `true` if `smth` strictly equals to `true`, `false` otherwise.\n *\n * @category Test\n *\n * @param {*} smth value to test\n * @returns {Boolean} true if `smth` strictly equals to `true`, false otherwise\n *\n * @example\n *\n *     import {isTrue} from '@yagni-js/yagni';\n *\n *     const foo = true;\n *     const baz = 42;\n *     const bar = false;\n *\n *     const res0 = isTrue(foo);   // => true\n *     const res1 = isTrue(baz);   // => false\n *     const res2 = isTrue(bar);   // => false\n *\n */\nfunction isTrue(smth) {\n  return smth === true;\n}\n\n\n/**\n * Takes some value `smth` as an argument and returns **boolean**\n * `true` if `smth` strictly equals to `false`, `false` otherwise.\n *\n * @category Test\n *\n * @param {*} smth value to test\n * @returns {Boolean} true if `smth` strictly equals to `false`, false otherwise\n *\n * @example\n *\n *     import {isFalse} from '@yagni-js/yagni';\n *\n *     const foo = false;\n *     const baz = 42;\n *     const bar = true;\n *\n *     const res0 = isFalse(foo);   // => true\n *     const res1 = isFalse(baz);   // => false\n *     const res2 = isFalse(bar);   // => false\n *\n */\nfunction isFalse(smth) {\n  return smth === false;\n}\n\n\n/**\n * Takes some value `left` as an argument and returns **a new function**,\n * which then takes some value `right` as an argument and returns **boolean**\n * as a result of strict comparision of `left` and `right`.\n *\n * @category Test\n *\n * @param {*} left some value to check equality to\n * @returns {Function} a new function to take `right` as an argument and\n * return true if `left` is strictly equal to `right` or false otherwise\n *\n * @example\n *\n *     import {equals} from '@yagni-js/yagni';\n *\n *     const isZero = equals(0);\n *\n *     const res0 = isZero(0);   // => true\n *     const res1 = isZero(42);  // => false\n *\n */\nfunction equals(left) {\n  return function _equals(right) {\n    return left === right;\n  };\n}\n\n/**\n * Takes a function `sideEffect` as an argument and returns **a new function**,\n * which then takes some value `smth` as an argument, calls `sideEffect(smth)`\n * throwing away it's result and returns back **`smth`**.\n *\n * @category Impure\n *\n * @param {Function} sideEffect function to call\n * @returns {Function} a new function to take `smth` as an argument, perform\n * a call `sideEffect(smth)` throwing away it's result and return `smth`\n *\n * @example\n *\n *     import {tap} from '@yagni-js/yagni';\n *\n *     const log = tap(console.log);\n *\n *     const res0 = log('foo');  // => 'foo', logs to console 'foo'\n *     const res1 = log(42);     // => 42, logs to console 42\n *\n */\nfunction tap(sideEffect) {\n  return function (smth) {\n    // NB. side effect\n    // eslint-disable-next-line fp/no-unused-expression\n    const r = sideEffect(smth);\n    return smth;\n  };\n}\n\n\n/**\n * Takes object, attribute name and new value for the attribute as arguments,\n * performs mutation and returns same object.\n *\n * @category Impure\n *\n * @param {Object} subj object to mutate\n * @param {String} attr attribute name\n * @param {*} value new value to assign to the attribute\n * @returns {Object} source object `subj`\n *\n * @example\n *\n *     import {mutate} from '@yagni-js/yagni';\n *\n *     var a = {};\n *\n *     var b = mutate(a, 'foo', 'baz');  // => {foo: 'baz'}, a === b\n *     var c = mutate(b, 'bar', 42);     // => {foo: 'baz', bar: 42}, b === c\n *\n */\nfunction mutate(subj, attr, value) {\n  // eslint-disable-next-line fp/no-mutation\n  subj[attr] = value;\n  return subj;\n}\n\n/**\n * Takes `key` and `value` as arguments and returns **a new object**.\n *\n * Uses `mutate` to mutate newly created empty object.\n *\n * @category Object\n *\n * @param {String} key key name\n * @param {*} value key value\n * @returns {Object} a new object, which has only one key\n *\n * @see mutate\n *\n * @example\n *\n *     import {obj} from '@yagni-js/yagni';\n *\n *     const o1 = obj('foo', 'baz');  // => {foo: 'baz'}\n *     const o2 = obj({'bar', 42);    // => {bar: 42}\n *\n */\nfunction obj(key, value) {\n  return mutate({}, key, value);\n}\n\n\n/**\n * Takes `key` as an argument and returns **a new function**, which then takes\n * some `value` as an argument and returns **a new object**.\n *\n * @category Object\n *\n * @param {String} key key name\n * @returns {Function} a new function to take `value` as an argument and return\n * a new object\n *\n * @see obj\n *\n * @example\n *\n *     import {objOf} from '@yagni-js/yagni';\n *\n *     const fooObj = objOf('foo');\n *\n *     const o1 = fooObj('baz');  // => {foo: 'baz'}\n *     const o2 = fooObj('bar');  // => {foo: 'bar'}\n *     const o3 = fooObj(42);     // => {foo: 42}\n *\n */\nfunction objOf(key) {\n  return function (value) {\n    return obj(key, value);\n  };\n}\n\n\n/**\n * Takes an object `a` as an argument and returns **a new function**,\n * which then takes an object `b` as an argument and returns **a new object**\n * as a result of merging `a` and `b`.\n *\n * Uses `Object.assign` method. Keeps source objects `a` and `b` untouched.\n *\n * @category Object\n *\n * @param {Object} a\n * @returns {Function} a new function to take an object `b` as an argument\n * and return a new object as a result of merging `a` and `b`\n *\n * @example\n *\n *     import {merge} from '@yagni-js/yagni';\n *\n *     const a = {foo: 'baz'};\n *     const b = {bar: 42};\n *     const mergeA = merge(a);\n *\n *     const res = mergeA(b);\n *     // => {foo: 'baz', bar: 42}, res !== a, res !== b\n *\n */\nfunction merge(a) {\n  return function (b) {\n    return Object.assign({}, a, b);\n  };\n}\n\n\n/**\n * Takes `key` name as an argument and returns **a new function**, which then\n * takes some object `smth` as an argument and returns **value** taken from\n * `smth` by `key`.\n *\n * @category Object\n *\n * @param {String} key key name\n * @returns {Function} a new function to take `smth` as an argument and\n * return value taken from `smth` by `key`\n *\n * @see pickFrom\n * @see pickPath\n *\n * @example\n *\n *     import {pick} from '@yagni-js/yagni';\n *\n *     const src = {foo: 12, baz: 42, bar: 80};\n *     const pickFoo = pick('foo');\n *     const pickBaz = pick('baz');\n *     const pickBar = pick('bar');\n *\n *     const foo = pickFoo(src);  // => 12\n *     const baz = pickBaz(src);  // => 42\n *     const bar = pickBar(src);  // => 80\n *\n */\nfunction pick(key) {\n  return function (smth) {\n    return smth[key];\n  };\n}\n\n\n/**\n * Takes some object `smth` as an argument and returns **a new function**,\n * which then takes `key` name as an argument and returns **value** taken from\n * `smth` by `key`.\n *\n * @category Object\n *\n * @param {Object} smth source object\n * @returns {Function} a new function to take `key` name as an argument and\n * return value taken from `smth` by `key`\n *\n * @see pick\n * @see pickPath\n *\n * @example\n *\n *     import {pickFrom} from '@yagni-js/yagni';\n *\n *     const src = {foo: 12, baz: 42, bar: 80};\n *     const pickSrc = pickFrom(src);\n *\n *     const foo = pickSrc('foo');  // => 12\n *     const baz = pickSrc('baz');  // => 42\n *     const bar = pickSrc('bar');  // => 80\n *\n */\nfunction pickFrom(smth) {\n  return function (key) {\n    return smth[key];\n  };\n}\n\n\n/**\n * Takes an array of key names chain `arr` as an argument and returns\n * **a new function**, which then takes an object `smth` and returns\n * **last value** in chain of keys from `arr` or `undefined`.\n *\n * Uses `reduce` method of `arr` argument.\n *\n * @category Object\n *\n * @param {Array} arr array of key names\n * @returns {Function} a new function to take some object `smth`\n * as an argument and return last value in chain of keys from `arr` or\n * `undefined`\n *\n * @see pick\n * @see pickFrom\n *\n * @example\n *\n *     import {pickPath} from '@yagni-js/yagni';\n *\n *     const path = ['foo', 'baz', 'bar'];\n *     const getFooBazBar = pickPath(path);\n *\n *     const src = {\n *       foo: {\n *         baz: {\n *           bar: 42\n *         }\n *       }\n *     };\n *\n *     const res0 = getFooBazBar(src);        // => 42\n *     const res1 = getFooBazBar({foo: {}});  // => undefined\n *     const res2 = getFooBazBar({});         // => undefined\n */\nfunction pickPath(arr) {\n  return function (smth) {\n    return arr.reduce(function (acc, key) { return isNil(acc) ? acc : acc[key]; }, smth);\n  };\n}\n\n\n/**\n * Takes key name `key` as an argument and returns **a new function**,\n * which then takes some object `smth` as an argument and returns\n * **boolean** - `true` in case object has defined value for `key`,\n * `false` otherwise.\n *\n * @category Object\n *\n * @param {String} key key name\n * @returns {Function} a new function to take some object `smth` as an argument\n * and return true if `smth` has defined value for `key`, `false` otherwise\n *\n * @example\n *\n *     import {has} from '@yagni-js/yagni';\n *\n *     const hasFoo = has('foo');\n *     const hasBaz = has('baz');\n *\n *     const src = {foo: 42};\n *\n *     const res0 = hasFoo(src);  // => true\n *     const res1 = hasBaz(src);  // => false\n *\n */\nfunction has(key) {\n  return function (smth) {\n    return isDefined(smth[key]);\n  };\n}\n\n\n/**\n * Takes some object `smth` and returns **an array** of key names.\n *\n * Uses `Object.keys` to get the result.\n *\n * @category Object\n *\n * @param {Object} smth source object\n * @returns {Array} an array of key names\n *\n * @see values\n * @see items\n *\n * @example\n *\n *     import {keys} from '@yagni-js/yagni';\n *\n *     const res = keys({foo: 42, baz: 'bar'});  // => ['foo', 'baz'];\n *\n */\nfunction keys(smth) {\n  return Object.keys(smth);\n}\n\n\n/**\n * Takes some object `smth` and returns **an array** of values.\n *\n * @category Object\n *\n * @param {Object} smth source object\n * @returns {Array} an array of values\n *\n * @see keys\n * @see items\n *\n * @example\n *\n *     import {values} from '@yagni-js/yagni';\n *\n *     const res = values({foo: 42, baz: 'bar'});  // => [42, 'bar'];\n *\n */\nfunction values(smth) {\n  return keys(smth).map(function (key) { return smth[key]; });\n}\n\n\n/**\n * Takes some object `smth` as an argument and returns **an array** of objects,\n * each object has correspondent `key` and `value` fields taken from `smth`.\n *\n * @category Object\n *\n * @param {Object} smth source object\n * @returns {Array} an array of objects\n *\n * @see keys\n * @see values\n *\n * @example\n *\n *     import {items} from '@yagni-js/yagni';\n *\n *     const src = {foo: 42, baz: 'bar'};\n *\n *     const res = items(src);\n *     // =>\n *     // [\n *     //   {key: 'foo', value: 42},\n *     //   {key: 'baz', value: 'bar'}\n *     // ]\n *\n */\nfunction items(smth) {\n  return keys(smth).map(function (key) { return {key: key, value: smth[key]}; });\n}\n\n\n/**\n * Takes an array of key names `arr` and returns **a new function**,\n * which then takes some object `smth` and returns **a new object**, which\n * doesn't have specified in `arr` keys.\n *\n * @category Object\n *\n * @param {Array} arr an array of key names to exclude\n * @returns {Function} a new function to take some object `smth`\n * as an argument and return a new object with keys from `arr` excluded\n *\n * @example\n *\n *     import {omit} from '@yagni-js/yagni';\n *\n *     const src = {foo: 'foo', baz: 'baz', bar: 'bar'};\n *     const omitFoo = omit(['foo']);\n *     const omitBazBar = omit(['baz', 'bar']);\n *\n *     const res0 = omitFoo(src);     // => {baz: 'baz', bar: 'bar'}\n *     const res1 = omitBazBar(src);  // => {foo: 'foo'}\n *\n */\nfunction omit(arr) {\n  return function _omit(smth) {\n    return keys(smth).reduce(\n      function (acc, key) {\n        return arr.indexOf(key) === -1 ? Object.assign({}, acc, obj(key, smth[key])) : acc;\n      },\n      {}\n    );\n  };\n}\n\n\n/**\n * Takes a function `mapper` as an argument and returns **a new function**,\n * which then takes an object `obj` as an argument and returns **a new array**,\n * produced by applying `mapper` to each `(key, value)` pair of `obj`.\n *\n * `mapper` function must have the following signature:\n *\n *     function mapper(key, value[, idx])\n *\n * Delegates to `map` method of array of `obj` keys.\n *\n * @category Object\n *\n * @param {Function} mapper function to apply to each `(key, value)` pair\n * of source object\n * @returns {Function} a new function to take an object `obj` as an argument\n * and produce a new array by applying `mapper` to each `(key, value)` pair\n * of `obj`.\n *\n * @see map\n *\n * @example\n *     import {mapObj} from '@yagni-js/yagni';\n *\n *     function toParam(key, value) { return key + '=' + value; }\n *     const mapper = mapObj(toParam);\n *\n *     const src = {foo: 'baz', bar: 42};\n *\n *     const res = mapper(src);  // => ['foo=baz', 'bar=42']\n *\n */\nfunction mapObj(mapper) {\n  return function _mapObj(obj) {\n    return keys(obj).map(\n      function __mapObj(key, idx) {\n        return mapper(key, obj[key], idx);\n      }\n    );\n  };\n}\n\n\n/**\n * Takes a function `reducer` as an argument and returns **a new function**,\n * which then takes an object `obj` as an argument and returns\n * **a new function**, which then takes some `initial` value as an argument\n * resulting **in a single output value**, produced by executing the specified\n * `reducer` function on each `(key, value)` pair from `obj`.\n *\n * `reducer` function must have the following signature:\n *\n *     function reducer(accumulator, key, value[, idx])\n *\n * and must return single output value.\n *\n * Delegates to `reduce` method of array of `obj` keys.\n *\n * @category Object\n *\n * @param {Function} reducer function to iteratively apply to each key, value\n * pair of source object\n * @returns {Function} a new function to take `obj` as an argument and\n * produce another new function to take `initial` value and execute\n * `reducer` function over each `(key, value)` pair of the `obj`\n * producing a single output value\n *\n * @see reduce\n *\n * @example\n *     import {reduceObj} from '@yagni-js/yagni';\n *\n *     function swap(acc, key, value) {\n *       return Object.assign({}, acc, _.obj(value, key));\n *     }\n *     const swapper = reduceObj(swap);\n *     const data = {foo: 'baz', bar: 42};\n *     const swapData = swapper(data);\n *\n *     const res0 = swapData({});\n *     // =>\n *     // {baz: 'foo', '42': 'bar'}\n *\n *     const res1 = swapData({lorem: 'ipsum'});\n *     // =>\n *     // {baz: 'foo', '42': 'bar', ipsum: 'lorem'}\n *\n */\nfunction reduceObj(reducer) {\n  return function _reduceObj(obj) {\n    return function __reduceObj(initial) {\n      return keys(obj).reduce(\n        function ___reduceObj(acc, key, idx) {\n          return reducer(acc, key, obj[key], idx);\n        },\n        initial\n      );\n    };\n  };\n}\n\n/**\n * Takes an array-like object `smth` as input\n * and returns **a new array**.\n *\n * Delegates to `Array.prototype.slice` method call.\n *\n * @category Array\n *\n * @param {*} smth array-like collection or object\n * @returns {Array} newly created array\n *\n * @example\n *     import {toArray} from '@yagni-js/yagni';\n *\n *     const obj = {0: 'foo', 1: 'baz', 2: 'bar', length: 3};\n *     const arr = toArray(obj);  // => ['foo', 'baz', 'bar']\n *\n */\nfunction toArray(smth) {\n  return Array.prototype.slice.call(smth);\n}\n\n\n/**\n * Takes an array as input and returns **first element** from it.\n *\n * @function\n * @category Array\n *\n * @param {Array} arr source array\n * @returns {*} first element from array or `undefined` if array is empty\n *\n * @example\n *     import {first} from '@yagni-js/yagni;\n *\n *     const arr = ['foo', 'baz', 'bar'];\n *     const foo = first(arr);  // => 'foo'\n *\n */\nconst first = pick(0);\n\n\n/**\n * Takes an array as input and returns **it's length**.\n *\n * @function\n * @category Array\n *\n * @param {Array} arr source array\n * @returns {Number} length of array\n *\n * @example\n *     import {length} from '@yagni-js/yagni';\n *\n *     const arr = ['foo', 'baz', 'bar'];\n *     const len = length(arr);  // => 3\n *\n */\nconst length = pick('length');\n\n\n/**\n * Takes a function `mapper` as an argument and returns **a new function**,\n * which then takes an array `arr` as an argument and returns **a new array**,\n * produced by applying `mapper` to each element of `arr`.\n *\n * Delegates to `map` method of `arr` argument.\n *\n * @category Array\n *\n * @param {Function} mapper function to apply to each element of source array\n * @returns {Function} a new function to take an array `arr` as an argument\n * and produce a new array by applying `mapper` to each element of `array`\n *\n * @see pipe\n * @see mapObj\n *\n * @example\n *     import {map} from '@yagni-js/yagni';\n *\n *     function _add2(x) { return x + 2; }\n *     const add2 = map(_add2);\n *\n *     const src = [2, 5, 8];\n *     const dst = add2(src);  // => [4, 7, 10]\n *\n */\nfunction map(mapper) {\n  return function _map(arr) {\n    return arr.map(mapper);\n  };\n}\n\n\n/**\n * Takes a function `reducer` as an argument and returns **a new function**,\n * which then takes an array `arr` as an argument and returns\n * **a new function**, which then takes some `initial` value as an argument\n * resulting **in a single output value**, produced by executing the specified\n * `reducer` function on each member of `arr` array.\n *\n * `reducer` function must have the following signature:\n *\n *     function reducer(accumulator, currentValue)\n *\n * and must return single output value.\n *\n * Delegates to `reduce` method of `arr` argument.\n *\n * @category Array\n *\n * @param {Function} reducer function to iteratively apply to each element of\n * source array\n * @returns {Function} a new function to take `arr` as an argument and\n * produce another new function to take `initial` value and execute\n * `reducer` function over each member of the `arr` producing a single\n * output value\n *\n * @see pipe\n * @see reduceObj\n *\n * @example\n *     import {reduce} from '@yagni-js/yagni';\n *\n *     function reducer(acc, val) { return acc + val; }\n *     const sum = reduce(reducer);\n *     const values = [2, 5, 8];\n *     const overall = sum(values);\n *\n *     const res0 = overall(-15);  // => 0\n *     const res1 = overall(27);  // => 42\n *     const res2 = overall(73);  // => 88\n *\n */\nfunction reduce(reducer) {\n  return function _reduce(arr) {\n    return function __reduce(initial) {\n      return arr.reduce(reducer, initial);\n    };\n  };\n}\n\n\n/**\n * Takes a function `reducer` as an argument and returns **a new function**,\n * which then takes an array `arr` as an argument and produces **a new array**\n * by executing the specified `reducer` function over each member\n * of `arr` array.\n *\n * `reducer` function must have the following signature:\n *\n *     function reducer(accumulator, currentValue)\n *\n * and must return an **array**.\n *\n * Delegates to `reduce` method of `arr` argument.\n *\n * @category Array\n *\n * @param {Function} reducer function to iteratively apply to each element of\n * source array\n * @returns {Function} a new function to take `array` as an argument and\n * execute `reducer` function over each member of the `array` producing a new\n * array as output value\n *\n * @see filterMap\n * @see flatten\n * @see unique\n *\n * @example\n *     import {reduceToArr} from '@yagni-js/yagni';\n *\n *     function reducer(acc, val) { return val === 0 ? acc : acc.concat(val); }\n *     const excludeZeros = reduceToArr(reducer);\n *     const values = [2, 0, 5, 8, 0, 1];\n *\n *     const res = excludeZeros(values);  // => [2, 5, 8, 1]\n *\n */\nfunction reduceToArr(reducer) {\n  return function _reduceToArr(arr) {\n    return arr.reduce(reducer, []);\n  };\n}\n\n\n/**\n * Takes an array `arr` of functions as an argument\n * and returns **a new function**,\n * which then takes an `initial` value as an argument resulting in **a single\n * output value**, produced by iteratively executing each function from `array`\n * over the result of a previous function call.\n *\n * This is the **cornerstone** of `@yagni-js/yagni`.\n *\n * The idea for such implementation was borrowed from Elixir - you prepare\n * functions to be executed one after another and trigger the execution by\n * providing initial value.\n *\n * All functions to execute must be unary (must take only one argument) and\n * must return single output value.\n *\n * Delegates to `reduce` method of `arr` argument.\n *\n * @function\n * @category Array\n *\n * @param {Array} arr array of functions\n * @returns {Function} a new function to take `initial` value as an argument\n * and execute one by one function from source `array` producing a single\n * output value\n *\n * @see reduce\n *\n * @example\n *     import {pipe} from '@yagni-js/yagni';\n *\n *     function add2(x) { return x + 2; }\n *     function square(x) { return x * x; }\n *     function minus7(x) { return x - 7; }\n *\n *     const ops = pipe([\n *       add2,\n *       square,\n *       minus7\n *     ]);\n *\n *     const res0 = ops(5);  // => 42\n *     const res1 = ops(6);  // => 57\n *\n */\nconst pipe = reduce(\n  function _pipe(acc, piper) {\n    return piper(acc);\n  }\n);\n\n\n/**\n * Promise-related version of `pipe` function.\n *\n * Takes an array `arr` of functions as an argument\n * and returns **a new function**,\n * which then takes an `initial` value as an argument resulting in **a single\n * output value** (an instance of Promise, ie. `thenable`),\n * produced by iteratively executing each function from `array`\n * over the result of a previous function call.\n *\n * All functions to execute must be unary (must take only one argument) and\n * must return single output value.\n *\n * `initial` value will be resolved using `Promise.resolve` method.\n * Functions to call will be passed to `Promise.then` method.\n *\n * NB. there is no way to handle errors within promises using this function.\n *\n * Delegates to `reduce` method of `arr` argument.\n *\n * @deprecated consider using `pipe` with `then` function\n * (for better error handling)\n *\n * @function\n * @category Array\n *\n * @param {Array} arr array of functions\n * @returns {Function} a new function to take `initial` value as an argument\n * and execute one by one function from source `array` producing a single\n * output value (an instance of Promise, ie. `thenable`)\n *\n * @example\n *     import {pipeP} from '@yagni-js/yagni';\n *\n *     function add2(x) { return x + 2; }\n *     function square(x) { return x * x; }\n *     function minus7(x) { return x - 7; }\n *\n *     const ops = pipeP([\n *       add2,\n *       square,\n *       minus7\n *     ]);\n *\n *     const res = ops(5);  // => resolved Promise with 42 as a result value\n *\n */\nfunction pipeP(arr) {\n  return function _pipeP(initial) {\n    return arr.reduce(function (acc, piper) { return acc.then(piper); }, Promise.resolve(initial));\n  };\n}\n\n\n/**\n * Takes a function `predicate` as an argument and returns **a new function**,\n * which then takes an array `arr` as an argument and returns **a new array**,\n * containing items from `arr` which satisfy `predicate`.\n *\n * Delegates to `filter` method of `arr` argument.\n *\n * @category Array\n *\n * @param {Function} predicate function to check if an array item satisfies\n * the condition\n * @returns {Function} a new function to take an array `array` as an argument\n * and produce a new array containing items which satisfy `predicate`\n *\n * @example\n *     import {filter} from '@yagni-js/yagni';\n *\n *     function belowZero(x) { return x < 0; }\n *     const negatives = filter(belowZero);\n *\n *     const values = negatives([-1, 2, 4, 3, -3, -2, 0]);  // => [-1, -3, -2]\n *\n */\nfunction filter(predicate) {\n  return function _filter(arr) {\n    return arr.filter(predicate);\n  };\n}\n\n\n/**\n * Takes a function `predicate` and function `mapper` as arguments\n * and returns **a new function**,\n * which then takes an array `arr` as an argument and returns **a new array**,\n * produced by applying `mapper` to such elements of `arr`, which satisfy\n * `predicate`.\n *\n * Delegates to `reduce` method of `arr` argument.\n *\n * @category Array\n *\n * @param {Function} predicate function to check if an array item satisfies\n * the condition\n * @param {Function} mapper function to apply to satisfied elements of array\n * @returns {Function} a new function to take an array `arr` as an argument\n * and produce a new array by applying `mapper` to such elements of `arr`,\n * which satisfy `predicate`\n *\n * @example\n *     import {filterMap} from '@yagni-js/yagni';\n *\n *     function aboveZero(x) { return x > 0; }\n *     function square(x) { return x * x; }\n *\n *     const doublePositives = filterMap(aboveZero, square);\n *\n *     const values = doublePositives([-1, 1, -2, 2, -3, 3]);  // => [1, 4, 9]\n *\n */\nfunction filterMap(predicate, mapper) {\n  return reduceToArr(\n    function _filterMap(acc, smth) {\n      return predicate(smth) ? acc.concat(mapper(smth)) : acc;\n    }\n  );\n}\n\n\n/**\n * Takes an array `arr` as an argument and returns **a new function**,\n * which then takes some value `smth` as an argument and returns\n * **a new array**, produced by concatenating `arr` and `smth`.\n *\n * Delegates to `concat` method of `arr` argument.\n *\n * @category Array\n *\n * @param {Array} arr source array\n * @returns {Function} a new function to take some value `smth` as an argument\n * and produce a new array by concatenating source `arr` with `smth`\n *\n * @example\n *     import {concat} from '@yagni-js/yagni';\n *\n *     const a = ['foo'];\n *     const b = ['baz'];\n *\n *     const c = concat(a);\n *\n *     const d = c(b);  // => ['foo', 'baz']\n *\n */\nfunction concat(arr) {\n  return function _concat(smth) {\n    return arr.concat(smth);\n  };\n}\n\n\n/**\n * Takes `separator` as an argument and returns **a new function**,\n * which then takes an array `arr` as an argument and returns **string**,\n * produced by concatenating all of the elements in `arr`,\n * separated by specified `separator`.\n *\n * If `separator` is not defined (`undefined` or `null`) `arr` will be\n * concatenated using *comma* as a separator.\n *\n * Delegates to `join` method of `arr` argument.\n *\n * @category Array\n *\n * @param {*} separator string to separate adjacent elements of array\n * @returns {Function} a new function to take array `arr` as an argument\n * and produce a string by concatenating all of the elements in `arr`\n * separated by `separator`\n *\n * @example\n *     import {join} from '@yagni-js/yagni';\n *\n *     const commaJoin = join();\n *     const dotJoin = join('.');\n *\n *     const data = ['foo', 'baz', 'bar'];\n *\n *     const res0 = commaJoin(data);  // => 'foo,baz,bar'\n *     const res1 = dotJoin(data);    // => 'foo.baz.bar'\n *\n */\nfunction join(separator) {\n  return function _join(arr) {\n    return isDefined(separator) ? arr.join(separator) : arr.join();\n  };\n}\n\n\n/**\n * Takes an array `arr` and produces **a new array** by taking all elements\n * from source `arr` and it's sub-arrays and placing them in a new array.\n *\n * Uses `concat` method of new array.\n *\n * @function\n * @category Array\n *\n * @param {Array} arr source array to flatten\n * @returns {Array} flattened version of source array\n *\n * @example\n *     import {flatten} from '@yagni-js/yagni';\n *\n *     const src = [[1, 2], [[3], 4, [[5]]]];\n *\n *     const dst = flatten(src);  // => [1, 2, 3, 4, 5]\n *\n */\nconst flatten = reduceToArr(\n  function _flatten(acc, item) {\n    return acc.concat(isArray(item) ? flatten(item) : item);\n  }\n);\n\n\n/**\n * Takes a function `mapper` as an argument and returns **a new function**,\n * which then takes an array `arr` as an argument and produces **a new array**\n * by taking all elements from source `arr` and it's sub-arrays,\n * applying `mapper` to them and placing the result in a new array.\n *\n * Uses `reduce` method of source array and `concat` method of new array.\n *\n * @category Array\n *\n * @param {Function} mapper function to apply to each element of new array\n * @returns {Function} a new function to take an array `arr` as an argument\n * and produce a new array by taking all elements from source `arr` and\n * it's sub-arrays, apply `mapper` to them and place the result in a new array\n *\n * @see flatten\n *\n * @example\n *     import {flattenMap} from '@yagni-js/yagni';\n *\n *     function square(x) { return x * x; }\n *\n *     const processor = flattenMap(square);\n *\n *     const src = [[1, 2], [[3], 4, [[5]]]];\n *\n *     const dst = processor(src);  // => [1, 4, 9, 16, 25]\n *\n */\nfunction flattenMap(mapper) {\n  return function _flattenMap(arr) {\n    return arr.reduce(\n      function __flattenMap(acc, item) {\n        return acc.concat(isArray(item) ? _flattenMap(item) : mapper(item));\n      },\n      []\n    );\n  };\n}\n\n\n/**\n * Takes a function `predicate` as an argument and returns **a new function**,\n * which then takes an array `arr` as an argument and returns **true** if\n * all `arr` items satisfy `predicate` or **false** otherwise.\n *\n * Delegates to `every` method of `arr` argument.\n *\n * @category Array\n *\n * @param {Function} predicate function to check if an array item satisfies\n * the condition\n * @returns {Function} a new function to take an array `arr` as an argument\n * and return `true` if all `arr` items satisfy `predicate` or `false` otherwise\n *\n * @example\n *     import {all} from '@yagni-js/yagni';\n *\n *     function below10(x) { return x < 10; }\n *     const allBelow10 = all(below10);\n *\n *     const res0 = allBelow10([2, 4, 6]);   // => true\n *     const res1 = allBelow10([12, 4, 6]);  // => false\n *\n */\nfunction all(predicate) {\n  return function _all(arr) {\n    return arr.every(predicate);\n  };\n}\n\n\n/**\n * Takes a function `predicate` as an argument and returns **a new function**,\n * which then takes an array `arr` as an argument and returns **true** if\n * at least one `arr` item satisfy `predicate` or **false** otherwise.\n *\n * Delegates to `some` method of `arr` argument.\n *\n * @category Array\n *\n * @param {Function} predicate function to check if an array item satisfies\n * the condition\n * @returns {Function} a new function to take an array `arr` as an argument\n * and return `true` if at least one `arr` item satisfy `predicate`\n * or `false` otherwise\n *\n * @example\n *     import {any} from '@yagni-js/yagni';\n *\n *     function below10(x) { return x < 10; }\n *     const anyBelow10 = any(below10);\n *\n *     const res0 = anyBelow10([10, 20, 30, 5, 40]);   // => true\n *     const res1 = anyBelow10([10, 20, 30, 40, 50]);  // => false\n *\n */\nfunction any(predicate) {\n  return function _any(arr) {\n    return arr.some(predicate);\n  };\n}\n\n\n/**\n * Takes `smth` as an argument and returns **a new function**,\n * which then takes an array `arr` as an argument and returns\n * **the first index** at which `smth` can be found in the `arr` or -1 if\n * it is not present.\n *\n * Delegates to `indexOf` method of `arr` argument.\n *\n * @category Array\n *\n * @param {*} smth element to locate in array\n * @returns {Function} a new function to take array `arr` as an argument\n * and return the first index at which `smth` can be found in `arr` or -1 if\n * it is not present in `arr`\n *\n * @example\n *     import {index} from '@yagni-js/yagni';\n *\n *     const data = ['foo', 'baz', 'bar'];\n *\n *     const fooIndex = index('foo');\n *     const ftIndex = index(42);\n *\n *     const res0 = fooIndex(data);  // => 0\n *     const res1 = ftIndex(data);   // => -1\n *\n */\nfunction index(smth) {\n  return function _index(arr) {\n    return arr.indexOf(smth);\n  };\n}\n\n\n/**\n * Takes an array `arr` as an argument and returns **a new function**,\n * which then takes `smth` as an argument and returns\n * **the first index** at which `smth` can be found in the `arr` or -1 if\n * it is not present.\n *\n * Delegates to `indexOf` method of `arr` argument.\n *\n * @category Array\n *\n * @param {Array} arr array to search for some element's index in\n * @returns {Function} a new function to take `smth` as an argument\n * and return the first index at which `smth` can be found in `arr` or -1 if\n * it is not present in `arr`\n *\n * @example\n *     import {indexIn} from '@yagni-js/yagni';\n *\n *     const data = ['foo', 'baz', 'bar'];\n *     const getIndexIn = indexIn(data);\n *\n *     const res0 = getIndexIn('foo');  // => 0\n *     const res1 = getIndexIn(42);     // => -1\n *\n */\nfunction indexIn(arr) {\n  return function _indexIn(smth) {\n    return arr.indexOf(smth);\n  };\n}\n\n\n/**\n * Takes `smth` as an argument and returns **a new function**,\n * which then takes an array `arr` as an argument and returns\n * **true** if `smth` is present in `arr` or **false** otherwise.\n *\n * Delegates to `indexOf` method of `arr` argument.\n *\n * @category Array\n *\n * @param {*} smth element to locate in array\n * @returns {Function} a new function to take array `arr` as an argument\n * and return true if `smth` was found in `arr` or false otherwise\n *\n * @example\n *     import {exists} from '@yagni-js/yagni';\n *\n *     const ftExists = exists(42);\n *\n *     const res0 = ftExists(['foo', 'baz', 'bar']);  // => false\n *     const res1 = ftExists(['foo', '42', 'bar']);   // => true\n *\n */\nfunction exists(smth) {\n  return pipe([\n    index(smth),\n    not(equals(-1))\n  ]);\n}\n\n\n/**\n * Takes an array `arr` as an argument and returns **a new function**,\n * which then takes `smth` as an argument and returns\n * **true** if `smth` is present in `arr` or **false** otherwise.\n *\n * Delegates to `indexOf` method of `arr` argument.\n *\n * @category Array\n *\n * @param {Array} arr array to check some element is inside\n * @returns {Function} a new function to take `smth` as an argument\n * and return true if `smth` was found in `arr` or false otherwise\n *\n * @example\n *     import {existsIn} from '@yagni-js/yagni';\n *\n *     const isInside = existsIn(['foo', 'baz', 42]);\n *\n *     const res0 = isInside('foo');  // => true\n *     const res1 = isInside('bar');  // => false\n *     const res2 = isInside(42);     // => true\n *\n */\nfunction existsIn(arr) {\n  return pipe([\n    indexIn(arr),\n    not(equals(-1))\n  ]);\n}\n\n\n/**\n * Takes an array `arr` and produces **a new array** by taking unique elements\n * from source `arr` and placing them in a new array.\n *\n * Uses `concat` and `indexOf` methods of new array.\n *\n * @function\n * @category Array\n *\n * @param {Array} arr source array to get unique elements from\n * @returns {Array} array with unique elements from `arr`\n *\n * @example\n *     import {unique} from '@yagni-js/yagni';\n *\n *     const src = [1, 2, 2, 3, 2, 3, 4, 4, 5];\n *\n *     const dst = unique(src);  // => [1, 2, 3, 4, 5]\n *\n */\nconst unique = reduceToArr(\n  function _unique(acc, item) {\n    return acc.indexOf(item) === -1 ? acc.concat(item) : acc;\n  }\n);\n\n/**\n * Takes some value `smth` as an argument and returns it back.\n *\n * @category Function\n *\n * @param {*} smth some value\n * @returns {*} `smth`\n *\n * @example\n *\n *     import {identity} from '@yagni-js/yagni';\n *\n *     const foo = identity('foo');  // => 'foo'\n *\n */\nfunction identity(smth) {\n  return smth;\n}\n\n\n/**\n * Takes some value `smth` as an argument and returns **a new function**,\n * which when called always return `smth`.\n *\n * @category Function\n *\n * @param {*} smth some value\n * @returns {Function} a new function which when called always return `smth`\n *\n * @example\n *\n *     import {always} from '@yagni-js/yagni';\n *\n *     const answer = _.always(42);\n *\n *     const res0 = answer();       // => 42\n *     const res1 = answer('foo');  // => 42\n *     const res2 = answer('baz');  // => 42\n *     const res3 = answer(true);   // => 42\n *     const res4 = answer([12]);   // => 42\n *\n */\nfunction always(smth) {\n  return function _always() {\n    return smth;\n  };\n}\n\n\n/**\n * Lazily evaluates function result.\n *\n * Takes an unary function `caller` and some value `arg` for it and returns\n * **a new function**, which when called always returns the result of\n * evaluating `caller(arg)`.\n *\n * @category Function\n *\n * @param {Function} caller function to call\n * @param {*} arg some value as an argument for `caller`\n * @returns {Function} a new function to call and return the result of\n * `caller(arg)`\n *\n * @example\n *\n *     import {lazy} from '@yagni-js/yagni';\n *\n *     function add2(x) { return x + 2; }\n *\n *     const fixedPrice = lazy(add2, 40);\n *\n *     const res0 = fixedPrice();       // => 42\n *     const res1 = fixedPrice('foo');  // => 42\n *\n */\nfunction lazy(caller, arg) {\n  return function _lazy() {\n    return caller(arg);\n  };\n}\n\n\n/**\n * Takes a function or some value `smth` as a first argument and\n * some value `arg` as a second argument and returns result of calling\n * `smth(arg)` if `smth` is a function; or just `smth` if it's not a function\n *\n * @category Function\n *\n * @param {Function|*} smth function or some value\n * @param {*} arg argument for `smth` if it's a function\n * @returns {*} result of calling `smth(arg)` if `smth` is a function;\n * `smth` otherwise\n *\n * @see resultArr\n *\n * @example\n *\n *     import {result} from '@yagni-js/yagni';\n *\n *     function add2(x) { return x + 2; }\n *\n *     const res0 = result(42);             // => 42\n *     const res1 = result('foo', 42);      // => 'foo'\n *     const res2 = result(add2, 40);       // => 42\n */\nfunction result(smth, arg) {\n  return isFunction(smth) ? smth(arg) : smth;\n}\n\n\n/**\n * Takes an array `arr` of functions or some values as a first argument\n * and some value `arg` as a second argument and returns **a new array**,\n * produced by calling `result(item, arg)` over each element of `arr`.\n *\n * Uses `map` method of `arr` argument.\n *\n * @category Function\n *\n * @param {Array} arr array of functions or some values\n * @returns {Array} a new array produced by calling `result(item, arg)`\n * over each element of `arr`\n *\n * @see result\n *\n * @example\n *\n *     import {resultArr} from '@yagni-js/yagni';\n *\n *     const src = [\n *       'foo',\n *       function single(x) { return x; },\n *       function double(x) { return x * x; },\n *       function triple(x) { return x * x * x; },\n *       42];\n *\n *     const res = resultArr(src, 2);  // => ['foo', 2, 4, 8, 42]\n *\n */\nfunction resultArr(arr, arg) {\n  return arr.map(function _resultArr(smth) { return result(smth, arg); });\n}\n\n\n/**\n * Takes two functions `caller` and `argGetter` as arguments and returns\n * **a new function** which then takes some value `smth` as an argument\n * and returns result of calling `caller(argGetter(smth))`.\n *\n * @category Function\n *\n * @param {Function} caller target function to call\n * @param {Function} argGetter function to call to get an argument `arg`\n * @returns {Function} a new function to take some value `smth`, call\n * `argGetter(smth)` to get some value `arg` and return the result of calling\n * `caller(arg)`\n *\n * @example\n *\n *     import {fn, pick} from '@yagni-js/yagni';\n *\n *     function add2(x) { return x + 2; }\n *     const pickFoo = pick('foo');\n *\n *     const answer = fn(add2, pickFoo);\n *\n *     const src = {foo: 40};\n *\n *     const res = answer(src);  // => 42\n *\n */\nfunction fn(caller, argGetter) {\n  return function _fn(smth) {\n    const param = argGetter(smth);\n    return caller(param);\n  };\n}\n\n\n/**\n * Takes three functions `caller`, `argGetter1` and `argGetter2`\n * as arguments and returns\n * **a new function** which then takes some value `smth` as an argument\n * and returns result of calling `caller(argGetter1(smth), argGetter2(smth))`.\n *\n * @category Function\n *\n * @param {Function} caller target function to call\n * @param {Function} argGetter1 function to call to get an argument `arg1`\n * @param {Function} argGetter2 function to call to get an argument `arg2`\n * @returns {Function} a new function to take some value `smth`, call\n * `argGetter1(smth)` and `argGetter2(smth)` to get some values\n * `arg1` and `arg2` and return the result of calling `caller(arg1, arg2)`\n *\n * @example\n *\n *     import {fn2, obj, pick} from '@yagni-js/yagni';\n *\n *     const pickFoo = pick('foo');\n *     const pickBaz = pick('baz');\n *\n *     const toObj = fn2(obj, pickFoo, pickBaz);\n *\n *     const src = {foo: 'key', baz: 'value'};\n *\n *     const res = toObj(src);   // => {key: 'value'}\n *\n */\nfunction fn2(caller, arg1Getter, arg2Getter) {\n  return function _fn2(smth) {\n    const arg1 = arg1Getter(smth);\n    const arg2 = arg2Getter(smth);\n    return caller(arg1, arg2);\n  };\n}\n\n\n/**\n * Takes some object `subj` as a first argument and `methodName` as a second\n * argument and returns **a new function**, which then takes some value `smth`\n * as an argument and returns result of calling `methodName` method of `subj`\n * using `smth` as an argument.\n *\n * @category Function\n *\n * @param {Object} subj owner of a method to call\n * @param {String} methodName method name\n * @returns {Function} a new function to take some value `smth` and return\n * the result of calling `methodName` method of `subj` using `smth` as an\n * argument\n *\n * @example\n *\n *     import {method} from '@yagni-js/yagni';\n *\n *     const stringify = method(JSON, 'stringify');\n *\n *     const src = {foo: 42, 'baz': true};\n *\n *     const res = stringify(src);  // => '{\"foo\":42,\"baz\":true}'\n *\n */\nfunction method(subj, methodName) {\n  return function _method(smth) {\n    return subj[methodName](smth);\n  };\n}\n\n\n/**\n * Takes two functions `fnGetter` and `argOrGetter` as arguments and returns\n * **a new function** which then takes some value `smth` as an argument\n * and:\n *   - calls `fnGetter(smth)` to get target function `caller` to call\n *   - calls `argOrGetter(smth)` to get an argument `arg` to use for `caller`\n *   - returns the result of `caller(arg)` call.\n *\n * `argOrGetter` can be a function or some static value to use as an `arg`\n * argument for `caller`.\n *\n * @category Function\n *\n * @param {Function} fnGetter function to call to return\n * target function `caller`\n * @param {Function|*} argOrGetter some static value or function to call\n * to get an argument `arg` for `caller`\n * @returns {Function} a new function to take some value `smth`, call\n * `fnGetter(smth)` to get target function to call,\n * call `argOrGetter(smth)` if it's a function or simply use `argOrGetter`\n * as an `arg` argument for `caller` and return the result of calling\n * `caller(arg)`\n *\n * @see isFunction\n * @see call2\n * @see callMethod\n * @see callMethod2\n *\n * @example\n *\n *     import {call, pick, prefix, pipe} from '@yagni-js/yagni';\n *\n *     const getFoo = pick('foo');\n *     const getBaz = pick('baz');\n *     const makePrefix = pipe([\n *       getFoo,\n *       prefix\n *     ];\n *\n *     const makeFooBaz = call(makePrefix, getBaz);\n *\n *     const src = {\n *       foo: 'foo',\n *       baz: 'baz'\n *     };\n *\n *     const res = makeFooBaz(src);  // => 'foobaz'\n *\n */\nfunction call(fnGetter, argOrGetter) {\n  return function _call(smth) {\n    const caller = fnGetter(smth);\n    const param = isFunction(argOrGetter) ? argOrGetter(smth) : argOrGetter;\n    return caller(param);\n  };\n}\n\n\n/**\n * Takes three functions `fnGetter`, `argOrGetter1` and `argOrGetter2`\n * as arguments and returns **a new function** which then takes\n * some value `smth` as an argument and:\n *   - calls `fnGetter(smth)` to get target function `caller` to call\n *   - calls `argOrGetter1(smth)` to get an argument `arg1`\n *     to use for `caller`\n *   - calls `argOrGetter2(smth)` to get an argument `arg2`\n *     to use for `caller`\n *   - returns the result of `caller(arg1, arg2)` call.\n *\n * `argOrGetter1` and `argOrGetter2` can be a function or some static values\n * to use as an `arg1` and `arg2` arguments for `caller`.\n *\n * @category Function\n *\n * @param {Function} fnGetter function to call to return\n * target function `caller`\n * @param {Function|*} argOrGetter1 some static value or function to call\n * to get an argument `arg1` for `caller`\n * @param {Function|*} argOrGetter2 some static value or function to call\n * to get an argument `arg2` for `caller`\n * @returns {Function} a new function to take some value `smth`, call\n * `fnGetter(smth)` to get target function to call,\n * call `argOrGetter1(smth)` if it's a function or simply use `argOrGetter1`\n * as an `arg1` argument for `caller`,\n * call `argOrGetter2(smth)` if it's a function or simply use `argOrGetter2`\n * as an `arg2` argument for `caller` and return the result of calling\n * `caller(arg1, arg2)`\n *\n * @see isFunction\n * @see call\n * @see callMethod\n * @see callMethod2\n *\n * @example\n *\n *     import {call2, pick} from '@yagni-js/yagni';\n *\n *     function sum(x, y) { return x + y; }\n *\n *     const pickSum = pick('sum');\n *     const pickX = pick('x');\n *     const pickY = pick('y');\n *\n *     const src = {\n *       sum: sum,\n *       x: 40,\n *       y: 2\n *     };\n *\n *     const answer = call2(pickSum, pickX, pickY);\n *\n *     const res = answer(src);  // => 42\n *\n *\n */\nfunction call2(fnGetter, argOrGetter1, argOrGetter2) {\n  return function _call2(smth) {\n    const caller = fnGetter(smth);\n    const arg1 = isFunction(argOrGetter1) ? argOrGetter1(smth) : argOrGetter1;\n    const arg2 = isFunction(argOrGetter2) ? argOrGetter2(smth) : argOrGetter2;\n    return caller(arg1, arg2);\n  };\n}\n\n\n/**\n * Takes three functions `subj`, `meth` and `argOrGetter`\n * as arguments and returns **a new function** which then takes\n * some value `smth` as an argument and:\n *   - calls `subj(smth)` to get `object` to operate on\n *   - calls `meth(smth)` to get `method` name to call\n *   - calls `argOrGetter(smth)` to get an argument `arg` to use for method call\n *   - returns the result of calling `method` of `subject` using `arg`\n *     as an argument.\n *\n * `meth` and `argOrGetter` can be a functions or some static values\n * to use as `method` and `arg`.\n *\n * @category Function\n *\n * @param {Function} subj function to call to get `object` to operate on\n * @param {Function|*} meth some static value or function to call\n * to get `method` name\n * @param {Function|*} argOrGetter some static value or function to call\n * to get an argument `arg` for `method`\n * @returns {Function} a new function to take some value `smth`, call\n * `subj(smth)` to get `object` to operate on,\n * call `meth(smth)` if it's a function or simply use `meth`\n * as a `method` name,\n * call `argOrGetter(smth)` if it's a function or simply use `argOrGetter`\n * as an `arg` argument for `method` and return the result of calling\n * `object.method(arg)`\n *\n * @see isFunction\n * @see call\n * @see call2\n * @see callMethod2\n *\n * @example\n *\n *     import {callMethod, pick} from '@yagni-js/yagni';\n *\n *     const arr = pick('arr');\n *     const method = 'slice';\n *     const start = pick('start');\n *\n *     const slice = _.callMethod(arr, method, start);\n *\n *     const src = {\n *       arr: [0, 1, 2, 3, 4, 5, 6],\n *       start: 3\n *     };\n *\n *     const res = slice(src);  // => [3, 4, 5, 6]\n *\n */\nfunction callMethod(subj, meth, argOrGetter) {\n  return function _callMethod(smth) {\n    const object = subj(smth);\n    const method = isFunction(meth) ? meth(smth) : meth;\n    const arg = isFunction(argOrGetter) ? argOrGetter(smth) : argOrGetter;\n    return object[method](arg);\n  };\n}\n\n\n/**\n * Takes four functions `subj`, `meth`, `argOrGetter1` and `argOrGetter2`\n * as arguments and returns **a new function** which then takes\n * some value `smth` as an argument and:\n *   - calls `subj(smth)` to get `object` to operate on\n *   - calls `meth(smth)` to get `method` name to call\n *   - calls `argOrGetter1(smth)` to get an argument `arg1`\n *     to use for method call\n *   - calls `argOrGetter2(smth)` to get an argument `arg2`\n *     to use for method call\n *   - returns the result of calling `method` of `subject` using `arg1`\n *     and `arg2` as arguments.\n *\n * `meth`, `argOrGetter1` and `argOrGetter2` can be functions or\n * some static values to use as `method`, `arg1` and `arg2`.\n *\n * @category Function\n *\n * @param {Function} subj function to call to get `object` to operate on\n * @param {Function|*} meth some static value or function to call\n * to get `method` name\n * @param {Function|*} argOrGetter1 some static value or function to call\n * to get an argument `arg1` for `method`\n * @param {Function|*} argOrGetter2 some static value or function to call\n * to get an argument `arg2` for `method`\n * @returns {Function} a new function to take some value `smth`, call\n * `subj(smth)` to get `object` to operate on,\n * call `meth(smth)` if it's a function or simply use `meth`\n * as a `method` name,\n * call `argOrGetter1(smth)` if it's a function or simply use `argOrGetter1`\n * as an `arg1` argument for `method`,\n * call `argOrGetter2(smth)` if it's a function or simply use `argOrGetter2`\n * as an `arg2` argument for `method` and return the result of calling\n * `object.method(arg1, arg2)`\n *\n * @see isFunction\n * @see call\n * @see call2\n * @see callMethod\n *\n * @example\n *\n *     import {callMethod2, pick} from '@yagni-js/yagni';\n *\n *     const arr = pick('arr');\n *     const method = 'slice';\n *     const start = pick('start');\n *     const end = pick('end');\n *\n *     const slice = _.callMethod2(arr, method, start, end);\n *\n *     const src = {\n *       arr: [0, 1, 2, 3, 4, 5, 6],\n *       start: 2,\n *       end: -2\n *     };\n *\n *     const res = slice(src);  // => [2, 3, 4]\n *\n */\nfunction callMethod2(subj, meth, argOrGetter1, argOrGetter2) {\n  return function _callMethod2(smth) {\n    const object = subj(smth);\n    const method = isFunction(meth) ? meth(smth) : meth;\n    const arg1 = isFunction(argOrGetter1) ? argOrGetter1(smth) : argOrGetter1;\n    const arg2 = isFunction(argOrGetter2) ? argOrGetter2(smth) : argOrGetter2;\n    return object[method](arg1, arg2);\n  };\n}\n\n/**\n * Takes some string `suff` as an argument and returns **a new function**,\n * which then takes another string `str` as an argument and returns\n * **a new string** by appending `suff` to `str`.\n *\n * @category String\n *\n * @param {String} suff string to append to `str`\n * @returns {Function} a new function to take `str` as an argument and return\n * a new string by appending `suff` to `str`\n *\n * @example\n *\n *     import {suffix} from '@yagni-js/yagni';\n *\n *     const appendBaz = suffix('-baz');\n *\n *     const res = appendBaz('foo');  // => 'foo-baz';\n *\n */\nfunction suffix(suff) {\n  return function _suffix(str) {\n    return str + suff;\n  };\n}\n\n\n/**\n * Takes some string `pref` as an argument and returns **a new function**,\n * which then takes another string `str` as an argument and returns\n * **a new string** by prepending `pref` to `str`.\n *\n * @category String\n *\n * @param {String} pref string to prepend to `str`\n * @returns {Function} a new function to take `str` as an argument and return\n * a new string by prepending `pref` to `str`\n *\n * @example\n *\n *     import {prefix} from '@yagni-js/yagni';\n *\n *     const prependFoo = prefix('foo-');\n *\n *     const res = prependFoo('baz');  // => 'foo-baz';\n *\n */\nfunction prefix(pref) {\n  return function _prefix(str) {\n    return pref + str;\n  };\n}\n\n\n/**\n * Takes some string `separator` to split a string as an argument and returns\n * **a new function**, which then takes another string `str` as an argument\n * and returns **an array** of substrings by splitting `str` into chunks\n * using `separator`.\n *\n * Uses `split` method of `str` argument.\n *\n * @category String\n *\n * @param {String} separator string to split `str` by\n * @returns {Function} a new function to take `str` as an argument and\n * return an array of substrings by splitting `str` into chunks using\n * `separator`\n *\n * @example\n *\n *     import {split} from '@yagni-js/yagni';\n *\n *     const splitByDot = split('.');\n *\n *     const res = splitByDot('foo.baz.bar');  // => ['foo', 'baz', 'bar']\n *\n */\nfunction split(separator) {\n  return function _split(str) {\n    return str.split(separator);\n  };\n}\n\n\n/**\n * Takes some string `str` as an argument and returns **a new string**, which\n * is a camelized version of `str`.\n *\n * Uses `replace` method of `str` argument.\n *\n * @category String\n *\n * @param {String} str source string\n * @returns {String} camelized version of `str`\n *\n * @example\n *\n *     import {camelize} from '@yagni-js/yagni';\n *\n *     const res = camelize('foo-baz-bar');  // => 'fooBazBar'\n *\n */\nfunction camelize(str) {\n  return str.replace(/-([a-z])/g, function (m, x) { return x.toUpperCase(); });\n}\n\n\n/**\n * Takes some regular expression `regexp` as an argument and returns\n * **a new function**, which then takes some string `str` as an argument\n * and returns **boolean** value as a result of searching for match between\n * `regexp` and `str`.\n *\n * Uses `test` method of `regexp` argument.\n *\n * @category String\n *\n * @param {RegExp} regexp regular expression for test\n * @returns {Function} a new function to take `str` as an argument and return\n * `true` in case there is a match between `regexp` and `str`,\n * `false` otherwise\n *\n * @example\n *\n *     import {test} from '@yagni-js/yagni';\n *\n *     const startsWithFoo = test(/^foo/);\n *\n *     const res0 = startsWithFoo('foo-baz-bar');  // => true\n *     const res1 = startsWithFoo('baz-bar');      // => false\n *\n */\nfunction test(regexp) {\n  return function _test(str) {\n    return regexp.test(str);\n  };\n}\n\n\n/**\n * Takes some regular expression `regexp` as an argument and returns\n * **a new function**, which then takes some string `str` as an argument and\n * returns **an array** of found matches if any, `null` otherwise.\n *\n * Uses `match` method of `str` argument.\n *\n * @category String\n *\n * @param {RegExp} regexp regular expression to find matches\n * @returns {Function} a new function to take `str` as an argument and return\n * an array of matches if any or `null` otherwise\n *\n * @example\n *\n *     import {match} from '@yagni-js/yagni';\n *\n *     const fooBazMatcher = match(/(foo|baz)/g);\n *\n *     const res0 = fooBazMatcher('baz.foo bar.baz');\n *     // => ['baz', 'foo', 'baz']\n *\n *     const res1 = fooBazMatcher('bar');  // => null\n *\n */\nfunction match(regexp) {\n  return function _match(str) {\n    return str.match(regexp);\n  };\n}\n\n\n/**\n * Takes `from` and `to` as arguments and returns **a new function**,\n * which then takes some string `str` as an argument and returns\n * **a new string** with some or all matches of `from` replaced by `to`.\n *\n * Uses `replace` method of `str` argument.\n *\n * @category String\n *\n * @param {RegExp|String} from regular expression or a string to match;\n * in case of a string only first occurrence will be replaced\n * @param {String|Function} to string that replaces some or all matches,\n * or function to be invoked to create new replacement\n * @returns {Function} a new function to take `str` as an argument and return\n * a new string with some or all matches of `from` replaced by `to`\n *\n * @example\n *\n *     import {replace} from '@yagni-js/yagni';\n *\n *     const fooToBar = replace(/foo/g, 'bar');\n *\n *     const res = fooTobar('foo.baz');  // => 'bar.baz'\n *\n */\nfunction replace(from, to) {\n  return function _replace(str) {\n    return str.replace(from, to);\n  };\n}\n\n\n/**\n * Takes a number `pos` as an argument and returns **a new function**,\n * which then takes some string `str` as an argument and returns\n * **a new string** - a section from `str` starting from position specified\n * by `pos`. `pos` can be negative to indicate section extraction from the end\n * of `str`.\n *\n * Uses `slice` method of `str` argument.\n *\n * @category String\n *\n * @param {Number} pos starting position for substring extraction\n * @returns {Function} a new function to take `str` as an argument and\n * return extracted section of `str` starting from `pos` position\n *\n * @example\n *\n *     import {slice} from '@yagni-js/yagni';\n *\n *     const skip4 = slice(4);\n *\n *     const res = skip4('foo-baz-bar');  // => 'baz-bar'\n *\n */\nfunction slice(pos) {\n  return function _slice(str) {\n    return str.slice(pos);\n  };\n}\n\n\n/**\n * Takes two numbers `start` and `end` as arguments and returns\n * **a new function**, which then takes some string `str` as an argument\n * and returns **a new string** - a section from `str` starting from\n * `start` position till `end` position (character at `end` position is not\n * included). `start` and `end` arguments can be negative to indicate\n * position from the end of `str`.\n *\n * Uses `slice` method of `str` argument.\n *\n * @category String\n *\n * @param {Number} start starting position for substring extraction\n * @param {Number} end ending position for substring extraction (excluding\n * character at this position)\n * @returns {Function} a new function to take `str` as an argument and\n * return extracted section of `str` starting from the `start` position\n * till the `end` position\n *\n * @example\n *\n *     import {slice2} from '@yagni-js/yagni';\n *\n *     const extractBaz = slice2(4, -4);\n *\n *     const res = extractBaz('foo-baz-bar');  // => 'baz'\n *\n */\nfunction slice2(start, end) {\n  return function _slice2(str) {\n    return str.slice(start, end);\n  };\n}\n\n\n/**\n * Takes some string `str` as an argument and returns **a new function**,\n * which then takes some number `count` and returns **a new string**, which\n * contains specified by `count` number of copies of `str`, concatenated\n * together.\n *\n * @category String\n *\n * @param {String} str source string to repeat\n * @returns {Function} a new function to take some number `count` and return\n * a new string, containing the specified by `count` number of copies of `str`\n *\n * @example\n *\n *     import {repeat} from '@yagni-js/yagni';\n *\n *     const repeatFoo = repeat('foo');\n *\n *     const res = repeatFoo(3);  // => 'foofoofoo'\n *\n */\nfunction repeat(str) {\n  return function _repeat(count) {\n    return count === 0 ? '' : (count > 1 ? (str + _repeat(count - 1)) : str);\n  };\n}\n\n/**\n * Takes an object `spec` as an argument and returns **a new function**,\n * which then takes some value `smth` and returns **a new object**, produced\n * according to `spec`.\n *\n * Uses `Array.reduce` method internally to generate the result.\n *\n * See source and example to get the idea.\n *\n * Useful in conjuction with `pipe`.\n *\n * @category Transformation\n *\n * @param {Object} spec an object specifying transformation rules,\n * `spec` key name can be any allowed value, `spec` key value can be\n * a function, an array of functions or some static value\n * @returns {Function} a new function to take `smth` as an argument and return\n * a new object according to `spec`\n *\n * @see pipe\n * @see isArray\n * @see result\n * @see resultArr\n * @see obj\n * @see keys\n *\n * @example\n *\n *     import {transform} from '@yagni-js/yagni';\n *\n *     function single(x) { return x; }\n *     function double(x) { return x * x; }\n *     function triple(x) { return x * x * x; }\n *\n *     const spec = {\n *       single: single,\n *       double: double,\n *       triple: triple,\n *       all: [single, double, triple],\n *       foo: 42\n *     };\n *     const transformer = transform(spec);\n *\n *     const res = transformer(2);\n *     // =>\n *     // {\n *     //    single: 2,\n *     //    double: 4,\n *     //    triple: 8,\n *     //    all: [2, 4, 8],\n *     //    foo: 42\n *     //  }\n *\n */\nfunction transform(spec) {\n  return function (smth) {\n    return keys(spec).reduce(\n      function (acc, key) {\n        const transformer = spec[key];\n        const value = isArray(transformer) ? resultArr(transformer, smth) : result(transformer, smth);\n        return Object.assign({}, acc, obj(key, value));\n      },\n      {}\n    );\n  };\n}\n\n\n/**\n * Takes an array `spec` of transformation functions or static values\n * as an argument and returns **a new function**,\n * which then takes some value `smth` and returns **a new array**, produced\n * according to `spec`.\n *\n * Uses `map` method of `spec` argument to generate the result.\n *\n * See source and example to get the idea.\n *\n * @category Transformation\n *\n * @param {Array} spec an array specifying transformation rules,\n * can contain functions or static values\n * @returns {Function} a new function to take `smth` as an argument and return\n * a new array according to `spec`\n *\n * @see isFunction\n *\n * @example\n *\n *     import {transformArr} from '@yagni-js/yagni';\n *\n *     function single(x) { return x; }\n *     function double(x) { return x * x; }\n *     function triple(x) { return x * x * x; }\n *\n *     const spec = [single, double, triple, 42];\n *     const transformer = transformArr(spec);\n *\n *     const res = transformer(2);  // => [2, 4, 8, 42];\n *\n */\nfunction transformArr(spec) {\n  return function (smth) {\n    return spec.map(function (transformer) { return isFunction(transformer) ? transformer(smth) : transformer; });\n  };\n}\n\n/**\n * Takes some value `smth` and returns **boolean** using following rules:\n *\n *    - for array: check it's length and return `true` if it equals to 0,\n *      return `false` otherwise\n *    - for object: check length of it's keys array and return `true` if it\n *      equals to 0, return `false` otherwise\n *    - for string: return `true` if string is empty, return `false` otherwise\n *    - for all other cases: return `true` if `smth` is `null` or `undefined`,\n *      return `false` otherwise.\n *\n * @function\n * @category Test\n *\n * @param {Array|Object|String|*} smth value to test for emptiness\n * @returns {Boolean} true if `smth` is empty, false otherwise\n *\n * @see ifElse\n * @see pipe\n * @see isArray\n * @see isObject\n * @see isString\n * @see isNil\n * @see equals\n * @see length\n * @see keys\n *\n * @example\n *\n *     import {isEmpty} from '@yagni-js/yagni';\n *\n *     var a = null;\n *     var b;\n *\n *     const res0 = isEmpty([]);         // => true\n *     const res1 = isEmpty({});         // => true\n *     const res2 = isEmpty('');         // => true\n *     const res3 = isEmpty(a);          // => true\n *     const res4 = isEmpty(b);          // => true\n *     const res5 = isEmpty(42);         // => false\n *     const res6 = isEmpty([42]);       // => false\n *     const res7 = isEmpty('42');       // => false\n *     const res8 = isEmpty({foo: 42});  // => false\n *\n */\nconst isEmpty = ifElse(\n  isArray,\n  pipe([length, equals(0)]),\n  ifElse(\n    isObject,\n    pipe([keys, length, equals(0)]),\n    ifElse(\n      isString,\n      equals(''),\n      isNil)\n  )\n);\n\n/**\n * Takes `executor` function as an argument and returns **a new promise**.\n *\n * `executor` function signature:\n *\n *     function executor(resolve, reject)\n *\n * @category Promise\n *\n * @param {Function} executor executor function\n * @returns {Promise} instance of Promise\n *\n * @see resolveP\n * @see rejectP\n * @see then\n *\n * @example\n *\n *     import {promise} from '@yagni-js/yagni';\n *\n *     function executor(resolve, reject) {\n *       // some asyncronous code\n *       // ...\n *       resolve('foo');\n *     }\n *\n *     const p = promise(executor);  // => instance of Promise\n *\n */\nfunction promise(executor) {\n  // eslint-disable-next-line better/no-new\n  return new Promise(executor);\n}\n\n\n/**\n * Takes some value `smth` as an argument and returns **a Promise object**\n * that is resolved with the given value.\n *\n * @category Promise\n *\n * @param {*} smth value to set a Promise object resolved to\n * @returns {Promise} an instance of resolved Promise\n *\n * @see promise\n * @see rejectP\n * @see then\n *\n * @example\n *\n *     import {resolveP} from '@yagni-js/yagni';\n *\n *     const p = resolveP(42);  // => instance of resolved Promise\n *\n */\nfunction resolveP(smth) {\n  return Promise.resolve(smth);\n}\n\n\n/**\n * Takes some value `smth` as an argument and returns **a Promise object**\n * that is rejected with the given value.\n *\n * @category Promise\n *\n * @param {*} smth value to set a Promise object rejected to\n * @returns {Promise} an instance of rejected Promise\n *\n * @see promise\n * @see resolveP\n * @see then\n *\n * @example\n *\n *     import {rejectP} from '@yagni-js/yagni';\n *\n *     const p = rejectP(42);  // => instance of rejected Promise\n *\n */\nfunction rejectP(smth) {\n  return Promise.reject(smth);\n}\n\n\n/**\n * Takes two functions `onSuccess` and `onError` for success and failure\n * cases of the `Promise` as an arguments and returns **a new function**,\n * which then takes `thenable` as an argument and returns\n * **a new Promise object**.\n *\n * Useful in conjunction with `pipe`.\n *\n * @category Promise\n *\n * @param {Function} onSuccess function to be called if `thenable` was fulfilled\n * @param {Function} onError function to be called if `thenable` was rejected\n * @returns {Function} a new function to take `thenable` as an argument\n * and return another promise object.\n *\n * @see promise\n * @see resolveP\n * @see rejectP\n * @see pipe\n *\n * @example\n *\n *     import {then, pipe} from '@yagni-js/yagni';\n *\n *     function onSuccess(response) {\n *       //\n *     }\n *     function onError(error) {\n *       //\n *     }\n *\n *     const load = pipe([\n *       fetch,\n *       then(onSuccess, onError)\n *     ]);\n *\n *     const res = load('http://domain.tld');\n *     // => promise with attached onSuccess and onError handlers\n *\n */\nfunction then(onSuccess, onError) {\n  return function (thenable) {\n    return thenable.then(onSuccess).catch(onError);\n  };\n}\n\nexports.all = all;\nexports.always = always;\nexports.and = and;\nexports.any = any;\nexports.call = call;\nexports.call2 = call2;\nexports.callMethod = callMethod;\nexports.callMethod2 = callMethod2;\nexports.camelize = camelize;\nexports.concat = concat;\nexports.equals = equals;\nexports.exists = exists;\nexports.existsIn = existsIn;\nexports.filter = filter;\nexports.filterMap = filterMap;\nexports.first = first;\nexports.flatten = flatten;\nexports.flattenMap = flattenMap;\nexports.fn = fn;\nexports.fn2 = fn2;\nexports.has = has;\nexports.identity = identity;\nexports.ifElse = ifElse;\nexports.index = index;\nexports.indexIn = indexIn;\nexports.isArray = isArray;\nexports.isDefined = isDefined;\nexports.isEmpty = isEmpty;\nexports.isFalse = isFalse;\nexports.isFunction = isFunction;\nexports.isNil = isNil;\nexports.isObject = isObject;\nexports.isString = isString;\nexports.isTrue = isTrue;\nexports.items = items;\nexports.join = join;\nexports.keys = keys;\nexports.lazy = lazy;\nexports.length = length;\nexports.map = map;\nexports.mapObj = mapObj;\nexports.match = match;\nexports.merge = merge;\nexports.method = method;\nexports.mutate = mutate;\nexports.not = not;\nexports.obj = obj;\nexports.objOf = objOf;\nexports.omit = omit;\nexports.or = or;\nexports.pick = pick;\nexports.pickFrom = pickFrom;\nexports.pickPath = pickPath;\nexports.pipe = pipe;\nexports.pipeP = pipeP;\nexports.prefix = prefix;\nexports.promise = promise;\nexports.reduce = reduce;\nexports.reduceObj = reduceObj;\nexports.reduceToArr = reduceToArr;\nexports.rejectP = rejectP;\nexports.repeat = repeat;\nexports.replace = replace;\nexports.resolveP = resolveP;\nexports.result = result;\nexports.resultArr = resultArr;\nexports.slice = slice;\nexports.slice2 = slice2;\nexports.split = split;\nexports.suffix = suffix;\nexports.tap = tap;\nexports.test = test;\nexports.then = then;\nexports.toArray = toArray;\nexports.transform = transform;\nexports.transformArr = transformArr;\nexports.unique = unique;\nexports.values = values;\n"]}